- Added osgi cmds so that user is able to configure a link. The link is added to... 25/425/1
authorJason Ye <yisye@cisco.com>
Tue, 4 Jun 2013 02:41:32 +0000 (19:41 -0700)
committerJason Ye <yisye@cisco.com>
Tue, 4 Jun 2013 02:41:32 +0000 (19:41 -0700)
Usage:

addUserLink <name> <node connector string> <node connector string>
deleteUserLink <name>
printUserLink

- Fixed an exception in SwitchManager osgi cmd pns

Signed-off-by: Jason Ye <yisye@cisco.com>
opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java
opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java

index 2937fe7e14710c3655cf99e954bcc6cd4aefa05c..1b1a47bf231b6613ae49fbe247552ea136c0e1f0 100644 (file)
@@ -1457,10 +1457,11 @@ CommandProvider {
             String nodeName = (desc == null) ? "" : desc.getValue();
             MacAddress mac = (MacAddress) getNodeProp(node,
                     MacAddress.name);
             String nodeName = (desc == null) ? "" : desc.getValue();
             MacAddress mac = (MacAddress) getNodeProp(node,
                     MacAddress.name);
+            String macAddr = (mac == null) ? "" : HexEncode
+                    .bytesToHexStringFormat(mac.getMacAddress());
             int tierNum = (tier == null) ? 0 : tier.getValue();
             int tierNum = (tier == null) ? 0 : tier.getValue();
-            ci.println(node + "     " + node.getType() + "     "
-                    + HexEncode.bytesToHexStringFormat(mac.getMacAddress())
-                    + "     " + nodeName + "     " + tierNum  );
+            ci.println(node + "     " + node.getType() + "     " + macAddr
+                    + "     " + nodeName + "     " + tierNum);
         }
         ci.println("Total number of Nodes: " + nodeSet.size());
     }
         }
         ci.println("Total number of Nodes: " + nodeSet.size());
     }
index 2002158bbbfe03751d9319238d6ca6fc9b44d60d..8c39098a5ec56f532ecd29c99045f2e644ca1d61 100644 (file)
@@ -136,7 +136,7 @@ public class TopologyManagerImpl implements ITopologyManager,
     /**
      * Function called by the dependency manager when all the required
      * dependencies are satisfied
     /**
      * Function called by the dependency manager when all the required
      * dependencies are satisfied
-     * 
+     *
      */
     void init(Component c) {
         String containerName = null;
      */
     void init(Component c) {
         String containerName = null;
@@ -204,7 +204,7 @@ public class TopologyManagerImpl implements ITopologyManager,
     /**
      * Function called after the topology manager has registered the service in
      * OSGi service registry.
     /**
      * Function called after the topology manager has registered the service in
      * OSGi service registry.
-     * 
+     *
      */
     void started() {
         // SollicitRefresh MUST be called here else if called at init
      */
     void started() {
         // SollicitRefresh MUST be called here else if called at init
@@ -217,7 +217,7 @@ public class TopologyManagerImpl implements ITopologyManager,
      * Function called by the dependency manager when at least one dependency
      * become unsatisfied or when the component is shutting down because for
      * example bundle is being stopped.
      * Function called by the dependency manager when at least one dependency
      * become unsatisfied or when the component is shutting down because for
      * example bundle is being stopped.
-     * 
+     *
      */
     void destroy() {
         if (this.clusterContainerService == null) {
      */
     void destroy() {
         if (this.clusterContainerService == null) {
@@ -257,7 +257,7 @@ public class TopologyManagerImpl implements ITopologyManager,
         // Publish the save config event to the cluster nodes
         /**
          * Get the CLUSTERING SERVICES WORKING BEFORE TRYING THIS
         // Publish the save config event to the cluster nodes
         /**
          * Get the CLUSTERING SERVICES WORKING BEFORE TRYING THIS
-         * 
+         *
          * configSaveEvent.put(new Date().getTime(), SAVE);
          */
         return saveConfigInternal();
          * configSaveEvent.put(new Date().getTime(), SAVE);
          */
         return saveConfigInternal();
@@ -327,7 +327,7 @@ public class TopologyManagerImpl implements ITopologyManager,
 
     /**
      * This method returns true if the edge is an ISL link.
 
     /**
      * This method returns true if the edge is an ISL link.
-     * 
+     *
      * @param e
      *            The edge
      * @return true if it is an ISL link
      * @param e
      *            The edge
      * @return true if it is an ISL link
@@ -338,7 +338,7 @@ public class TopologyManagerImpl implements ITopologyManager,
 
     /**
      * This method returns true if the edge is a production link.
 
     /**
      * This method returns true if the edge is a production link.
-     * 
+     *
      * @param e
      *            The edge
      * @return true if it is a production link
      * @param e
      *            The edge
      * @return true if it is a production link
@@ -353,7 +353,7 @@ public class TopologyManagerImpl implements ITopologyManager,
     /**
      * The Map returned is a copy of the current topology hence if the topology
      * changes the copy doesn't
     /**
      * The Map returned is a copy of the current topology hence if the topology
      * changes the copy doesn't
-     * 
+     *
      * @return A Map representing the current topology expressed as edges of the
      *         network
      */
      * @return A Map representing the current topology expressed as edges of the
      *         network
      */
@@ -699,13 +699,16 @@ public class TopologyManagerImpl implements ITopologyManager,
 
         Edge linkTuple = getLinkTuple(link);
         if (linkTuple != null) {
 
         Edge linkTuple = getLinkTuple(link);
         if (linkTuple != null) {
-            try {
-                linkTuple = getReverseLinkTuple(link);
+            if (!isProductionLink(linkTuple)) {
+                edgeUpdate(linkTuple, UpdateType.ADDED, new HashSet<Property>());
+            }
+
+            linkTuple = getReverseLinkTuple(link);
+            if (linkTuple != null) {
                 link.setStatus(TopologyUserLinkConfig.STATUS.SUCCESS);
                 link.setStatus(TopologyUserLinkConfig.STATUS.SUCCESS);
-            } catch (Exception e) {
-                return new Status(StatusCode.INTERNALERROR,
-                        "Exception while adding custom link : "
-                                + e.getMessage());
+                if (!isProductionLink(linkTuple)) {
+                    edgeUpdate(linkTuple, UpdateType.ADDED, new HashSet<Property>());
+                }
             }
         }
         return new Status(StatusCode.SUCCESS, null);
             }
         }
         return new Status(StatusCode.SUCCESS, null);
@@ -723,20 +726,13 @@ public class TopologyManagerImpl implements ITopologyManager,
         Edge linkTuple = getLinkTuple(link);
         userLinks.remove(linkName);
         if (linkTuple != null) {
         Edge linkTuple = getLinkTuple(link);
         userLinks.remove(linkName);
         if (linkTuple != null) {
-            try {
-                // oneTopology.deleteUserConfiguredLink(linkTuple);
-            } catch (Exception e) {
-                log.warn(
-                        "Harmless : Exception while Deleting User Configured link {} {}",
-                        link, e.toString());
+            if (!isProductionLink(linkTuple)) {
+                edgeUpdate(linkTuple, UpdateType.REMOVED, null);
             }
             }
+
             linkTuple = getReverseLinkTuple(link);
             linkTuple = getReverseLinkTuple(link);
-            try {
-                // oneTopology.deleteUserConfiguredLink(linkTuple);
-            } catch (Exception e) {
-                log.warn(
-                        "Harmless : Exception while Deleting User Configured Reverse link {} {}",
-                        link, e.toString());
+            if ((linkTuple != null) && !isProductionLink(linkTuple)) {
+                edgeUpdate(linkTuple, UpdateType.REMOVED, null);
             }
         }
         return new Status(StatusCode.SUCCESS, null);
             }
         }
         return new Status(StatusCode.SUCCESS, null);
@@ -753,14 +749,14 @@ public class TopologyManagerImpl implements ITopologyManager,
     public String getHelp() {
         StringBuffer help = new StringBuffer();
         help.append("---Topology Manager---\n");
     public String getHelp() {
         StringBuffer help = new StringBuffer();
         help.append("---Topology Manager---\n");
-        help.append("\t addTopo name <NodeIDType> <src-sw-id> <NodeConnectorIDType> <port-number> <NodeIDType> <dst-sw-id> <NodeConnectorIDType> <port-number>\n");
-        help.append("\t delTopo name\n");
-        help.append("\t printTopo\n");
+        help.append("\t addUserLink <name> <node connector string> <node connector string>\n");
+        help.append("\t deleteUserLink <name>\n");
+        help.append("\t printUserLink\n");
         help.append("\t printNodeEdges\n");
         return help.toString();
     }
 
         help.append("\t printNodeEdges\n");
         return help.toString();
     }
 
-    public void _printTopo(CommandInterpreter ci) {
+    public void _printUserLink(CommandInterpreter ci) {
         for (String name : this.userLinks.keySet()) {
             TopologyUserLinkConfig linkConfig = userLinks.get(name);
             ci.println("Name : " + name);
         for (String name : this.userLinks.keySet()) {
             TopologyUserLinkConfig linkConfig = userLinks.get(name);
             ci.println("Name : " + name);
@@ -770,67 +766,52 @@ public class TopologyManagerImpl implements ITopologyManager,
         }
     }
 
         }
     }
 
-    public void _addTopo(CommandInterpreter ci) {
+    public void _addUserLink(CommandInterpreter ci) {
         String name = ci.nextArgument();
         if ((name == null)) {
             ci.println("Please enter a valid Name");
             return;
         }
 
         String name = ci.nextArgument();
         if ((name == null)) {
             ci.println("Please enter a valid Name");
             return;
         }
 
-        String srcNodeIDType = ci.nextArgument();
-        if (srcNodeIDType == null) {
-            ci.println("Null source node ID Type. Example: OF or PR");
+        String ncStr1 = ci.nextArgument();
+        if (ncStr1 == null) {
+            ci.println("Please enter two node connector strings");
             return;
         }
             return;
         }
-
-        String dpid = ci.nextArgument();
-        if (dpid == null) {
-            ci.println("Null source node id");
+        String ncStr2 = ci.nextArgument();
+        if (ncStr2 == null) {
+            ci.println("Please enter second node connector string");
             return;
         }
 
             return;
         }
 
-        String srcNodeConnectorIDType = ci.nextArgument();
-        if (srcNodeConnectorIDType == null) {
-            ci.println("Null source node connector ID Type. Example: OF or PR");
+        NodeConnector nc1 = NodeConnector.fromString(ncStr1);
+        if (nc1 == null) {
+            ci.println("Invalid input node connector 1 string: " + ncStr1);
             return;
         }
             return;
         }
-
-        String port = ci.nextArgument();
-        if (port == null) {
-            ci.println("Null source port number");
+        NodeConnector nc2 = NodeConnector.fromString(ncStr2);
+        if (nc2 == null) {
+            ci.println("Invalid input node connector 2 string: " + ncStr2);
             return;
         }
 
             return;
         }
 
-        String dstNodeIDType = ci.nextArgument();
-        if (dstNodeIDType == null) {
-            ci.println("Null destination node ID Type. Example: OF or PR");
-            return;
-        }
+        String nodeType1 = nc1.getNode().getType().toString();
+        String nid1 = nc1.getNode().getID().toString();
+        String ncType1 = nc1.getType().toString();
+        String ncid1 = nc1.getID().toString();
 
 
-        String ddpid = ci.nextArgument();
-        if (ddpid == null) {
-            ci.println("Null destination node ID");
-            return;
-        }
+        String nodeType2 = nc2.getNode().getType().toString();
+        String nid2 = nc2.getNode().getID().toString();
+        String ncType2 = nc2.getType().toString();
+        String ncid2 = nc2.getID().toString();
 
 
-        String dstNodeConnectorIDType = ci.nextArgument();
-        if (dstNodeConnectorIDType == null) {
-            ci.println("Null destination node connector ID Type. Example: OF or PR");
-            return;
-        }
-
-        String dport = ci.nextArgument();
-        if (dport == null) {
-            ci.println("Null destination port number");
-            return;
-        }
         TopologyUserLinkConfig config = new TopologyUserLinkConfig(name,
         TopologyUserLinkConfig config = new TopologyUserLinkConfig(name,
-                srcNodeIDType, dpid, srcNodeConnectorIDType, port,
-                dstNodeIDType, ddpid, dstNodeConnectorIDType, dport);
+                nodeType1, nid1, ncType1, ncid1, nodeType2, nid2, ncType2,
+                ncid2);
         ci.println(this.addUserLink(config));
     }
 
         ci.println(this.addUserLink(config));
     }
 
-    public void _delTopo(CommandInterpreter ci) {
+    public void _deleteUserLink(CommandInterpreter ci) {
         String name = ci.nextArgument();
         if ((name == null)) {
             ci.println("Please enter a valid Name");
         String name = ci.nextArgument();
         if ((name == null)) {
             ci.println("Please enter a valid Name");