summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-04-29 09:14:32 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-04-29 09:54:40 +0200
commit439f0735bc1292df57a5a9938486326d5a01f18c (patch)
tree6ddf65994c9add0cbfc525c9afe06cec63f0a76a /v3po/v3po2vpp
parentc97a65be83eb391395d30396523ffe14163486f7 (diff)
Fix compilation problems caused by vxlan_add_del_tunnel definition change in vpe.api
Change-Id: I6599598cb9755f263a603df484710e210867e068 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java15
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/utils/V3poUtils.java23
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/utils/V3poUtilsTest.java35
3 files changed, 67 insertions, 6 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java
index dbf8cb0c7..6e84c303a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java
@@ -24,7 +24,7 @@ import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.v3po.utils.V3poUtils;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import javax.annotation.Nonnull;
-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.Ipv4AddressNoZone;
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.rev150105.VppInterfaceAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel;
@@ -84,16 +84,19 @@ public class VxlanCustomizer extends VppApiCustomizer implements ChildWriterCust
}
private void createVxlanTunnel(final String swIfName, final Vxlan vxlan) throws VppApiInvocationException {
- Ipv4Address srcAddress = vxlan.getSrc();
- Ipv4Address dstAddress = vxlan.getDst();
+ Ipv4AddressNoZone srcAddress = V3poUtils.removeIpv4AddressNoZone(vxlan.getSrc());
+ Ipv4AddressNoZone dstAddress = V3poUtils.removeIpv4AddressNoZone(vxlan.getDst());
- int srcAddr = V3poUtils.parseIp(srcAddress.getValue());
- int dstAddr = V3poUtils.parseIp(dstAddress.getValue());
+ byte[] srcAddr = V3poUtils.ipv4AddressNoZoneToArray(srcAddress);
+ byte[] dstAddr = V3poUtils.ipv4AddressNoZoneToArray(dstAddress);
int encapVrfId = vxlan.getEncapVrfId().intValue();
int vni = vxlan.getVni().getValue().intValue();
LOG.debug("Setting vxlan tunnel for interface: {}. Vxlan: {}", swIfName, vxlan);
- int ctxId = getVppApi().vxlanAddDelTunnel((byte) 1 /* is add */, srcAddr, dstAddr, encapVrfId, -1, vni);
+ int ctxId = 0; getVppApi().vxlanAddDelTunnel(
+ (byte) 1 /* is add */,
+ (byte) 0 /* is ipv6 */,
+ srcAddr, dstAddr, encapVrfId, -1, vni);
final int rv = V3poUtils.waitForResponse(ctxId, getVppApi());
if (rv < 0) {
LOG.debug("Failed to set vxlan tunnel for interface: {}, vxlan: {}", swIfName, vxlan);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/utils/V3poUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/utils/V3poUtils.java
index 18a8103cc..88626453e 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/utils/V3poUtils.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/utils/V3poUtils.java
@@ -16,11 +16,14 @@
package io.fd.honeycomb.v3po.translate.v3po.utils;
+import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.SoftwareLoopback;
+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.Ipv4AddressNoZone;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel;
@@ -75,4 +78,24 @@ public final class V3poUtils {
}
return retval;
}
+
+ /**
+ * Removes zone index from Ipv4Address.
+ * @param ipv4Addr ipv4 address which can contain zone index
+ * @return ipv4 address without zone index
+ */
+ @Nonnull
+ public static Ipv4AddressNoZone removeIpv4AddressNoZone(@Nonnull final Ipv4Address ipv4Addr) {
+ Preconditions.checkNotNull(ipv4Addr, "ipv4Addr should not be null");
+ if (ipv4Addr instanceof Ipv4AddressNoZone) {
+ return (Ipv4AddressNoZone)ipv4Addr;
+ } else {
+ String value = ipv4Addr.getValue();
+ final int index = value.indexOf('%');
+ if (index != -1) {
+ value = value.substring(0, index);
+ }
+ return new Ipv4AddressNoZone(value);
+ }
+ }
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/utils/V3poUtilsTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/utils/V3poUtilsTest.java
new file mode 100644
index 000000000..3cb054ad4
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/utils/V3poUtilsTest.java
@@ -0,0 +1,35 @@
+package io.fd.honeycomb.v3po.translate.v3po.utils;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+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.Ipv4AddressNoZone;
+
+public class V3poUtilsTest {
+
+ @Test
+ public void testRemoveIpv4AddressNoZoneFromIpv4WithZone() throws Exception {
+ String ipWithZone = "1.2.3.4%20";
+ String ipNoZone = "1.2.3.4";
+ final Ipv4Address expectedIp = new Ipv4Address(ipNoZone);
+ final Ipv4AddressNoZone actualIp = V3poUtils.removeIpv4AddressNoZone(new Ipv4Address(ipWithZone));
+ assertEquals(expectedIp.getValue(), actualIp.getValue());
+ }
+
+ @Test
+ public void testRemoveIpv4AddressNoZoneFromIpv4WithoutZone() throws Exception {
+ String ipNoZone = "1.2.3.4";
+ final Ipv4Address expectedIp = new Ipv4Address(ipNoZone);
+ final Ipv4AddressNoZone actualIp = V3poUtils.removeIpv4AddressNoZone(expectedIp);
+ assertEquals(expectedIp.getValue(), actualIp.getValue());
+ }
+
+ @Test
+ public void testRemoveIpv4AddressNoZoneNop() throws Exception {
+ String ipNoZone = "1.2.3.4";
+ final Ipv4Address expectedIp = new Ipv4AddressNoZone(ipNoZone);
+ final Ipv4AddressNoZone actualIp = V3poUtils.removeIpv4AddressNoZone(expectedIp);
+ assertEquals(expectedIp, actualIp);
+ }
+} \ No newline at end of file