Change nodeconnector string shown on the troubleshoot tab when clicked on ports 73/973/1
authorlakshya <lakshya@cisco.com>
Fri, 23 Aug 2013 00:42:41 +0000 (17:42 -0700)
committerlakshya <lakshya@cisco.com>
Fri, 23 Aug 2013 00:45:31 +0000 (17:45 -0700)
to show node name if it is available and node id otherwise.

Change-Id: I7ccb73ac56f963feaf31380ddbd87417c905804e
Signed-off-by: lakshya <lakshya@cisco.com>
opendaylight/web/troubleshoot/src/main/java/org/opendaylight/controller/troubleshoot/web/Troubleshoot.java

index 337d721..71ba687 100644 (file)
@@ -208,7 +208,7 @@ public class Troubleshoot implements IDaylightWeb {
                 List<NodeConnectorStatistics> statistics = statisticsManager
                         .getNodeConnectorStatistics(node);
                 for (NodeConnectorStatistics stats : statistics) {
-                    cells.add(this.convertPortsStatistics(stats));
+                    cells.add(this.convertPortsStatistics(stats, containerName));
                 }
             }
         }
@@ -220,11 +220,19 @@ public class Troubleshoot implements IDaylightWeb {
     }
 
     private Map<String, String> convertPortsStatistics(
-            NodeConnectorStatistics ncStats) {
+            NodeConnectorStatistics ncStats, String containerName) {
         Map<String, String> row = new HashMap<String, String>();
 
+        ISwitchManager switchManager = (ISwitchManager) ServiceHelper
+                .getInstance(ISwitchManager.class, containerName, this);
+        NodeConnector nodeConnector = ncStats.getNodeConnector();
+        Description description = (Description) switchManager.getNodeProp(nodeConnector.getNode(), Description.propertyName);
+        String desc = (description == null) ? "" : description.getValue();
+        String nodeName = desc.equalsIgnoreCase("none") ? nodeConnector.getNode().getNodeIDString() : desc;
+        String nodeConnectorDisplayName = nodeConnector.getType() + "|" + nodeConnector.getID() + "@" + nodeName;
         row.put("nodeConnector",
-                String.valueOf(ncStats.getNodeConnector().toString()));
+                String.valueOf(nodeConnectorDisplayName));
+
         row.put("rxPkts", String.valueOf(ncStats.getReceivePacketCount()));
         row.put("txPkts", String.valueOf(ncStats.getTransmitPacketCount()));
         row.put("rxBytes", String.valueOf(ncStats.getReceiveByteCount()));