diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2017-10-06 13:36:45 +0200 |
---|---|---|
committer | Jan Srnicek <jsrnicek@cisco.com> | 2017-10-10 07:39:28 +0000 |
commit | 4e9fe17852628fc2f839801f39fada24f34896ff (patch) | |
tree | dbd61407c43e146b8dde6149c335fa2b15792925 /lisp/lisp2vpp/src/main | |
parent | 2c4fdea301293a4d034a78db0067394c44e2e931 (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>
Diffstat (limited to 'lisp/lisp2vpp/src/main')
2 files changed, 24 insertions, 7 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)); } } |