HONEYCOMB-83: Add Gre Feature within HC
[honeycomb.git] / v3po / v3po2vpp / src / main / java / org / opendaylight / yang / gen / v1 / urn / honeycomb / params / xml / ns / yang / v3po2vpp / rev160406 / InterfacesStateHoneycombReaderModule.java
1 package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406;
2
3 import com.google.common.collect.Sets;
4 import io.fd.honeycomb.translate.impl.read.GenericListReader;
5 import io.fd.honeycomb.translate.impl.read.GenericReader;
6 import io.fd.honeycomb.translate.read.ReaderFactory;
7 import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
8 import io.fd.honeycomb.translate.v3po.interfacesstate.AclCustomizer;
9 import io.fd.honeycomb.translate.v3po.interfacesstate.EthernetCustomizer;
10 import io.fd.honeycomb.translate.v3po.interfacesstate.GreCustomizer;
11 import io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceCustomizer;
12 import io.fd.honeycomb.translate.v3po.interfacesstate.L2Customizer;
13 import io.fd.honeycomb.translate.v3po.interfacesstate.TapCustomizer;
14 import io.fd.honeycomb.translate.v3po.interfacesstate.VhostUserCustomizer;
15 import io.fd.honeycomb.translate.v3po.interfacesstate.VxlanCustomizer;
16 import io.fd.honeycomb.translate.v3po.interfacesstate.VxlanGpeCustomizer;
17 import io.fd.honeycomb.translate.v3po.interfacesstate.ip.Ipv4AddressCustomizer;
18 import io.fd.honeycomb.translate.v3po.interfacesstate.ip.Ipv4Customizer;
19 import io.fd.honeycomb.translate.v3po.interfacesstate.ip.Ipv4NeighbourCustomizer;
20 import io.fd.honeycomb.translate.v3po.interfacesstate.ip.Ipv6Customizer;
21 import io.fd.honeycomb.translate.v3po.util.NamingContext;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesStateBuilder;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface2;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface2Builder;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.Ipv4;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.Ipv6;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.Address;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.Neighbor;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentation;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentationBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.acl.base.attributes.Ip4Acl;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.acl.base.attributes.Ip6Acl;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.acl.base.attributes.L2Acl;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Acl;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Ethernet;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.L2;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Tap;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.VhostUser;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Vxlan;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.VxlanGpe;
43 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
44 import org.openvpp.jvpp.future.FutureJVpp;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Gre;
46 import org.opendaylight.yangtools.yang.binding.Augmentation;
47 import org.opendaylight.yangtools.yang.binding.ChildOf;
48
49 public class InterfacesStateHoneycombReaderModule extends
50         org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.AbstractInterfacesStateHoneycombReaderModule {
51
52     public static final InstanceIdentifier<InterfacesState> IFC_STATE_ID = InstanceIdentifier.create(InterfacesState.class);
53     static final InstanceIdentifier<Interface> IFC_ID = IFC_STATE_ID.child(Interface.class);
54
55     public InterfacesStateHoneycombReaderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
56                                                 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
57         super(identifier, dependencyResolver);
58     }
59
60     public InterfacesStateHoneycombReaderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
61                                                 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
62                                                 org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.InterfacesStateHoneycombReaderModule oldModule,
63                                                 java.lang.AutoCloseable oldInstance) {
64         super(identifier, dependencyResolver, oldModule, oldInstance);
65     }
66
67     @Override
68     public void customValidation() {
69         // add custom validation form module attributes here.
70     }
71
72     @Override
73     public java.lang.AutoCloseable createInstance() {
74         return new VppStateReaderFactory(getVppJvppDependency(),
75                 getInterfaceContextIfcStateDependency(),
76                 getBridgeDomainContextIfcStateDependency(),
77                 getClassifyTableContextDependency());
78     }
79
80     private static final class VppStateReaderFactory implements ReaderFactory, AutoCloseable {
81
82         private NamingContext ifcCtx;
83         private NamingContext bdCtx;
84         private NamingContext classifyCtx;
85         private FutureJVpp jvpp;
86
87         VppStateReaderFactory(final FutureJVpp jvpp,
88                               final NamingContext ifcCtx,
89                               final NamingContext bdCtx,
90                               final NamingContext classifyCtx) {
91             this.jvpp = jvpp;
92             this.ifcCtx = ifcCtx;
93             this.bdCtx = bdCtx;
94             this.classifyCtx = classifyCtx;
95         }
96
97         @Override
98         public void init(final ModifiableReaderRegistryBuilder registry) {
99             // InterfacesState(Structural)
100             registry.addStructuralReader(IFC_STATE_ID, InterfacesStateBuilder.class);
101             //  Interface
102             registry.add(new GenericListReader<>(IFC_ID, new InterfaceCustomizer(jvpp, ifcCtx)));
103
104             // v3po.yang
105             initVppIfcAugmentationReaders(registry, IFC_ID);
106             // ietf-ip.yang
107             initInterface2AugmentationReaders(registry, IFC_ID);
108             // vpp-vlan.yang
109             new SubinterfaceStateAugmentationReaderFactory(jvpp, ifcCtx, bdCtx, classifyCtx).init(registry);
110         }
111
112         private void initInterface2AugmentationReaders(final ModifiableReaderRegistryBuilder registry,
113                                                        final InstanceIdentifier<Interface> ifcId) {
114             //   Interface2Augmentation(Structural)
115             final InstanceIdentifier<Interface2> ifc2AugId = ifcId.augmentation(Interface2.class);
116             registry.addStructuralReader(ifc2AugId, Interface2Builder.class);
117             //    Ipv4
118             // TODO unfinished customizer
119             final InstanceIdentifier<Ipv4> ipv4Id = ifc2AugId.child(Ipv4.class);
120             registry.add(new GenericReader<>(ipv4Id, new Ipv4Customizer(jvpp)));
121             //     Address
122             final InstanceIdentifier<Address> ipv4AddrId = ipv4Id.child(Address.class);
123             registry.add(new GenericListReader<>(ipv4AddrId, new Ipv4AddressCustomizer(jvpp, ifcCtx)));
124             //     Neighbor
125             final InstanceIdentifier<Neighbor> neighborId = ipv4Id.child(Neighbor.class);
126             registry.add(new GenericListReader<>(neighborId, new Ipv4NeighbourCustomizer(jvpp)));
127             //    Ipv6
128             // TODO unfinished customizer
129             final InstanceIdentifier<Ipv6> ipv6Id = ifc2AugId.child(Ipv6.class);
130             registry.add(new GenericReader<>(ipv6Id, new Ipv6Customizer(jvpp, ifcCtx)));
131         }
132
133         private void initVppIfcAugmentationReaders(final ModifiableReaderRegistryBuilder registry,
134                                                    final InstanceIdentifier<Interface> ifcId) {
135             //   VppInterfaceStateAugmentation
136             final InstanceIdentifier<VppInterfaceStateAugmentation> vppIfcAugId = ifcId.augmentation(VppInterfaceStateAugmentation.class);
137             registry.addStructuralReader(vppIfcAugId, VppInterfaceStateAugmentationBuilder.class);
138             //    Ethernet
139             registry.add(new GenericReader<>(vppIfcAugId.child(Ethernet.class), new EthernetCustomizer(jvpp, ifcCtx)));
140             //    Tap
141             registry.add(new GenericReader<>(vppIfcAugId.child(Tap.class), new TapCustomizer(jvpp, ifcCtx)));
142             //    VhostUser
143             registry.add(new GenericReader<>(vppIfcAugId.child(VhostUser.class), new VhostUserCustomizer(jvpp, ifcCtx)));
144             //    Vxlan
145             registry.add(new GenericReader<>(vppIfcAugId.child(Vxlan.class), new VxlanCustomizer(jvpp, ifcCtx)));
146             //    VxlanGpe
147             registry.add(new GenericReader<>(vppIfcAugId.child(VxlanGpe.class), new VxlanGpeCustomizer(jvpp, ifcCtx)));
148             //    Gre
149             registry.add(new GenericReader<>(vppIfcAugId.child(Gre.class), new GreCustomizer(jvpp, ifcCtx)));
150             //    L2
151             registry.add(new GenericReader<>(vppIfcAugId.child(L2.class), new L2Customizer(jvpp, ifcCtx, bdCtx)));
152             //    Acl(Subtree)
153             final InstanceIdentifier<Acl> aclIdRelative = InstanceIdentifier.create(Acl.class);
154             registry.subtreeAdd(
155                     Sets.newHashSet(aclIdRelative.child(L2Acl.class), aclIdRelative.child(Ip4Acl.class), aclIdRelative.child(Ip6Acl.class)),
156                     new GenericReader<>(vppIfcAugId.child(Acl.class), new AclCustomizer(jvpp, ifcCtx, classifyCtx)));
157
158         }
159     }
160 }