Allow Topology DB to keep track of production switches 56/1656/4
authorAlessandro Boch <aboch@cisco.com>
Thu, 3 Oct 2013 19:09:42 +0000 (12:09 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 3 Oct 2013 23:07:51 +0000 (23:07 +0000)
ISSUE: Discovery service is able to discover any non SDN enable
switch directly conencted to the controlled SDN switches which
advertise itself through LLDP. It is a nice feature to be able
to see on the topology to which non-SDN switches the controlled
network nodes are conencted to.
Change in https://git.opendaylight.org/gerrit/#/c/1450/ breaks this feature.

CHANGE: Limit the validation check introduced in the above commit
to the edge head end point only.

Change-Id: I081f4320a73eea9bf2a39ca80717771d9c7adfb3
Signed-off-by: Alessandro Boch <aboch@cisco.com>
opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java
opendaylight/topologymanager/implementation/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java

index 526ba41..7452abb 100644 (file)
@@ -521,11 +521,16 @@ public class TopologyManagerImpl implements
         }
     }
 
-    private boolean nodeConnectorsExist(Edge e) {
+    private boolean headNodeConnectorExist(Edge e) {
+        /*
+         * Only check the head end point which is supposed to be part of a
+         * network node we control (present in our inventory). If we checked the
+         * tail end point as well, we would not store the edges that connect to
+         * a non sdn enable port on a non sdn capable production switch. We want
+         * to be able to see these switches on the topology.
+         */
         NodeConnector head = e.getHeadNodeConnector();
-        NodeConnector tail = e.getTailNodeConnector();
-        return (switchManager.doesNodeConnectorExist(head) &&
-                switchManager.doesNodeConnectorExist(tail));
+        return (switchManager.doesNodeConnectorExist(head));
     }
 
     private TopoEdgeUpdate edgeUpdate(Edge e, UpdateType type, Set<Property> props) {
@@ -536,8 +541,9 @@ public class TopologyManagerImpl implements
                 log.trace("Skipping redundant edge addition: {}", e);
                 return null;
             }
-            // Ensure that both tail and head node connectors exist.
-            if (!nodeConnectorsExist(e)) {
+
+            // Ensure that head node connector exists
+            if (!headNodeConnectorExist(e)) {
                 log.warn("Ignore edge that contains invalid node connector: {}", e);
                 return null;
             }
index 1388864..9796625 100644 (file)
@@ -457,13 +457,13 @@ public class TopologyManagerImplTest {
     @Test
     public void testAddDeleteUserLink() {
         TopologyUserLinkConfig link1 = new TopologyUserLinkConfig("default1",
-                "OF|1@OF|2", "OF|1@OF|2");
+                "OF|1@OF|2", "OF|1@OF|3");
         TopologyUserLinkConfig link2 = new TopologyUserLinkConfig("default1",
-                "OF|10@OF|20", "OF|10@OF|20");
+                "OF|10@OF|20", "OF|10@OF|30");
         TopologyUserLinkConfig link3 = new TopologyUserLinkConfig("default2",
-                "OF|1@OF|2", "OF|1@OF|2");
+                "OF|1@OF|2", "OF|1@OF|3");
         TopologyUserLinkConfig link4 = new TopologyUserLinkConfig("default20",
-                "OF|10@OF|20", "OF|10@OF|20");
+                "OF|10@OF|20", "OF|10@OF|30");
 
         TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
         TestSwitchManager swMgr = new TestSwitchManager();
@@ -485,9 +485,9 @@ public class TopologyManagerImplTest {
         Assert.assertTrue(topoManagerImpl.getUserLinks().isEmpty());
 
         TopologyUserLinkConfig badlink1 =
-            new TopologyUserLinkConfig("bad1", "OF|1@OF|2", "OF|1@OF|3");
+            new TopologyUserLinkConfig("bad1", "OF|1@OF|4", "OF|1@OF|5");
         TopologyUserLinkConfig badlink2 =
-            new TopologyUserLinkConfig("bad2", "OF|10@OF|21", "OF|10@OF|20");
+            new TopologyUserLinkConfig("bad2", "OF|10@OF|7", "OF|7@OF|13");
         Assert.assertEquals(StatusCode.NOTFOUND,
                             topoManagerImpl.addUserLink(badlink1).getCode());
         Assert.assertEquals(StatusCode.NOTFOUND,
@@ -630,10 +630,11 @@ public class TopologyManagerImplTest {
 
         for (int i = 0; i < 5; i++) {
             Host host = topoManagerImpl.getHostAttachedToNodeConnector(nc[i]);
-            if (i == 4)
+            if (i == 4) {
                 Assert.assertTrue(host == null);
-            else
+            } else {
                 Assert.assertTrue(host.equals(h[i]));
+            }
         }
 
         Set<NodeConnector> ncSet = topoManagerImpl.getNodeConnectorWithHost();