Introduced forwarding.yang and l2-l3-forwarding.yang 87/38387/6
authorMartin Sunal <msunal@cisco.com>
Wed, 4 May 2016 21:47:21 +0000 (23:47 +0200)
committerMartin Sunal <msunal@cisco.com>
Thu, 5 May 2016 15:37:08 +0000 (17:37 +0200)
forwarding.yang is generic forwarding model. Its elements are used
  in endpoints from base-endpoint.yang
l2-l3-forwarding.yang contains forwarding model specific for L2 and L3
  networking. It also augments forwarding.yang with further information

Change-Id: I3343bee9ae1ba40963fb3be9592e6b5178b3c3d9
Signed-off-by: Martin Sunal <msunal@cisco.com>
groupbasedpolicy/src/main/yang/model/base-endpoint.yang
groupbasedpolicy/src/main/yang/model/common.yang
groupbasedpolicy/src/main/yang/model/endpoint-location-provider.yang
groupbasedpolicy/src/main/yang/model/endpoint.yang
groupbasedpolicy/src/main/yang/model/forwarding.yang [new file with mode: 0644]
groupbasedpolicy/src/main/yang/model/l2-l3-forwarding.yang [new file with mode: 0644]
groupbasedpolicy/src/main/yang/model/policy.yang
sxp-mapper/src/main/java/org/opendaylight/groupbasedpolicy/sxp/mapper/impl/SxpMapperReactorImpl.java
sxp-mapper/src/main/yang/sxp-mapper-model.yang
sxp-mapper/src/test/java/org/opendaylight/groupbasedpolicy/sxp/mapper/impl/SxpMapperReactorImplTest.java

index 0807a5db6944b5a6ad55d2d8c25c9196b0c36e09..6936a2978f69126ba13fd860260bec923ea05ce0 100644 (file)
@@ -13,103 +13,29 @@ module base-endpoint {
     prefix "base-endpoint";
 
     import gbp-common { prefix gbp-common; revision-date 2014-04-21; }
-    import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
-    import ietf-yang-types { prefix yang; revision-date 2010-09-24; }
+    import forwarding { prefix forwarding; revision-date 2016-04-27; }
 
     revision "2016-04-27" {
         description
                 "Initial revision.";
     }
 
-    typedef address {
-        type string;
-    }
-
-    typedef mac-address {
-        // TODO should be moved to separate yang
-        type address {
-            pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
-        }
-    }
-
-    typedef ipv4-prefix {
-        // TODO should be moved to separate yang
-        type address {
-            pattern
-                '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
-              +  '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
-              + '/(([0-9])|([1-2][0-9])|(3[0-2]))';
-        }
-        description
-            "The ipv4-prefix type represents an IPv4 address prefix.
-             The prefix length is given by the number following the
-             slash character and must be less than or equal to 32.
-             A prefix length value of n corresponds to an IP address
-             mask that has n contiguous 1-bits from the most
-             significant bit (MSB) and all other bits set to 0.
-             The canonical format of an IPv4 prefix has all bits of
-             the IPv4 address set to zero that are not part of the
-             IPv4 prefix.";
-    }
-
-    typedef ipv6-prefix {
-        // TODO should be moved to separate yang
-        type address {
-            pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
-                + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
-                + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
-                + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
-                + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
-            pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
-                + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
-                + '(/.+)';
-        }
-        description
-            "The ipv6-prefix type represents an IPv6 address prefix.
-             The prefix length is given by the number following the
-             slash character and must be less than or equal 128.
-             A prefix length value of n corresponds to an IP address
-             mask that has n contiguous 1-bits from the most
-             significant bit (MSB) and all other bits set to 0.
-             The IPv6 address should have all bits that do not belong
-             to the prefix set to zero.
-             The canonical format of an IPv6 prefix has all bits of
-             the IPv6 address set to zero that are not part of the
-             IPv6 prefix.  Furthermore, IPv6 address is represented
-             in the compressed format described in RFC 4291, Section
-             2.2, item 2 with the following additional rules: the ::
-             substitution must be applied to the longest sequence of
-             all-zero 16-bit chunks in an IPv6 address.  If there is
-             a tie, the first sequence of all-zero 16-bit chunks is
-             replaced by ::.  Single all-zero 16-bit chunks are not
-             compressed.  The canonical format uses lowercase
-             characters and leading zeros are not allowed.";
-        reference
-            "RFC 4291: IP Version 6 Addressing Architecture";
-    }
-
-    grouping containment-endpoint-key {
-        leaf containment {
-            type gbp-common:context-id;
-            mandatory true;
-        }
-    }
-
     grouping address-endpoint-key {
+        uses forwarding:has-address-type;
         leaf address {
-            type address;
+            type string;
             mandatory true;
         }
     }
 
     grouping endpoint-key {
-        uses containment-endpoint-key;
+        uses forwarding:context-key;
         uses address-endpoint-key;
     }
 
     grouping has-child-endpoints {
         list child-endpoint {
-            key "containment address";
+            key "context-type context-id address-type address";
             uses endpoint-key;
         }
     }
@@ -118,13 +44,13 @@ module base-endpoint {
         choice parent-endpoint-choice {
             case parent-containment-endpoint-case {
                 list parent-containment-endpoint {
-                    key "containment";
-                    uses containment-endpoint-key;
+                    key "context-type context-id";
+                    uses forwarding:context-key;
                 }
             }
             case parent-endpoint-case {
                 list parent-endpoint {
-                    key "containment address";
+                    key "context-type context-id address-type address";
                     uses endpoint-key;
                 }
             }
@@ -139,12 +65,11 @@ module base-endpoint {
             description
                         "The tenant with which this endpoint is associated";
         }
-        leaf network-containment {
+        container network-containment {
             description
                         "The network domain associated with this endpoint's fowarding
                         context.";
-            mandatory true;
-            type gbp-common:network-domain-id;
+            uses forwarding:network-domain-key;
         }
         leaf-list endpoint-group {
             type gbp-common:endpoint-group-id;
@@ -238,11 +163,11 @@ module base-endpoint {
         config false;
 
         list address-endpoints-by-containment {
-            key containment;
-            uses containment-endpoint-key;
+            key "context-type context-id";
+            uses forwarding:context-key;
 
             list address-endpoint {
-                key address;
+                key "address-type address";
                 uses address-endpoint-key;
 
                 uses parent-child-endpoints;
@@ -252,8 +177,8 @@ module base-endpoint {
         }
 
         list containment-endpoint {
-            key "containment";
-            uses containment-endpoint-key;
+            key "context-type context-id";
+            uses forwarding:context-key;
 
             uses has-child-endpoints;
             uses common-endpoint-fields;
@@ -262,14 +187,14 @@ module base-endpoint {
 
     container endpoint-locations {
         list address-endpoint-location {
-            key "containment address";
+            key "context-type context-id address-type address";
             uses endpoint-key;
             uses has-location;
         }
 
         list containment-endpoint-location {
-            key "containment";
-            uses containment-endpoint-key;
+            key "context-type context-id";
+            uses forwarding:context-key;
             uses has-location;
         }
     }
@@ -281,17 +206,17 @@ module base-endpoint {
                 with the new information.";
 
         input {
-            list address-endpoint {
-                key "containment address";
+            list address-endpoint-reg {
+                key "context-type context-id address-type address";
                 uses endpoint-key;
 
                 uses parent-child-endpoints;
                 uses common-endpoint-fields;
                 uses has-location;
             }
-            list containment-endpoint {
-                key "containment";
-                uses containment-endpoint-key;
+            list containment-endpoint-reg {
+                key "context-type context-id";
+                uses forwarding:context-key;
 
                 uses has-child-endpoints;
                 uses common-endpoint-fields;
@@ -304,13 +229,13 @@ module base-endpoint {
         description "Unregister an endpoint or endpoints from the registry.";
 
         input {
-            list address-endpoint {
-                key "containment address";
+            list address-endpoint-unreg {
+                key "context-type context-id address-type address";
                 uses endpoint-key;
             }
-            list containment-endpoint {
-                key "containment";
-                uses containment-endpoint-key;
+            list containment-endpoint-unreg {
+                key "context-type context-id";
+                uses forwarding:context-key;
             }
         }
     }
index fd12157952acf450dabd99078761aef77037bf13..7f7058e7dfa8a8f44a7511c8fc809766bff1cf5f 100755 (executable)
@@ -99,6 +99,9 @@ module gbp-common {
     }
 
     typedef subnet-id {
+
+        status deprecated;
+
         type network-domain-id;
         description "A unique ID for a subnet";
     }
@@ -109,21 +112,33 @@ module gbp-common {
     }
 
     typedef l2-context-id {
+
+        status deprecated;
+
         type context-id;
         description "A unique ID for a layer 2 context";
     }
 
     typedef l2-bridge-domain-id {
+
+        status deprecated;
+
         type l2-context-id;
         description "A unique ID for a bridge domain";
     }
 
     typedef l2-flood-domain-id {
+
+        status deprecated;
+
         type l2-context-id;
         description "A unique ID for a flood domain";
     }
 
     typedef l3-context-id {
+
+        status deprecated;
+
         type context-id;
         description "A unique ID for a layer 3 context";
     }
index 58267c575212fd145fded9319c1bca42590cbf52..0eeacff2f2a83e34aa1f4ac600e433b0b5bd99a3 100644 (file)
@@ -13,6 +13,7 @@ module endpoint-locations {
     prefix "endpoints-location";\r
 \r
     import base-endpoint { prefix base-endpoint; revision-date 2016-04-27; }\r
+    import forwarding { prefix forwarding; revision-date 2016-04-27; }\r
 \r
     description\r
         "This module defines network element structure for location provider.";\r
@@ -33,13 +34,13 @@ module endpoint-locations {
                 type provider-name;\r
             }\r
             list endpoint-location {\r
-                key "containment address";\r
+                key "context-type context-id address-type address";\r
                 uses base-endpoint:endpoint-key;\r
                 uses base-endpoint:has-location;\r
             }\r
             list containment-endpoint-location {\r
-                key "containment";\r
-                uses base-endpoint:containment-endpoint-key;\r
+                key "context-type context-id";\r
+                uses forwarding:context-key;\r
                 uses base-endpoint:has-location;\r
             }\r
         }\r
index bc0bfef878db9922048215b8a754fe4eb37078a7..0f1690730316e15ad34e8151999ba4b797405472 100644 (file)
@@ -188,6 +188,10 @@ module endpoint {
     }
 
     container endpoints {
+
+        // use base-endpoint.yang instead
+        status deprecated;
+
         description
             "Repository for operational state data about endpoints needed for
              policy resolution.";
@@ -229,6 +233,10 @@ module endpoint {
     }
 
     rpc register-endpoint {
+
+        // use base-endpoint.yang instead
+        status deprecated;
+
         description
             "Register a new endpoint into the registry.  If there
              is already an existing endpoint with the same keys, they
@@ -240,6 +248,10 @@ module endpoint {
     }
 
     rpc register-l3-prefix-endpoint {
+
+        // use base-endpoint.yang instead
+        status deprecated;
+
         description
             "Register an L3 Prefix Endpoint to the endpoint registery. If there
             is already an existing endpoint with the same keys, they
@@ -251,6 +263,10 @@ module endpoint {
     }
 
     rpc unregister-endpoint {
+
+        // use base-endpoint.yang instead
+        status deprecated;
+
         description "Unregister an endpoint or endpoints from the registry.";
 
         input {
@@ -270,6 +286,9 @@ module endpoint {
     }
 
     rpc set-endpoint-group-conditions {
+
+        status deprecated;
+
         description
             "Set a list of conditions for a particular endpoint group.
              These conditions will apply to all endpoints in the
@@ -282,6 +301,9 @@ module endpoint {
     }
 
     rpc unset-endpoint-group-conditions {
+
+        status deprecated;
+
         description
             "Remove a list of conditions from an endpoint group.";
 
diff --git a/groupbasedpolicy/src/main/yang/model/forwarding.yang b/groupbasedpolicy/src/main/yang/model/forwarding.yang
new file mode 100644 (file)
index 0000000..a191cc1
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+module forwarding {
+    yang-version 1;
+
+    namespace "urn:opendaylight:groupbasedpolicy:forwarding";
+    prefix "forwarding";
+
+    import gbp-common { prefix gbp-common; revision-date 2014-04-21; }
+
+    revision "2016-04-27" {
+        description
+                "Initial revision.";
+    }
+
+    identity address-type {
+        description "Address type used in endoints.";
+    }
+
+    identity network-domain {
+        description "Basic forwarding entity";
+    }
+
+    identity context-type {
+        description "Type of context.";
+        base network-domain;
+    }
+
+    typedef address-type-ref {
+        description "Reference to address type.";
+        type identityref {
+            base address-type;
+        }
+    }
+
+    typedef network-domain-ref {
+        description "Reference to network domain.";
+        type identityref {
+            base network-domain;
+        }
+    }
+
+    typedef context-type-ref {
+        description "Reference to context type.";
+        type identityref {
+            base context-type;
+        }
+    }
+
+    grouping network-domain-key {
+        leaf network-domain-type {
+            type network-domain-ref;
+            mandatory true;
+        }
+        leaf network-domain-id {
+            type gbp-common:network-domain-id;
+            mandatory true;
+        }
+    }
+
+    grouping context-key {
+        leaf context-type {
+            type context-type-ref;
+            mandatory true;
+        }
+        leaf context-id {
+            type gbp-common:context-id;
+            mandatory true;
+        }
+    }
+
+    grouping has-address-type {
+        leaf address-type {
+            type address-type-ref;
+            mandatory true;
+        }
+    }
+
+    container forwarding {
+        list forwarding-by-tenant {
+            key tenant-id;
+            leaf tenant-id {
+                type gbp-common:tenant-id;
+                description
+                            "The tenant with which forwarding-context is associated";
+            }
+
+            list forwarding-context {
+                key "context-type context-id";
+                uses context-key;
+
+                uses has-address-type;
+                container parent {
+                    uses context-key;
+                }
+            }
+
+            list network-domain {
+                key "network-domain-type network-domain-id";
+                uses network-domain-key;
+
+                container parent {
+                    uses context-key;
+                }
+
+                description "Network domain can be augmented with further information.";
+            }
+        }
+    }
+
+}
diff --git a/groupbasedpolicy/src/main/yang/model/l2-l3-forwarding.yang b/groupbasedpolicy/src/main/yang/model/l2-l3-forwarding.yang
new file mode 100644 (file)
index 0000000..9f25376
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+module l2-l3-forwarding {
+    yang-version 1;
+
+    namespace "urn:opendaylight:groupbasedpolicy:forwarding:l2_l3";
+    prefix "l2-l3-forwarding";
+
+    import forwarding { prefix forwarding; revision-date 2016-04-27; }
+    import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
+    import yang-ext {prefix ext; revision-date 2013-07-09;}
+
+    revision "2016-04-27" {
+        description
+                "Initial revision.";
+    }
+
+    identity l3-context {
+        base forwarding:context-type;
+    }
+
+    identity l2-bridge-domain {
+        base forwarding:context-type;
+    }
+
+    identity l2-flood-domain {
+        base forwarding:context-type;
+    }
+
+    identity subnet {
+        base forwarding:network-domain;
+    }
+
+    identity mac-address-type {
+        description "Values by MAC address type MUST be compatible with type ietf-yang-types:mac-address.
+            This address type can be used only if forwarding:context-type is l2-bridge-domain.";
+        base forwarding:address-type;
+    }
+
+    identity ip-prefix-type {
+        description "Values by IP prefix type MUST be compatible with type ietf-inet-types:ipv-prefix.
+            This address type can be used only if forwarding:context-type is l3-context.";
+        base forwarding:address-type;
+    }
+
+    grouping subnet-fields {
+        leaf ip-prefix {
+            description "The IP prefix that defines the subnet";
+            type inet:ip-prefix;
+        }
+        leaf virtual-router-ip {
+            description
+                "IP address to use for a virtual gateway router
+                 for the subnet, if desired.";
+            type inet:ip-address;
+        }
+        list gateways {
+            description
+                "External gateways for subnets we serve,
+                includes prefixes for static routing";
+            key "gateway";
+            leaf gateway {
+                type inet:ip-address;
+            }
+            list prefixes {
+                key "prefix";
+                leaf prefix {
+                    type inet:ip-prefix;
+                }
+            }
+        }
+    }
+
+    augment "/forwarding:forwarding/forwarding:forwarding-by-tenant/forwarding:network-domain" {
+        ext:augment-identifier "subnet-augment-forwarding";
+        container subnet {
+            when "../forwarding:network-domain-type = 'l2-l3-forwarding:subnet'";
+            uses subnet-fields;
+        }
+    }
+
+    // TODO add augment to renderer.yang
+
+}
index 2830fc39e7e90f80b1fd612de557780994e1657e..fce531f99e6e21a74ee59f1bc7723c67d6afd2aa 100755 (executable)
@@ -745,6 +745,10 @@ module policy {
             // ***************
 
             container forwarding-context {
+
+                // use forwarding-context.yang instead
+                status deprecated;
+
                 list l3-context {
                     description
                         "A layer 3 context represents a namespace for layer 3
index 8589a08989a527ff1e5268e9509dddfe57ac932d..1aa20ed4f126d4fa0d920e55902441650d5e6b18 100644 (file)
@@ -22,18 +22,22 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.groupbasedpolicy.sxp.mapper.api.SxpMapperReactor;
 import org.opendaylight.groupbasedpolicy.sxp.mapper.impl.util.SxpListenerUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContextId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.BaseEndpointService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.Endpoints;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.RegisterEndpointInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.RegisterEndpointInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.common.endpoint.fields.NetworkContainment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.common.endpoint.fields.NetworkContainmentBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.endpoints.AddressEndpointsByContainment;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.endpoints.AddressEndpointsByContainmentKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.endpoints.address.endpoints.by.containment.AddressEndpoint;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.endpoints.address.endpoints.by.containment.AddressEndpointKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.register.endpoint.input.AddressEndpointBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.register.endpoint.input.AddressEndpointReg;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.register.endpoint.input.AddressEndpointRegBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.l2_l3.rev160427.IpPrefixType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.forwarding.l2_l3.rev160427.L3Context;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.groupbasedpolicy.sxp.mapper.model.rev160302.sxp.mapper.EndpointForwardingTemplateBySubnet;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.groupbasedpolicy.sxp.mapper.model.rev160302.sxp.mapper.EndpointPolicyTemplateBySgt;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.database.rev160308.master.database.fields.MasterDatabaseBinding;
@@ -67,14 +71,20 @@ public class SxpMapperReactorImpl implements SxpMapperReactor {
                 masterDBBinding.getSecurityGroupTag(), masterDBBinding.getIpPrefix());
         // apply sxpMasterDB to policy template
         final Ipv4Prefix address = new Ipv4Prefix(epForwardingTemplate.getIpPrefix().getIpv4Prefix().getValue());
+        final NetworkContainment networkContainment = new NetworkContainmentBuilder()
+            .setNetworkDomainType(epForwardingTemplate.getNetworkContainment().getNetworkDomainType())
+            .setNetworkDomainId(epForwardingTemplate.getNetworkContainment().getNetworkDomainId())
+            .build();
         final RegisterEndpointInput epInput = new RegisterEndpointInputBuilder()
-                .setAddressEndpoint(Collections.singletonList(new AddressEndpointBuilder()
-                        .setNetworkContainment(epForwardingTemplate.getNetworkContainment())
+                .setAddressEndpointReg(Collections.singletonList(new AddressEndpointRegBuilder()
+                        .setAddressType(IpPrefixType.class)
+                        .setAddress(address.getValue())
+                        .setContextType(L3Context.class)
+                        .setContextId(epForwardingTemplate.getL3Context())
+                        .setNetworkContainment(networkContainment)
                         .setCondition(epPolicyTemplate.getConditions())
                         .setTenant(epPolicyTemplate.getTenant())
-                        .setContainment(epForwardingTemplate.getL3Context())
                         .setEndpointGroup(epPolicyTemplate.getEndpointGroups())
-                        .setAddress(address)
                         .build()))
                 .build();
                 epForwardingTemplate.getL3Context();
@@ -83,11 +93,11 @@ public class SxpMapperReactorImpl implements SxpMapperReactor {
     }
 
     private CheckedFuture<Optional<AddressEndpoint>, ReadFailedException> findExistingEndPoint(final ContextId containment,
-                                                                                          final Address address) {
+                                                                                          final String address) {
         KeyedInstanceIdentifier<AddressEndpoint, AddressEndpointKey> addressEndpointPath =
                 InstanceIdentifier.create(Endpoints.class)
-                .child(AddressEndpointsByContainment.class, new AddressEndpointsByContainmentKey(containment))
-                .child(AddressEndpoint.class, new AddressEndpointKey(address));
+                .child(AddressEndpointsByContainment.class, new AddressEndpointsByContainmentKey(containment, L3Context.class))
+                .child(AddressEndpoint.class, new AddressEndpointKey(address, IpPrefixType.class));
         final ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction();
         final CheckedFuture<Optional<AddressEndpoint>, ReadFailedException> read = rTx.read(
                 LogicalDatastoreType.OPERATIONAL, addressEndpointPath);
@@ -96,9 +106,9 @@ public class SxpMapperReactorImpl implements SxpMapperReactor {
     }
 
     private ListenableFuture<RpcResult<Void>> chainL3EPServiceIfEpAbsent(final RegisterEndpointInput epInput) {
-        final org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.register.endpoint.input.AddressEndpoint addressEndpoint = epInput.getAddressEndpoint().get(0);
+        AddressEndpointReg addressEndpoint = epInput.getAddressEndpointReg().get(0);
         CheckedFuture<Optional<AddressEndpoint>, ReadFailedException> existingEndpointFuture =
-                findExistingEndPoint(addressEndpoint.getContainment(), addressEndpoint.getAddress());
+                findExistingEndPoint(addressEndpoint.getContextId(), addressEndpoint.getAddress());
 
         return Futures.transform(existingEndpointFuture, new AsyncFunction<Optional<AddressEndpoint>, RpcResult<Void>>() {
             @Override
@@ -109,7 +119,7 @@ public class SxpMapperReactorImpl implements SxpMapperReactor {
                     return JdkFutureAdapters.listenInPoolThread(l3EndpointService.registerEndpoint(epInput));
                 } else {
                     final String existingL3EpMsg = String.format("address-endpoint for given key already exists: %s | %s",
-                            addressEndpoint.getContainment(), addressEndpoint.getAddress() );
+                            addressEndpoint.getContextId(), addressEndpoint.getAddress() );
                     nextResult = Futures.immediateFailedFuture(new IllegalStateException(existingL3EpMsg));
                 }
                 return nextResult;
index a37ab2b6eeb50a2d6ca23f18d92318d034f0b419..9252cae337e902177df8f9fedd5996261dae7c95 100644 (file)
@@ -14,6 +14,7 @@ module sxp-mapper-model {
     import sxp-database { prefix sxp-database; revision-date 2016-03-08; }
     import gbp-common { prefix gbp-common; revision-date 2014-04-21; }
     import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
+    import forwarding { prefix forwarding; revision-date 2016-04-27; }
 
     description
         "This module contains the YANG definitions for
@@ -63,16 +64,16 @@ module sxp-mapper-model {
                     "The IP prefix where an endpoint can be connected.";
             }
             leaf l3-context {
-               type gbp-common:l3-context-id;
+               type gbp-common:context-id;
                mandatory true;
                description
                     "The context for the endpoint's layer 3 address";
             }
-            leaf network-containment {
+            container network-containment {
                 description
-                    "The network domain associated with this endpoint's fowarding
-                    context.";
-                type gbp-common:network-domain-id;
+                            "The network domain associated with this endpoint's fowarding
+                            context.";
+                uses forwarding:network-domain-key;
             }
         }
     }
index 3156845e5012b06e799955f11f5fb620b0bedb98..87188df3fa24eb4b8e12ef17dcf4882bdeb91bb0 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoints.rev160427.endpoints.address.endpoints.by.containment.AddressEndpoint;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.groupbasedpolicy.sxp.mapper.model.rev160302.sxp.mapper.EndpointForwardingTemplateBySubnet;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.groupbasedpolicy.sxp.mapper.model.rev160302.sxp.mapper.EndpointPolicyTemplateBySgt;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.groupbasedpolicy.sxp.mapper.model.rev160302.sxp.mapper.endpoint.forwarding.template.by.subnet.NetworkContainment;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.sxp.database.rev160308.master.database.fields.MasterDatabaseBinding;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
@@ -48,6 +49,8 @@ public class SxpMapperReactorImplTest {
     @Mock
     private EndpointForwardingTemplateBySubnet epForwardingTemplate;
     @Mock
+    private NetworkContainment networkContainment;
+    @Mock
     private DataBroker dataBroker;
     @Mock
     private ReadOnlyTransaction rTx;
@@ -63,6 +66,7 @@ public class SxpMapperReactorImplTest {
         Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(rTx);
         Mockito.when(rTx.read(Matchers.same(LogicalDatastoreType.OPERATIONAL),
                 Matchers.<InstanceIdentifier<AddressEndpoint>>any())).thenReturn(Futures.immediateCheckedFuture(Optional.absent()));
+        Mockito.when(epForwardingTemplate.getNetworkContainment()).thenReturn(networkContainment);
     }
 
     @After