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.rev150105.acl.base.attributes.Ip4Acl;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.acl.base.attributes.Ip6Acl;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.acl.base.attributes.L2Acl;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.ietf.acl.base.attributes.AccessLists;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceAugmentation;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.SubInterfaces;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterface;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.match.attributes.match.type.vlan.tagged.VlanTagged;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.Acl;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.IetfAcl;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.Match;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.Tags;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.acl.Ingress;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.l2.Rewrite;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.tags.Tag;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.Ipv4;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.ipv4.Address;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.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.rev150527.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.rev150527.sub._interface.base.attributes.ietf.acl.Ingress.class);
79 public SubinterfaceAugmentationWriterFactory(final FutureJVppCore jvpp,
80 final IetfAClWriter aclWriter,
81 final NamingContext ifcContext, final NamingContext bdContext, final VppClassifierContextManager classifyTableContext) {
83 this.aclWriter = aclWriter;
84 this.ifcContext = ifcContext;
85 this.bdContext = bdContext;
86 this.classifyTableContext = classifyTableContext;
90 public void init(final ModifiableWriterRegistryBuilder registry) {
92 // Subinterface(Handle only after all interface related stuff gets processed) =
93 registry.subtreeAddAfter(
94 // TODO HONEYCOMB-188 this customizer covers quite a lot of complex child nodes (maybe refactor ?)
96 InstanceIdentifier.create(SubInterface.class).child(Tags.class),
97 InstanceIdentifier.create(SubInterface.class).child(Tags.class).child(Tag.class),
98 InstanceIdentifier.create(SubInterface.class).child(Tags.class).child(Tag.class).child(
100 InstanceIdentifier.create(SubInterface.class).child(Match.class),
101 InstanceIdentifier.create(SubInterface.class).child(Match.class).child(VlanTagged.class)),
102 new GenericListWriter<>(SUB_IFC_ID, new SubInterfaceCustomizer(jvpp, ifcContext)),
103 InterfacesWriterFactory.IFC_ID);
105 registry.addAfter(new GenericWriter<>(L2_ID, new SubInterfaceL2Customizer(jvpp, ifcContext, bdContext)),
107 // Rewrite(also handles pushTags + pushTags/dot1qtag) =
108 final InstanceIdentifier<Rewrite> rewriteId = L2_ID.child(Rewrite.class);
109 registry.subtreeAddAfter(
111 InstanceIdentifier.create(Rewrite.class).child(PushTags.class),
112 InstanceIdentifier.create(Rewrite.class).child(PushTags.class)
113 .child(org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.dot1q.tag.Dot1qTag.class)),
114 new GenericWriter<>(rewriteId, new RewriteCustomizer(jvpp, ifcContext)),
116 // Ipv4(handled after L2 and L2/rewrite is done) =
117 final InstanceIdentifier<Address> ipv4SubifcAddressId = SUB_IFC_ID.child(Ipv4.class).child(Address.class);
118 registry.addAfter(new GenericListWriter<>(ipv4SubifcAddressId,
119 new SubInterfaceIpv4AddressCustomizer(jvpp, ifcContext)),
122 // Ingress (execute after classify table and session writers)
123 // also handles L2Acl, Ip4Acl and Ip6Acl:
124 final InstanceIdentifier<Ingress> aclId = InstanceIdentifier.create(Ingress.class);
127 Sets.newHashSet(aclId.child(L2Acl.class), aclId.child(Ip4Acl.class), aclId.child(Ip6Acl.class)),
128 new GenericWriter<>(SUBIF_INGRESS_ACL_ID, new SubInterfaceAclCustomizer(jvpp, ifcContext, classifyTableContext)),
129 Sets.newHashSet(CLASSIFY_TABLE_ID, CLASSIFY_SESSION_ID));
131 // Ingress IETF-ACL, also handles AccessLists and Acl:
132 final InstanceIdentifier<AccessLists> accessListsID = InstanceIdentifier.create(
133 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.ietf.acl.Ingress.class)
134 .child(AccessLists.class);
135 final InstanceIdentifier<?> aclListId = accessListsID.child(
136 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.ietf.acl.base.attributes.access.lists.Acl.class);
138 Sets.newHashSet(accessListsID, aclListId),
139 new GenericWriter<>(SUBIF_INGRESS_IETF_ACL_ID, new SubInterfaceIetfAclCustomizer(aclWriter, ifcContext)));