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.ExternalImplicitGroup;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.ExternalImplicitGroupKey;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.SubjectFeatureInstances;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.Clause;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.ClauseKey;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.Subject;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.SubjectKey;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.subject.Rule;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.subject.RuleKey;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ConsumerNamedSelector;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ConsumerNamedSelectorKey;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ProviderNamedSelector;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ProviderNamedSelectorKey;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstance;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstanceKey;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstanceKey;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.RendererName;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.Renderers;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.Renderer;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.RendererKey;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Capabilities;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Interests;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedActionDefinition;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinition;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.FollowedTenants;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.FollowedTenant;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.FollowedTenantKey;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.followed.tenant.FollowedEndpointGroup;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.followed.tenant.FollowedEndpointGroupKey;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.statistics.store.rev151215.StatisticsStore;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.statistics.store.rev151215.statistics.store.StatisticRecord;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.statistics.store.rev151215.statistics.store.StatisticRecordKey;
93 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
95 public class IidFactory {
97 private IidFactory() {
98 throw new UnsupportedOperationException();
101 private static final InstanceIdentifier<Endpoints> ENDPOINTS_IID =
102 InstanceIdentifier.builder(Endpoints.class).build();
104 public static InstanceIdentifier<Tenant> tenantIid(TenantId id) {
105 return InstanceIdentifier.builder(Tenants.class).child(Tenant.class, new TenantKey(id)).build();
108 public static InstanceIdentifier<EndpointGroup> endpointGroupIid(TenantId tenantId, EndpointGroupId epgId) {
109 return InstanceIdentifier.builder(Tenants.class)
110 .child(Tenant.class, new TenantKey(tenantId))
112 .child(EndpointGroup.class, new EndpointGroupKey(epgId))
116 public static InstanceIdentifier<Contract> contractIid(TenantId tenantId, ContractId contractId) {
117 return InstanceIdentifier.builder(Tenants.class)
118 .child(Tenant.class, new TenantKey(tenantId))
120 .child(Contract.class, new ContractKey(contractId))
124 public static InstanceIdentifier<Contract> contractWildcardIid(TenantId tenantId) {
125 return InstanceIdentifier.builder(Tenants.class)
126 .child(Tenant.class, new TenantKey(tenantId))
128 .child(Contract.class)
132 public static InstanceIdentifier<Subject> subjectIid(TenantId tenantId, ContractId contractId,
133 SubjectName subjectName) {
134 return InstanceIdentifier.builder(Tenants.class)
135 .child(Tenant.class, new TenantKey(tenantId))
137 .child(Contract.class, new ContractKey(contractId))
138 .child(Subject.class, new SubjectKey(subjectName))
142 public static InstanceIdentifier<ProviderNamedSelector> providerNamedSelectorIid(TenantId tenantId,
143 EndpointGroupId epgId, SelectorName providerSelectorName) {
144 return InstanceIdentifier.builder(Tenants.class)
145 .child(Tenant.class, new TenantKey(tenantId))
147 .child(EndpointGroup.class, new EndpointGroupKey(epgId))
148 .child(ProviderNamedSelector.class, new ProviderNamedSelectorKey(providerSelectorName))
152 public static InstanceIdentifier<ConsumerNamedSelector> consumerNamedSelectorIid(TenantId tenantId,
153 EndpointGroupId epgId, SelectorName consumerSelectorName) {
154 return InstanceIdentifier.builder(Tenants.class)
155 .child(Tenant.class, new TenantKey(tenantId))
157 .child(EndpointGroup.class, new EndpointGroupKey(epgId))
158 .child(ConsumerNamedSelector.class, new ConsumerNamedSelectorKey(consumerSelectorName))
162 public static InstanceIdentifier<Clause> clauseIid(TenantId tenantId, ContractId contractId,
163 ClauseName clauseName) {
164 return InstanceIdentifier.builder(Tenants.class)
165 .child(Tenant.class, new TenantKey(tenantId))
167 .child(Contract.class, new ContractKey(contractId))
168 .child(Clause.class, new ClauseKey(clauseName))
172 public static InstanceIdentifier<Rule> ruleIid(TenantId tenantId, ContractId contractId, SubjectName subjectName,
174 return InstanceIdentifier.builder(Tenants.class)
175 .child(Tenant.class, new TenantKey(tenantId))
177 .child(Contract.class, new ContractKey(contractId))
178 .child(Subject.class, new SubjectKey(subjectName))
179 .child(Rule.class, new RuleKey(ruleName))
183 public static InstanceIdentifier<ActionInstance> actionInstanceIid(TenantId tenantId, ActionName actionName) {
184 return InstanceIdentifier.builder(Tenants.class)
185 .child(Tenant.class, new TenantKey(tenantId))
187 .child(SubjectFeatureInstances.class)
188 .child(ActionInstance.class, new ActionInstanceKey(actionName))
192 public static InstanceIdentifier<ClassifierInstance> classifierInstanceIid(TenantId tenantId,
193 ClassifierName classifierName) {
194 return InstanceIdentifier.builder(Tenants.class)
195 .child(Tenant.class, new TenantKey(tenantId))
197 .child(SubjectFeatureInstances.class)
198 .child(ClassifierInstance.class, new ClassifierInstanceKey(classifierName))
202 public static InstanceIdentifier<ClassifierDefinition> classifierDefinitionIid(
203 ClassifierDefinitionId classifierDefinitionId) {
204 return InstanceIdentifier.builder(SubjectFeatureDefinitions.class)
205 .child(ClassifierDefinition.class, new ClassifierDefinitionKey(classifierDefinitionId))
209 public static InstanceIdentifier<ActionDefinition> actionDefinitionIid(ActionDefinitionId actionDefinitionId) {
210 return InstanceIdentifier.builder(SubjectFeatureDefinitions.class)
211 .child(ActionDefinition.class, new ActionDefinitionKey(actionDefinitionId))
215 public static InstanceIdentifier<ClassifierRef> classifierRefIid(TenantId tenantId, ContractId contractId,
216 SubjectName subjectName, RuleName ruleName, ClassifierName classifierRefName) {
217 return InstanceIdentifier.builder(Tenants.class)
218 .child(Tenant.class, new TenantKey(tenantId))
220 .child(Contract.class, new ContractKey(contractId))
221 .child(Subject.class, new SubjectKey(subjectName))
222 .child(Rule.class, new RuleKey(ruleName))
223 .child(ClassifierRef.class, new ClassifierRefKey(classifierRefName))
227 public static InstanceIdentifier<L2FloodDomain> l2FloodDomainIid(TenantId tenantId,
228 L2FloodDomainId l2FloodDomainId) {
229 return InstanceIdentifier.builder(Tenants.class)
230 .child(Tenant.class, new TenantKey(tenantId))
231 .child(ForwardingContext.class)
232 .child(L2FloodDomain.class, new L2FloodDomainKey(l2FloodDomainId))
236 public static InstanceIdentifier<L2BridgeDomain> l2BridgeDomainIid(TenantId tenantId,
237 L2BridgeDomainId l2BridgeDomainId) {
238 return InstanceIdentifier.builder(Tenants.class)
239 .child(Tenant.class, new TenantKey(tenantId))
240 .child(ForwardingContext.class)
241 .child(L2BridgeDomain.class, new L2BridgeDomainKey(l2BridgeDomainId))
245 public static InstanceIdentifier<L3Context> l3ContextIid(TenantId tenantId, L3ContextId l3ContextId) {
246 return InstanceIdentifier.builder(Tenants.class)
247 .child(Tenant.class, new TenantKey(tenantId))
248 .child(ForwardingContext.class)
249 .child(L3Context.class, new L3ContextKey(l3ContextId))
254 * Get the {@link Endpoint} {@link InstanceIdentifier} based on the {@link EndpointKey}
256 * @param endpointKey The {@link EndpointKey} of a particular {@link Endpoint}
257 * @return The {@link InstanceIdentifier} of the {@link Endpoint}
259 public static InstanceIdentifier<Endpoint> endpointIid(EndpointKey endpointKey) {
260 return InstanceIdentifier.builder(Endpoints.class).child(Endpoint.class, endpointKey).build();
263 public static InstanceIdentifier<Endpoint> endpointIid(L2BridgeDomainId l2Context, MacAddress macAddress) {
264 return IidFactory.endpointIid(new EndpointKey(l2Context, macAddress));
267 public static InstanceIdentifier<EndpointL3> l3EndpointIid(EndpointL3Key endpointL3Key) {
268 return InstanceIdentifier.builder(Endpoints.class).child(EndpointL3.class, endpointL3Key).build();
271 public static InstanceIdentifier<EndpointL3> l3EndpointIid(L3ContextId l3Context, IpAddress ipAddress) {
272 return IidFactory.l3EndpointIid(new EndpointL3Key(ipAddress, l3Context));
275 public static InstanceIdentifier<EndpointL3> l3EndpointsIidWildcard() {
276 return InstanceIdentifier.builder(Endpoints.class).child(EndpointL3.class).build();
279 public static InstanceIdentifier<EndpointL3Prefix> endpointL3PrefixIid(L3ContextId l3Context, IpPrefix ipPrefix) {
280 return InstanceIdentifier.builder(Endpoints.class)
281 .child(EndpointL3Prefix.class, new EndpointL3PrefixKey(ipPrefix, l3Context))
285 public static InstanceIdentifier<Endpoints> endpointsIidWildcard() {
286 return ENDPOINTS_IID;
289 public static InstanceIdentifier<Subnet> subnetIid(TenantId tenantId, SubnetId subnetId) {
290 return InstanceIdentifier.builder(Tenants.class)
291 .child(Tenant.class, new TenantKey(tenantId))
292 .child(ForwardingContext.class)
293 .child(Subnet.class, new SubnetKey(subnetId))
297 public static InstanceIdentifier<Subnet> subnetWildcardIid(TenantId tenantId) {
298 return InstanceIdentifier.builder(Tenants.class)
299 .child(Tenant.class, new TenantKey(tenantId))
300 .child(ForwardingContext.class)
305 public static InstanceIdentifier<FollowedEndpointGroup> followedEndpointgroupIid(RendererName rendererName,
306 TenantId tenantId, EndpointGroupId epgId) {
307 return InstanceIdentifier.builder(Renderers.class)
308 .child(Renderer.class, new RendererKey(rendererName))
309 .child(Interests.class)
310 .child(FollowedTenants.class)
311 .child(FollowedTenant.class, new FollowedTenantKey(tenantId))
312 .child(FollowedEndpointGroup.class, new FollowedEndpointGroupKey(epgId))
316 public static InstanceIdentifier<SupportedActionDefinition> supportedActionDefinitionIidWildcard() {
317 return InstanceIdentifier.builder(Renderers.class)
318 .child(Renderer.class)
319 .child(Capabilities.class)
320 .child(SupportedActionDefinition.class)
324 public static InstanceIdentifier<SupportedClassifierDefinition> supportedClassifierDefinitionIidWildcard() {
325 return InstanceIdentifier.builder(Renderers.class)
326 .child(Renderer.class)
327 .child(Capabilities.class)
328 .child(SupportedClassifierDefinition.class)
332 public static InstanceIdentifier<StatisticRecord> statisticRecordIid(StatisticRecordKey key) {
333 return InstanceIdentifier.builder(StatisticsStore.class).child(StatisticRecord.class, key).build();
336 public static InstanceIdentifier<FollowedTenant> followedTenantIid(RendererName rendererName, TenantId tenantId) {
337 return InstanceIdentifier.builder(Renderers.class)
338 .child(Renderer.class, new RendererKey(rendererName))
339 .child(Interests.class)
340 .child(FollowedTenants.class)
341 .child(FollowedTenant.class, new FollowedTenantKey(tenantId))
345 public static InstanceIdentifier<Renderer> rendererIid(RendererName rendererName) {
346 return InstanceIdentifier.builder(Renderers.class).child(Renderer.class, new RendererKey(rendererName)).build();
349 public static InstanceIdentifier<Renderers> renderersIid() {
350 return InstanceIdentifier.builder(Renderers.class).build();
353 public static InstanceIdentifier<ExternalImplicitGroup> externalImplicitGroupIid(TenantId tenantId,
354 EndpointGroupId epgId) {
355 return InstanceIdentifier.builder(Tenants.class)
356 .child(Tenant.class, new TenantKey(tenantId))
358 .child(ExternalImplicitGroup.class, new ExternalImplicitGroupKey(epgId))