1 package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406;
3 import com.google.common.collect.Lists;
4 import io.fd.honeycomb.v3po.translate.impl.TraversalType;
5 import io.fd.honeycomb.v3po.translate.impl.write.CompositeChildWriter;
6 import io.fd.honeycomb.v3po.translate.impl.write.CompositeListWriter;
7 import io.fd.honeycomb.v3po.translate.impl.write.CompositeRootWriter;
8 import io.fd.honeycomb.v3po.translate.util.RWUtils;
9 import io.fd.honeycomb.v3po.translate.util.write.CloseableWriter;
10 import io.fd.honeycomb.v3po.translate.util.write.NoopWriterCustomizer;
11 import io.fd.honeycomb.v3po.translate.util.write.ReflexiveChildWriterCustomizer;
12 import io.fd.honeycomb.v3po.translate.v3po.interfaces.EthernetCustomizer;
13 import io.fd.honeycomb.v3po.translate.v3po.interfaces.InterfaceCustomizer;
14 import io.fd.honeycomb.v3po.translate.v3po.interfaces.L2Customizer;
15 import io.fd.honeycomb.v3po.translate.v3po.interfaces.RoutingCustomizer;
16 import io.fd.honeycomb.v3po.translate.v3po.interfaces.VppInterfaceCustomizer;
17 import io.fd.honeycomb.v3po.translate.v3po.interfaces.VxlanCustomizer;
18 import io.fd.honeycomb.v3po.translate.v3po.interfaces.ip.Ipv4Customizer;
19 import io.fd.honeycomb.v3po.translate.v3po.interfaces.ip.Ipv6Customizer;
20 import io.fd.honeycomb.v3po.translate.write.ChildWriter;
21 import java.util.ArrayList;
22 import java.util.List;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv4;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv6;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceAugmentation;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.Ethernet;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.L2;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.Routing;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.Vxlan;
33 import org.opendaylight.yangtools.yang.binding.Augmentation;
34 import org.opendaylight.yangtools.yang.binding.ChildOf;
36 public class InterfacesHoneycombWriterModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.AbstractInterfacesHoneycombWriterModule {
37 public InterfacesHoneycombWriterModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
38 super(identifier, dependencyResolver);
41 public InterfacesHoneycombWriterModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.InterfacesHoneycombWriterModule oldModule, java.lang.AutoCloseable oldInstance) {
42 super(identifier, dependencyResolver, oldModule, oldInstance);
46 public void customValidation() {
47 // add custom validation form module attributes here.
51 public java.lang.AutoCloseable createInstance() {
53 final List<ChildWriter<? extends Augmentation<Interface>>> ifcAugmentations = Lists.newArrayList();
54 ifcAugmentations.add(getVppIfcAugmentationWriter());
56 final ChildWriter<Interface> interfaceWriter = new CompositeListWriter<>(Interface.class,
57 RWUtils.<Interface>emptyChildWriterList(),
59 new InterfaceCustomizer(getVppJapiIfcDependency()));
61 final List<ChildWriter<? extends ChildOf<Interfaces>>> childWriters = new ArrayList<>();
62 childWriters.add(interfaceWriter);
64 // FIXME if we just return the root writer and cfg subsystem takes care to set it into reader registry,
65 // we loose the ordering information for root writers
66 // Or can we rely to the order in which readers are configured ?
67 return new CloseableWriter<>(new CompositeRootWriter<>(Interfaces.class,
68 childWriters, new NoopWriterCustomizer<Interfaces>()));
71 private ChildWriter<? extends Augmentation<Interface>> getInterface1AugmentationWriter() {
72 final ChildWriter<Ipv4> ipv4Writer = new CompositeChildWriter<>(Ipv4.class,
73 new Ipv4Customizer(getVppJapiIfcDependency()));
74 final ChildWriter<Ipv6> ipv6Writer = new CompositeChildWriter<>(Ipv6.class,
75 new Ipv6Customizer(getVppJapiIfcDependency()));
77 final List<ChildWriter<? extends ChildOf<Interface1>>> interface1ChildWriters = Lists.newArrayList();
78 interface1ChildWriters.add(ipv4Writer);
79 interface1ChildWriters.add(ipv6Writer);
81 return new CompositeChildWriter<>(Interface1.class,
82 interface1ChildWriters, new ReflexiveChildWriterCustomizer<Interface1>());
85 private ChildWriter<VppInterfaceAugmentation> getVppIfcAugmentationWriter() {
87 final ChildWriter<Ethernet> ethernetWriter = new CompositeChildWriter<>(Ethernet.class,
88 new EthernetCustomizer(getVppJapiIfcDependency()));
90 final ChildWriter<Routing> routingWriter = new CompositeChildWriter<>(Routing.class,
91 new RoutingCustomizer(getVppJapiIfcDependency()));
93 final ChildWriter<Vxlan> vxlanWriter = new CompositeChildWriter<>(Vxlan.class,
94 new VxlanCustomizer(getVppJapiIfcDependency()));
96 final ChildWriter<L2> l2Writer = new CompositeChildWriter<>(L2.class,
97 new L2Customizer(getVppJapiIfcDependency()));
99 final List<ChildWriter<? extends ChildOf<VppInterfaceAugmentation>>> vppIfcChildWriters = Lists.newArrayList();
100 // TODO what's the order here ?
101 vppIfcChildWriters.add(ethernetWriter);
102 vppIfcChildWriters.add(vxlanWriter);
103 vppIfcChildWriters.add(l2Writer);
104 vppIfcChildWriters.add(routingWriter);
106 return new CompositeChildWriter<>(VppInterfaceAugmentation.class,
108 RWUtils.<VppInterfaceAugmentation>emptyAugWriterList(),
109 new VppInterfaceCustomizer(getVppJapiIfcDependency()),
110 // It's important that this customizer is handled in a postorder way, because you first have to handle child nodes
111 // e.g. Vxlan before setting other interface or vppInterfaceAugmentation leaves
112 TraversalType.POSTORDER);