2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.translate.v3po;
19 import static io.fd.honeycomb.translate.v3po.VppClassifierHoneycombWriterFactory.CLASSIFY_SESSION_ID;
20 import static io.fd.honeycomb.translate.v3po.VppClassifierHoneycombWriterFactory.CLASSIFY_TABLE_ID;
22 import com.google.common.collect.Sets;
23 import io.fd.honeycomb.translate.impl.write.GenericListWriter;
24 import io.fd.honeycomb.translate.impl.write.GenericWriter;
25 import io.fd.honeycomb.translate.v3po.interfaces.RewriteCustomizer;
26 import io.fd.honeycomb.translate.v3po.interfaces.SubInterfaceCustomizer;
27 import io.fd.honeycomb.translate.v3po.interfaces.SubInterfaceL2Customizer;
28 import io.fd.honeycomb.translate.v3po.interfaces.acl.egress.EgressIetfAclWriter;
29 import io.fd.honeycomb.translate.v3po.interfaces.acl.ingress.IngressIetfAclWriter;
30 import io.fd.honeycomb.translate.v3po.interfaces.acl.ingress.SubInterfaceAclCustomizer;
31 import io.fd.honeycomb.translate.v3po.interfaces.acl.ingress.SubInterfaceIetfAclCustomizer;
32 import io.fd.honeycomb.translate.v3po.interfaces.ip.SubInterfaceIpv4AddressCustomizer;
33 import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager;
34 import io.fd.honeycomb.translate.vpp.util.NamingContext;
35 import io.fd.honeycomb.translate.write.WriterFactory;
36 import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
37 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
38 import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.dot1q.tag.or.any.Dot1qTag;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.acl.base.attributes.Ip4Acl;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.acl.base.attributes.Ip6Acl;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.acl.base.attributes.L2Acl;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.ietf.acl.base.attributes.AccessLists;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.SubinterfaceAugmentation;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces._interface.SubInterfaces;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces._interface.sub.interfaces.SubInterface;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.match.attributes.match.type.vlan.tagged.VlanTagged;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Acl;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.IetfAcl;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.L2;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Match;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Tags;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.acl.Ingress;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.l2.Rewrite;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.tags.Tag;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip4.attributes.Ipv4;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip4.attributes.ipv4.Address;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.tag.rewrite.PushTags;
58 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
60 public final class SubinterfaceAugmentationWriterFactory implements WriterFactory {
62 private final FutureJVppCore jvpp;
63 private final IngressIetfAclWriter ingressAclWriter;
64 private final EgressIetfAclWriter egressAclWriter;
65 private final NamingContext ifcContext;
66 private final NamingContext bdContext;
67 private final VppClassifierContextManager classifyTableContext;
69 public static final InstanceIdentifier<SubinterfaceAugmentation> SUB_IFC_AUG_ID =
70 InterfacesWriterFactory.IFC_ID.augmentation(SubinterfaceAugmentation.class);
71 public static final InstanceIdentifier<SubInterface> SUB_IFC_ID =
72 SUB_IFC_AUG_ID.child(SubInterfaces.class).child(SubInterface.class);
73 public static final InstanceIdentifier<L2> L2_ID = SUB_IFC_ID.child(
75 public static final InstanceIdentifier<Acl> SUBIF_ACL_ID = SUB_IFC_ID.child(Acl.class);
76 public static final InstanceIdentifier<Ingress> SUBIF_INGRESS_ACL_ID = SUBIF_ACL_ID.child(Ingress.class);
77 public static final InstanceIdentifier<IetfAcl> SUBIF_IETF_ACL_ID = SUB_IFC_ID.child(IetfAcl.class);
78 public static final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Ingress> SUBIF_INGRESS_IETF_ACL_ID = SUBIF_IETF_ACL_ID.child(
79 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Ingress.class);
80 public static final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Egress> SUBIF_EGRESS_IETF_ACL_ID = SUBIF_IETF_ACL_ID.child(
81 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Egress.class);
83 public SubinterfaceAugmentationWriterFactory(final FutureJVppCore jvpp,
84 final IngressIetfAclWriter ingressAclWriter,
85 final EgressIetfAclWriter egressAclWriter,
86 final NamingContext ifcContext, final NamingContext bdContext, final VppClassifierContextManager classifyTableContext) {
88 this.ingressAclWriter = ingressAclWriter;
89 this.egressAclWriter = egressAclWriter;
90 this.ifcContext = ifcContext;
91 this.bdContext = bdContext;
92 this.classifyTableContext = classifyTableContext;
96 public void init(final ModifiableWriterRegistryBuilder registry) {
98 // Subinterface(Handle only after all interface related stuff gets processed) =
99 registry.subtreeAddAfter(
100 // TODO HONEYCOMB-188 this customizer covers quite a lot of complex child nodes (maybe refactor ?)
102 InstanceIdentifier.create(SubInterface.class).child(Tags.class),
103 InstanceIdentifier.create(SubInterface.class).child(Tags.class).child(Tag.class),
104 InstanceIdentifier.create(SubInterface.class).child(Tags.class).child(Tag.class).child(
106 InstanceIdentifier.create(SubInterface.class).child(Match.class),
107 InstanceIdentifier.create(SubInterface.class).child(Match.class).child(VlanTagged.class)),
108 new GenericListWriter<>(SUB_IFC_ID, new SubInterfaceCustomizer(jvpp, ifcContext)),
109 InterfacesWriterFactory.IFC_ID);
111 registry.addAfter(new GenericWriter<>(L2_ID, new SubInterfaceL2Customizer(jvpp, ifcContext, bdContext)),
113 // Rewrite(also handles pushTags + pushTags/dot1qtag) =
114 final InstanceIdentifier<Rewrite> rewriteId = L2_ID.child(Rewrite.class);
115 registry.subtreeAddAfter(
117 InstanceIdentifier.create(Rewrite.class).child(PushTags.class),
118 InstanceIdentifier.create(Rewrite.class).child(PushTags.class)
119 .child(org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.dot1q.tag.Dot1qTag.class)),
120 new GenericWriter<>(rewriteId, new RewriteCustomizer(jvpp, ifcContext)),
122 // Ipv4(handled after L2 and L2/rewrite is done) =
123 final InstanceIdentifier<Address> ipv4SubifcAddressId = SUB_IFC_ID.child(Ipv4.class).child(Address.class);
124 registry.addAfter(new GenericListWriter<>(ipv4SubifcAddressId,
125 new SubInterfaceIpv4AddressCustomizer(jvpp, ifcContext)),
128 // Ingress (execute after classify table and session writers)
129 // also handles L2Acl, Ip4Acl and Ip6Acl:
130 final InstanceIdentifier<Ingress> aclId = InstanceIdentifier.create(Ingress.class);
133 Sets.newHashSet(aclId.child(L2Acl.class), aclId.child(Ip4Acl.class), aclId.child(Ip6Acl.class)),
134 new GenericWriter<>(SUBIF_INGRESS_ACL_ID, new SubInterfaceAclCustomizer(jvpp, ifcContext, classifyTableContext)),
135 Sets.newHashSet(CLASSIFY_TABLE_ID, CLASSIFY_SESSION_ID));
137 // Ingress IETF-ACL, also handles AccessLists and Acl:
138 final InstanceIdentifier<AccessLists> accessListsIdIngress = InstanceIdentifier.create(
139 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Ingress.class)
140 .child(AccessLists.class);
141 final InstanceIdentifier<?> aclIdIngress = accessListsIdIngress.child(
142 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.ietf.acl.base.attributes.access.lists.Acl.class);
144 Sets.newHashSet(accessListsIdIngress, aclIdIngress),
145 new GenericWriter<>(SUBIF_INGRESS_IETF_ACL_ID, new SubInterfaceIetfAclCustomizer(ingressAclWriter, ifcContext)));
147 // Egress IETF-ACL, also handles AccessLists and Acl:
148 final InstanceIdentifier<AccessLists> accessListsIdEgress = InstanceIdentifier.create(
149 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Egress.class)
150 .child(AccessLists.class);
151 final InstanceIdentifier<?> aclIdEgress = accessListsIdEgress.child(
152 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.ietf.acl.base.attributes.access.lists.Acl.class);
154 Sets.newHashSet(accessListsIdEgress, aclIdEgress),
155 new GenericWriter<>(SUBIF_EGRESS_IETF_ACL_ID, new io.fd.honeycomb.translate.v3po.interfaces.acl.egress.SubInterfaceIetfAclCustomizer(
156 egressAclWriter, ifcContext)));