From: Andrew Kim Date: Wed, 1 May 2013 17:17:20 +0000 (-0700) Subject: Hide production nodes in visual topology X-Git-Tag: releasepom-0.1.0~507^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=2429b6be7f76de1a8f4f9f7008bcff405adc4059 Hide production nodes in visual topology At least for now, we don't want to display production nodes within the visual topology. However, if there are production nodes, then the user can still view them using the northbound interface. Signed-off-by: Andrew Kim --- diff --git a/opendaylight/web/topology/src/main/java/org/opendaylight/controller/topology/web/Topology.java b/opendaylight/web/topology/src/main/java/org/opendaylight/controller/topology/web/Topology.java index 285e33f53b..af25abded0 100644 --- a/opendaylight/web/topology/src/main/java/org/opendaylight/controller/topology/web/Topology.java +++ b/opendaylight/web/topology/src/main/java/org/opendaylight/controller/topology/web/Topology.java @@ -28,6 +28,7 @@ import org.opendaylight.controller.sal.core.Host; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.core.Property; +import org.opendaylight.controller.sal.core.Node.NodeIDType; import org.opendaylight.controller.sal.packet.address.EthernetAddress; import org.opendaylight.controller.sal.utils.ServiceHelper; import org.opendaylight.controller.switchmanager.ISwitchManager; @@ -131,12 +132,21 @@ public class Topology { for (Map.Entry> e : nodeEdges.entrySet()) { Node n = e.getKey(); + + // skip production node + if (nodeIgnore(n)) { + continue; + } + String description = switchManager.getNodeDescription(n); NodeBean node = createNodeBean(description, n); List> adjacencies = new LinkedList>(); Set links = e.getValue(); for (Edge link : links) { + if (edgeIgnore(link)) { + continue; + } for (Property p : properties.get(link)) { if (p instanceof Bandwidth) { bandwidth = (Bandwidth) p; @@ -166,6 +176,45 @@ public class Topology { } } + /** + * Check if this node shouldn't appear in the visual topology + * + * @param node + * @return + */ + private boolean nodeIgnore(Node node) { + String nodeType = node.getType(); + + // add other node types to ignore later + if (nodeType.equals(NodeIDType.PRODUCTION)) { + return true; + } + + return false; + } + + /** + * Check if this edge shouldn't appear in the visual topology + * + * @param edge + * @return + */ + private boolean edgeIgnore(Edge edge) { + NodeConnector headNodeConnector = edge.getHeadNodeConnector(); + Node headNode = headNodeConnector.getNode(); + if (nodeIgnore(headNode)) { + return true; + } + + NodeConnector tailNodeConnector = edge.getTailNodeConnector(); + Node tailNode = tailNodeConnector.getNode(); + if (nodeIgnore(tailNode)) { + return true; + } + + return false; + } + protected NodeBean createNodeBean(String description, Node node) { String name = (description == null || description.trim().isEmpty() || @@ -179,6 +228,11 @@ public class Topology { if (nodes == null) return; for (Switch sw : nodes) { Node n = sw.getNode(); + + // skip production node + if (nodeIgnore(n)) { + continue; + } String description = switchManager.getNodeDescription(n);