From: Martin Sunal Date: Mon, 16 May 2016 20:44:33 +0000 (+0200) Subject: Containment endpoint can only have relative location X-Git-Tag: release/boron~171 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=71ad24e8d71ea86dfaa1faf84de1e6fca3ae4cc7;p=groupbasedpolicy.git Containment endpoint can only have relative location 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 --- diff --git a/groupbasedpolicy/src/main/yang/model/base-endpoint.yang b/groupbasedpolicy/src/main/yang/model/base-endpoint.yang index ce394e27c..2d4d388d3 100644 --- a/groupbasedpolicy/src/main/yang/model/base-endpoint.yang +++ b/groupbasedpolicy/src/main/yang/model/base-endpoint.yang @@ -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; } } } diff --git a/groupbasedpolicy/src/main/yang/model/endpoint-location-provider.yang b/groupbasedpolicy/src/main/yang/model/endpoint-location-provider.yang index 9e1f19b39..5519d5e64 100644 --- a/groupbasedpolicy/src/main/yang/model/endpoint-location-provider.yang +++ b/groupbasedpolicy/src/main/yang/model/endpoint-location-provider.yang @@ -41,7 +41,7 @@ module endpoint-location-provider { list provider-containment-endpoint-location { key "context-type context-id"; uses forwarding:context-key; - uses base-endpoint:has-location; + uses base-endpoint:has-relative-location; } } } diff --git a/groupbasedpolicy/src/main/yang/model/renderer.yang b/groupbasedpolicy/src/main/yang/model/renderer.yang index 2b15e8487..6d508eec3 100755 --- a/groupbasedpolicy/src/main/yang/model/renderer.yang +++ b/groupbasedpolicy/src/main/yang/model/renderer.yang @@ -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; } } diff --git a/location-providers/ne-location-provider/src/main/java/org/opendaylight/groupbasedpolicy/ne/location/provider/NeLocationProvider.java b/location-providers/ne-location-provider/src/main/java/org/opendaylight/groupbasedpolicy/ne/location/provider/NeLocationProvider.java index a25469f21..99325e089 100644 --- a/location-providers/ne-location-provider/src/main/java/org/opendaylight/groupbasedpolicy/ne/location/provider/NeLocationProvider.java +++ b/location-providers/ne-location-provider/src/main/java/org/opendaylight/groupbasedpolicy/ne/location/provider/NeLocationProvider.java @@ -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 iid = IidFactory + InstanceIdentifier 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 iid = IidFactory + InstanceIdentifier 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 iid = IidFactory + InstanceIdentifier 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 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 iid = IidFactory + InstanceIdentifier 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 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 List nullToEmpty(@Nullable List list) {