From: Alessandro Boch Date: Thu, 3 Oct 2013 19:09:42 +0000 (-0700) Subject: Allow Topology DB to keep track of production switches X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-1~673 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=17e56497531f66554f6d533ef0f85ac7264f48fa Allow Topology DB to keep track of production switches 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 --- diff --git a/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java b/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java index 526ba41c35..7452abbbb4 100644 --- a/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java +++ b/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImpl.java @@ -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 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; } diff --git a/opendaylight/topologymanager/implementation/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java b/opendaylight/topologymanager/implementation/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java index 13888646bc..97966255a0 100644 --- a/opendaylight/topologymanager/implementation/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java +++ b/opendaylight/topologymanager/implementation/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java @@ -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 ncSet = topoManagerImpl.getNodeConnectorWithHost();