summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-10-06 13:36:45 +0200
committerJan Srnicek <jsrnicek@cisco.com>2017-10-10 07:39:47 +0000
commit50d5c2e2649ff07e2ff803d29fd0f9d62d851d8d (patch)
tree8c5d2df232c35f958e661f25afd109bdc7923fa0
parented51dab992b6a03d63ae2096f4736a6ddf449ecf (diff)
HC2VPP-243 - don't throw on remove of map-request-mode
Allows removing all lisp-feature-data. Also fixes ordering for itr remote locator set. Change-Id: Ib181c724dfa76f5ac380eec5e50f5d76f6b01389 Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizer.java23
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java8
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java5
3 files changed, 27 insertions, 9 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizer.java
index cea02264c..d211a747f 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizer.java
@@ -16,8 +16,6 @@
package io.fd.hc2vpp.lisp.translate.write;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
@@ -27,14 +25,24 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.OneMapRequestMode;
import io.fd.vpp.jvpp.core.dto.OneMapRequestModeReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-import java.util.concurrent.CompletableFuture;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170911.map.request.mode.grouping.MapRequestMode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170911.map.request.mode.grouping.MapRequestModeBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nonnull;
+import java.util.concurrent.CompletableFuture;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170911.MapRequestMode.DestinationOnly;
public class MapRequestModeCustomizer extends CheckedLispCustomizer
implements WriterCustomizer<MapRequestMode>, JvppReplyConsumer {
+ private static final Logger LOG = LoggerFactory.getLogger(MapRequestModeCustomizer.class);
+ private static final MapRequestMode DEFAULT_MODE = new MapRequestModeBuilder().setMode(DestinationOnly).build();
+
public MapRequestModeCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
@Nonnull final LispStateCheckService lispStateCheckService) {
super(futureJVppCore, lispStateCheckService);
@@ -44,6 +52,7 @@ public class MapRequestModeCustomizer extends CheckedLispCustomizer
public void writeCurrentAttributes(@Nonnull InstanceIdentifier<MapRequestMode> instanceIdentifier,
@Nonnull MapRequestMode mapRequestMode,
@Nonnull WriteContext writeContext) throws WriteFailedException {
+ LOG.debug("Setting map request mode to [{}]", mapRequestMode);
lispStateCheckService.checkLispEnabledAfter(writeContext);
getReplyForWrite(mapRequestModeRequestFuture(mapRequestMode), instanceIdentifier);
}
@@ -54,6 +63,7 @@ public class MapRequestModeCustomizer extends CheckedLispCustomizer
@Nonnull MapRequestMode mapRequestModeAfter, @Nonnull WriteContext writeContext)
throws WriteFailedException {
lispStateCheckService.checkLispEnabledAfter(writeContext);
+ LOG.debug("Setting map request mode to [{}]", mapRequestModeAfter);
getReplyForUpdate(mapRequestModeRequestFuture(mapRequestModeAfter), instanceIdentifier,
mapRequestModeBefore, mapRequestModeAfter);
}
@@ -62,7 +72,10 @@ public class MapRequestModeCustomizer extends CheckedLispCustomizer
public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<MapRequestMode> instanceIdentifier,
@Nonnull MapRequestMode mapRequestMode,
@Nonnull WriteContext writeContext) throws WriteFailedException {
- throw new UnsupportedOperationException("Map request mode cannot be deleted");
+ LOG.debug("Setting map request mode to default[{}]", DEFAULT_MODE);
+ // there is no delete, just set to default. also prevents failing on delete of parent node
+ lispStateCheckService.checkLispEnabledBefore(writeContext);
+ getReplyForWrite(mapRequestModeRequestFuture(DEFAULT_MODE), instanceIdentifier);
}
private CompletableFuture<OneMapRequestModeReply> mapRequestModeRequestFuture(
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java
index 88d24dc62..d6a8761ba 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java
@@ -36,6 +36,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170911.Lisp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170911.itr.remote.locator.sets.grouping.ItrRemoteLocatorSet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170911.lisp.feature.data.grouping.LispFeatureData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170911.locator.sets.grouping.LocatorSets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170911.locator.sets.grouping.locator.sets.LocatorSet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170911.map.register.grouping.MapRegister;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170911.map.request.mode.grouping.MapRequestMode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170911.pitr.cfg.grouping.PitrCfg;
@@ -76,7 +78,9 @@ public final class LispWriterFactory extends AbstractLispInfraFactoryBase implem
registry.add(writer(LISP_FEATURE_IDENTIFIER.child(RlocProbe.class),
new RlocProbeCustomizer(vppApi, lispStateCheckService)));
- registry.add(writer(LISP_FEATURE_IDENTIFIER.child(ItrRemoteLocatorSet.class),
- new ItrRemoteLocatorSetCustomizer(vppApi, lispStateCheckService)));
+ // itr remote locator set has reference to locator set, so must be deleted before locator set
+ registry.addAfter(writer(LISP_FEATURE_IDENTIFIER.child(ItrRemoteLocatorSet.class),
+ new ItrRemoteLocatorSetCustomizer(vppApi, lispStateCheckService)),
+ LISP_FEATURE_IDENTIFIER.child(LocatorSets.class).child(LocatorSet.class));
}
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java
index b2050d280..674a3a640 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java
@@ -74,7 +74,8 @@ public class MapRequestModeCustomizerTest extends LispWriterCustomizerTest {
@Test
public void deleteCurrentAttributes() throws Exception {
- verify(api, times(0)).lispMapRequestMode(any());
+ customizer.deleteCurrentAttributes(ID, sourceDestinationMode, writeContext);
+ verifyModeRequest(DestinationOnly);// always should be destination only - its default
}
@Test
@@ -93,7 +94,7 @@ public class MapRequestModeCustomizerTest extends LispWriterCustomizerTest {
public void testUpdateLispDisabled() throws WriteFailedException {
mockLispDisabledAfter();
try {
- customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
+ customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA, EMPTY_DATA, writeContext);
} catch (IllegalArgumentException e) {
verifyZeroInteractions(api);
return;