From afab782c07481c8a618ccb4baa72b8a4d293a428 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 27 Jun 2016 15:23:28 +0200 Subject: 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 --- .../rev160406/InterfacesHoneycombWriterModule.java | 100 ++++++------------- .../InterfacesStateHoneycombReaderModule.java | 45 +-------- .../SubinterfaceAugmentationWriterFactory.java | 105 ++++++++++++++++++++ ...SubinterfaceStateAugmentationReaderFactory.java | 107 +++++++++++++++++++++ 4 files changed, 241 insertions(+), 116 deletions(-) create mode 100644 v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/SubinterfaceAugmentationWriterFactory.java create mode 100644 v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/v3po2vpp/rev160406/SubinterfaceStateAugmentationReaderFactory.java (limited to 'v3po/v3po2vpp/src/main/java/org/opendaylight/yang/gen') 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>> ifcAugmentations = Lists.newArrayList(); ifcAugmentations.add(getVppIfcAugmentationWriter()); ifcAugmentations.add(getInterface1AugmentationWriter()); - ifcAugmentations.add(getSubinterfaceAugmentationWriter()); + ifcAugmentations.add( + SubinterfaceAugmentationWriterFactory.createInstance(getVppJvppIfcDependency(), getInterfaceContextDependency(), + getBridgeDomainContextDependency())); final ChildWriter 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>> 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> getInterface1AugmentationWriter() { final ChildWriter
addressWriter = new CompositeListWriter<>(Address.class, - new AddressCustomizer(getVppJvppIfcDependency(),getInterfaceContextDependency())); + new Ipv4AddressCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter ipv4Writer = new CompositeChildWriter<>(Ipv4.class, - RWUtils.singletonChildWriterList(addressWriter), - new Ipv4Customizer(getVppJvppIfcDependency(),getInterfaceContextDependency())); + RWUtils.singletonChildWriterList(addressWriter), + new Ipv4Customizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter ipv6Writer = new CompositeChildWriter<>(Ipv6.class, - new Ipv6Customizer(getVppJvppIfcDependency())); + new Ipv6Customizer(getVppJvppIfcDependency())); final List>> interface1ChildWriters = Lists.newArrayList(); interface1ChildWriters.add(ipv4Writer); interface1ChildWriters.add(ipv6Writer); return new CompositeChildWriter<>(Interface1.class, - interface1ChildWriters, new ReflexiveAugmentWriterCustomizer<>()); + interface1ChildWriters, new ReflexiveAugmentWriterCustomizer<>()); } private ChildWriter getVppIfcAugmentationWriter() { final ChildWriter ethernetWriter = new CompositeChildWriter<>(Ethernet.class, - new EthernetCustomizer(getVppJvppIfcDependency())); + new EthernetCustomizer(getVppJvppIfcDependency())); final ChildWriter routingWriter = new CompositeChildWriter<>(Routing.class, - new RoutingCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); + new RoutingCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter vxlanWriter = new CompositeChildWriter<>(Vxlan.class, - new VxlanCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); + new VxlanCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter vxlanGpeWriter = new CompositeChildWriter<>(VxlanGpe.class, - new VxlanGpeCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); + new VxlanGpeCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter vhostUserWriter = new CompositeChildWriter<>(VhostUser.class, - new VhostUserCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); + new VhostUserCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter tapWriter = new CompositeChildWriter<>(Tap.class, - new TapCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); + new TapCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); final ChildWriter l2Writer = new CompositeChildWriter<>(L2.class, - new L2Customizer(getVppJvppIfcDependency(), getInterfaceContextDependency(), - getBridgeDomainContextDependency()) + new L2Customizer(getVppJvppIfcDependency(), getInterfaceContextDependency(), + getBridgeDomainContextDependency()) ); final List>> 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 getSubinterfaceAugmentationWriter() { - final ChildWriter> rewriteWriter = - new CompositeChildWriter<>(Rewrite.class, - new RewriteCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); - - final List>> childWriters = new ArrayList<>(); - final ChildWriter - 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, 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 subInterfaceWriter = new CompositeListWriter<>( - SubInterface.class, - childWriters, - new SubInterfaceCustomizer(getVppJvppIfcDependency(), getInterfaceContextDependency())); - - final ChildWriter 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 interfaceReader = new CompositeListReader<>(Interface.class, @@ -159,35 +147,4 @@ public class InterfacesStateHoneycombReaderModule extends VppInterfaceStateAugmentation.class)); return vppInterfaceStateAugmentationChildReader; } - - private ChildReader getSubinterfaceStateAugmentationReader() { - - final ChildReader rewriteReader = - new CompositeChildReader<>(Rewrite.class, - new RewriteCustomizer(getVppJvppDependency(), getInterfaceContextIfcStateDependency())); - - final ChildReader 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>> childReaders = new ArrayList<>(); - childReaders.add((ChildReader) l2Reader); // TODO can get rid of that cast? - - final CompositeListReader subInterfaceReader = - new CompositeListReader<>(SubInterface.class, childReaders, new SubInterfaceCustomizer(getVppJvppDependency(), - getInterfaceContextIfcStateDependency())); - - final ChildReader subInterfacesReader = new CompositeChildReader<>( - SubInterfaces.class, - RWUtils.singletonChildReaderList(subInterfaceReader), - new ReflexiveChildReaderCustomizer<>(SubInterfacesBuilder.class)); - - final ChildReader 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 getIp4Writer( + @Nonnull final FutureJVpp futureJvpp, @Nonnull final NamingContext interfaceContext) { + + final ChildWriter
addressWriter = new CompositeListWriter<>( + Address.class, + new SubInterfaceIpv4AddressCustomizer(futureJvpp, interfaceContext)); + + return new CompositeChildWriter<>( + Ipv4.class, + RWUtils.singletonChildWriterList(addressWriter), + new ReflexiveChildWriterCustomizer<>()); + } + + private static ChildWriter getL2Writer( + @Nonnull final FutureJVpp futureJvpp, @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext bridgeDomainContext) { + + final ChildWriter> rewriteWriter = + new CompositeChildWriter<>(Rewrite.class, new RewriteCustomizer(futureJvpp, interfaceContext)); + + return new CompositeChildWriter<>( + L2.class, + singletonChildWriterList(rewriteWriter), + new SubInterfaceL2Customizer(futureJvpp, interfaceContext, bridgeDomainContext) + ); + } + + static ChildWriter createInstance( + @Nonnull final FutureJVpp futureJvpp, @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext bridgeDomainContext) { + final List>> childWriters = new ArrayList<>(); + + // TODO L2 is ChildOf, 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 subInterfaceWriter = new CompositeListWriter<>( + SubInterface.class, + childWriters, + new SubInterfaceCustomizer(futureJvpp, interfaceContext)); + + final ChildWriter 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 getL2Reader(@Nonnull final FutureJVpp futureJvpp, + @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext bridgeDomainContext) { + final ChildReader rewriteReader = new CompositeChildReader<>( + Rewrite.class, new RewriteCustomizer(futureJvpp, interfaceContext)); + + return new CompositeChildReader<>(L2.class, + singletonChildReaderList(rewriteReader), + new SubInterfaceL2Customizer(futureJvpp, interfaceContext, bridgeDomainContext)); + } + + private static ChildReader getIpv4Reader(@Nonnull final FutureJVpp futureJvpp, + @Nonnull final NamingContext interfaceContext) { + + final ChildReader
addressReader = new CompositeListReader<>(Address.class, + new SubInterfaceIpv4AddressCustomizer(futureJvpp, interfaceContext)); + + return new CompositeChildReader<>( + Ipv4.class, + RWUtils.singletonChildReaderList(addressReader), + new ReflexiveChildReaderCustomizer<>(Ipv4Builder.class)); + + } + + static ChildReader createInstance( + @Nonnull final FutureJVpp futureJvpp, @Nonnull final NamingContext interfaceContext, + @Nonnull final NamingContext bridgeDomainContext) { + + List>> 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 subInterfaceReader = + new CompositeListReader<>(SubInterface.class, childReaders, new SubInterfaceCustomizer(futureJvpp, + interfaceContext)); + + final ChildReader subInterfacesReader = new CompositeChildReader<>( + SubInterfaces.class, + RWUtils.singletonChildReaderList(subInterfaceReader), + new ReflexiveChildReaderCustomizer<>(SubInterfacesBuilder.class)); + + final ChildReader subinterfaceStateAugmentationReader = + new CompositeChildReader<>(SubinterfaceStateAugmentation.class, + singletonChildReaderList(subInterfacesReader), + new ReflexiveAugmentReaderCustomizer<>( + SubinterfaceStateAugmentationBuilder.class, + SubinterfaceStateAugmentation.class)); + + return subinterfaceStateAugmentationReader; + } +} -- cgit 1.2.3-korg