diff options
author | 2016-06-27 15:23:28 +0200 | |
---|---|---|
committer | 2016-07-01 13:21:14 +0200 | |
commit | 95611a1a69dbe85c00c12ac2adc2761550f3f52d (patch) | |
tree | 18fb89a5de528ae075fd549850e151c3fafa16a6 /v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1 | |
parent | f1bbf132dd65e6fbb26b23c9c1c39f86ce7f08bc (diff) |
HONEYCOMB-104: add Ipv4 support to sub-interfaces
* updates vpp-vlan.yang with Ipv4 and Ipv6 support
based on ietf-ip rev. 2014-06-16
* adds Ipv4 support for sub-interfaces
Ipv6 support for interfaces and sub-interfaces will
be addded in the future (HONEYCOMB-102)
Change-Id: I0bf10fe3ff1c543685f651d8b6fb06bbeee3db92
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1')
4 files changed, 241 insertions, 116 deletions
diff --git a/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/InterfacesHoneycombWriterModule.java b/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/InterfacesHoneycombWriterModule.java index 9215f395d..e1513c213 100644 --- a/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/InterfacesHoneycombWriterModule.java +++ b/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/InterfacesHoneycombWriterModule.java @@ -1,7 +1,5 @@ package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406; -import static io.fd.honeycomb.v3po.translate.util.RWUtils.singletonChildWriterList; - import com.google.common.collect.Lists; import io.fd.honeycomb.v3po.translate.impl.TraversalType; import io.fd.honeycomb.v3po.translate.impl.write.CompositeChildWriter; @@ -11,19 +9,15 @@ import io.fd.honeycomb.v3po.translate.util.RWUtils; import io.fd.honeycomb.v3po.translate.util.write.CloseableWriter; import io.fd.honeycomb.v3po.translate.util.write.NoopWriterCustomizer; import io.fd.honeycomb.v3po.translate.util.write.ReflexiveAugmentWriterCustomizer; -import io.fd.honeycomb.v3po.translate.util.write.ReflexiveChildWriterCustomizer; import io.fd.honeycomb.v3po.translate.v3po.interfaces.EthernetCustomizer; import io.fd.honeycomb.v3po.translate.v3po.interfaces.InterfaceCustomizer; import io.fd.honeycomb.v3po.translate.v3po.interfaces.L2Customizer; -import io.fd.honeycomb.v3po.translate.v3po.interfaces.RewriteCustomizer; import io.fd.honeycomb.v3po.translate.v3po.interfaces.RoutingCustomizer; -import io.fd.honeycomb.v3po.translate.v3po.interfaces.SubInterfaceCustomizer; -import io.fd.honeycomb.v3po.translate.v3po.interfaces.SubInterfaceL2Customizer; import io.fd.honeycomb.v3po.translate.v3po.interfaces.TapCustomizer; import io.fd.honeycomb.v3po.translate.v3po.interfaces.VhostUserCustomizer; import io.fd.honeycomb.v3po.translate.v3po.interfaces.VxlanCustomizer; import io.fd.honeycomb.v3po.translate.v3po.interfaces.VxlanGpeCustomizer; -import io.fd.honeycomb.v3po.translate.v3po.interfaces.ip.AddressCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.interfaces.ip.Ipv4AddressCustomizer; import io.fd.honeycomb.v3po.translate.v3po.interfaces.ip.Ipv4Customizer; import io.fd.honeycomb.v3po.translate.v3po.interfaces.ip.Ipv6Customizer; import io.fd.honeycomb.v3po.translate.write.ChildWriter; @@ -43,16 +37,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VhostUser; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.Vxlan; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VxlanGpe; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceAugmentation; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.SubInterfaces; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterface; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterfaceKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.l2.Rewrite; import org.opendaylight.yangtools.yang.binding.Augmentation; import org.opendaylight.yangtools.yang.binding.ChildOf; public class InterfacesHoneycombWriterModule extends - org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.AbstractInterfacesHoneycombWriterModule { + org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406.AbstractInterfacesHoneycombWriterModule { public InterfacesHoneycombWriterModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); @@ -76,15 +65,17 @@ public class InterfacesHoneycombWriterModule extends final List<ChildWriter<? extends Augmentation<Interface>>> ifcAugmentations = Lists.newArrayList(); ifcAugmentations.add(getVppIfcAugmentationWriter()); ifcAugmentations.add(getInterface1AugmentationWriter()); - ifcAugmentations.add(getSubinterfaceAugmentationWriter()); + ifcAugmentations.add( + SubinterfaceAugmentationWriterFactory.createInstance(getVppJvppIfcDependency(), getInterfaceContextDependency(), + getBridgeDomainContextDependency())); final ChildWriter<Interface> interfaceWriter = new CompositeListWriter<>(Interface.class, - RWUtils.emptyChildWriterList(), - ifcAugmentations, - new InterfaceCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency()), - // It's important that this customizer is handled in a postorder way, because you first have to handle child nodes - // e.g. Vxlan before setting other interface or vppInterfaceAugmentation leaves - TraversalType.POSTORDER); + RWUtils.emptyChildWriterList(), + ifcAugmentations, + new InterfaceCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency()), + // It's important that this customizer is handled in a postorder way, because you first have to handle child nodes + // e.g. Vxlan before setting other interface or vppInterfaceAugmentation leaves + TraversalType.POSTORDER); final List<ChildWriter<? extends ChildOf<Interfaces>>> childWriters = new ArrayList<>(); childWriters.add(interfaceWriter); @@ -93,51 +84,51 @@ public class InterfacesHoneycombWriterModule extends // we loose the ordering information for root writers // Or can we rely to the order in which readers are configured ? return new CloseableWriter<>(new CompositeRootWriter<>(Interfaces.class, - childWriters, new NoopWriterCustomizer<>())); + childWriters, new NoopWriterCustomizer<>())); } private ChildWriter<? extends Augmentation<Interface>> getInterface1AugmentationWriter() { final ChildWriter<Address> addressWriter = new CompositeListWriter<>(Address.class, - new AddressCustomizer(getVppJvppIfcDependency(),getInterfaceContextDependency())); + new Ipv4AddressCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter<Ipv4> ipv4Writer = new CompositeChildWriter<>(Ipv4.class, - RWUtils.singletonChildWriterList(addressWriter), - new Ipv4Customizer(getVppJvppIfcDependency(),getInterfaceContextDependency())); + RWUtils.singletonChildWriterList(addressWriter), + new Ipv4Customizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter<Ipv6> ipv6Writer = new CompositeChildWriter<>(Ipv6.class, - new Ipv6Customizer(getVppJvppIfcDependency())); + new Ipv6Customizer(getVppJvppIfcDependency())); final List<ChildWriter<? extends ChildOf<Interface1>>> interface1ChildWriters = Lists.newArrayList(); interface1ChildWriters.add(ipv4Writer); interface1ChildWriters.add(ipv6Writer); return new CompositeChildWriter<>(Interface1.class, - interface1ChildWriters, new ReflexiveAugmentWriterCustomizer<>()); + interface1ChildWriters, new ReflexiveAugmentWriterCustomizer<>()); } private ChildWriter<VppInterfaceAugmentation> getVppIfcAugmentationWriter() { final ChildWriter<Ethernet> ethernetWriter = new CompositeChildWriter<>(Ethernet.class, - new EthernetCustomizer(getVppJvppIfcDependency())); + new EthernetCustomizer(getVppJvppIfcDependency())); final ChildWriter<Routing> routingWriter = new CompositeChildWriter<>(Routing.class, - new RoutingCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); + new RoutingCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter<Vxlan> vxlanWriter = new CompositeChildWriter<>(Vxlan.class, - new VxlanCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); + new VxlanCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter<VxlanGpe> vxlanGpeWriter = new CompositeChildWriter<>(VxlanGpe.class, - new VxlanGpeCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); + new VxlanGpeCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter<VhostUser> vhostUserWriter = new CompositeChildWriter<>(VhostUser.class, - new VhostUserCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); + new VhostUserCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter<Tap> tapWriter = new CompositeChildWriter<>(Tap.class, - new TapCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); + new TapCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter<L2> l2Writer = new CompositeChildWriter<>(L2.class, - new L2Customizer(getVppJvppIfcDependency(), getInterfaceContextDependency(), - getBridgeDomainContextDependency()) + new L2Customizer(getVppJvppIfcDependency(), getInterfaceContextDependency(), + getBridgeDomainContextDependency()) ); final List<ChildWriter<? extends ChildOf<VppInterfaceAugmentation>>> vppIfcChildWriters = Lists.newArrayList(); @@ -150,43 +141,8 @@ public class InterfacesHoneycombWriterModule extends vppIfcChildWriters.add(routingWriter); return new CompositeChildWriter<>(VppInterfaceAugmentation.class, - vppIfcChildWriters, - RWUtils.emptyAugWriterList(), - new ReflexiveAugmentWriterCustomizer<>()); - } - - private ChildWriter<SubinterfaceAugmentation> getSubinterfaceAugmentationWriter() { - final ChildWriter<? extends ChildOf<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2>> rewriteWriter = - new CompositeChildWriter<>(Rewrite.class, - new RewriteCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); - - final List<ChildWriter<? extends ChildOf<SubInterface>>> childWriters = new ArrayList<>(); - final ChildWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2> - l2Writer = new CompositeChildWriter<>( - org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2.class, - singletonChildWriterList(rewriteWriter), - new SubInterfaceL2Customizer(getVppJvppIfcDependency(), getInterfaceContextDependency(), - getBridgeDomainContextDependency()) - ); - - // TODO L2 is ChildOf<SubInterfaceBaseAttributes>, but SubInterface extends SubInterfaceBaseAttributes - // If we use containers inside groupings, we need to cast and lose static type checking. - // Can we get rid of the cast? - childWriters.add((ChildWriter) l2Writer); - - final CompositeListWriter<SubInterface, SubInterfaceKey> subInterfaceWriter = new CompositeListWriter<>( - SubInterface.class, - childWriters, - new SubInterfaceCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); - - final ChildWriter<SubInterfaces> subInterfacesWriter = new CompositeChildWriter<>( - SubInterfaces.class, - singletonChildWriterList(subInterfaceWriter), - new ReflexiveChildWriterCustomizer<>()); - - return new CompositeChildWriter<>(SubinterfaceAugmentation.class, - singletonChildWriterList(subInterfacesWriter), - RWUtils.emptyAugWriterList(), - new ReflexiveAugmentWriterCustomizer<>()); + vppIfcChildWriters, + RWUtils.emptyAugWriterList(), + new ReflexiveAugmentWriterCustomizer<>()); } } diff --git a/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/InterfacesStateHoneycombReaderModule.java b/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/InterfacesStateHoneycombReaderModule.java index 644a272a5..3b8c5a863 100644 --- a/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/InterfacesStateHoneycombReaderModule.java +++ b/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/InterfacesStateHoneycombReaderModule.java @@ -12,14 +12,10 @@ import io.fd.honeycomb.v3po.translate.read.ChildReader; import io.fd.honeycomb.v3po.translate.util.RWUtils; import io.fd.honeycomb.v3po.translate.util.read.CloseableReader; import io.fd.honeycomb.v3po.translate.util.read.ReflexiveAugmentReaderCustomizer; -import io.fd.honeycomb.v3po.translate.util.read.ReflexiveChildReaderCustomizer; import io.fd.honeycomb.v3po.translate.util.read.ReflexiveRootReaderCustomizer; import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.EthernetCustomizer; import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceCustomizer; import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.L2Customizer; -import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.RewriteCustomizer; -import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.SubInterfaceCustomizer; -import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.SubInterfaceL2Customizer; import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.TapCustomizer; import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.VhostUserCustomizer; import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.VxlanCustomizer; @@ -47,14 +43,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.VhostUser; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.Vxlan; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.VxlanGpe; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceStateAugmentation; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceStateAugmentationBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.SubInterfaces; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.SubInterfacesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterface; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterfaceBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterfaceKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.l2.Rewrite; import org.opendaylight.yangtools.yang.binding.Augmentation; import org.opendaylight.yangtools.yang.binding.ChildOf; @@ -83,7 +71,7 @@ public class InterfacesStateHoneycombReaderModule extends interfaceAugReaders = new ArrayList<>(); interfaceAugReaders.add(getVppInterfaceStateAugmentationReader()); interfaceAugReaders.add(getInterface1AugmentationReader()); - interfaceAugReaders.add(getSubinterfaceStateAugmentationReader()); + interfaceAugReaders.add(SubinterfaceStateAugmentationReaderFactory.createInstance(getVppJvppDependency(), getInterfaceContextIfcStateDependency(), getBridgeDomainContextIfcStateDependency())); final CompositeListReader<Interface, InterfaceKey, InterfaceBuilder> interfaceReader = new CompositeListReader<>(Interface.class, @@ -159,35 +147,4 @@ public class InterfacesStateHoneycombReaderModule extends VppInterfaceStateAugmentation.class)); return vppInterfaceStateAugmentationChildReader; } - - private ChildReader<SubinterfaceStateAugmentation> getSubinterfaceStateAugmentationReader() { - - final ChildReader<Rewrite> rewriteReader = - new CompositeChildReader<>(Rewrite.class, - new RewriteCustomizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency())); - - final ChildReader<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2> l2Reader = - new CompositeChildReader<>(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2.class, - singletonChildReaderList(rewriteReader), - new SubInterfaceL2Customizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency(), getBridgeDomainContextIfcStateDependency())); - - List<ChildReader<? extends ChildOf<SubInterface>>> childReaders = new ArrayList<>(); - childReaders.add((ChildReader) l2Reader); // TODO can get rid of that cast? - - final CompositeListReader<SubInterface, SubInterfaceKey, SubInterfaceBuilder> subInterfaceReader = - new CompositeListReader<>(SubInterface.class, childReaders, new SubInterfaceCustomizer(getVppJvppDependency(), - getInterfaceContextIfcStateDependency())); - - final ChildReader<SubInterfaces> subInterfacesReader = new CompositeChildReader<>( - SubInterfaces.class, - RWUtils.singletonChildReaderList(subInterfaceReader), - new ReflexiveChildReaderCustomizer<>(SubInterfacesBuilder.class)); - - final ChildReader<SubinterfaceStateAugmentation> subinterfaceStateAugmentationReader = - new CompositeChildReader<>(SubinterfaceStateAugmentation.class, - singletonChildReaderList(subInterfacesReader), - new ReflexiveAugmentReaderCustomizer<>(SubinterfaceStateAugmentationBuilder.class, - SubinterfaceStateAugmentation.class)); - return subinterfaceStateAugmentationReader; - } } diff --git a/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/SubinterfaceAugmentationWriterFactory.java b/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/SubinterfaceAugmentationWriterFactory.java new file mode 100644 index 000000000..f24dbf7e0 --- /dev/null +++ b/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/SubinterfaceAugmentationWriterFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406; + +import static io.fd.honeycomb.v3po.translate.util.RWUtils.singletonChildWriterList; + +import io.fd.honeycomb.v3po.translate.impl.write.CompositeChildWriter; +import io.fd.honeycomb.v3po.translate.impl.write.CompositeListWriter; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.util.write.ReflexiveAugmentWriterCustomizer; +import io.fd.honeycomb.v3po.translate.util.write.ReflexiveChildWriterCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.interfaces.RewriteCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.interfaces.SubInterfaceCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.interfaces.SubInterfaceL2Customizer; +import io.fd.honeycomb.v3po.translate.v3po.interfaces.ip.SubInterfaceIpv4AddressCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext; +import io.fd.honeycomb.v3po.translate.write.ChildWriter; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceAugmentation; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.SubInterfaces; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterface; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterfaceKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.l2.Rewrite; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.Ipv4; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.ipv4.Address; +import org.opendaylight.yangtools.yang.binding.ChildOf; +import org.openvpp.jvpp.future.FutureJVpp; + +final class SubinterfaceAugmentationWriterFactory { + + private SubinterfaceAugmentationWriterFactory() { + } + + private static ChildWriter<Ipv4> getIp4Writer( + @Nonnull final FutureJVpp futureJvpp, @Nonnull final NamingContext interfaceContext) { + + final ChildWriter<Address> addressWriter = new CompositeListWriter<>( + Address.class, + new SubInterfaceIpv4AddressCustomizer(futureJvpp, interfaceContext)); + + return new CompositeChildWriter<>( + Ipv4.class, + RWUtils.singletonChildWriterList(addressWriter), + new ReflexiveChildWriterCustomizer<>()); + } + + private static ChildWriter<L2> getL2Writer( + @Nonnull final FutureJVpp futureJvpp, @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext bridgeDomainContext) { + + final ChildWriter<? extends ChildOf<L2>> rewriteWriter = + new CompositeChildWriter<>(Rewrite.class, new RewriteCustomizer(futureJvpp, interfaceContext)); + + return new CompositeChildWriter<>( + L2.class, + singletonChildWriterList(rewriteWriter), + new SubInterfaceL2Customizer(futureJvpp, interfaceContext, bridgeDomainContext) + ); + } + + static ChildWriter<SubinterfaceAugmentation> createInstance( + @Nonnull final FutureJVpp futureJvpp, @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext bridgeDomainContext) { + final List<ChildWriter<? extends ChildOf<SubInterface>>> childWriters = new ArrayList<>(); + + // TODO L2 is ChildOf<SubInterfaceBaseAttributes>, but SubInterface extends SubInterfaceBaseAttributes + // If we use containers inside groupings, we need to cast and lose static type checking. + // Can we get rid of the cast? + childWriters.add((ChildWriter) getL2Writer(futureJvpp, interfaceContext, bridgeDomainContext)); + childWriters.add((ChildWriter) getIp4Writer(futureJvpp, interfaceContext)); + + final CompositeListWriter<SubInterface, SubInterfaceKey> subInterfaceWriter = new CompositeListWriter<>( + SubInterface.class, + childWriters, + new SubInterfaceCustomizer(futureJvpp, interfaceContext)); + + final ChildWriter<SubInterfaces> subInterfacesWriter = new CompositeChildWriter<>( + SubInterfaces.class, + singletonChildWriterList(subInterfaceWriter), + new ReflexiveChildWriterCustomizer<>()); + + return new CompositeChildWriter<>( + SubinterfaceAugmentation.class, + singletonChildWriterList(subInterfacesWriter), + RWUtils.emptyAugWriterList(), + new ReflexiveAugmentWriterCustomizer<>()); + } +} diff --git a/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/SubinterfaceStateAugmentationReaderFactory.java b/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/SubinterfaceStateAugmentationReaderFactory.java new file mode 100644 index 000000000..9e182b1fe --- /dev/null +++ b/v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/SubinterfaceStateAugmentationReaderFactory.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.v3po2vpp.rev160406; + +import static io.fd.honeycomb.v3po.translate.util.RWUtils.singletonChildReaderList; + +import io.fd.honeycomb.v3po.translate.impl.read.CompositeChildReader; +import io.fd.honeycomb.v3po.translate.impl.read.CompositeListReader; +import io.fd.honeycomb.v3po.translate.read.ChildReader; +import io.fd.honeycomb.v3po.translate.util.RWUtils; +import io.fd.honeycomb.v3po.translate.util.read.ReflexiveAugmentReaderCustomizer; +import io.fd.honeycomb.v3po.translate.util.read.ReflexiveChildReaderCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.RewriteCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.SubInterfaceCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.SubInterfaceL2Customizer; +import io.fd.honeycomb.v3po.translate.v3po.interfacesstate.ip.SubInterfaceIpv4AddressCustomizer; +import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceStateAugmentation; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceStateAugmentationBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.SubInterfaces; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.SubInterfacesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterface; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterfaceBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterfaceKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.l2.Rewrite; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.Ipv4; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.Ipv4Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.ipv4.Address; +import org.opendaylight.yangtools.yang.binding.ChildOf; +import org.openvpp.jvpp.future.FutureJVpp; + +final class SubinterfaceStateAugmentationReaderFactory { + + private SubinterfaceStateAugmentationReaderFactory() { + } + + private static ChildReader<L2> getL2Reader(@Nonnull final FutureJVpp futureJvpp, + @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext bridgeDomainContext) { + final ChildReader<Rewrite> rewriteReader = new CompositeChildReader<>( + Rewrite.class, new RewriteCustomizer(futureJvpp, interfaceContext)); + + return new CompositeChildReader<>(L2.class, + singletonChildReaderList(rewriteReader), + new SubInterfaceL2Customizer(futureJvpp, interfaceContext, bridgeDomainContext)); + } + + private static ChildReader<Ipv4> getIpv4Reader(@Nonnull final FutureJVpp futureJvpp, + @Nonnull final NamingContext interfaceContext) { + + final ChildReader<Address> addressReader = new CompositeListReader<>(Address.class, + new SubInterfaceIpv4AddressCustomizer(futureJvpp, interfaceContext)); + + return new CompositeChildReader<>( + Ipv4.class, + RWUtils.singletonChildReaderList(addressReader), + new ReflexiveChildReaderCustomizer<>(Ipv4Builder.class)); + + } + + static ChildReader<SubinterfaceStateAugmentation> createInstance( + @Nonnull final FutureJVpp futureJvpp, @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext bridgeDomainContext) { + + List<ChildReader<? extends ChildOf<SubInterface>>> childReaders = new ArrayList<>(); + + // TODO can get rid of that cast? + childReaders.add((ChildReader) getL2Reader(futureJvpp, interfaceContext, bridgeDomainContext)); + childReaders.add((ChildReader) getIpv4Reader(futureJvpp, interfaceContext)); + + final CompositeListReader<SubInterface, SubInterfaceKey, SubInterfaceBuilder> subInterfaceReader = + new CompositeListReader<>(SubInterface.class, childReaders, new SubInterfaceCustomizer(futureJvpp, + interfaceContext)); + + final ChildReader<SubInterfaces> subInterfacesReader = new CompositeChildReader<>( + SubInterfaces.class, + RWUtils.singletonChildReaderList(subInterfaceReader), + new ReflexiveChildReaderCustomizer<>(SubInterfacesBuilder.class)); + + final ChildReader<SubinterfaceStateAugmentation> subinterfaceStateAugmentationReader = + new CompositeChildReader<>(SubinterfaceStateAugmentation.class, + singletonChildReaderList(subInterfacesReader), + new ReflexiveAugmentReaderCustomizer<>( + SubinterfaceStateAugmentationBuilder.class, + SubinterfaceStateAugmentation.class)); + + return subinterfaceStateAugmentationReader; + } +} |