summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java34
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizerTest.java17
2 files changed, 40 insertions, 11 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java
index a68baa06a..8b93f7551 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java
@@ -23,15 +23,15 @@ import io.fd.honeycomb.translate.vpp.util.NamingContext;
import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.VppBaseCallException;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceSetTable;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceSetTableReply;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
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.interfaces._interface.Routing;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.VppBaseCallException;
-import io.fd.vpp.jvpp.core.dto.SwInterfaceSetTable;
-import io.fd.vpp.jvpp.core.dto.SwInterfaceSetTableReply;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -76,8 +76,15 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements WriterCus
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Routing> id,
- @Nonnull final Routing dataBefore, @Nonnull final WriteContext writeContext) {
- // TODO HONEYCOMB-176 implement delete
+ @Nonnull final Routing dataBefore, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+ final String ifName = id.firstKeyOf(Interface.class).getName();
+ try {
+ disableRouting(id, ifName, writeContext);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to disable routing for interface: {}, {}", ifName, writeContext);
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
}
private void setRouting(final InstanceIdentifier<Routing> id, final String name, final Routing rt,
@@ -98,6 +105,21 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements WriterCus
}
}
+ /**
+ * In this case, there is no such thing as delete routing,only thing that can be done is to disable it by setting
+ * default value 0
+ */
+ private void disableRouting(final InstanceIdentifier<Routing> id, final String name,
+ final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException {
+ final int swIfc = interfaceContext.getIndex(name, writeContext.getMappingContext());
+ LOG.debug("Disabling routing for interface: {}, {}.", name, swIfc);
+
+ getReplyForWrite(getFutureJVpp()
+ .swInterfaceSetTable(getInterfaceSetTableRequest(swIfc, (byte) 0, 0)).toCompletableFuture(), id);
+ LOG.debug("Routing for interface: {}, {} successfully disabled", name, swIfc);
+
+ }
+
private SwInterfaceSetTable getInterfaceSetTableRequest(final int swIfc, final byte isIpv6, final int vrfId) {
final SwInterfaceSetTable swInterfaceSetTable = new SwInterfaceSetTable();
swInterfaceSetTable.isIpv6 = isIpv6;
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizerTest.java
index 54dc81d6a..930e3d14f 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizerTest.java
@@ -24,6 +24,8 @@ import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.vpp.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceSetTable;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceSetTableReply;
import org.junit.Test;
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;
@@ -32,16 +34,14 @@ 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.Routing;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.RoutingBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.dto.SwInterfaceSetTable;
-import io.fd.vpp.jvpp.core.dto.SwInterfaceSetTableReply;
public class RoutingCustomizerTest extends WriterCustomizerTest {
private static final String IFACE_CTX_NAME = "interface-ctx";
private static final String IF_NAME = "eth1";
private static final int IF_INDEX = 1;
private static final InstanceIdentifier<Routing> IID =
- InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IF_NAME))
- .augmentation(VppInterfaceAugmentation.class).child(Routing.class);
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IF_NAME))
+ .augmentation(VppInterfaceAugmentation.class).child(Routing.class);
private RoutingCustomizer customizer;
@@ -80,8 +80,15 @@ public class RoutingCustomizerTest extends WriterCustomizerTest {
@Test
public void testDelete() throws WriteFailedException {
+ when(api.swInterfaceSetTable(any())).thenReturn(future(new SwInterfaceSetTableReply()));
+ customizer.deleteCurrentAttributes(IID, routing(123), writeContext);
+ verify(api).swInterfaceSetTable(expectedRequest(0));
+ }
+
+ @Test(expected = WriteFailedException.DeleteFailedException.class)
+ public void testDeleteFailed() throws WriteFailedException {
+ when(api.swInterfaceSetTable(any())).thenReturn(failedFuture());
customizer.deleteCurrentAttributes(IID, routing(123), writeContext);
- verifyZeroInteractions(api);
}
private Routing routing(final long vrfId) {