Containment endpoint can only have relative location 47/38947/4
authorMartin Sunal <msunal@cisco.com>
Mon, 16 May 2016 20:44:33 +0000 (22:44 +0200)
committerMartin Sunal <msunal@cisco.com>
Wed, 18 May 2016 12:52:52 +0000 (12:52 +0000)
Containment endpoint must not contain real location because
containment endpoint represents part of forwarding context
which is out of policy domain(It also means that containment endpoint
can be located only in EIG EPG)

Change-Id: I7b7147c2c23f7bf1bcca116c99970dbb52e9707d
Signed-off-by: Martin Sunal <msunal@cisco.com>
groupbasedpolicy/src/main/yang/model/base-endpoint.yang
groupbasedpolicy/src/main/yang/model/endpoint-location-provider.yang
groupbasedpolicy/src/main/yang/model/renderer.yang
location-providers/ne-location-provider/src/main/java/org/opendaylight/groupbasedpolicy/ne/location/provider/NeLocationProvider.java

index ce394e27c1bedfb106d5a8d721e9c9db7adb174d..2d4d388d30bd4c5dc691f054fa23825e2342b23a 100644 (file)
@@ -125,22 +125,27 @@ module base-endpoint {
         }
     }
 
-    grouping has-regular-location {
-        leaf node {
+    grouping internal-location-fields {
+        description "Location inside ODL - node and node-connector
+            are represented directly in ODL.";
+        leaf internal-node {
             mandatory true;
             type instance-identifier;
         }
-        leaf node-connector {
+        leaf internal-node-connector {
             type instance-identifier;
         }
     }
 
-    grouping has-external-location {
+    grouping external-location-fields {
+        description "Location outside of ODL - node and node-connector
+            are outside of ODL. external-node-mount-point is path
+            to external system where node and node-connector are located.";
         leaf external-node-mount-point {
             mandatory true;
             type instance-identifier;
         }
-        leaf external-node-location {
+        leaf external-node {
             type string; // TODO switch to external-reference
         }
         leaf external-node-connector {
@@ -148,29 +153,37 @@ module base-endpoint {
         }
     }
 
-    grouping has-location {
-        container real-location {
+    grouping has-absolute-location {
+        container absolute-location {
             choice location-type {
-                case regular-location-case {
-                    uses has-regular-location;
+                case internal-location-case {
+                    uses internal-location-fields;
                 }
                 case external-location-case {
-                    uses has-external-location;
+                    uses external-location-fields;
                 }
             }
         }
-        container relative-location {
-            list location {
-                key "node node-connector";
-                uses has-regular-location;
+    }
+
+    grouping has-relative-location {
+        container relative-locations {
+            list internal-location {
+                key "internal-node internal-node-connector";
+                uses internal-location-fields;
             }
             list external-location {
                 key "external-node-mount-point external-node-connector";
-                uses has-external-location;
+                uses external-location-fields;
             }
         }
     }
 
+    grouping has-location {
+        uses has-absolute-location;
+        uses has-relative-location;
+    }
+
     container endpoints {
         description
                 "Repository for operational state data about endpoints needed
@@ -202,7 +215,7 @@ module base-endpoint {
         list containment-endpoint-location {
             key "context-type context-id";
             uses forwarding:context-key;
-            uses has-location;
+            uses has-relative-location;
         }
     }
 
@@ -221,7 +234,7 @@ module base-endpoint {
             list containment-endpoint-reg {
                 key "context-type context-id";
                 uses containment-endpoint-fields;
-                uses has-location;
+                uses has-relative-location;
             }
         }
     }
index 9e1f19b39a825aa0c2fd5f883093934995aeb7b2..5519d5e645a62b9456724b71d20903969a599b28 100644 (file)
@@ -41,7 +41,7 @@ module endpoint-location-provider {
             list provider-containment-endpoint-location {\r
                 key "context-type context-id";\r
                 uses forwarding:context-key;\r
-                uses base-endpoint:has-location;\r
+                uses base-endpoint:has-relative-location;\r
             }\r
         }\r
     }\r
index 2b15e8487c5ceff3b2c19efd0ab4f891569e0268..6d508eec353d16e89eeb62b768ff003a261d1b26 100755 (executable)
@@ -164,7 +164,9 @@ module renderer {
                 list renderer-node {
                     key "node-path";
                     leaf node-path {
-                        description "Path to the node where policy needs to be enforced.";
+                        description "Path to the node where policy needs to be enforced.
+                            This field is matched against internal-node and external-node-mount-point
+                            from base-endoint:endpoint-locations.";
                         type instance-identifier;
                     }
                 }
@@ -234,7 +236,7 @@ module renderer {
                         list containment-endpoint-with-location {
                             key "context-type context-id";
                             uses base-endpoint:address-endpoint-fields;
-                            uses base-endpoint:has-location;
+                            uses base-endpoint:has-relative-location;
                         }
                     }
 
index a25469f2112e7d7dde7e100be882aad2ce13ba43..99325e0896c77271169fd912475b952fcacf8722 100644 (file)
@@ -26,9 +26,9 @@ import org.opendaylight.groupbasedpolicy.util.IidFactory;
 import org.opendaylight.groupbasedpolicy.util.NetUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoints.address.endpoints.AddressEndpoint;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.location.RealLocation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.location.RealLocationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.location.real.location.location.type.RegularLocationCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.absolute.location.AbsoluteLocation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.absolute.location.AbsoluteLocationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.has.absolute.location.absolute.location.location.type.InternalLocationCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.network.elements.rev160407.NetworkElements;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.network.elements.rev160407.NetworkElementsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.network.elements.rev160407.network.elements.NetworkElement;
@@ -111,10 +111,10 @@ public class NeLocationProvider implements DataTreeChangeListener<NetworkElement
                             && endpoint.getAddressType().isAssignableFrom(IpPrefixType.class) && NetUtils
                                 .samePrefix(new IpPrefix(endpoint.getAddress().toCharArray()), en.getIpPrefix())) {
                         WriteTransaction wtx = dataBroker.newWriteOnlyTransaction();
-                        InstanceIdentifier<RealLocation> iid = IidFactory
+                        InstanceIdentifier<AbsoluteLocation> iid = IidFactory
                             .providerAddressEndpointLocationIid(NE_LOCATION_PROVIDER_NAME, IpPrefixType.class,
                                     endpoint.getAddress(), endpoint.getContextType(), endpoint.getContextId())
-                            .child(RealLocation.class)
+                            .child(AbsoluteLocation.class)
                             .build();
                         wtx.put(LogicalDatastoreType.OPERATIONAL, iid, createRealLocation(ne.getIid(), iface.getIid()),
                                 true);
@@ -136,10 +136,10 @@ public class NeLocationProvider implements DataTreeChangeListener<NetworkElement
                             && endpoint.getAddressType().isAssignableFrom(IpPrefixType.class) && NetUtils
                                 .samePrefix(new IpPrefix(endpoint.getAddress().toCharArray()), en.getIpPrefix())) {
                         WriteTransaction wtx = dataBroker.newWriteOnlyTransaction();
-                        InstanceIdentifier<RealLocation> iid = IidFactory
+                        InstanceIdentifier<AbsoluteLocation> iid = IidFactory
                             .providerAddressEndpointLocationIid(NE_LOCATION_PROVIDER_NAME, IpPrefixType.class,
                                     endpoint.getAddress(), endpoint.getContextType(), endpoint.getContextId())
-                            .child(RealLocation.class)
+                            .child(AbsoluteLocation.class)
                             .build();
                         wtx.delete(LogicalDatastoreType.OPERATIONAL, iid);
                         wtx.submit();
@@ -160,7 +160,7 @@ public class NeLocationProvider implements DataTreeChangeListener<NetworkElement
                     for (NetworkElement ne : nullToEmpty(nes.getNetworkElement())) {
                         for (Interface iface : nullToEmpty(ne.getInterface())) {
                             for (EndpointNetwork en : nullToEmpty(iface.getEndpointNetwork())) {
-                                processDeletedEN(en, ne.getIid(), iface.getIid());
+                                processDeletedEN(en);
                             }
                         }
                     }
@@ -174,7 +174,7 @@ public class NeLocationProvider implements DataTreeChangeListener<NetworkElement
                         for (NetworkElement ne : nullToEmpty(nes.getNetworkElement())) {
                             for (Interface iface : nullToEmpty(ne.getInterface())) {
                                 for (EndpointNetwork en : nullToEmpty(iface.getEndpointNetwork())) {
-                                    processDeletedEN(en, ne.getIid(), iface.getIid());
+                                    processDeletedEN(en);
                                 }
                             }
                         }
@@ -225,7 +225,7 @@ public class NeLocationProvider implements DataTreeChangeListener<NetworkElement
                 NetworkElement ne = netElement.getDataBefore();
                 for (Interface iface : nullToEmpty(ne.getInterface())) {
                     for (EndpointNetwork en : nullToEmpty(iface.getEndpointNetwork())) {
-                        processDeletedEN(en, ne.getIid(), iface.getIid());
+                        processDeletedEN(en);
                     }
                 }
                 networkElements.getNetworkElement().remove(ne);
@@ -237,7 +237,7 @@ public class NeLocationProvider implements DataTreeChangeListener<NetworkElement
                 if (ne != null) {
                     for (Interface iface : nullToEmpty(ne.getInterface())) {
                         for (EndpointNetwork en : nullToEmpty(iface.getEndpointNetwork())) {
-                            processDeletedEN(en, ne.getIid(), iface.getIid());
+                            processDeletedEN(en);
                         }
                     }
                     networkElements.getNetworkElement().remove(ne);
@@ -284,7 +284,7 @@ public class NeLocationProvider implements DataTreeChangeListener<NetworkElement
             case DELETE: {
                 Interface iface = modifiedInterface.getDataBefore();
                 for (EndpointNetwork en : nullToEmpty(iface.getEndpointNetwork())) {
-                    processDeletedEN(en, nodeBefore.getIid(), iface.getIid());
+                    processDeletedEN(en);
                 }
                 int nodeIndex = getIndexOf(nodeBefore);
                 networkElements.getNetworkElement().get(nodeIndex).getInterface().remove(iface);
@@ -296,7 +296,7 @@ public class NeLocationProvider implements DataTreeChangeListener<NetworkElement
                 int nodeIndex = getIndexOf(nodeBefore);
                 if (iface != null) {
                     for (EndpointNetwork en : nullToEmpty(iface.getEndpointNetwork())) {
-                        processDeletedEN(en, nodeBefore.getIid(), iface.getIid());
+                        processDeletedEN(en);
                     }
                     networkElements.getNetworkElement().get(nodeIndex).getInterface().remove(iface);
                 }
@@ -339,7 +339,7 @@ public class NeLocationProvider implements DataTreeChangeListener<NetworkElement
             NetworkElement nodeBefore, Interface ifaceBefore) {
         switch (modifiedEN.getModificationType()) {
             case DELETE: {
-                processDeletedEN(modifiedEN.getDataBefore(), nodeBefore.getIid(), ifaceBefore.getIid());
+                processDeletedEN(modifiedEN.getDataBefore());
                 int nodeIndex = getIndexOf(nodeBefore);
                 int ifaceIndex = getIndexOf(ifaceBefore, nodeIndex);
                 networkElements.getNetworkElement()
@@ -379,10 +379,10 @@ public class NeLocationProvider implements DataTreeChangeListener<NetworkElement
                     && endpoint.getContextId().equals(en.getL3ContextId())
                     && endpoint.getAddressType().isAssignableFrom(IpPrefixType.class)
                     && NetUtils.samePrefix(new IpPrefix(endpoint.getAddress().toCharArray()), en.getIpPrefix())) {
-                InstanceIdentifier<RealLocation> iid = IidFactory
+                InstanceIdentifier<AbsoluteLocation> iid = IidFactory
                     .providerAddressEndpointLocationIid(NE_LOCATION_PROVIDER_NAME, IpPrefixType.class,
                             endpoint.getAddress(), endpoint.getContextType(), endpoint.getContextId())
-                    .child(RealLocation.class)
+                    .child(AbsoluteLocation.class)
                     .build();
                 wtx.put(LogicalDatastoreType.OPERATIONAL, iid, createRealLocation(nodeIID, connectorIID), true);
                 wtx.submit();
@@ -392,18 +392,17 @@ public class NeLocationProvider implements DataTreeChangeListener<NetworkElement
         }
     }
 
-    private void processDeletedEN(EndpointNetwork en, InstanceIdentifier<?> nodeIID,
-            InstanceIdentifier<?> connectorIID) {
+    private void processDeletedEN(EndpointNetwork en) {
         WriteTransaction wtx = dataBroker.newWriteOnlyTransaction();
         for (AddressEndpoint endpoint : endpoints) {
             if (endpoint.getContextType().isAssignableFrom(L3Context.class)
                     && endpoint.getContextId().equals(en.getL3ContextId())
                     && endpoint.getAddressType().isAssignableFrom(IpPrefixType.class)
                     && NetUtils.samePrefix(new IpPrefix(endpoint.getAddress().toCharArray()), en.getIpPrefix())) {
-                InstanceIdentifier<RealLocation> iid = IidFactory
+                InstanceIdentifier<AbsoluteLocation> iid = IidFactory
                     .providerAddressEndpointLocationIid(NE_LOCATION_PROVIDER_NAME, IpPrefixType.class,
                             endpoint.getAddress(), endpoint.getContextType(), endpoint.getContextId())
-                    .child(RealLocation.class)
+                    .child(AbsoluteLocation.class)
                     .build();
                 wtx.delete(LogicalDatastoreType.OPERATIONAL, iid);
                 wtx.submit();
@@ -413,9 +412,9 @@ public class NeLocationProvider implements DataTreeChangeListener<NetworkElement
         }
     }
 
-    private RealLocation createRealLocation(InstanceIdentifier<?> node, InstanceIdentifier<?> iface) {
-        return new RealLocationBuilder()
-            .setLocationType(new RegularLocationCaseBuilder().setNode(node).setNodeConnector(iface).build()).build();
+    private AbsoluteLocation createRealLocation(InstanceIdentifier<?> node, InstanceIdentifier<?> iface) {
+        return new AbsoluteLocationBuilder()
+            .setLocationType(new InternalLocationCaseBuilder().setInternalNode(node).setInternalNodeConnector(iface).build()).build();
     }
 
     private <T> List<T> nullToEmpty(@Nullable List<T> list) {