Fixing mistake of having port-name in base and not augmentation. 41/18141/3
authorKeith Burns (alagalah) <alagalah@gmail.com>
Sat, 11 Apr 2015 00:36:10 +0000 (17:36 -0700)
committerKeith Burns <alagalah@gmail.com>
Sun, 12 Apr 2015 02:28:24 +0000 (02:28 +0000)
In lieu of NB API consume augmentations

Change-Id: I9f3d390cdc413ccef8e2e28b46cb66bcc1af10a5
Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
groupbasedpolicy/src/main/yang/model/endpoint.yang
renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/EndpointManager.java
renderers/ofoverlay/src/main/yang/ofoverlay.yang

index 7e8372f1cc89ed703d1da122b15e6811188e2deb..f3143cd2880c9a8e04e8633f2d51f722f6385e8e 100644 (file)
@@ -113,12 +113,6 @@ module endpoint {
             description
                 "The conditions associated with this endpoint";
         }
-        // This was a mistake and now it's an abomination.
-        leaf port-name {
-            type gbp-common:name;
-            description
-                "Port name";
-        } // end the abomination.
         leaf timestamp {
             type int64;
             description
index e45165bf16f8470d013f0c58a82d36bfaca4ef6e..dd19fcab8d34c10cd70ef3f3292516a131c40ca1 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.groupbasedpolicy.util.SetUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ConditionName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.Name;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput;
@@ -422,16 +423,19 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
                         for (Endpoint ep : endpoints.getEndpoint()) {
                             // 2. Search for portname
                             OfOverlayContext currentAugmentation = ep.getAugmentation(OfOverlayContext.class);
-                            if (ep.getPortName() != null && fcnc.getName() != null
-                                    && ep.getPortName().getValue().equals(fcnc.getName())) {
+                            if (currentAugmentation.getPortName() != null && fcnc.getName() != null
+                                    && currentAugmentation.getPortName().getValue().equals(fcnc.getName())) {
                                 NodeId nodeId;
                                 NodeConnectorId nodeConnectorId;
+                                Name name;
                                 try {
                                     nodeId = currentAugmentation.getNodeId();
                                     nodeConnectorId = currentAugmentation.getNodeConnectorId();
+                                    name = currentAugmentation.getPortName();
                                 } catch (Exception e) {
                                     nodeId = null;
                                     nodeConnectorId = null;
+                                    name = null;
                                 }
                                 Boolean process = false;
                                 if (nodeId == null && nodeConnectorId == null) {
@@ -451,6 +455,7 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
                                     OfOverlayContextBuilder ofOverlayAugmentation = new OfOverlayContextBuilder();
                                     ofOverlayAugmentation.setNodeId(node.getId());
                                     ofOverlayAugmentation.setNodeConnectorId(nc.getId());
+                                    ofOverlayAugmentation.setPortName(name);
                                     epBuilder.addAugmentation(OfOverlayContext.class, ofOverlayAugmentation.build());
                                     epBuilder.setL3Address(ep.getL3Address());
                                     InstanceIdentifier<Endpoint> iidEp = InstanceIdentifier.builder(Endpoints.class)
@@ -824,13 +829,24 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
 
         ictx = input.getAugmentation(OfOverlayContextInput.class);
         if (ictx != null) {
-            ictxBuilder.setNodeConnectorId(ictx.getNodeConnectorId());
-            ictxBuilder.setNodeId(ictx.getNodeId());
-        } else if (input.getPortName() != null) {
-            NodeInfo augmentation = fetchAugmentation(input.getPortName().getValue());
-            if (augmentation != null) {
-                ictxBuilder.setNodeId(augmentation.getNode().getId());
-                ictxBuilder.setNodeConnectorId(augmentation.getNodeConnector().getId());
+            /*
+             * 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;
index 0f014b6a745e3145478edc54e2a3c0cfcd1a85c5..d2b7d4989a6e8b1ff6951c5ce0994029bc0ec379 100644 (file)
@@ -123,6 +123,17 @@ module ofoverlay {
                  the endpoint is connected.";
             type inv:node-connector-id;
         }
+        leaf port-name {
+            type gbp-common:name;
+            description
+                "Port name";
+        }
+        leaf interface-id {
+            type gbp-common:unique-id;
+            description
+                "Unique identifier for interface";
+        }
+
     }
 
     augment "/endpoint:endpoints/endpoint:endpoint" {