Publishing of ofoverlay augmentations, fixed port-name augmentation bug 73/18173/1
authorMartin Sunal <msunal@cisco.com>
Sun, 12 Apr 2015 22:54:45 +0000 (00:54 +0200)
committerMartin Sunal <msunal@cisco.com>
Sun, 12 Apr 2015 22:54:45 +0000 (00:54 +0200)
Signed-off-by: Martin Sunal <msunal@cisco.com>
renderers/ofoverlay/pom.xml
renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/EndpointManager.java

index a1cf6576a2683c5ea187c46b9dbc63ed437a10a0..54f58310fc2857508ed3e7567853d7d5828e0e47 100644 (file)
@@ -70,7 +70,8 @@
             </Import-Package>
             <Embed-Dependency>httpclient,httpcore,commons-lang,commons-exec;type=!pom;inline=false</Embed-Dependency>
             <Export-Package>
-              org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf
+              org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sf,
+              org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528
             </Export-Package>
           </instructions>
           <manifestLocation>${project.basedir}/META-INF</manifestLocation>
index cb5d8c61e604926edd326b41ba0e9a88f456ff0a..0c79c4f346647ee165454c619ee87aedb7df5a77 100644 (file)
@@ -336,6 +336,71 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
             // TODO Auto-generated method stub
 
         }
+
+        private OfOverlayContextBuilder checkAugmentation(RegisterEndpointInput input) {
+            OfOverlayContextInput ictx = input.getAugmentation(OfOverlayContextInput.class);
+            if (ictx == null) {
+                return null;
+            }
+
+            OfOverlayContextBuilder ictxBuilder = new OfOverlayContextBuilder(ictx);
+            if (ictx.getPortName() != null && ictx.getNodeId() != null && ictx.getNodeConnectorId() != null) {
+                return ictxBuilder;
+            }
+
+            /*
+             * In the case where they've provided just the port name,
+             * go see if we can find the NodeId and NodeConnectorId
+             * from inventory.
+             */
+            if (ictx.getPortName() != null) {
+                NodeInfo augmentation = fetchAugmentation(ictx.getPortName().getValue());
+                if (augmentation != null) {
+                    ictxBuilder.setNodeId(augmentation.getNode().getId());
+                    ictxBuilder.setNodeConnectorId(augmentation.getNodeConnector().getId());
+                }
+            }
+            return ictxBuilder;
+        }
+
+        private NodeInfo fetchAugmentation(String portName) {
+            NodeInfo nodeInfo = null;
+
+            if (dataProvider != null) {
+
+                Optional<Nodes> result;
+                try {
+                    result = dataProvider
+                            .newReadOnlyTransaction().read(
+                                    LogicalDatastoreType.OPERATIONAL, nodesIid).get();
+                    if (result.isPresent()) {
+                        Nodes nodes = result.get();
+                        for (Node node : nodes.getNode()) {
+                            if (node.getNodeConnector() != null) {
+                                boolean found = false;
+                                for (NodeConnector nc : node.getNodeConnector()) {
+                                    FlowCapableNodeConnector fcnc = nc
+                                            .getAugmentation(FlowCapableNodeConnector.class);
+                                    if (fcnc.getName().equals(portName)) {
+                                        nodeInfo = new NodeInfo();
+                                        nodeInfo.setNode(node);
+                                        nodeInfo.setNodeConnector(nc);
+                                        found = true;
+                                        break;
+                                    }
+                                }
+                                if (found)
+                                    break;
+                            }
+                        }
+                    }
+                } catch (InterruptedException | ExecutionException e) {
+                    LOG.error("Caught exception in fetchAugmentation portName", e);
+                }
+
+            }
+            return nodeInfo;
+        }
     }
 
     // *************
@@ -823,37 +888,6 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
         }
     }
 
-    private OfOverlayContextBuilder checkAugmentation(RegisterEndpointInput input) {
-        OfOverlayContextBuilder ictxBuilder = new OfOverlayContextBuilder();
-        OfOverlayContextInput ictx = null;
-
-        ictx = input.getAugmentation(OfOverlayContextInput.class);
-        if (ictx != null) {
-            /*
-             * In the case where they've provided just the port name,
-             * go see if we can find the NodeId and NodeConnectorId
-             * from inventory.
-             */
-            if (ictx.getPortName() != null &&
-               (ictx.getNodeId() == null &&
-                ictx.getNodeConnectorId() == null)) {
-                NodeInfo augmentation = fetchAugmentation(ictx.getPortName().getValue());
-                if (augmentation != null) {
-                    ictxBuilder.setNodeId(augmentation.getNode().getId());
-                    ictxBuilder.setNodeConnectorId(augmentation.getNodeConnector().getId());
-                    ictxBuilder.setPortName(ictx.getPortName());
-                }
-            } else {
-                ictxBuilder.setNodeConnectorId(ictx.getNodeConnectorId());
-                ictxBuilder.setNodeId(ictx.getNodeId());
-                ictxBuilder.setPortName(ictx.getPortName());
-            }
-        } else {
-            ictxBuilder = null;
-        }
-        return ictxBuilder;
-    }
-
     // A wrapper class around node, nodeConnector info so we can pass a final
     // object inside OnSuccess anonymous inner class
     private static class NodeInfo {
@@ -886,42 +920,4 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
         }
     }
 
-    private NodeInfo fetchAugmentation(String portName) {
-        NodeInfo nodeInfo = null;
-
-        if (dataProvider != null) {
-
-            Optional<Nodes> result;
-            try {
-                result = dataProvider
-                        .newReadOnlyTransaction().read(
-                                LogicalDatastoreType.OPERATIONAL, nodesIid).get();
-                if (result.isPresent()) {
-                    Nodes nodes = result.get();
-                    for (Node node : nodes.getNode()) {
-                        if (node.getNodeConnector() != null) {
-                            boolean found = false;
-                            for (NodeConnector nc : node.getNodeConnector()) {
-                                FlowCapableNodeConnector fcnc = nc
-                                        .getAugmentation(FlowCapableNodeConnector.class);
-                                if (fcnc.getName().equals(portName)) {
-                                    nodeInfo = new NodeInfo();
-                                    nodeInfo.setNode(node);
-                                    nodeInfo.setNodeConnector(nc);
-                                    found = true;
-                                    break;
-                                }
-                            }
-                            if (found)
-                                break;
-                        }
-                    }
-                }
-            } catch (InterruptedException | ExecutionException e) {
-                LOG.error("Caught exception in fetchAugmentation portName", e);
-            }
-
-        }
-        return nodeInfo;
-    }
 }