summaryrefslogtreecommitdiffstats
path: root/v3po
diff options
context:
space:
mode:
authorMichal Cmarada <mcmarada@cisco.com>2019-04-23 20:55:01 +0200
committerMichal Cmarada <mcmarada@cisco.com>2019-04-23 20:55:01 +0200
commit2415267fa79372807e52d0dc5d800166829dac27 (patch)
tree783bf807b7220d0fdf7019ab36261dd25a9591fc /v3po
parent0c5c324ebcf4d180232b227fba9f55ec36bd0e17 (diff)
Fix GRE tunnel after API changes
Change-Id: I346a2e1793e3fc5758a23ca4f049e8118a81b54b Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
Diffstat (limited to 'v3po')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizer.java40
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizer.java16
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizerTest.java30
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java14
4 files changed, 59 insertions, 41 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizer.java
index e44909752..b1ecc3a9f 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizer.java
@@ -24,8 +24,8 @@ 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.jvpp.core.dto.GreAddDelTunnel;
-import io.fd.jvpp.core.dto.GreAddDelTunnelReply;
+import io.fd.jvpp.core.dto.GreTunnelAddDel;
+import io.fd.jvpp.core.dto.GreTunnelAddDelReply;
import io.fd.jvpp.core.future.FutureJVppCore;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
@@ -48,16 +48,26 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
this.interfaceContext = interfaceContext;
}
- private static GreAddDelTunnel getGreTunnelRequest(final byte isAdd, final IpAddressNoZone srcAddr,
+ private static GreTunnelAddDel 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 = AddressTranslator.INSTANCE.ipAddressToArray(srcAddr);
- greAddDelTunnel.dstAddress = AddressTranslator.INSTANCE.ipAddressToArray(dstAddr);
- greAddDelTunnel.outerFibId = outerFibId;
- greAddDelTunnel.isIpv6 = isIpv6;
- return greAddDelTunnel;
+ final GreTunnelAddDel greTunnelAddDel = new GreTunnelAddDel();
+ greTunnelAddDel.isAdd = isAdd;
+ greTunnelAddDel.tunnel = new io.fd.jvpp.core.types.GreTunnel();
+ if (isIpv6==0) {
+ greTunnelAddDel.tunnel.src =
+ AddressTranslator.INSTANCE.ipv4AddressNoZoneToAddress(srcAddr.getIpv4AddressNoZone());
+ greTunnelAddDel.tunnel.dst =
+ AddressTranslator.INSTANCE.ipv4AddressNoZoneToAddress(dstAddr.getIpv4AddressNoZone());
+ } else {
+ greTunnelAddDel.tunnel.src =
+ AddressTranslator.INSTANCE.ipv6AddressToAddress(srcAddr.getIpv6AddressNoZone());
+ greTunnelAddDel.tunnel.dst =
+ AddressTranslator.INSTANCE.ipv6AddressToAddress(dstAddr.getIpv6AddressNoZone());
+ }
+ greTunnelAddDel.tunnel.outerFibId = outerFibId;
+ greTunnelAddDel.tunnel.isIpv6 = isIpv6;
+ return greTunnelAddDel;
}
@Override
@@ -90,11 +100,11 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
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 */, gre.getSrc(),
+ final CompletionStage<GreTunnelAddDelReply> greAddDelTunnelReplyCompletionStage =
+ getFutureJVpp().greTunnelAddDel(getGreTunnelRequest((byte) 1 /* is add */, gre.getSrc(),
gre.getDst(), outerFibId, isIpv6));
- final GreAddDelTunnelReply reply =
+ final GreTunnelAddDelReply reply =
getReplyForCreate(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id, gre);
LOG.debug("Gre tunnel set successfully for: {}, gre: {}", swIfName, gre);
if (interfaceContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) {
@@ -135,8 +145,8 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
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 */, gre.getSrc(),
+ final CompletionStage<GreTunnelAddDelReply> greAddDelTunnelReplyCompletionStage =
+ getFutureJVpp().greTunnelAddDel(getGreTunnelRequest((byte) 0 /* is add */, gre.getSrc(),
gre.getDst(), outerFibId, isIpv6));
getReplyForDelete(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizer.java
index 874330ff6..19d0a12dd 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizer.java
@@ -112,14 +112,18 @@ public class GreCustomizer extends FutureJVppCustomizer
LOG.trace("Gre tunnel: {} attributes returned from VPP: {}", key.getName(), reply);
final GreTunnelDetails swInterfaceGreDetails = reply.greTunnelDetails.get(0);
- if (swInterfaceGreDetails.isIpv6 == 1) {
- builder.setDst(new IpAddressNoZone(arrayToIpv6AddressNoZone(swInterfaceGreDetails.dstAddress)));
- builder.setSrc(new IpAddressNoZone(arrayToIpv6AddressNoZone(swInterfaceGreDetails.srcAddress)));
+ if (swInterfaceGreDetails.tunnel.isIpv6 == 1) {
+ builder.setDst(new IpAddressNoZone(
+ arrayToIpv4AddressNoZone(swInterfaceGreDetails.tunnel.dst.un.getIp6().ip6Address)));
+ builder.setSrc(new IpAddressNoZone(
+ arrayToIpv6AddressNoZone(swInterfaceGreDetails.tunnel.src.un.getIp6().ip6Address)));
} else {
- builder.setDst(new IpAddressNoZone(arrayToIpv4AddressNoZone(swInterfaceGreDetails.dstAddress)));
- builder.setSrc(new IpAddressNoZone(arrayToIpv4AddressNoZone(swInterfaceGreDetails.srcAddress)));
+ builder.setDst(new IpAddressNoZone(
+ arrayToIpv4AddressNoZone(swInterfaceGreDetails.tunnel.dst.un.getIp4().ip4Address)));
+ builder.setSrc(new IpAddressNoZone(
+ arrayToIpv4AddressNoZone(swInterfaceGreDetails.tunnel.src.un.getIp4().ip4Address)));
}
- builder.setOuterFibId((long) swInterfaceGreDetails.outerFibId);
+ builder.setOuterFibId((long) swInterfaceGreDetails.tunnel.outerFibId);
LOG.debug("Gre tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder);
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizerTest.java
index 133e5ec54..0e0875baf 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizerTest.java
@@ -32,8 +32,8 @@ import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.jvpp.VppBaseCallException;
import io.fd.jvpp.VppInvocationException;
-import io.fd.jvpp.core.dto.GreAddDelTunnel;
-import io.fd.jvpp.core.dto.GreAddDelTunnelReply;
+import io.fd.jvpp.core.dto.GreTunnelAddDel;
+import io.fd.jvpp.core.dto.GreTunnelAddDelReply;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190128.VppInterfaceAugmentation;
@@ -73,33 +73,33 @@ public class GreCustomizerTest extends WriterCustomizerTest implements AddressTr
}
private void whenGreAddDelTunnelThenSuccess() {
- final GreAddDelTunnelReply reply = new GreAddDelTunnelReply();
+ final GreTunnelAddDelReply reply = new GreTunnelAddDelReply();
reply.swIfIndex = IFACE_ID;
- doReturn(future(reply)).when(api).greAddDelTunnel(any(GreAddDelTunnel.class));
+ doReturn(future(reply)).when(api).greTunnelAddDel(any(GreTunnelAddDel.class));
}
private void whenGreAddDelTunnelThenFailure() {
- doReturn(failedFuture()).when(api).greAddDelTunnel(any(GreAddDelTunnel.class));
+ doReturn(failedFuture()).when(api).greTunnelAddDel(any(GreTunnelAddDel.class));
}
- private GreAddDelTunnel verifyGreAddDelTunnelWasInvoked(final Gre gre) throws VppInvocationException {
- ArgumentCaptor<GreAddDelTunnel> argumentCaptor = ArgumentCaptor.forClass(GreAddDelTunnel.class);
- verify(api).greAddDelTunnel(argumentCaptor.capture());
- final GreAddDelTunnel actual = argumentCaptor.getValue();
- assertEquals(0, actual.isIpv6);
- assertArrayEquals(ipAddressToArray(gre.getSrc()), actual.srcAddress);
- assertArrayEquals(ipAddressToArray(gre.getDst()), actual.dstAddress);
- assertEquals(gre.getOuterFibId().intValue(), actual.outerFibId);
+ private GreTunnelAddDel verifyGreAddDelTunnelWasInvoked(final Gre gre) throws VppInvocationException {
+ ArgumentCaptor<GreTunnelAddDel> argumentCaptor = ArgumentCaptor.forClass(GreTunnelAddDel.class);
+ verify(api).greTunnelAddDel(argumentCaptor.capture());
+ final GreTunnelAddDel actual = argumentCaptor.getValue();
+ assertEquals(0, actual.tunnel.isIpv6);
+ assertArrayEquals(ipAddressToArray(gre.getSrc()), actual.tunnel.src.un.getIp4().ip4Address);
+ assertArrayEquals(ipAddressToArray(gre.getDst()), actual.tunnel.dst.un.getIp4().ip4Address);
+ assertEquals(gre.getOuterFibId().intValue(), actual.tunnel.outerFibId);
return actual;
}
private void verifyGreAddWasInvoked(final Gre gre) throws VppInvocationException {
- final GreAddDelTunnel actual = verifyGreAddDelTunnelWasInvoked(gre);
+ final GreTunnelAddDel actual = verifyGreAddDelTunnelWasInvoked(gre);
assertEquals(ADD_GRE, actual.isAdd);
}
private void verifyGreDeleteWasInvoked(final Gre gre) throws VppInvocationException {
- final GreAddDelTunnel actual = verifyGreAddDelTunnelWasInvoked(gre);
+ final GreTunnelAddDel actual = verifyGreAddDelTunnelWasInvoked(gre);
assertEquals(DEL_GRE, actual.isAdd);
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java
index 0e0775916..33617fbc6 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java
@@ -37,12 +37,15 @@ import io.fd.jvpp.core.dto.GreTunnelDetails;
import io.fd.jvpp.core.dto.GreTunnelDetailsReplyDump;
import io.fd.jvpp.core.dto.GreTunnelDump;
import io.fd.jvpp.core.dto.SwInterfaceDetails;
+import io.fd.jvpp.core.types.Address;
+import io.fd.jvpp.core.types.GreTunnel;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190128.VppInterfaceStateAugmentation;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190128.VppInterfaceStateAugmentationBuilder;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190128.interfaces.state._interface.Gre;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190128.interfaces.state._interface.GreBuilder;
+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.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;
@@ -78,11 +81,12 @@ public class GreCustomizerTest extends ReaderCustomizerTest<Gre, GreBuilder> imp
final GreTunnelDetailsReplyDump value = new GreTunnelDetailsReplyDump();
final GreTunnelDetails greTunnelDetails = new GreTunnelDetails();
- greTunnelDetails.isIpv6 = 0;
- greTunnelDetails.dstAddress = ipv4AddressNoZoneToArray("1.2.3.4");
- greTunnelDetails.srcAddress = ipv4AddressNoZoneToArray("1.2.3.5");
- greTunnelDetails.outerFibId = 55;
- greTunnelDetails.swIfIndex = 0;
+ greTunnelDetails.tunnel = new GreTunnel();
+ greTunnelDetails.tunnel.isIpv6 = 0;
+ greTunnelDetails.tunnel.dst = ipv4AddressToAddress(new Ipv4Address("1.2.3.4"));
+ greTunnelDetails.tunnel.src = ipv4AddressToAddress(new Ipv4Address("1.2.3.5"));
+ greTunnelDetails.tunnel.outerFibId = 55;
+ greTunnelDetails.tunnel.swIfIndex = 0;
value.greTunnelDetails = Lists.newArrayList(greTunnelDetails);
doReturn(future(value)).when(api).greTunnelDump(any(GreTunnelDump.class));