diff options
author | Hongjun Ni <hongjun.ni@intel.com> | 2016-12-13 01:23:43 +0800 |
---|---|---|
committer | Hongjun Ni <hongjun.ni@intel.com> | 2016-12-13 19:00:53 +0800 |
commit | a0053ac0bfadabafca3d80e3b3500f82913f3235 (patch) | |
tree | 64e52c8912fde9004e6ebb66d020f95303199e56 | |
parent | 10ae85f84a55c5c1bf35d9d943c34df82ef18cae (diff) |
Augment vxlan to support decap-next: YANG model
Change-Id: I97571254c7da7d010d542515864d8f39ea1499d1
Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
5 files changed, 147 insertions, 75 deletions
diff --git a/v3po/api/src/main/yang/v3po.yang b/v3po/api/src/main/yang/v3po.yang index fff8293d5..c1c0ce23d 100644 --- a/v3po/api/src/main/yang/v3po.yang +++ b/v3po/api/src/main/yang/v3po.yang @@ -328,6 +328,28 @@ module v3po { } } + /* + * Defines the supported decap node for vxlan. + */ + identity decap-node { + description + "Define the supported decap node"; + } + identity l2-input { + base decap-node; + description + "The next decap node is l2-input"; + } + identity nsh-proxy { + base decap-node; + description + "The next decap node is nsh-proxy"; + } + typedef vxlan-decap-node { + type identityref { + base "decap-node"; + } + } grouping vxlan-base-attributes { // FIXME: this should be in an vxlan-specific extension leaf src { @@ -345,6 +367,10 @@ module v3po { leaf encap-vrf-id { type uint32; } + leaf decap-next { + type vxlan-decap-node; + default "l2-input"; + } } grouping gre-base-attributes { diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizer.java index ec2193476..2e5da5adb 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizer.java @@ -18,28 +18,34 @@ package io.fd.hc2vpp.v3po.interfaces; import static com.google.common.base.Preconditions.checkArgument; -import com.google.common.net.InetAddresses; -import io.fd.hc2vpp.v3po.DisabledInterfacesManager; -import io.fd.hc2vpp.common.translate.util.AbstractInterfaceTypeCustomizer; -import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.honeycomb.translate.write.WriteContext; -import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnel; -import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnelReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.net.InetAddress; import java.util.concurrent.CompletionStage; + import javax.annotation.Nonnull; + import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.L2Input; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.NshProxy; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VxlanTunnel; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.Vxlan; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.net.InetAddresses; + +import io.fd.hc2vpp.common.translate.util.AbstractInterfaceTypeCustomizer; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.DisabledInterfacesManager; +import io.fd.honeycomb.translate.write.WriteContext; +import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnel; +import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnelReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; + public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> implements JvppReplyConsumer { private static final Logger LOG = LoggerFactory.getLogger(VxlanCustomizer.class); @@ -48,8 +54,8 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl private final DisabledInterfacesManager interfaceDisableContext; public VxlanCustomizer(@Nonnull final FutureJVppCore vppApi, - @Nonnull final NamingContext interfaceNamingContext, - @Nonnull final DisabledInterfacesManager interfaceDisableContext) { + @Nonnull final NamingContext interfaceNamingContext, + @Nonnull final DisabledInterfacesManager interfaceDisableContext) { super(vppApi); this.interfaceNamingContext = interfaceNamingContext; this.interfaceDisableContext = interfaceDisableContext; @@ -62,44 +68,51 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl @Override protected final void writeInterface(@Nonnull final InstanceIdentifier<Vxlan> id, @Nonnull final Vxlan dataAfter, - @Nonnull final WriteContext writeContext) - throws WriteFailedException { + @Nonnull final WriteContext writeContext) + throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); createVxlanTunnel(id, swIfName, dataAfter, writeContext); } @Override public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Vxlan> id, @Nonnull final Vxlan dataBefore, - @Nonnull final Vxlan dataAfter, @Nonnull final WriteContext writeContext) - throws WriteFailedException.UpdateFailedException { + @Nonnull final Vxlan dataAfter, @Nonnull final WriteContext writeContext) + throws WriteFailedException.UpdateFailedException { throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, new UnsupportedOperationException("Vxlan tunnel update is not supported")); } @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Vxlan> id, @Nonnull final Vxlan dataBefore, - @Nonnull final WriteContext writeContext) - throws WriteFailedException { + @Nonnull final WriteContext writeContext) + throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); deleteVxlanTunnel(id, swIfName, dataBefore, writeContext); } private void createVxlanTunnel(final InstanceIdentifier<Vxlan> id, final String swIfName, final Vxlan vxlan, - final WriteContext writeContext) - throws WriteFailedException { + final WriteContext writeContext) + throws WriteFailedException { final byte isIpv6 = (byte) (isIpv6(vxlan) ? 1 - : 0); + : 0); final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc())); final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst())); int encapVrfId = vxlan.getEncapVrfId().intValue(); int vni = vxlan.getVni().getValue().intValue(); + int decapNext = -1; + if (vxlan.getDecapNext() == L2Input.class) { + decapNext = 1; + } else if (vxlan.getDecapNext() == NshProxy.class) { + decapNext = 2; + } + LOG.debug("Setting vxlan tunnel for interface: {}. Vxlan: {}", swIfName, vxlan); final CompletionStage<VxlanAddDelTunnelReply> vxlanAddDelTunnelReplyCompletionStage = getFutureJVpp().vxlanAddDelTunnel(getVxlanTunnelRequest((byte) 1 /* is add */, srcAddress.getAddress(), - dstAddress.getAddress(), encapVrfId, -1, vni, isIpv6)); + dstAddress.getAddress(), encapVrfId, decapNext, vni, isIpv6)); final VxlanAddDelTunnelReply reply = getReplyForCreate(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id, vxlan); @@ -145,24 +158,31 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl private String getAddressString(final IpAddress addr) { return addr.getIpv4Address() == null ? addr.getIpv6Address().getValue() - : addr.getIpv4Address().getValue(); + : addr.getIpv4Address().getValue(); } private void deleteVxlanTunnel(final InstanceIdentifier<Vxlan> id, final String swIfName, final Vxlan vxlan, - final WriteContext writeContext) throws WriteFailedException { + final WriteContext writeContext) throws WriteFailedException { final byte isIpv6 = (byte) (isIpv6(vxlan) ? 1 - : 0); + : 0); final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc())); final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst())); int encapVrfId = vxlan.getEncapVrfId().intValue(); int vni = vxlan.getVni().getValue().intValue(); + int decapNext = -1; + if (vxlan.getDecapNext() == L2Input.class) { + decapNext = 1; + } else if (vxlan.getDecapNext() == NshProxy.class) { + decapNext = 2; + } + LOG.debug("Deleting vxlan tunnel for interface: {}. Vxlan: {}", swIfName, vxlan); final CompletionStage<VxlanAddDelTunnelReply> vxlanAddDelTunnelReplyCompletionStage = getFutureJVpp().vxlanAddDelTunnel(getVxlanTunnelRequest((byte) 0 /* is add */, srcAddress.getAddress(), - dstAddress.getAddress(), encapVrfId, -1, vni, isIpv6)); + dstAddress.getAddress(), encapVrfId, decapNext, vni, isIpv6)); getReplyForDelete(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Vxlan tunnel deleted successfully for: {}, vxlan: {}", swIfName, vxlan); @@ -177,8 +197,8 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl } private static VxlanAddDelTunnel getVxlanTunnelRequest(final byte isAdd, final byte[] srcAddr, final byte[] dstAddr, - final int encapVrfId, - final int decapNextIndex, final int vni, final byte isIpv6) { + final int encapVrfId, + final int decapNextIndex, final int vni, final byte isIpv6) { final VxlanAddDelTunnel vxlanAddDelTunnel = new VxlanAddDelTunnel(); vxlanAddDelTunnel.isAdd = isAdd; vxlanAddDelTunnel.srcAddress = srcAddr; diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizer.java index d3174e643..485897d76 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizer.java @@ -18,28 +18,20 @@ package io.fd.hc2vpp.v3po.interfacesstate; import static com.google.common.base.Preconditions.checkState; -import io.fd.honeycomb.translate.read.ReadContext; -import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.spi.read.Initialized; -import io.fd.honeycomb.translate.spi.read.InitializingReaderCustomizer; -import io.fd.honeycomb.translate.util.RWUtils; -import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; -import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.vpp.jvpp.core.dto.VxlanTunnelDetails; -import io.fd.vpp.jvpp.core.dto.VxlanTunnelDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.VxlanTunnelDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Arrays; import java.util.concurrent.CompletionStage; + import javax.annotation.Nonnull; + import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.L2Input; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.NshProxy; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppInterfaceAugmentation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppInterfaceStateAugmentationBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VxlanTunnel; @@ -52,8 +44,21 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.spi.read.Initialized; +import io.fd.honeycomb.translate.spi.read.InitializingReaderCustomizer; +import io.fd.honeycomb.translate.util.RWUtils; +import io.fd.vpp.jvpp.core.dto.VxlanTunnelDetails; +import io.fd.vpp.jvpp.core.dto.VxlanTunnelDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.VxlanTunnelDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; + public class VxlanCustomizer extends FutureJVppCustomizer - implements InitializingReaderCustomizer<Vxlan, VxlanBuilder>, InterfaceDataTranslator, JvppReplyConsumer { +implements InitializingReaderCustomizer<Vxlan, VxlanBuilder>, InterfaceDataTranslator, JvppReplyConsumer { private static final Logger LOG = LoggerFactory.getLogger(VxlanCustomizer.class); private final NamingContext interfaceContext; @@ -65,7 +70,7 @@ public class VxlanCustomizer extends FutureJVppCustomizer @Override public void merge(@Nonnull Builder<? extends DataObject> parentBuilder, - @Nonnull Vxlan readValue) { + @Nonnull Vxlan readValue) { ((VppInterfaceStateAugmentationBuilder) parentBuilder).setVxlan(readValue); } @@ -77,8 +82,8 @@ public class VxlanCustomizer extends FutureJVppCustomizer @Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Vxlan> id, - @Nonnull final VxlanBuilder builder, - @Nonnull final ReadContext ctx) throws ReadFailedException { + @Nonnull final VxlanBuilder builder, + @Nonnull final ReadContext ctx) throws ReadFailedException { final InterfaceKey key = id.firstKeyOf(Interface.class); final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext()); @@ -129,6 +134,17 @@ public class VxlanCustomizer extends FutureJVppCustomizer } builder.setEncapVrfId((long) swInterfaceVxlanDetails.encapVrfId); builder.setVni(new VxlanVni((long) swInterfaceVxlanDetails.vni)); + switch (swInterfaceVxlanDetails.decapNextIndex) { + case 1: + builder.setDecapNext(L2Input.class); + break; + case 2: + builder.setDecapNext(NshProxy.class); + break; + default: + LOG.trace("Unsupported decap next index for vxlan: {}", swInterfaceVxlanDetails.decapNextIndex); + return; + } LOG.debug("Vxlan tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder); } @@ -146,11 +162,12 @@ public class VxlanCustomizer extends FutureJVppCustomizer @Nonnull final InstanceIdentifier<Vxlan> id, @Nonnull final Vxlan readValue, @Nonnull final ReadContext ctx) { return Initialized.create(getCfgId(id), new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.VxlanBuilder() - .setDst(readValue.getDst()) - .setSrc(readValue.getSrc()) - .setEncapVrfId(readValue.getEncapVrfId()) - .setVni(new VxlanVni(readValue.getVni())) - .build()); + .setDst(readValue.getDst()) + .setSrc(readValue.getSrc()) + .setEncapVrfId(readValue.getEncapVrfId()) + .setVni(new VxlanVni(readValue.getVni())) + .setDecapNext(readValue.getDecapNext()) + .build()); } private InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.Vxlan> getCfgId( diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizerTest.java index e39c523d3..2ab72b159 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizerTest.java @@ -20,22 +20,13 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.common.net.InetAddresses; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.v3po.DisabledInterfacesManager; -import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.VppInvocationException; -import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnel; -import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnelReply; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; @@ -44,12 +35,24 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.L2Input; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppInterfaceAugmentation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VxlanVni; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.Vxlan; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.VxlanBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import com.google.common.net.InetAddresses; + +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.DisabledInterfacesManager; +import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.VppInvocationException; +import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnel; +import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnelReply; + public class VxlanCustomizerTest extends WriterCustomizerTest { private static final byte ADD_VXLAN = 1; @@ -68,6 +71,7 @@ public class VxlanCustomizerTest extends WriterCustomizerTest { builder.setDst(new IpAddress(new Ipv4Address("192.168.20.11"))); builder.setEncapVrfId(Long.valueOf(123)); builder.setVni(new VxlanVni(Long.valueOf(vni))); + builder.setDecapNext(L2Input.class); return builder.build(); } @@ -78,14 +82,14 @@ public class VxlanCustomizerTest extends WriterCustomizerTest { @Override public void setUpTest() throws Exception { InterfaceTypeTestUtils.setupWriteContext(writeContext, - org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VxlanTunnel.class); + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VxlanTunnel.class); customizer = - new VxlanCustomizer(api, new NamingContext("generateInterfaceNAme", "test-instance"), disableContext); + new VxlanCustomizer(api, new NamingContext("generateInterfaceNAme", "test-instance"), disableContext); ifaceName = "eth0"; id = InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(ifaceName)) - .augmentation(VppInterfaceAugmentation.class).child(Vxlan.class); + .augmentation(VppInterfaceAugmentation.class).child(Vxlan.class); } private void whenVxlanAddDelTunnelThenSuccess() { @@ -101,11 +105,11 @@ public class VxlanCustomizerTest extends WriterCustomizerTest { verify(api).vxlanAddDelTunnel(argumentCaptor.capture()); final VxlanAddDelTunnel actual = argumentCaptor.getValue(); assertEquals(0, actual.isIpv6); - assertEquals(-1, actual.decapNextIndex); + assertEquals(1, actual.decapNextIndex); assertArrayEquals(InetAddresses.forString(vxlan.getSrc().getIpv4Address().getValue()).getAddress(), - actual.srcAddress); + actual.srcAddress); assertArrayEquals(InetAddresses.forString(vxlan.getDst().getIpv4Address().getValue()).getAddress(), - actual.dstAddress); + actual.dstAddress); assertEquals(vxlan.getEncapVrfId().intValue(), actual.encapVrfId); assertEquals(vxlan.getVni().getValue().intValue(), actual.vni); return actual; @@ -161,7 +165,7 @@ public class VxlanCustomizerTest extends WriterCustomizerTest { // Remove the first mapping before putting in the new one verify(mappingContext).delete(eq(mappingIid(ifaceName, "test-instance"))); verify(mappingContext) - .put(eq(mappingIid(ifaceName, "test-instance")), eq(mapping(ifaceName, ifaceId).get())); + .put(eq(mappingIid(ifaceName, "test-instance")), eq(mapping(ifaceName, ifaceId).get())); } @Test @@ -177,7 +181,7 @@ public class VxlanCustomizerTest extends WriterCustomizerTest { verifyVxlanAddWasInvoked(vxlan); // Mapping not stored due to failure verify(mappingContext, times(0)) - .put(eq(mappingIid(ifaceName, "test-instance")), eq(mapping(ifaceName, 0).get())); + .put(eq(mappingIid(ifaceName, "test-instance")), eq(mapping(ifaceName, 0).get())); return; } fail("WriteFailedException.CreateFailedException was expected"); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java index d59d13672..41b0c4927 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java @@ -19,28 +19,32 @@ package io.fd.hc2vpp.v3po.interfacesstate; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; -import com.google.common.collect.Lists; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; + import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.L2Input; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppInterfaceStateAugmentation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppInterfaceStateAugmentationBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces.state._interface.Vxlan; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces.state._interface.VxlanBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +import com.google.common.collect.Lists; + +import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.vpp.jvpp.VppInvocationException; import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails; import io.fd.vpp.jvpp.core.dto.VxlanTunnelDetails; @@ -55,7 +59,7 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde private NamingContext interfacesContext; static final InstanceIdentifier<Vxlan> IID = - InstanceIdentifier.create(InterfacesState.class).child(Interface.class, new InterfaceKey(IF_NAME)) + InstanceIdentifier.create(InterfacesState.class).child(Interface.class, new InterfaceKey(IF_NAME)) .augmentation(VppInterfaceStateAugmentation.class).child(Vxlan.class); public VxlanCustomizerTest() { @@ -76,12 +80,12 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde final VxlanTunnelDetailsReplyDump value = new VxlanTunnelDetailsReplyDump(); final VxlanTunnelDetails vxlanTunnelDetails = new VxlanTunnelDetails(); vxlanTunnelDetails.isIpv6 = 0; - vxlanTunnelDetails.decapNextIndex = 1; vxlanTunnelDetails.dstAddress = InetAddress.getByName("1.2.3.4").getAddress(); vxlanTunnelDetails.srcAddress = InetAddress.getByName("1.2.3.5").getAddress(); vxlanTunnelDetails.encapVrfId = 55; vxlanTunnelDetails.swIfIndex = 0; vxlanTunnelDetails.vni = 9; + vxlanTunnelDetails.decapNextIndex = 1; value.vxlanTunnelDetails = Lists.newArrayList(vxlanTunnelDetails); doReturn(future(value)).when(api).vxlanTunnelDump(any(VxlanTunnelDump.class)); } @@ -93,6 +97,7 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde assertEquals(9, builder.getVni().getValue().intValue()); assertEquals(55, builder.getEncapVrfId().intValue()); + assertEquals(L2Input.class, builder.getDecapNext()); assertNull(builder.getSrc().getIpv6Address()); assertNotNull(builder.getSrc().getIpv4Address()); |