2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.groupbasedpolicy.util;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionName;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierName;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClauseName;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContractId;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L2BridgeDomainId;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L2FloodDomainId;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L3ContextId;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.RuleName;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.SelectorName;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.SubjectName;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.SubnetId;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointKey;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Key;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3PrefixKey;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitions;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.Tenants;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.has.classifier.refs.ClassifierRef;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.has.classifier.refs.ClassifierRefKey;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinitionKey;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinitionKey;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.Tenant;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.TenantKey;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.ForwardingContext;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.Policy;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2BridgeDomain;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2BridgeDomainKey;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2FloodDomain;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2FloodDomainKey;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L3Context;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L3ContextKey;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.Subnet;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.SubnetKey;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.Contract;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.ContractKey;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroup;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroupKey;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.SubjectFeatureInstances;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.Clause;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.ClauseKey;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.Subject;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.SubjectKey;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.subject.Rule;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.subject.RuleKey;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ConsumerNamedSelector;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ConsumerNamedSelectorKey;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ProviderNamedSelector;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ProviderNamedSelectorKey;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstance;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstanceKey;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstanceKey;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.RendererName;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.Renderers;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.Renderer;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.RendererKey;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Capabilities;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Interests;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedActionDefinition;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinition;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.FollowedTenants;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.FollowedTenant;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.FollowedTenantKey;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.followed.tenant.FollowedEndpointGroup;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.followed.tenant.FollowedEndpointGroupKey;
88 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
90 public class IidFactory {
92 private IidFactory() {
93 throw new UnsupportedOperationException();
96 private static final InstanceIdentifier<Endpoints> ENDPOINTS_IID =
97 InstanceIdentifier.builder(Endpoints.class).build();
99 public static InstanceIdentifier<Tenant> tenantIid(TenantId id) {
100 return InstanceIdentifier.builder(Tenants.class).child(Tenant.class, new TenantKey(id)).build();
103 public static InstanceIdentifier<EndpointGroup> endpointGroupIid(TenantId tenantId, EndpointGroupId epgId) {
104 return InstanceIdentifier.builder(Tenants.class)
105 .child(Tenant.class, new TenantKey(tenantId))
107 .child(EndpointGroup.class, new EndpointGroupKey(epgId))
111 public static InstanceIdentifier<Contract> contractIid(TenantId tenantId, ContractId contractId) {
112 return InstanceIdentifier.builder(Tenants.class)
113 .child(Tenant.class, new TenantKey(tenantId))
115 .child(Contract.class, new ContractKey(contractId))
119 public static InstanceIdentifier<Contract> contractWildcardIid(TenantId tenantId) {
120 return InstanceIdentifier.builder(Tenants.class)
121 .child(Tenant.class, new TenantKey(tenantId))
123 .child(Contract.class)
127 public static InstanceIdentifier<Subject> subjectIid(TenantId tenantId, ContractId contractId,
128 SubjectName subjectName) {
129 return InstanceIdentifier.builder(Tenants.class)
130 .child(Tenant.class, new TenantKey(tenantId))
132 .child(Contract.class, new ContractKey(contractId))
133 .child(Subject.class, new SubjectKey(subjectName))
137 public static InstanceIdentifier<ProviderNamedSelector> providerNamedSelectorIid(TenantId tenantId,
138 EndpointGroupId epgId, SelectorName providerSelectorName) {
139 return InstanceIdentifier.builder(Tenants.class)
140 .child(Tenant.class, new TenantKey(tenantId))
142 .child(EndpointGroup.class, new EndpointGroupKey(epgId))
143 .child(ProviderNamedSelector.class, new ProviderNamedSelectorKey(providerSelectorName))
147 public static InstanceIdentifier<ConsumerNamedSelector> consumerNamedSelectorIid(TenantId tenantId,
148 EndpointGroupId epgId, SelectorName consumerSelectorName) {
149 return InstanceIdentifier.builder(Tenants.class)
150 .child(Tenant.class, new TenantKey(tenantId))
152 .child(EndpointGroup.class, new EndpointGroupKey(epgId))
153 .child(ConsumerNamedSelector.class, new ConsumerNamedSelectorKey(consumerSelectorName))
157 public static InstanceIdentifier<Clause> clauseIid(TenantId tenantId, ContractId contractId,
158 ClauseName clauseName) {
159 return InstanceIdentifier.builder(Tenants.class)
160 .child(Tenant.class, new TenantKey(tenantId))
162 .child(Contract.class, new ContractKey(contractId))
163 .child(Clause.class, new ClauseKey(clauseName))
167 public static InstanceIdentifier<Rule> ruleIid(TenantId tenantId, ContractId contractId, SubjectName subjectName,
169 return InstanceIdentifier.builder(Tenants.class)
170 .child(Tenant.class, new TenantKey(tenantId))
172 .child(Contract.class, new ContractKey(contractId))
173 .child(Subject.class, new SubjectKey(subjectName))
174 .child(Rule.class, new RuleKey(ruleName))
178 public static InstanceIdentifier<ActionInstance> actionInstanceIid(TenantId tenantId, ActionName actionName) {
179 return InstanceIdentifier.builder(Tenants.class)
180 .child(Tenant.class, new TenantKey(tenantId))
182 .child(SubjectFeatureInstances.class)
183 .child(ActionInstance.class, new ActionInstanceKey(actionName))
187 public static InstanceIdentifier<ClassifierInstance> classifierInstanceIid(TenantId tenantId,
188 ClassifierName classifierName) {
189 return InstanceIdentifier.builder(Tenants.class)
190 .child(Tenant.class, new TenantKey(tenantId))
192 .child(SubjectFeatureInstances.class)
193 .child(ClassifierInstance.class, new ClassifierInstanceKey(classifierName))
197 public static InstanceIdentifier<ClassifierDefinition> classifierDefinitionIid(
198 ClassifierDefinitionId classifierDefinitionId) {
199 return InstanceIdentifier.builder(SubjectFeatureDefinitions.class)
200 .child(ClassifierDefinition.class, new ClassifierDefinitionKey(classifierDefinitionId))
204 public static InstanceIdentifier<ActionDefinition> actionDefinitionIid(ActionDefinitionId actionDefinitionId) {
205 return InstanceIdentifier.builder(SubjectFeatureDefinitions.class)
206 .child(ActionDefinition.class, new ActionDefinitionKey(actionDefinitionId))
210 public static InstanceIdentifier<ClassifierRef> classifierRefIid(TenantId tenantId, ContractId contractId,
211 SubjectName subjectName, RuleName ruleName, ClassifierName classifierRefName) {
212 return InstanceIdentifier.builder(Tenants.class)
213 .child(Tenant.class, new TenantKey(tenantId))
215 .child(Contract.class, new ContractKey(contractId))
216 .child(Subject.class, new SubjectKey(subjectName))
217 .child(Rule.class, new RuleKey(ruleName))
218 .child(ClassifierRef.class, new ClassifierRefKey(classifierRefName))
222 public static InstanceIdentifier<L2FloodDomain> l2FloodDomainIid(TenantId tenantId,
223 L2FloodDomainId l2FloodDomainId) {
224 return InstanceIdentifier.builder(Tenants.class)
225 .child(Tenant.class, new TenantKey(tenantId))
226 .child(ForwardingContext.class)
227 .child(L2FloodDomain.class, new L2FloodDomainKey(l2FloodDomainId))
231 public static InstanceIdentifier<L2BridgeDomain> l2BridgeDomainIid(TenantId tenantId,
232 L2BridgeDomainId l2BridgeDomainId) {
233 return InstanceIdentifier.builder(Tenants.class)
234 .child(Tenant.class, new TenantKey(tenantId))
235 .child(ForwardingContext.class)
236 .child(L2BridgeDomain.class, new L2BridgeDomainKey(l2BridgeDomainId))
240 public static InstanceIdentifier<L3Context> l3ContextIid(TenantId tenantId, L3ContextId l3ContextId) {
241 return InstanceIdentifier.builder(Tenants.class)
242 .child(Tenant.class, new TenantKey(tenantId))
243 .child(ForwardingContext.class)
244 .child(L3Context.class, new L3ContextKey(l3ContextId))
249 * Get the {@link Endpoint} {@link InstanceIdentifier} based on the {@link EndpointKey}
251 * @param endpointKey The {@link EndpointKey} of a particular {@link Endpoint}
252 * @return The {@link InstanceIdentifier} of the {@link Endpoint}
254 public static InstanceIdentifier<Endpoint> endpointIid(EndpointKey endpointKey) {
255 return InstanceIdentifier.builder(Endpoints.class).child(Endpoint.class, endpointKey).build();
258 public static InstanceIdentifier<Endpoint> endpointIid(L2BridgeDomainId l2Context, MacAddress macAddress) {
259 return IidFactory.endpointIid(new EndpointKey(l2Context, macAddress));
262 public static InstanceIdentifier<EndpointL3> l3EndpointIid(EndpointL3Key endpointL3Key) {
263 return InstanceIdentifier.builder(Endpoints.class).child(EndpointL3.class, endpointL3Key).build();
266 public static InstanceIdentifier<EndpointL3> l3EndpointIid(L3ContextId l3Context, IpAddress ipAddress) {
267 return IidFactory.l3EndpointIid(new EndpointL3Key(ipAddress, l3Context));
270 public static InstanceIdentifier<EndpointL3> l3EndpointsIidWildcard() {
271 return InstanceIdentifier.builder(Endpoints.class).child(EndpointL3.class).build();
274 public static InstanceIdentifier<EndpointL3Prefix> endpointL3PrefixIid(L3ContextId l3Context, IpPrefix ipPrefix) {
275 return InstanceIdentifier.builder(Endpoints.class)
276 .child(EndpointL3Prefix.class, new EndpointL3PrefixKey(ipPrefix, l3Context))
280 public static InstanceIdentifier<Endpoints> endpointsIidWildcard() {
281 return ENDPOINTS_IID;
284 public static InstanceIdentifier<Subnet> subnetIid(TenantId tenantId, SubnetId subnetId) {
285 return InstanceIdentifier.builder(Tenants.class)
286 .child(Tenant.class, new TenantKey(tenantId))
287 .child(ForwardingContext.class)
288 .child(Subnet.class, new SubnetKey(subnetId))
292 public static InstanceIdentifier<Subnet> subnetWildcardIid(TenantId tenantId) {
293 return InstanceIdentifier.builder(Tenants.class)
294 .child(Tenant.class, new TenantKey(tenantId))
295 .child(ForwardingContext.class)
300 public static InstanceIdentifier<FollowedEndpointGroup> followedEndpointgroupIid(RendererName rendererName,
301 TenantId tenantId, EndpointGroupId epgId) {
302 return InstanceIdentifier.builder(Renderers.class)
303 .child(Renderer.class, new RendererKey(rendererName))
304 .child(Interests.class)
305 .child(FollowedTenants.class)
306 .child(FollowedTenant.class, new FollowedTenantKey(tenantId))
307 .child(FollowedEndpointGroup.class, new FollowedEndpointGroupKey(epgId))
311 public static InstanceIdentifier<SupportedActionDefinition> supportedActionDefinitionIidWildcard() {
312 return InstanceIdentifier.builder(Renderers.class)
313 .child(Renderer.class)
314 .child(Capabilities.class)
315 .child(SupportedActionDefinition.class)
319 public static InstanceIdentifier<SupportedClassifierDefinition> supportedClassifierDefinitionIidWildcard() {
320 return InstanceIdentifier.builder(Renderers.class)
321 .child(Renderer.class)
322 .child(Capabilities.class)
323 .child(SupportedClassifierDefinition.class)
327 public static InstanceIdentifier<FollowedTenant> followedTenantIid(RendererName rendererName, TenantId tenantId) {
328 return InstanceIdentifier.builder(Renderers.class)
329 .child(Renderer.class, new RendererKey(rendererName))
330 .child(Interests.class)
331 .child(FollowedTenants.class)
332 .child(FollowedTenant.class, new FollowedTenantKey(tenantId))
336 public static InstanceIdentifier<Renderer> rendererIid(RendererName rendererName) {
337 return InstanceIdentifier.builder(Renderers.class).child(Renderer.class, new RendererKey(rendererName)).build();
340 public static InstanceIdentifier<Renderers> renderersIid() {
341 return InstanceIdentifier.builder(Renderers.class).build();