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