Description: 76/276/1
authordibhatia <dibhatia@cisco.com>
Wed, 1 May 2013 19:27:39 +0000 (12:27 -0700)
committerdibhatia <dibhatia@cisco.com>
Wed, 1 May 2013 19:27:39 +0000 (12:27 -0700)
- Made changes in devices.web bundle and sal.core.Config
- files changed for this: pages.js, Devices.java and Config.java
- changes seen in the diff in StatusJsonBean.java are purely sun xml style coding    \
related
- Port status is correctly shown as "Up" or "Down".  In case the port status cannot  \
be determined, it will be displayed as "Undefined"

Change-Id: I15f4281fb0a00c466942d7c4effab6fe4d25a7b9
Signed-off-by: dibhatia <dibhatia@cisco.com>
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Config.java
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/StatusJsonBean.java
opendaylight/web/devices/src/main/resources/js/page.js

index c585aa2..dbb93fb 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -18,8 +17,8 @@ import javax.xml.bind.annotation.XmlElement;
 
 /**
  * The class represents Admin Config status
- *
- *
+ * 
+ * 
  */
 @XmlRootElement
 @SuppressWarnings("serial")
@@ -65,6 +64,14 @@ public class Config extends Property {
 
     @Override
     public String toString() {
-        return "Config[" + ReflectionToStringBuilder.toString(this) + "]";
+        StringBuffer ret = new StringBuffer();
+        if (this.configValue == 0) {
+            ret.append("Down");
+        } else if (this.configValue == 1) {
+            ret.append("Up");
+        } else {
+            ret.append("Undefined");
+        }
+        return ret.toString();
     }
 }
index f451204..7898f78 100644 (file)
@@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.opendaylight.controller.forwarding.staticrouting.IForwardingStaticRouting;
 import org.opendaylight.controller.forwarding.staticrouting.StaticRouteConfig;
 import org.opendaylight.controller.sal.authorization.UserLevel;
+import org.opendaylight.controller.sal.core.Config;
 import org.opendaylight.controller.sal.core.Name;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
@@ -87,6 +88,7 @@ public class Devices implements IDaylightWeb {
         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
                 .getInstance(ISwitchManager.class, containerName, this);
         List<Map<String, String>> nodeData = new ArrayList<Map<String, String>>();
+        Map<String, String> portListStatus = new HashMap<String, String>();
         for (Switch device : switchManager.getNetworkDevices()) {
             HashMap<String, String> nodeDatum = new HashMap<String, String>();
             Node node = device.getNode();
@@ -110,6 +112,7 @@ public class Devices implements IDaylightWeb {
             nodeDatum.put("mac",
                     HexEncode.bytesToHexString(device.getDataLayerAddress()));
             StringBuffer sb1 = new StringBuffer();
+            StringBuffer sb2 = new StringBuffer();
             Set<NodeConnector> nodeConnectorSet = device.getNodeConnectors();
             String nodeConnectorName;
             String nodeConnectorNumberToStr;
@@ -119,19 +122,28 @@ public class Devices implements IDaylightWeb {
                     nodeConnectorNumberToStr = nodeConnector.getID().toString();
                     Name ncName = ((Name) switchManager.getNodeConnectorProp(
                             nodeConnector, Name.NamePropName));
+                    Config portStatus = ((Config) switchManager
+                            .getNodeConnectorProp(nodeConnector,
+                                    Config.ConfigPropName));
                     nodeConnectorName = (ncName != null) ? ncName.getValue()
                             : "";
                     portList.put(Short.parseShort(nodeConnectorNumberToStr),
                             nodeConnectorName);
+                    portListStatus
+                            .put(nodeConnectorName, portStatus.toString());
                 }
+
                 Map<Short, String> sortedPortList = new TreeMap<Short, String>(
                         portList);
+
                 for (Entry<Short, String> e : sortedPortList.entrySet()) {
                     sb1.append(e.getValue() + "(" + e.getKey() + ")");
                     sb1.append("<br>");
+                    sb2.append(portListStatus.get(e.getValue()) + "<br>");
                 }
             }
             nodeDatum.put("ports", sb1.toString());
+            nodeDatum.put("portStatus", sb2.toString());
             nodeData.add(nodeDatum);
         }
         DevicesJsonBean result = new DevicesJsonBean();
@@ -142,6 +154,7 @@ public class Devices implements IDaylightWeb {
         columnNames.add("Tier");
         columnNames.add("Mac Address");
         columnNames.add("Ports");
+        columnNames.add("Port Status");
 
         result.setColumnNames(columnNames);
         return result;
index cbfc121..a354603 100644 (file)
@@ -8,18 +8,22 @@
 package org.opendaylight.controller.devices.web;
 
 public class StatusJsonBean {
-       private boolean status;
-       private String message;
-       public boolean isStatus() {
-               return status;
-       }
-       public void setStatus(boolean status) {
-               this.status = status;
-       }
-       public String getMessage() {
-               return message;
-       }
-       public void setMessage(String message) {
-               this.message = message;
-       }
+    private boolean status;
+    private String message;
+
+    public boolean isStatus() {
+        return status;
+    }
+
+    public void setStatus(boolean status) {
+        this.status = status;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
 }
index 7a2b579..29f03d5 100644 (file)
@@ -77,6 +77,7 @@ one.f.switchmanager.nodesLearnt = {
                        form: {
                                nodeId: "one_f_switchmanager_nodesLearnt_id_modal_form_nodeid",
                                nodeName : "one_f_switchmanager_nodesLearnt_id_modal_form_nodename",
+                               portStatus : "one_f_switchmanager_nodesLearnt_id_modal_form_portstatus",
                                tier: "one_f_switchmanager_nodesLearnt_id_modal_form_tier",
                                operationMode: "one_f_switchmanager_nodesLearnt_id_modal_form_opmode"
                        }
@@ -89,7 +90,7 @@ one.f.switchmanager.nodesLearnt = {
 
                one.f.switchmanager.nodesLearnt.ajax.main(url, function(content) {
                        var body = one.f.switchmanager.nodesLearnt.data.abridged(content);
-                       var $table = one.f.switchmanager.createTable(["Node Name", "Node ID", "Ports"], body);
+                       var $table = one.f.switchmanager.createTable(["Node Name", "Node ID", "Ports", "Port Status"], body);
                        $dashlet.append($table);
                });
        },
@@ -129,7 +130,7 @@ one.f.switchmanager.nodesLearnt = {
                        }
                },
                body: {
-                       updateNode: function(nodeId, switchDetails, tiers) {
+                       updateNode: function(nodeId, portStatus, switchDetails, tiers) {
                                var $form = $(document.createElement('form'));
                                var $fieldset = $(document.createElement('fieldset'));
                                // node ID. not editable.
@@ -147,6 +148,13 @@ one.f.switchmanager.nodesLearnt = {
                                        $input.attr('value', switchDetails["nodeName"]);
                                }
                                $fieldset.append($label).append($input);
+                               // Port Status. not editable.
+                               var $label = one.lib.form.label("Port Status");
+                               var $input = one.lib.form.input("Port Status");
+                               $input.attr('id', one.f.switchmanager.nodesLearnt.id.modal.form.portStatus);
+                               $input.attr("disabled", true);
+                               $input.attr("value", portStatus);
+                               $fieldset.append($label).append($input);
                                // node tier
                                var $label = one.lib.form.label("Tier");
                                var $select = one.lib.form.select.create(tiers);
@@ -238,6 +246,7 @@ one.f.switchmanager.nodesLearnt = {
                                entry.push(aTag);
                                entry.push(value["nodeId"]);
                                entry.push(value["ports"]);
+                               entry.push(value["portStatus"]);
                                tr.entry = entry;
                                result.push(tr);
                        });
@@ -255,6 +264,7 @@ one.f.switchmanager.nodesLearnt = {
                                entry.push(value["tierName"]);
                                entry.push(value["mac"]);
                                entry.push(value["ports"]);
+                               entry.push(value["portStatus"]);
                                tr.entry = entry;
                                result.push(tr);
                        });