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;
}
}
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;
}
}
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;
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;
}
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;
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;
}
}
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;
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;
}
}
}
}
typedef subnet-id {
+
+ status deprecated;
+
type network-domain-id;
description "A unique ID for a subnet";
}
}
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";
}
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
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
}
container endpoints {
+
+ // use base-endpoint.yang instead
+ status deprecated;
+
description
"Repository for operational state data about endpoints needed for
policy resolution.";
}
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
}
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
}
rpc unregister-endpoint {
+
+ // use base-endpoint.yang instead
+ status deprecated;
+
description "Unregister an endpoint or endpoints from the registry.";
input {
}
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
}
rpc unset-endpoint-group-conditions {
+
+ status deprecated;
+
description
"Remove a list of conditions from an endpoint group.";
--- /dev/null
+/*
+ * 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.";
+ }
+ }
+ }
+
+}
--- /dev/null
+/*
+ * 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
+
+}
// ***************
container forwarding-context {
+
+ // use forwarding-context.yang instead
+ status deprecated;
+
list l3-context {
description
"A layer 3 context represents a namespace for layer 3
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;
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();
}
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);
}
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
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;
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
"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;
}
}
}
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;
@Mock
private EndpointForwardingTemplateBySubnet epForwardingTemplate;
@Mock
+ private NetworkContainment networkContainment;
+ @Mock
private DataBroker dataBroker;
@Mock
private ReadOnlyTransaction rTx;
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