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 org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406;
19 import com.google.common.collect.Sets;
20 import io.fd.honeycomb.v3po.translate.impl.write.GenericListWriter;
21 import io.fd.honeycomb.v3po.translate.impl.write.GenericWriter;
22 import io.fd.honeycomb.v3po.translate.v3po.interfaces.RewriteCustomizer;
23 import io.fd.honeycomb.v3po.translate.v3po.interfaces.SubInterfaceCustomizer;
24 import io.fd.honeycomb.v3po.translate.v3po.interfaces.SubInterfaceL2Customizer;
25 import io.fd.honeycomb.v3po.translate.v3po.interfaces.ip.SubInterfaceIpv4AddressCustomizer;
26 import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
27 import io.fd.honeycomb.v3po.translate.write.ModifiableWriterRegistry;
28 import io.fd.honeycomb.v3po.translate.write.WriterFactory;
29 import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.dot1q.tag.or.any.Dot1qTag;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceAugmentation;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.SubInterfaces;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterface;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.match.attributes.match.type.vlan.tagged.VlanTagged;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.Match;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.Tags;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.l2.Rewrite;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.tags.Tag;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.Ipv4;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.ipv4.Address;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.tag.rewrite.PushTags;
42 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
43 import org.openvpp.jvpp.future.FutureJVpp;
45 final class SubinterfaceAugmentationWriterFactory implements WriterFactory {
47 private final InstanceIdentifier<Interface> ifcId;
48 private final FutureJVpp jvpp;
49 private final NamingContext ifcContext;
50 private final NamingContext bdContext;
52 public SubinterfaceAugmentationWriterFactory(
53 final InstanceIdentifier<Interface> ifcId, final FutureJVpp jvpp,
54 final NamingContext ifcContext, final NamingContext bdContext) {
57 this.ifcContext = ifcContext;
58 this.bdContext = bdContext;
62 public void init(final ModifiableWriterRegistry registry) {
63 final InstanceIdentifier<SubinterfaceAugmentation> subIfcAugId =
64 ifcId.augmentation(SubinterfaceAugmentation.class);
66 // Subinterface(Handle only after all interface related stuff gets processed) =
67 final InstanceIdentifier<SubInterface> subIfcId = subIfcAugId.child(SubInterfaces.class).child(SubInterface.class);
68 registry.addSubtreeWriterAfter(
69 // TODO this customizer covers quite a lot of complex child nodes (maybe refactor ?)
71 InstanceIdentifier.create(SubInterface.class).child(Tags.class),
72 InstanceIdentifier.create(SubInterface.class).child(Tags.class).child(Tag.class),
73 InstanceIdentifier.create(SubInterface.class).child(Tags.class).child(Tag.class).child(
75 InstanceIdentifier.create(SubInterface.class).child(Match.class),
76 InstanceIdentifier.create(SubInterface.class).child(Match.class).child(VlanTagged.class)),
77 new GenericListWriter<>(subIfcId, new SubInterfaceCustomizer(jvpp, ifcContext)),
80 final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2>
81 l2Id = subIfcId.child(
82 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2.class);
83 registry.addWriterAfter(new GenericWriter<>(l2Id, new SubInterfaceL2Customizer(jvpp, ifcContext, bdContext)),
85 // Rewrite(also handles pushTags + pushTags/dot1qtag) =
86 final InstanceIdentifier<Rewrite> rewriteId = l2Id.child(Rewrite.class);
87 registry.addSubtreeWriterAfter(
89 InstanceIdentifier.create(Rewrite.class).child(PushTags.class),
90 InstanceIdentifier.create(Rewrite.class).child(PushTags.class)
91 .child(org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.dot1q.tag.Dot1qTag.class)),
92 new GenericWriter<>(rewriteId, new RewriteCustomizer(jvpp, ifcContext)),
94 // Ipv4(handled after L2 and L2/rewrite is done) =
95 final InstanceIdentifier<Address> ipv4SubifcAddressId = subIfcId.child(Ipv4.class).child(Address.class);
96 registry.addWriterAfter(new GenericListWriter<>(ipv4SubifcAddressId,
97 new SubInterfaceIpv4AddressCustomizer(jvpp, ifcContext)),