HC2VPP-79: use AddressTranslator for ip-address-no-zone translation 34/13334/2
authorMarek Gradzki <[email protected]>
Tue, 3 Jul 2018 12:09:36 +0000 (14:09 +0200)
committerMarek Gradzki <[email protected]>
Wed, 4 Jul 2018 10:57:22 +0000 (10:57 +0000)
Change-Id: I46955630709e3d837f95f488cb2fe089952865c4
Signed-off-by: Marek Gradzki <[email protected]>
l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/ProxyRangeCustomizer.java
v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizer.java
v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizer.java
v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeCustomizer.java
v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizerTest.java
v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizerTest.java
v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeCustomizerTest.java
v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java
v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java
v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanGpeCustomizerTest.java

index 8c55df0..111e322 100644 (file)
@@ -16,8 +16,8 @@
 
 package io.fd.hc2vpp.l3.write.ipv4;
 
-import com.google.common.net.InetAddresses;
 import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
 import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
 import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
 import io.fd.honeycomb.translate.write.WriteContext;
@@ -26,9 +26,9 @@ import io.fd.vpp.jvpp.core.dto.ProxyArpAddDel;
 import io.fd.vpp.jvpp.core.dto.ProxyArpAddDelReply;
 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
 import io.fd.vpp.jvpp.core.types.ProxyArp;
-import java.net.InetAddress;
 import java.util.concurrent.Future;
 import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.proxy.arp.rev180703.proxy.ranges.ProxyRange;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.proxy.arp.rev180703.proxy.ranges.ProxyRangeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -62,11 +62,9 @@ public class ProxyRangeCustomizer extends FutureJVppCustomizer
 
     private Future<ProxyArpAddDelReply> getProxyArpRequestFuture(ProxyRange proxyArp, byte operation)
         throws WriteFailedException {
-        final InetAddress srcAddress = InetAddresses.forString(proxyArp.getLowAddr().getValue());
-        final InetAddress dstAddress = InetAddresses.forString(proxyArp.getHighAddr().getValue());
         final int vrfId = proxyArp.getVrfId().getValue().intValue();
         return getFutureJVpp().proxyArpAddDel(
-            getProxyArpConfRequest(operation, srcAddress.getAddress(), dstAddress.getAddress(), vrfId))
+            getProxyArpConfRequest(operation, proxyArp.getLowAddr(), proxyArp.getHighAddr(), vrfId))
             .toCompletableFuture();
     }
 
@@ -85,13 +83,13 @@ public class ProxyRangeCustomizer extends FutureJVppCustomizer
         LOG.debug("Proxy ARP setting delete successful, with reply context:", reply.context);
     }
 
-    private static ProxyArpAddDel getProxyArpConfRequest(final byte isAdd, final byte[] lAddr, final byte[] hAddr,
-                                                         final int vrfId) {
+    private static ProxyArpAddDel getProxyArpConfRequest(final byte isAdd, final Ipv4AddressNoZone lAddr,
+                                                         final Ipv4AddressNoZone hAddr, final int vrfId) {
         final ProxyArpAddDel proxyArpAddDel = new ProxyArpAddDel();
         proxyArpAddDel.isAdd = isAdd;
         proxyArpAddDel.proxy = new ProxyArp();
-        proxyArpAddDel.proxy.lowAddress = lAddr;
-        proxyArpAddDel.proxy.hiAddress = hAddr;
+        proxyArpAddDel.proxy.lowAddress = Ipv4Translator.INSTANCE.ipv4AddressNoZoneToArray(lAddr);
+        proxyArpAddDel.proxy.hiAddress = Ipv4Translator.INSTANCE.ipv4AddressNoZoneToArray(hAddr);
         proxyArpAddDel.proxy.vrfId = vrfId;
         return proxyArpAddDel;
     }
index 2f6d4a5..4e99c93 100644 (file)
@@ -18,8 +18,8 @@ package io.fd.hc2vpp.v3po.interfaces;
 
 import static com.google.common.base.Preconditions.checkArgument;
 
-import com.google.common.net.InetAddresses;
 import io.fd.hc2vpp.common.translate.util.AbstractInterfaceTypeCustomizer;
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
 import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
 import io.fd.honeycomb.translate.write.WriteContext;
@@ -27,7 +27,6 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
 import io.fd.vpp.jvpp.core.dto.GreAddDelTunnel;
 import io.fd.vpp.jvpp.core.dto.GreAddDelTunnelReply;
 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.IpAddressNoZone;
@@ -49,12 +48,13 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
         this.interfaceContext = interfaceContext;
     }
 
-    private static GreAddDelTunnel getGreTunnelRequest(final byte isAdd, final byte[] srcAddr, final byte[] dstAddr,
-                                                       final int outerFibId, final byte isIpv6) {
+    private static GreAddDelTunnel getGreTunnelRequest(final byte isAdd, final IpAddressNoZone srcAddr,
+                                                       final IpAddressNoZone dstAddr, final int outerFibId,
+                                                       final byte isIpv6) {
         final GreAddDelTunnel greAddDelTunnel = new GreAddDelTunnel();
         greAddDelTunnel.isAdd = isAdd;
-        greAddDelTunnel.srcAddress = srcAddr;
-        greAddDelTunnel.dstAddress = dstAddr;
+        greAddDelTunnel.srcAddress = AddressTranslator.INSTANCE.ipAddressToArray(srcAddr);
+        greAddDelTunnel.dstAddress = AddressTranslator.INSTANCE.ipAddressToArray(dstAddr);
         greAddDelTunnel.outerFibId = outerFibId;
         greAddDelTunnel.isIpv6 = isIpv6;
         return greAddDelTunnel;
@@ -87,15 +87,12 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
         final byte isIpv6 = (byte) (isIpv6(gre)
                 ? 1
                 : 0);
-        final InetAddress srcAddress = InetAddresses.forString(getAddressString(gre.getSrc()));
-        final InetAddress dstAddress = InetAddresses.forString(getAddressString(gre.getDst()));
-
         int outerFibId = gre.getOuterFibId().intValue();
 
         LOG.debug("Setting gre tunnel for interface: {}. Gre: {}", swIfName, gre);
         final CompletionStage<GreAddDelTunnelReply> greAddDelTunnelReplyCompletionStage =
-                getFutureJVpp().greAddDelTunnel(getGreTunnelRequest((byte) 1 /* is add */, srcAddress.getAddress(),
-                        dstAddress.getAddress(), outerFibId, isIpv6));
+            getFutureJVpp().greAddDelTunnel(getGreTunnelRequest((byte) 1 /* is add */, gre.getSrc(),
+                gre.getDst(), outerFibId, isIpv6));
 
         final GreAddDelTunnelReply reply =
                 getReplyForCreate(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id, gre);
@@ -129,26 +126,18 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
         }
     }
 
-    private String getAddressString(final IpAddressNoZone addr) {
-        return addr.getIpv4AddressNoZone() == null
-                ? addr.getIpv6AddressNoZone().getValue()
-                : addr.getIpv4AddressNoZone().getValue();
-    }
-
     private void deleteGreTunnel(final InstanceIdentifier<Gre> id, final String swIfName, final Gre gre,
                                  final WriteContext writeContext) throws WriteFailedException {
         final byte isIpv6 = (byte) (isIpv6(gre)
                 ? 1
                 : 0);
-        final InetAddress srcAddress = InetAddresses.forString(getAddressString(gre.getSrc()));
-        final InetAddress dstAddress = InetAddresses.forString(getAddressString(gre.getDst()));
 
         int outerFibId = gre.getOuterFibId().intValue();
 
         LOG.debug("Deleting gre tunnel for interface: {}. Gre: {}", swIfName, gre);
         final CompletionStage<GreAddDelTunnelReply> greAddDelTunnelReplyCompletionStage =
-                getFutureJVpp().greAddDelTunnel(getGreTunnelRequest((byte) 0 /* is add */, srcAddress.getAddress(),
-                        dstAddress.getAddress(), outerFibId, isIpv6));
+            getFutureJVpp().greAddDelTunnel(getGreTunnelRequest((byte) 0 /* is add */, gre.getSrc(),
+                gre.getDst(), outerFibId, isIpv6));
 
         getReplyForDelete(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
         LOG.debug("Gre tunnel deleted successfully for: {}, gre: {}", swIfName, gre);
index b0387d1..5d5b086 100644 (file)
@@ -18,8 +18,8 @@ package io.fd.hc2vpp.v3po.interfaces;
 
 import static com.google.common.base.Preconditions.checkArgument;
 
-import com.google.common.net.InetAddresses;
 import io.fd.hc2vpp.common.translate.util.AbstractInterfaceTypeCustomizer;
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
 import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
 import io.fd.hc2vpp.v3po.DisabledInterfacesManager;
@@ -28,7 +28,6 @@ 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.IpAddressNoZone;
@@ -82,10 +81,8 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl
             final WriteContext writeContext)
                     throws WriteFailedException {
         final byte isIpv6 = (byte) (isIpv6(vxlan)
-                ? 1
-                        : 0);
-        final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc()));
-        final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst()));
+            ? 1
+            : 0);
 
         checkArgument(vxlan.getEncapVrfId() != null && vxlan.getEncapVrfId().getValue() != null,
             "encap-vrf-id is mandatory but was not given");
@@ -101,8 +98,8 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl
 
         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, decapNext, vni, isIpv6));
+            getFutureJVpp().vxlanAddDelTunnel(getVxlanTunnelRequest((byte) 1 /* is add */, vxlan.getSrc(),
+                vxlan.getDst(), encapVrfId, decapNext, vni, isIpv6));
 
         final VxlanAddDelTunnelReply reply =
                 getReplyForCreate(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id, vxlan);
@@ -145,19 +142,11 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl
         }
     }
 
-    private String getAddressString(final IpAddressNoZone addr) {
-        return addr.getIpv4AddressNoZone() == null
-                ? addr.getIpv6AddressNoZone().getValue()
-                        : addr.getIpv4AddressNoZone().getValue();
-    }
-
     private void deleteVxlanTunnel(final InstanceIdentifier<Vxlan> id, final String swIfName, final Vxlan vxlan,
             final WriteContext writeContext) throws WriteFailedException {
         final byte isIpv6 = (byte) (isIpv6(vxlan)
-                ? 1
-                        : 0);
-        final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc()));
-        final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst()));
+            ? 1
+            : 0);
 
         checkArgument(vxlan.getEncapVrfId() != null && vxlan.getEncapVrfId().getValue() != null,
             "encap-vrf-id is mandatory but was not given");
@@ -173,8 +162,8 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl
 
         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, decapNext, vni, isIpv6));
+            getFutureJVpp().vxlanAddDelTunnel(getVxlanTunnelRequest((byte) 0 /* is add */, vxlan.getSrc(),
+                vxlan.getDst(), encapVrfId, decapNext, vni, isIpv6));
 
         getReplyForDelete(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
         LOG.debug("Vxlan tunnel deleted successfully for: {}, vxlan: {}", swIfName, vxlan);
@@ -188,13 +177,14 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl
         interfaceNamingContext.removeName(swIfName, writeContext.getMappingContext());
     }
 
-    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) {
+    private static VxlanAddDelTunnel getVxlanTunnelRequest(final byte isAdd, final IpAddressNoZone srcAddr,
+                                                           final IpAddressNoZone dstAddr,
+                                                           final int encapVrfId,
+                                                           final int decapNextIndex, final int vni, final byte isIpv6) {
         final VxlanAddDelTunnel vxlanAddDelTunnel = new VxlanAddDelTunnel();
         vxlanAddDelTunnel.isAdd = isAdd;
-        vxlanAddDelTunnel.srcAddress = srcAddr;
-        vxlanAddDelTunnel.dstAddress = dstAddr;
+        vxlanAddDelTunnel.srcAddress = AddressTranslator.INSTANCE.ipAddressToArray(srcAddr);
+        vxlanAddDelTunnel.dstAddress = AddressTranslator.INSTANCE.ipAddressToArray(dstAddr);
         vxlanAddDelTunnel.encapVrfId = encapVrfId;
         vxlanAddDelTunnel.vni = vni;
         vxlanAddDelTunnel.decapNextIndex = decapNextIndex;
index ac21c4d..c875b87 100644 (file)
@@ -18,8 +18,8 @@ package io.fd.hc2vpp.v3po.interfaces;
 
 import static com.google.common.base.Preconditions.checkArgument;
 
-import com.google.common.net.InetAddresses;
 import io.fd.hc2vpp.common.translate.util.AbstractInterfaceTypeCustomizer;
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
 import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
 import io.fd.hc2vpp.v3po.DisabledInterfacesManager;
@@ -28,7 +28,6 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
 import io.fd.vpp.jvpp.core.dto.VxlanGpeAddDelTunnel;
 import io.fd.vpp.jvpp.core.dto.VxlanGpeAddDelTunnelReply;
 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.IpAddressNoZone;
@@ -83,8 +82,6 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
         final byte isIpv6 = (byte) (isIpv6(vxlanGpe)
                 ? 1
                 : 0);
-        final InetAddress Local = InetAddresses.forString(getAddressString(vxlanGpe.getLocal()));
-        final InetAddress Remote = InetAddresses.forString(getAddressString(vxlanGpe.getRemote()));
 
         int vni = vxlanGpe.getVni().getValue().intValue();
         byte protocol = (byte) vxlanGpe.getNextProtocol().getIntValue();
@@ -93,8 +90,8 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
 
         LOG.debug("Setting VxlanGpe tunnel for interface: {}. VxlanGpe: {}", swIfName, vxlanGpe);
         final CompletionStage<VxlanGpeAddDelTunnelReply> VxlanGpeAddDelTunnelReplyCompletionStage =
-                getFutureJVpp().vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 1 /* is add */, Local.getAddress(),
-                        Remote.getAddress(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
+            getFutureJVpp().vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 1 /* is add */, vxlanGpe.getLocal(),
+                vxlanGpe.getRemote(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
 
         final VxlanGpeAddDelTunnelReply reply =
                 getReplyForCreate(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id, vxlanGpe);
@@ -131,20 +128,12 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
         }
     }
 
-    private String getAddressString(final IpAddressNoZone addr) {
-        return addr.getIpv4AddressNoZone() == null
-                ? addr.getIpv6AddressNoZone().getValue()
-                : addr.getIpv4AddressNoZone().getValue();
-    }
-
     private void deleteVxlanGpeTunnel(final InstanceIdentifier<VxlanGpe> id, final String swIfName,
                                       final VxlanGpe vxlanGpe, final WriteContext writeContext)
             throws WriteFailedException {
         final byte isIpv6 = (byte) (isIpv6(vxlanGpe)
                 ? 1
                 : 0);
-        final InetAddress local = InetAddresses.forString(getAddressString(vxlanGpe.getLocal()));
-        final InetAddress remote = InetAddresses.forString(getAddressString(vxlanGpe.getRemote()));
 
         int vni = vxlanGpe.getVni().getValue().intValue();
         byte protocol = (byte) vxlanGpe.getNextProtocol().getIntValue();
@@ -154,8 +143,8 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
         LOG.debug("Deleting VxlanGpe tunnel for interface: {}. VxlanGpe: {}", swIfName, vxlanGpe);
         final CompletionStage<VxlanGpeAddDelTunnelReply> VxlanGpeAddDelTunnelReplyCompletionStage =
                 getFutureJVpp()
-                        .vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 0 /* is delete */, local.getAddress(),
-                                remote.getAddress(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
+                    .vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 0 /* is delete */, vxlanGpe.getLocal(),
+                        vxlanGpe.getRemote(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
         getReplyForDelete(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
         final int index = interfaceNamingContext.getIndex(swIfName, writeContext.getMappingContext());
         // Mark this interface as disabled to not include it in operational reads
@@ -166,15 +155,15 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
         interfaceNamingContext.removeName(swIfName, writeContext.getMappingContext());
     }
 
-    private static VxlanGpeAddDelTunnel getVxlanGpeTunnelRequest(final byte isAdd, final byte[] local,
-                                                                 final byte[] remote,
+    private static VxlanGpeAddDelTunnel getVxlanGpeTunnelRequest(final byte isAdd, final IpAddressNoZone local,
+                                                                 final IpAddressNoZone remote,
                                                                  final int vni, final byte protocol,
                                                                  final int encapVrfId, final int decapVrfId,
                                                                  final byte isIpv6) {
         final VxlanGpeAddDelTunnel VxlanGpeAddDelTunnel = new VxlanGpeAddDelTunnel();
         VxlanGpeAddDelTunnel.isAdd = isAdd;
-        VxlanGpeAddDelTunnel.local = local;
-        VxlanGpeAddDelTunnel.remote = remote;
+        VxlanGpeAddDelTunnel.local = AddressTranslator.INSTANCE.ipAddressToArray(local);
+        VxlanGpeAddDelTunnel.remote = AddressTranslator.INSTANCE.ipAddressToArray(remote);
         VxlanGpeAddDelTunnel.vni = vni;
         VxlanGpeAddDelTunnel.protocol = protocol;
         VxlanGpeAddDelTunnel.encapVrfId = encapVrfId;
index 68f266d..087110e 100644 (file)
@@ -26,8 +26,8 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
-import com.google.common.net.InetAddresses;
 import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
 import io.fd.honeycomb.translate.write.WriteFailedException;
 import io.fd.vpp.jvpp.VppBaseCallException;
@@ -46,7 +46,7 @@ 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.rev180703.interfaces._interface.GreBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-public class GreCustomizerTest extends WriterCustomizerTest {
+public class GreCustomizerTest extends WriterCustomizerTest implements AddressTranslator {
 
     private static final String IFC_TEST_INSTANCE = "ifc-test-instance";
     private static final byte ADD_GRE = 1;
@@ -87,10 +87,8 @@ public class GreCustomizerTest extends WriterCustomizerTest {
         verify(api).greAddDelTunnel(argumentCaptor.capture());
         final GreAddDelTunnel actual = argumentCaptor.getValue();
         assertEquals(0, actual.isIpv6);
-        assertArrayEquals(InetAddresses.forString(gre.getSrc().getIpv4AddressNoZone().getValue()).getAddress(),
-                actual.srcAddress);
-        assertArrayEquals(InetAddresses.forString(gre.getDst().getIpv4AddressNoZone().getValue()).getAddress(),
-                actual.dstAddress);
+        assertArrayEquals(ipAddressToArray(gre.getSrc()), actual.srcAddress);
+        assertArrayEquals(ipAddressToArray(gre.getDst()), actual.dstAddress);
         assertEquals(gre.getOuterFibId().intValue(), actual.outerFibId);
         return actual;
     }
index 5e758c4..9a1994b 100644 (file)
@@ -27,8 +27,8 @@ 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.AddressTranslator;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
 import io.fd.hc2vpp.v3po.DisabledInterfacesManager;
 import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -52,7 +52,7 @@ 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.vpp.fib.table.management.rev180521.VniReference;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-public class VxlanCustomizerTest extends WriterCustomizerTest {
+public class VxlanCustomizerTest extends WriterCustomizerTest implements AddressTranslator {
 
     private static final byte ADD_VXLAN = 1;
     private static final byte DEL_VXLAN = 0;
@@ -105,10 +105,9 @@ public class VxlanCustomizerTest extends WriterCustomizerTest {
         final VxlanAddDelTunnel actual = argumentCaptor.getValue();
         assertEquals(0, actual.isIpv6);
         assertEquals(1, actual.decapNextIndex);
-        assertArrayEquals(InetAddresses.forString(vxlan.getSrc().getIpv4AddressNoZone().getValue()).getAddress(),
-                actual.srcAddress);
-        assertArrayEquals(InetAddresses.forString(vxlan.getDst().getIpv4AddressNoZone().getValue()).getAddress(),
-                actual.dstAddress);
+
+        assertArrayEquals(ipAddressToArray(vxlan.getSrc()), actual.srcAddress);
+        assertArrayEquals(ipAddressToArray(vxlan.getDst()), actual.dstAddress);
         assertEquals(vxlan.getEncapVrfId().getValue().intValue(), actual.encapVrfId);
         assertEquals(vxlan.getVni().getValue().intValue(), actual.vni);
         return actual;
index 7d282c0..946f837 100644 (file)
@@ -27,8 +27,8 @@ 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.AddressTranslator;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
 import io.fd.hc2vpp.v3po.DisabledInterfacesManager;
 import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -50,7 +50,7 @@ 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.rev180703.interfaces._interface.VxlanGpeBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-public class VxlanGpeCustomizerTest extends WriterCustomizerTest {
+public class VxlanGpeCustomizerTest extends WriterCustomizerTest implements AddressTranslator {
 
     private static final byte ADD_VXLAN_GPE = 1;
     private static final byte DEL_VXLAN_GPE = 0;
@@ -104,10 +104,8 @@ public class VxlanGpeCustomizerTest extends WriterCustomizerTest {
         verify(api).vxlanGpeAddDelTunnel(argumentCaptor.capture());
         final VxlanGpeAddDelTunnel actual = argumentCaptor.getValue();
         assertEquals(0, actual.isIpv6);
-        assertArrayEquals(InetAddresses.forString(vxlanGpe.getLocal().getIpv4AddressNoZone().getValue()).getAddress(),
-            actual.local);
-        assertArrayEquals(InetAddresses.forString(vxlanGpe.getRemote().getIpv4AddressNoZone().getValue()).getAddress(),
-            actual.remote);
+        assertArrayEquals(ipAddressToArray(vxlanGpe.getLocal()), actual.local);
+        assertArrayEquals(ipAddressToArray(vxlanGpe.getRemote()), actual.remote);
         assertEquals(vxlanGpe.getVni().getValue().intValue(), actual.vni);
         assertEquals(vxlanGpe.getNextProtocol().getIntValue(), actual.protocol);
         assertEquals(vxlanGpe.getEncapVrfId().intValue(), actual.encapVrfId);
index 6861262..ab5ca58 100644 (file)
@@ -26,8 +26,8 @@ import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
 
 import com.google.common.collect.Lists;
-import com.google.common.net.InetAddresses;
 import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
 import io.fd.hc2vpp.v3po.interfacesstate.cache.InterfaceCacheDumpManager;
 import io.fd.honeycomb.translate.read.ReadFailedException;
@@ -48,7 +48,7 @@ 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.rev180703.interfaces.state._interface.GreBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-public class GreCustomizerTest extends ReaderCustomizerTest<Gre, GreBuilder> {
+public class GreCustomizerTest extends ReaderCustomizerTest<Gre, GreBuilder> implements AddressTranslator {
 
     private static final String IFACE_NAME = "ifc1";
     private static final int IFACE_ID = 0;
@@ -79,8 +79,8 @@ public class GreCustomizerTest extends ReaderCustomizerTest<Gre, GreBuilder> {
         final GreTunnelDetailsReplyDump value = new GreTunnelDetailsReplyDump();
         final GreTunnelDetails greTunnelDetails = new GreTunnelDetails();
         greTunnelDetails.isIpv6 = 0;
-        greTunnelDetails.dstAddress = InetAddresses.forString("1.2.3.4").getAddress();
-        greTunnelDetails.srcAddress = InetAddresses.forString("1.2.3.5").getAddress();
+        greTunnelDetails.dstAddress = ipv4AddressNoZoneToArray("1.2.3.4");
+        greTunnelDetails.srcAddress = ipv4AddressNoZoneToArray("1.2.3.5");
         greTunnelDetails.outerFibId = 55;
         greTunnelDetails.swIfIndex = 0;
         value.greTunnelDetails = Lists.newArrayList(greTunnelDetails);
index 6ce0913..a98a2cf 100644 (file)
@@ -26,8 +26,8 @@ import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
 
 import com.google.common.collect.Lists;
-import com.google.common.net.InetAddresses;
 import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
 import io.fd.hc2vpp.v3po.interfacesstate.cache.InterfaceCacheDumpManager;
 import io.fd.honeycomb.translate.read.ReadFailedException;
@@ -143,8 +143,8 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde
         final VxlanTunnelDetailsReplyDump replyDump = new VxlanTunnelDetailsReplyDump();
         final VxlanTunnelDetails vxlanTunnelDetails = new VxlanTunnelDetails();
         vxlanTunnelDetails.isIpv6 = 0;
-        vxlanTunnelDetails.dstAddress = InetAddresses.forString("1.2.3.4").getAddress();
-        vxlanTunnelDetails.srcAddress = InetAddresses.forString("1.2.3.5").getAddress();
+        vxlanTunnelDetails.dstAddress = AddressTranslator.INSTANCE.ipv4AddressNoZoneToArray("1.2.3.4");
+        vxlanTunnelDetails.srcAddress = AddressTranslator.INSTANCE.ipv4AddressNoZoneToArray("1.2.3.5");
         vxlanTunnelDetails.encapVrfId = encapVrfId;
         vxlanTunnelDetails.swIfIndex = 0;
         vxlanTunnelDetails.vni = 9;
index 319ef93..c10a7fe 100644 (file)
@@ -27,8 +27,8 @@ import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
 
 import com.google.common.collect.Lists;
-import com.google.common.net.InetAddresses;
 import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
 import io.fd.hc2vpp.common.translate.util.NamingContext;
 import io.fd.hc2vpp.v3po.interfacesstate.cache.InterfaceCacheDumpManager;
 import io.fd.honeycomb.translate.read.ReadFailedException;
@@ -49,7 +49,8 @@ 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.rev180703.interfaces.state._interface.VxlanGpeBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-public class VxlanGpeCustomizerTest extends ReaderCustomizerTest<VxlanGpe, VxlanGpeBuilder> {
+public class VxlanGpeCustomizerTest extends ReaderCustomizerTest<VxlanGpe, VxlanGpeBuilder>
+    implements AddressTranslator {
 
     private static final String IFC_CTX_NAME = "ifc-test-instance";
     private static final String IF_NAME = "ifc2";
@@ -80,8 +81,8 @@ public class VxlanGpeCustomizerTest extends ReaderCustomizerTest<VxlanGpe, Vxlan
         final VxlanGpeTunnelDetailsReplyDump value = new VxlanGpeTunnelDetailsReplyDump();
         final VxlanGpeTunnelDetails vxlanGpeTunnelDetails = new VxlanGpeTunnelDetails();
         vxlanGpeTunnelDetails.isIpv6 = 0;
-        vxlanGpeTunnelDetails.local = InetAddresses.forString("1.2.3.4").getAddress();
-        vxlanGpeTunnelDetails.remote = InetAddresses.forString("1.2.3.5").getAddress();
+        vxlanGpeTunnelDetails.local = ipv4AddressNoZoneToArray("1.2.3.4");
+        vxlanGpeTunnelDetails.remote = ipv4AddressNoZoneToArray("1.2.3.5");
         vxlanGpeTunnelDetails.vni = 9;
         vxlanGpeTunnelDetails.protocol = 1;
         vxlanGpeTunnelDetails.encapVrfId = 55;