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.acl.ingress.SubInterfaceAclCustomizer;
27 import io.fd.honeycomb.translate.v3po.interfaces.SubInterfaceCustomizer;
28 import io.fd.honeycomb.translate.v3po.interfaces.SubInterfaceL2Customizer;
29 import io.fd.honeycomb.translate.v3po.interfaces.acl.ingress.IetfAClWriter;
30 import io.fd.honeycomb.translate.v3po.interfaces.acl.ingress.SubInterfaceIetfAclCustomizer;
31 import io.fd.honeycomb.translate.v3po.interfaces.ip.SubInterfaceIpv4AddressCustomizer;
32 import io.fd.honeycomb.translate.vpp.util.NamingContext;
33 import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager;
34 import io.fd.honeycomb.translate.write.WriterFactory;
35 import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
36 import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.dot1q.tag.or.any.Dot1qTag;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.acl.base.attributes.Ip4Acl;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.acl.base.attributes.Ip6Acl;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.acl.base.attributes.L2Acl;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.ietf.acl.base.attributes.AccessLists;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.SubinterfaceAugmentation;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces._interface.SubInterfaces;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces._interface.sub.interfaces.SubInterface;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.match.attributes.match.type.vlan.tagged.VlanTagged;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Acl;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.IetfAcl;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.L2;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Match;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Tags;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.acl.Ingress;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.l2.Rewrite;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.tags.Tag;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip4.attributes.Ipv4;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip4.attributes.ipv4.Address;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.tag.rewrite.PushTags;
56 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
57 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
59 public final class SubinterfaceAugmentationWriterFactory implements WriterFactory {
61 private final FutureJVppCore jvpp;
62 private final IetfAClWriter aclWriter;
63 private final NamingContext ifcContext;
64 private final NamingContext bdContext;
65 private final VppClassifierContextManager classifyTableContext;
67 public static final InstanceIdentifier<SubinterfaceAugmentation> SUB_IFC_AUG_ID =
68 InterfacesWriterFactory.IFC_ID.augmentation(SubinterfaceAugmentation.class);
69 public static final InstanceIdentifier<SubInterface> SUB_IFC_ID =
70 SUB_IFC_AUG_ID.child(SubInterfaces.class).child(SubInterface.class);
71 public static final InstanceIdentifier<L2> L2_ID = SUB_IFC_ID.child(
73 public static final InstanceIdentifier<Acl> SUBIF_ACL_ID = SUB_IFC_ID.child(Acl.class);
74 public static final InstanceIdentifier<Ingress> SUBIF_INGRESS_ACL_ID = SUBIF_ACL_ID.child(Ingress.class);
75 public static final InstanceIdentifier<IetfAcl> SUBIF_IETF_ACL_ID = SUB_IFC_ID.child(IetfAcl.class);
76 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(
77 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Ingress.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.Egress> SUBIF_EGRESS_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.Egress.class);
81 public SubinterfaceAugmentationWriterFactory(final FutureJVppCore jvpp,
82 final IetfAClWriter aclWriter,
83 final NamingContext ifcContext, final NamingContext bdContext, final VppClassifierContextManager classifyTableContext) {
85 this.aclWriter = aclWriter;
86 this.ifcContext = ifcContext;
87 this.bdContext = bdContext;
88 this.classifyTableContext = classifyTableContext;
92 public void init(final ModifiableWriterRegistryBuilder registry) {
94 // Subinterface(Handle only after all interface related stuff gets processed) =
95 registry.subtreeAddAfter(
96 // TODO HONEYCOMB-188 this customizer covers quite a lot of complex child nodes (maybe refactor ?)
98 InstanceIdentifier.create(SubInterface.class).child(Tags.class),
99 InstanceIdentifier.create(SubInterface.class).child(Tags.class).child(Tag.class),
100 InstanceIdentifier.create(SubInterface.class).child(Tags.class).child(Tag.class).child(
102 InstanceIdentifier.create(SubInterface.class).child(Match.class),
103 InstanceIdentifier.create(SubInterface.class).child(Match.class).child(VlanTagged.class)),
104 new GenericListWriter<>(SUB_IFC_ID, new SubInterfaceCustomizer(jvpp, ifcContext)),
105 InterfacesWriterFactory.IFC_ID);
107 registry.addAfter(new GenericWriter<>(L2_ID, new SubInterfaceL2Customizer(jvpp, ifcContext, bdContext)),
109 // Rewrite(also handles pushTags + pushTags/dot1qtag) =
110 final InstanceIdentifier<Rewrite> rewriteId = L2_ID.child(Rewrite.class);
111 registry.subtreeAddAfter(
113 InstanceIdentifier.create(Rewrite.class).child(PushTags.class),
114 InstanceIdentifier.create(Rewrite.class).child(PushTags.class)
115 .child(org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.dot1q.tag.Dot1qTag.class)),
116 new GenericWriter<>(rewriteId, new RewriteCustomizer(jvpp, ifcContext)),
118 // Ipv4(handled after L2 and L2/rewrite is done) =
119 final InstanceIdentifier<Address> ipv4SubifcAddressId = SUB_IFC_ID.child(Ipv4.class).child(Address.class);
120 registry.addAfter(new GenericListWriter<>(ipv4SubifcAddressId,
121 new SubInterfaceIpv4AddressCustomizer(jvpp, ifcContext)),
124 // Ingress (execute after classify table and session writers)
125 // also handles L2Acl, Ip4Acl and Ip6Acl:
126 final InstanceIdentifier<Ingress> aclId = InstanceIdentifier.create(Ingress.class);
129 Sets.newHashSet(aclId.child(L2Acl.class), aclId.child(Ip4Acl.class), aclId.child(Ip6Acl.class)),
130 new GenericWriter<>(SUBIF_INGRESS_ACL_ID, new SubInterfaceAclCustomizer(jvpp, ifcContext, classifyTableContext)),
131 Sets.newHashSet(CLASSIFY_TABLE_ID, CLASSIFY_SESSION_ID));
133 // Ingress IETF-ACL, also handles AccessLists and Acl:
134 final InstanceIdentifier<AccessLists> accessListsIdIngress = InstanceIdentifier.create(
135 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Ingress.class)
136 .child(AccessLists.class);
137 final InstanceIdentifier<?> aclIdIngress = accessListsIdIngress.child(
138 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.ietf.acl.base.attributes.access.lists.Acl.class);
140 Sets.newHashSet(accessListsIdIngress, aclIdIngress),
141 new GenericWriter<>(SUBIF_INGRESS_IETF_ACL_ID, new SubInterfaceIetfAclCustomizer(aclWriter, ifcContext)));
143 // Egress IETF-ACL, also handles AccessLists and Acl:
144 final InstanceIdentifier<AccessLists> accessListsIdEgress = InstanceIdentifier.create(
145 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Egress.class)
146 .child(AccessLists.class);
147 final InstanceIdentifier<?> aclIdEgress = accessListsIdEgress.child(
148 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.ietf.acl.base.attributes.access.lists.Acl.class);
150 Sets.newHashSet(accessListsIdEgress, aclIdEgress),
151 new GenericWriter<>(SUBIF_EGRESS_IETF_ACL_ID, new io.fd.honeycomb.translate.v3po.interfaces.acl.egress.SubInterfaceIetfAclCustomizer(aclWriter, ifcContext)));