summaryrefslogtreecommitdiffstats
path: root/lisp/lisp2vpp
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-03-22 10:35:49 +0100
committerJan Srnicek <jsrnicek@cisco.com>2017-03-22 11:03:13 +0000
commitd474f0648427615a70c81f40d4bfdd2ec8c76b74 (patch)
tree22a59520ae9f9a27ad8013229900085a86ff3138 /lisp/lisp2vpp
parent00046200da55e56e62d03d39248a75b0e4c49bd6 (diff)
HC2VPP-115 - lisp state check before write/read
- checks lisp state before read,disabled state will result in returning empty data - checks lisp state before write,disabled state will result in throwing IllegalStateException - fixes ordering issues for lisp gpe interfaces Change-Id: I6dcfc6c7f514aad57841f2aac1b2ee0c6b868c3c Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'lisp/lisp2vpp')
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/LispModule.java4
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/AbstractLispInfraFactoryBase.java7
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizer.java26
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizer.java34
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizer.java21
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizer.java18
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java39
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizer.java22
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizer.java20
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizer.java19
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizer.java19
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java33
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/EidTableReaderFactory.java12
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java10
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LocatorSetReaderFactory.java5
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapResolverReaderFactory.java5
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapServerReaderFactory.java2
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckService.java37
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImpl.java70
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/CheckedLispCustomizer.java34
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizer.java26
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizer.java12
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizer.java23
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizer.java19
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizer.java22
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizer.java15
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizer.java21
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizer.java22
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizer.java16
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizer.java16
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/EidTableWriterFactory.java2
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java18
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LocatorSetWriterFactory.java3
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapResolverWriterFactory.java2
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapServerWriterFactory.java2
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingListReaderCustomizerTest.java70
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingReaderCustomizerTest.java59
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java26
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java8
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java10
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java9
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java6
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImplTest.java93
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java5
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispWriterCustomizerTest.java38
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java34
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java47
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRequestModeCustomizerTest.java34
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java33
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java33
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java46
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java46
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java46
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java32
59 files changed, 1100 insertions, 261 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/LispModule.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/LispModule.java
index 5e674f52b..5324eec2d 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/LispModule.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/LispModule.java
@@ -36,6 +36,8 @@ import io.fd.hc2vpp.lisp.translate.read.factory.LispStateReaderFactory;
import io.fd.hc2vpp.lisp.translate.read.factory.LocatorSetReaderFactory;
import io.fd.hc2vpp.lisp.translate.read.factory.MapResolverReaderFactory;
import io.fd.hc2vpp.lisp.translate.read.factory.MapServerReaderFactory;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckServiceImpl;
import io.fd.hc2vpp.lisp.translate.write.factory.EidTableWriterFactory;
import io.fd.hc2vpp.lisp.translate.write.factory.LispWriterFactory;
import io.fd.hc2vpp.lisp.translate.write.factory.LocatorSetWriterFactory;
@@ -98,6 +100,8 @@ public class LispModule extends AbstractModule {
final Multibinder<ReaderFactory> readerBinder = Multibinder.newSetBinder(binder(), ReaderFactory.class);
readerBinder.addBinding().toProvider(ContextsReaderFactoryProvider.class).in(Singleton.class);
+ bind(LispStateCheckService.class).to(LispStateCheckServiceImpl.class).in(Singleton.class);
+
LOG.info("Module Lisp successfully configured");
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/AbstractLispInfraFactoryBase.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/AbstractLispInfraFactoryBase.java
index 022ea19ed..5d2904cb5 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/AbstractLispInfraFactoryBase.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/AbstractLispInfraFactoryBase.java
@@ -27,16 +27,16 @@ import com.google.inject.name.Named;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.lisp.context.util.AdjacenciesMappingContext;
import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
import io.fd.honeycomb.translate.impl.write.GenericWriter;
import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.Lisp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.LispState;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import javax.annotation.Nonnull;
-
/**
* Basic attributes for lisp writer factories
@@ -74,6 +74,9 @@ public abstract class AbstractLispInfraFactoryBase {
@Named(ADJACENCIES_IDENTIFICATION_CONTEXT)
protected AdjacenciesMappingContext adjacenciesMappingContext;
+ @Inject
+ protected LispStateCheckService lispStateCheckService;
+
@Nonnull
protected <D extends DataObject> GenericWriter<D> writer(@Nonnull final InstanceIdentifier<D> type,
@Nonnull final WriterCustomizer<D> customizer) {
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizer.java
index 2c82b9ad4..5799bd9c3 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizer.java
@@ -17,11 +17,14 @@
package io.fd.hc2vpp.lisp.translate.read;
+import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
+
import com.google.common.base.Optional;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.lisp.translate.read.init.LispInitPathsMapper;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -31,25 +34,27 @@ import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager.DumpCacheManag
import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocs;
import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocsReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.itr.remote.locator.sets.grouping.ItrRemoteLocatorSet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.itr.remote.locator.sets.grouping.ItrRemoteLocatorSetBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import javax.annotation.Nonnull;
-
-import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
-
-public class ItrRemoteLocatorSetCustomizer extends FutureJVppCustomizer
+public class ItrRemoteLocatorSetCustomizer extends CheckedLispCustomizer
implements InitializingReaderCustomizer<ItrRemoteLocatorSet, ItrRemoteLocatorSetBuilder>, ByteDataTranslator,
JvppReplyConsumer, LispInitPathsMapper {
+ private static final Logger LOG = LoggerFactory.getLogger(ItrRemoteLocatorSetCustomizer.class);
+
private final DumpCacheManager<LispGetMapRequestItrRlocsReply, Void> dumpCacheManager;
- public ItrRemoteLocatorSetCustomizer(@Nonnull final FutureJVppCore futureJVppCore) {
- super(futureJVppCore);
+ public ItrRemoteLocatorSetCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJVppCore, lispStateCheckService);
dumpCacheManager = new DumpCacheManagerBuilder<LispGetMapRequestItrRlocsReply, Void>()
.withExecutor(((identifier, params) -> getReplyForRead(
futureJVppCore.lispGetMapRequestItrRlocs(new LispGetMapRequestItrRlocs()).toCompletableFuture(),
@@ -69,6 +74,11 @@ public class ItrRemoteLocatorSetCustomizer extends FutureJVppCustomizer
@Nonnull final ItrRemoteLocatorSetBuilder builder, @Nonnull final ReadContext ctx)
throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(ctx)) {
+ LOG.info("Lisp feature must be enabled first");
+ return;
+ }
+
final Optional<LispGetMapRequestItrRlocsReply> reply =
dumpCacheManager.getDump(id, ctx.getModificationCache(), NO_PARAMS);
if (!reply.isPresent() || reply.get().locatorSetName == null) {
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizer.java
index 4b176fc75..4e23347c9 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizer.java
@@ -16,12 +16,16 @@
package io.fd.hc2vpp.lisp.translate.read;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
+
import com.google.common.base.Optional;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.lisp.translate.read.init.LispInitPathsMapper;
import io.fd.hc2vpp.lisp.translate.read.trait.LocatorSetReader;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -30,6 +34,10 @@ import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetails;
import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.locator.sets.grouping.LocatorSetsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.locator.sets.grouping.locator.sets.LocatorSet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.locator.sets.grouping.locator.sets.LocatorSetBuilder;
@@ -40,15 +48,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.annotation.Nonnull;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
-
-public class LocatorSetCustomizer extends FutureJVppCustomizer
+public class LocatorSetCustomizer extends CheckedLispCustomizer
implements InitializingListReaderCustomizer<LocatorSet, LocatorSetKey, LocatorSetBuilder>, ByteDataTranslator,
LocatorSetReader, LispInitPathsMapper {
@@ -58,8 +58,9 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer
private final NamingContext locatorSetContext;
public LocatorSetCustomizer(@Nonnull final FutureJVppCore futureJvpp,
- @Nonnull final NamingContext locatorSetContext) {
- super(futureJvpp);
+ @Nonnull final NamingContext locatorSetContext,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJvpp, lispStateCheckService);
this.locatorSetContext = checkNotNull(locatorSetContext, "Locator Set mapping context cannot be null");
this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<LispLocatorSetDetailsReplyDump, Void>()
.withExecutor(createExecutor(futureJvpp))
@@ -76,6 +77,10 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(InstanceIdentifier<LocatorSet> id, LocatorSetBuilder builder, ReadContext ctx)
throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(ctx)) {
+ LOG.info("Lisp feature must be enabled first");
+ return;
+ }
LOG.debug("Reading attributes for Locator Set {}", id);
final Optional<LispLocatorSetDetailsReplyDump> dumpOptional =
@@ -105,6 +110,11 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer
@Override
public List<LocatorSetKey> getAllIds(InstanceIdentifier<LocatorSet> id, ReadContext context)
throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(context)) {
+ LOG.info("Lisp feature must be enabled first");
+ return Collections.emptyList();
+ }
+
LOG.debug("Dumping Locator Set {}", id);
final Optional<LispLocatorSetDetailsReplyDump> dumpOptional =
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizer.java
index e94bb92f0..808f53eff 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizer.java
@@ -17,9 +17,10 @@
package io.fd.hc2vpp.lisp.translate.read;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.lisp.translate.read.init.LispInitPathsMapper;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -28,21 +29,24 @@ import io.fd.vpp.jvpp.core.dto.ShowLispMapRegisterState;
import io.fd.vpp.jvpp.core.dto.ShowLispMapRegisterStateReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.Lisp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegister;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegisterBuilder;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-public class MapRegisterCustomizer extends FutureJVppCustomizer
+public class MapRegisterCustomizer extends CheckedLispCustomizer
implements InitializingReaderCustomizer<MapRegister, MapRegisterBuilder>, ByteDataTranslator,
JvppReplyConsumer, LispInitPathsMapper {
- public MapRegisterCustomizer(@Nonnull FutureJVppCore futureJVppCore) {
- super(futureJVppCore);
+ private static final Logger LOG = LoggerFactory.getLogger(MapRegisterCustomizer.class);
+
+ public MapRegisterCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJVppCore, lispStateCheckService);
}
@Nonnull
@@ -55,6 +59,11 @@ public class MapRegisterCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull InstanceIdentifier<MapRegister> instanceIdentifier,
@Nonnull MapRegisterBuilder mapRegisterBuilder,
@Nonnull ReadContext readContext) throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(readContext)) {
+ LOG.info("Lisp feature must be enabled first");
+ return;
+ }
+
final ShowLispMapRegisterStateReply read = getReplyForRead(getFutureJVpp()
.showLispMapRegisterState(new ShowLispMapRegisterState()).toCompletableFuture(), instanceIdentifier);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizer.java
index 9de5b5c68..267bc04c9 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizer.java
@@ -16,9 +16,10 @@
package io.fd.hc2vpp.lisp.translate.read;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.lisp.translate.read.init.LispInitPathsMapper;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -33,13 +34,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-public class MapRequestModeCustomizer extends FutureJVppCustomizer
+public class MapRequestModeCustomizer extends CheckedLispCustomizer
implements InitializingReaderCustomizer<MapRequestMode, MapRequestModeBuilder>,
JvppReplyConsumer, LispInitPathsMapper {
- public MapRequestModeCustomizer(@Nonnull FutureJVppCore futureJVppCore) {
- super(futureJVppCore);
+ private static final Logger LOG = LoggerFactory.getLogger(MapRequestModeCustomizer.class);
+
+ public MapRequestModeCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJVppCore, lispStateCheckService);
}
@Nonnull
@@ -52,6 +58,10 @@ public class MapRequestModeCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull InstanceIdentifier<MapRequestMode> instanceIdentifier,
@Nonnull MapRequestModeBuilder mapRequestModeBuilder,
@Nonnull ReadContext readContext) throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(readContext)) {
+ LOG.info("Lisp feature must be enabled first");
+ return;
+ }
final ShowLispMapRequestModeReply reply = getReplyForRead(
getFutureJVpp().showLispMapRequestMode(new ShowLispMapRequestMode()).toCompletableFuture(),
instanceIdentifier);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java
index ac947878b..199d1ff70 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java
@@ -16,11 +16,14 @@
package io.fd.hc2vpp.lisp.translate.read;
+import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
+
import com.google.common.base.Optional;
import io.fd.hc2vpp.common.translate.util.AddressTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.lisp.translate.read.init.LispInitPathsMapper;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -31,6 +34,11 @@ import io.fd.vpp.jvpp.core.dto.LispMapResolverDetails;
import io.fd.vpp.jvpp.core.dto.LispMapResolverDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.LispMapResolverDump;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.resolvers.grouping.MapResolvers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.resolvers.grouping.MapResolversBuilder;
@@ -43,15 +51,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.annotation.Nonnull;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
-
-public class MapResolverCustomizer extends FutureJVppCustomizer
+public class MapResolverCustomizer extends CheckedLispCustomizer
implements InitializingListReaderCustomizer<MapResolver, MapResolverKey, MapResolverBuilder>, AddressTranslator,
JvppReplyConsumer, LispInitPathsMapper {
@@ -59,8 +59,9 @@ public class MapResolverCustomizer extends FutureJVppCustomizer
private final DumpCacheManager<LispMapResolverDetailsReplyDump, Void> dumpManager;
- public MapResolverCustomizer(FutureJVppCore futureJvpp) {
- super(futureJvpp);
+ public MapResolverCustomizer(@Nonnull final FutureJVppCore futureJvpp,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJvpp, lispStateCheckService);
this.dumpManager =
new DumpCacheManager.DumpCacheManagerBuilder<LispMapResolverDetailsReplyDump, Void>()
.withExecutor((identifier, params) -> getReplyForRead(
@@ -78,6 +79,10 @@ public class MapResolverCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(InstanceIdentifier<MapResolver> id, MapResolverBuilder builder, ReadContext ctx)
throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(ctx)) {
+ LOG.info("Lisp feature must be enabled first");
+ return;
+ }
LOG.debug("Reading attributes...");
final Optional<LispMapResolverDetailsReplyDump> dumpOptional =
@@ -109,6 +114,10 @@ public class MapResolverCustomizer extends FutureJVppCustomizer
@Override
public List<MapResolverKey> getAllIds(InstanceIdentifier<MapResolver> id, ReadContext context)
throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(context)) {
+ LOG.info("Lisp feature must be enabled first");
+ return Collections.emptyList();
+ }
LOG.debug("Dumping MapResolver...");
final Optional<LispMapResolverDetailsReplyDump> dumpOptional =
@@ -131,7 +140,9 @@ public class MapResolverCustomizer extends FutureJVppCustomizer
@Nonnull
@Override
- public Initialized<? extends DataObject> init(@Nonnull InstanceIdentifier<MapResolver> instanceIdentifier, @Nonnull MapResolver mapResolver, @Nonnull ReadContext readContext) {
- return Initialized.create(lispFeaturesBasePath().child(MapResolvers.class).child(MapResolver.class, instanceIdentifier.firstKeyOf(MapResolver.class)), mapResolver);
+ public Initialized<? extends DataObject> init(@Nonnull InstanceIdentifier<MapResolver> instanceIdentifier,
+ @Nonnull MapResolver mapResolver, @Nonnull ReadContext readContext) {
+ return Initialized.create(lispFeaturesBasePath().child(MapResolvers.class)
+ .child(MapResolver.class, instanceIdentifier.firstKeyOf(MapResolver.class)), mapResolver);
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizer.java
index 8e53f265d..bd4c0ba5d 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizer.java
@@ -20,8 +20,9 @@ import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PA
import com.google.common.base.Optional;
import io.fd.hc2vpp.common.translate.util.AddressTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -49,15 +50,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-public class MapServerCustomizer extends FutureJVppCustomizer
+public class MapServerCustomizer extends CheckedLispCustomizer
implements InitializingListReaderCustomizer<MapServer, MapServerKey, MapServerBuilder>, JvppReplyConsumer,
AddressTranslator {
+ private static final Logger LOG = LoggerFactory.getLogger(MapServerCustomizer.class);
+
private final DumpCacheManager<LispMapServerDetailsReplyDump, Void> dumpManager;
- public MapServerCustomizer(@Nonnull FutureJVppCore futureJVppCore) {
- super(futureJVppCore);
+ public MapServerCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJVppCore, lispStateCheckService);
dumpManager = new DumpCacheManagerBuilder<LispMapServerDetailsReplyDump, Void>()
.acceptOnly(LispMapServerDetailsReplyDump.class)
.withExecutor((instanceIdentifier, aVoid) ->
@@ -83,6 +89,10 @@ public class MapServerCustomizer extends FutureJVppCustomizer
@Override
public List<MapServerKey> getAllIds(@Nonnull InstanceIdentifier<MapServer> instanceIdentifier,
@Nonnull ReadContext readContext) throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(readContext)) {
+ LOG.info("Lisp feature must be enabled first");
+ return Collections.emptyList();
+ }
final Optional<LispMapServerDetailsReplyDump> dump =
dumpManager.getDump(instanceIdentifier, readContext.getModificationCache(), NO_PARAMS);
@@ -112,6 +122,10 @@ public class MapServerCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull InstanceIdentifier<MapServer> instanceIdentifier,
@Nonnull MapServerBuilder mapServerBuilder, @Nonnull ReadContext readContext)
throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(readContext)) {
+ LOG.info("Lisp feature must be enabled first");
+ return;
+ }
final Optional<LispMapServerDetailsReplyDump> dump =
dumpManager.getDump(instanceIdentifier, readContext.getModificationCache(), NO_PARAMS);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizer.java
index 0e27a0ee8..da8f35743 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizer.java
@@ -17,9 +17,10 @@
package io.fd.hc2vpp.lisp.translate.read;
import io.fd.hc2vpp.common.translate.util.AddressTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.lisp.translate.read.init.LispInitPathsMapper;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -34,13 +35,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-public class PetrCfgCustomizer extends FutureJVppCustomizer
+public class PetrCfgCustomizer extends CheckedLispCustomizer
implements InitializingReaderCustomizer<PetrCfg, PetrCfgBuilder>, JvppReplyConsumer,
AddressTranslator, LispInitPathsMapper {
- public PetrCfgCustomizer(@Nonnull FutureJVppCore futureJVppCore) {
- super(futureJVppCore);
+ private static final Logger LOG = LoggerFactory.getLogger(PetrCfgCustomizer.class);
+
+ public PetrCfgCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJVppCore, lispStateCheckService);
}
@Nonnull
@@ -61,11 +67,15 @@ public class PetrCfgCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull InstanceIdentifier<PetrCfg> instanceIdentifier,
@Nonnull PetrCfgBuilder petrCfgBuilder,
@Nonnull ReadContext readContext) throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(readContext)) {
+ LOG.info("Lisp feature must be enabled first");
+ return;
+ }
+
final ShowLispUsePetrReply read = getReplyForRead(getFutureJVpp().showLispUsePetr(new ShowLispUsePetr())
.toCompletableFuture(), instanceIdentifier);
if (read != null && read.status != 0) {
- // TODO - https://jira.fd.io/browse/VPP-660 - returns address back in bad form
petrCfgBuilder.setPetrAddress(arrayToIpAddress(!byteToBoolean(read.isIp4), read.address));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizer.java
index c7c966f77..6e807ad36 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizer.java
@@ -18,9 +18,10 @@ package io.fd.hc2vpp.lisp.translate.read;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.lisp.translate.read.init.LispInitPathsMapper;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -29,6 +30,8 @@ import io.fd.vpp.jvpp.VppBaseCallException;
import io.fd.vpp.jvpp.core.dto.ShowLispPitr;
import io.fd.vpp.jvpp.core.dto.ShowLispPitrReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.pitr.cfg.grouping.PitrCfg;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.pitr.cfg.grouping.PitrCfgBuilder;
@@ -38,21 +41,19 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.annotation.Nonnull;
-import java.util.concurrent.TimeoutException;
-
/**
* Customizer for reading {@link PitrCfg}<br> Currently unsupported in jvpp
*/
-public class PitrCfgCustomizer extends FutureJVppCustomizer
+public class PitrCfgCustomizer extends CheckedLispCustomizer
implements InitializingReaderCustomizer<PitrCfg, PitrCfgBuilder>, ByteDataTranslator, JvppReplyConsumer,
LispInitPathsMapper {
private static final Logger LOG = LoggerFactory.getLogger(PitrCfgCustomizer.class);
- public PitrCfgCustomizer(FutureJVppCore futureJvpp) {
- super(futureJvpp);
+ public PitrCfgCustomizer(@Nonnull final FutureJVppCore futureJvpp,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJvpp, lispStateCheckService);
}
@Override
@@ -63,6 +64,10 @@ public class PitrCfgCustomizer extends FutureJVppCustomizer
@Override
public void readCurrentAttributes(InstanceIdentifier<PitrCfg> id, PitrCfgBuilder builder, ReadContext ctx)
throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(ctx)) {
+ LOG.info("Lisp feature must be enabled first");
+ return;
+ }
LOG.debug("Reading status for Lisp Pitr node {}", id);
ShowLispPitrReply reply;
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizer.java
index bd0070141..0cd5b857f 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizer.java
@@ -17,9 +17,10 @@
package io.fd.hc2vpp.lisp.translate.read;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.lisp.translate.read.init.LispInitPathsMapper;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -34,13 +35,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-public class RlocProbeCustomizer extends FutureJVppCustomizer
+public class RlocProbeCustomizer extends CheckedLispCustomizer
implements InitializingReaderCustomizer<RlocProbe, RlocProbeBuilder>, JvppReplyConsumer, ByteDataTranslator,
LispInitPathsMapper {
- public RlocProbeCustomizer(@Nonnull FutureJVppCore futureJVppCore) {
- super(futureJVppCore);
+ private static final Logger LOG = LoggerFactory.getLogger(RlocProbeCustomizer.class);
+
+ public RlocProbeCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJVppCore, lispStateCheckService);
}
@Nonnull
@@ -53,6 +59,11 @@ public class RlocProbeCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull InstanceIdentifier<RlocProbe> instanceIdentifier,
@Nonnull RlocProbeBuilder rlocProbeBuilder,
@Nonnull ReadContext readContext) throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(readContext)) {
+ LOG.info("Lisp feature must be enabled first");
+ return;
+ }
+
final ShowLispRlocProbeStateReply read = getReplyForRead(getFutureJVpp()
.showLispRlocProbeState(new ShowLispRlocProbeState()).toCompletableFuture(), instanceIdentifier);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java
index 3dfb6d6aa..56e60c231 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizer.java
@@ -16,9 +16,13 @@
package io.fd.hc2vpp.lisp.translate.read;
+import static com.google.common.base.Preconditions.checkState;
+import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
+
import com.google.common.base.Optional;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -29,6 +33,10 @@ import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetails;
import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.LispEidTableVniDump;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.Lisp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.EidTable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.EidTableBuilder;
@@ -43,26 +51,19 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.annotation.Nonnull;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static com.google.common.base.Preconditions.checkState;
-import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
-
/**
* Handles the reads of {@link VniTable} nodes
*/
-public class VniTableCustomizer extends FutureJVppCustomizer
+public class VniTableCustomizer extends CheckedLispCustomizer
implements InitializingListReaderCustomizer<VniTable, VniTableKey, VniTableBuilder>, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(VniTableCustomizer.class);
private final DumpCacheManager<LispEidTableVniDetailsReplyDump, Void> dumpManager;
- public VniTableCustomizer(@Nonnull final FutureJVppCore futureJvpp) {
- super(futureJvpp);
+ public VniTableCustomizer(@Nonnull final FutureJVppCore futureJvpp,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJvpp, lispStateCheckService);
this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<LispEidTableVniDetailsReplyDump, Void>()
.withExecutor(((identifier, params) -> getReplyForRead(
futureJvpp.lispEidTableVniDump(new LispEidTableVniDump()).toCompletableFuture(), identifier)))
@@ -91,6 +92,10 @@ public class VniTableCustomizer extends FutureJVppCustomizer
public List<VniTableKey> getAllIds(@Nonnull final InstanceIdentifier<VniTable> id,
@Nonnull final ReadContext context)
throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(context)) {
+ LOG.info("Lisp feature must be enabled first");
+ return Collections.emptyList();
+ }
LOG.trace("Reading all IDS...");
final Optional<LispEidTableVniDetailsReplyDump> optionalReply =
@@ -108,6 +113,10 @@ public class VniTableCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<VniTable> id,
@Nonnull final VniTableBuilder builder, @Nonnull final ReadContext ctx)
throws ReadFailedException {
+ if (!lispStateCheckService.lispEnabled(ctx)) {
+ LOG.info("Lisp feature must be enabled first");
+ return;
+ }
checkState(id.firstKeyOf(VniTable.class) != null, "No VNI present");
VniTableKey key = new VniTableKey(id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier());
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/EidTableReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/EidTableReaderFactory.java
index 325be4836..be99d4fac 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/EidTableReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/EidTableReaderFactory.java
@@ -19,11 +19,17 @@ package io.fd.hc2vpp.lisp.translate.read.factory;
import com.google.common.collect.ImmutableSet;
import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase;
-import io.fd.hc2vpp.lisp.translate.read.*;
+import io.fd.hc2vpp.lisp.translate.read.AdjacencyCustomizer;
+import io.fd.hc2vpp.lisp.translate.read.BridgeDomainSubtableCustomizer;
+import io.fd.hc2vpp.lisp.translate.read.LocalMappingCustomizer;
+import io.fd.hc2vpp.lisp.translate.read.RemoteMappingCustomizer;
+import io.fd.hc2vpp.lisp.translate.read.VniTableCustomizer;
+import io.fd.hc2vpp.lisp.translate.read.VrfSubtableCustomizer;
import io.fd.honeycomb.translate.impl.read.GenericInitListReader;
import io.fd.honeycomb.translate.impl.read.GenericInitReader;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.adjacencies.grouping.Adjacencies;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.adjacencies.grouping.AdjacenciesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.adjacencies.grouping.adjacencies.Adjacency;
@@ -47,8 +53,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import javax.annotation.Nonnull;
-
/**
* Factory that produces {@code Reader} for {@code EidTable}<br> with all its inhired child readers
@@ -71,7 +75,7 @@ public final class EidTableReaderFactory extends AbstractLispInfraFactoryBase im
//EidTable
registry.addStructuralReader(EID_TABLE_IID, EidTableBuilder.class);
//EidTable -> VniTable
- registry.add(new GenericInitListReader<>(VNI_TABLE_IID, new VniTableCustomizer(vppApi)));
+ registry.add(new GenericInitListReader<>(VNI_TABLE_IID, new VniTableCustomizer(vppApi, lispStateCheckService)));
//EidTable -> VniTable -> VrfSubtable
registry.add(new GenericInitReader<>(VRF_SUBTABLE_IID, new VrfSubtableCustomizer(vppApi)));
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java
index b7bd37588..7757d0822 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java
@@ -54,18 +54,18 @@ public class LispStateReaderFactory extends AbstractLispInfraFactoryBase impleme
registry.addStructuralReader(lispStateId.child(LispFeatureData.class), LispFeatureDataBuilder.class);
registry.add(new GenericInitReader<>(LISP_FEATURE_ID.child(PitrCfg.class),
- new PitrCfgCustomizer(vppApi)));
+ new PitrCfgCustomizer(vppApi, lispStateCheckService)));
registry.add(new GenericInitReader<>(LISP_FEATURE_ID.child(RlocProbe.class),
- new RlocProbeCustomizer(vppApi)));
+ new RlocProbeCustomizer(vppApi, lispStateCheckService)));
registry.add(new GenericInitReader<>(LISP_FEATURE_ID.child(PetrCfg.class),
- new PetrCfgCustomizer(vppApi)));
+ new PetrCfgCustomizer(vppApi, lispStateCheckService)));
registry.add(new GenericInitReader<>(LISP_FEATURE_ID.child(MapRegister.class),
- new MapRegisterCustomizer(vppApi)));
+ new MapRegisterCustomizer(vppApi, lispStateCheckService)));
registry.add(new GenericInitReader<>(LISP_FEATURE_ID.child(MapRequestMode.class),
- new MapRequestModeCustomizer(vppApi)));
+ new MapRequestModeCustomizer(vppApi, lispStateCheckService)));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LocatorSetReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LocatorSetReaderFactory.java
index 17c41f304..75faf0b8f 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LocatorSetReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LocatorSetReaderFactory.java
@@ -23,6 +23,7 @@ import io.fd.hc2vpp.lisp.translate.read.LocatorSetCustomizer;
import io.fd.honeycomb.translate.impl.read.GenericInitListReader;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.locator.sets.grouping.LocatorSets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.locator.sets.grouping.LocatorSetsBuilder;
@@ -30,8 +31,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.locator.sets.grouping.locator.sets.locator.set.Interface;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import javax.annotation.Nonnull;
-
/**
* Produces reader for {@link LocatorSets} <br> and all its inhired child readers.
@@ -48,7 +47,7 @@ public class LocatorSetReaderFactory extends AbstractLispInfraFactoryBase implem
registry.addStructuralReader(locatorSetsInstanceIdentifier, LocatorSetsBuilder.class);
registry.add(new GenericInitListReader<>(locatorSetInstanceIdentifier,
- new LocatorSetCustomizer(vppApi, locatorSetContext)));
+ new LocatorSetCustomizer(vppApi, locatorSetContext, lispStateCheckService)));
registry.add(new GenericInitListReader<>(locatorSetInstanceIdentifier.child(Interface.class),
new InterfaceCustomizer(vppApi, interfaceContext, locatorSetContext)));
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapResolverReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapResolverReaderFactory.java
index 2908770be..8b9fb3cb9 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapResolverReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapResolverReaderFactory.java
@@ -22,14 +22,13 @@ import io.fd.hc2vpp.lisp.translate.read.MapResolverCustomizer;
import io.fd.honeycomb.translate.impl.read.GenericInitListReader;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.resolvers.grouping.MapResolvers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.resolvers.grouping.MapResolversBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.resolvers.grouping.map.resolvers.MapResolver;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import javax.annotation.Nonnull;
-
/**
* Builds reader for {@link MapResolvers}<br> and all its inhired child readers
@@ -44,6 +43,6 @@ public class MapResolverReaderFactory extends AbstractLispInfraFactoryBase imple
registry.addStructuralReader(mapResolversInstanceIdentifier, MapResolversBuilder.class);
registry.add(new GenericInitListReader<>(mapResolversInstanceIdentifier.child(MapResolver.class),
- new MapResolverCustomizer(vppApi)));
+ new MapResolverCustomizer(vppApi, lispStateCheckService)));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapServerReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapServerReaderFactory.java
index 1af8f939f..e53cee3b3 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapServerReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapServerReaderFactory.java
@@ -38,6 +38,6 @@ public class MapServerReaderFactory extends AbstractLispInfraFactoryBase impleme
public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
registry.addStructuralReader(MAP_SERVERS_ID, MapServersBuilder.class);
registry.add(new GenericInitListReader<>(MAP_SERVERS_ID.child(MapServer.class),
- new MapServerCustomizer(vppApi)));
+ new MapServerCustomizer(vppApi, lispStateCheckService)));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckService.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckService.java
new file mode 100644
index 000000000..ab0ea797c
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckService.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.lisp.translate.service;
+
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.write.WriteContext;
+import javax.annotation.Nonnull;
+
+/**
+ * Provides functionality to check whether lisp is enabled
+ */
+public interface LispStateCheckService {
+
+ /**
+ * Checks whether lisp is enabled while operating inside {@link WriteContext}
+ */
+ void checkLispEnabled(@Nonnull final WriteContext ctx);
+
+ /**
+ * Checks whether lisp is enabled while operating inside {@link ReadContext}
+ */
+ boolean lispEnabled(@Nonnull final ReadContext ctx);
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImpl.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImpl.java
new file mode 100644
index 000000000..8d46e9bed
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImpl.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.lisp.translate.service;
+
+import static com.google.common.base.Preconditions.checkState;
+import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
+
+import com.google.inject.Inject;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager.DumpCacheManagerBuilder;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.vpp.jvpp.core.dto.ShowLispStatus;
+import io.fd.vpp.jvpp.core.dto.ShowLispStatusReply;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.LispBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public final class LispStateCheckServiceImpl implements LispStateCheckService, JvppReplyConsumer, ByteDataTranslator {
+
+ private static final Lisp STATIC_LISP_INSTANCE = new LispBuilder().setEnable(false).build();
+ private static final ShowLispStatusReply DEFAULT_REPLY = new ShowLispStatusReply();
+ private static final InstanceIdentifier<Lisp> IDENTIFIER = InstanceIdentifier.create(Lisp.class);
+
+ private final DumpCacheManager<ShowLispStatusReply, Void> dumpManager;
+
+ @Inject
+ public LispStateCheckServiceImpl(@Nonnull final FutureJVppCore vppApi) {
+ dumpManager = new DumpCacheManagerBuilder<ShowLispStatusReply, Void>()
+ .withExecutor((instanceIdentifier, aVoid) -> getReplyForRead(vppApi.showLispStatus(new ShowLispStatus())
+ .toCompletableFuture(), instanceIdentifier))
+ .acceptOnly(ShowLispStatusReply.class)
+ .build();
+ }
+
+ public void checkLispEnabled(@Nonnull final WriteContext ctx) {
+ // no need to dump here, can be read directly from context
+ checkState(ctx.readAfter(InstanceIdentifier.create(Lisp.class))
+ .or(STATIC_LISP_INSTANCE).isEnable(), "Lisp feature not enabled");
+ }
+
+ public boolean lispEnabled(@Nonnull final ReadContext ctx) {
+ // in this case it must be dumped
+ try {
+ return byteToBoolean(dumpManager.getDump(IDENTIFIER, ctx.getModificationCache(), NO_PARAMS)
+ .or(DEFAULT_REPLY).featureStatus);
+ } catch (ReadFailedException e) {
+ throw new IllegalStateException("Unable to read Lisp Feature status", e);
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/CheckedLispCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/CheckedLispCustomizer.java
new file mode 100644
index 000000000..008e20c11
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/CheckedLispCustomizer.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.lisp.translate.util;
+
+
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
+
+public abstract class CheckedLispCustomizer extends FutureJVppCustomizer {
+
+ protected final LispStateCheckService lispStateCheckService;
+
+ public CheckedLispCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJVppCore);
+ this.lispStateCheckService = lispStateCheckService;
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizer.java
index f4c36cfb3..71be3c749 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizer.java
@@ -17,26 +17,28 @@
package io.fd.hc2vpp.lisp.translate.write;
-import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
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.LispAddDelMapRequestItrRlocs;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeoutException;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.itr.remote.locator.sets.grouping.ItrRemoteLocatorSet;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.VppBaseCallException;
-import io.fd.vpp.jvpp.core.dto.LispAddDelMapRequestItrRlocs;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-public class ItrRemoteLocatorSetCustomizer extends FutureJVppCustomizer implements
+public class ItrRemoteLocatorSetCustomizer extends CheckedLispCustomizer implements
WriterCustomizer<ItrRemoteLocatorSet>, ByteDataTranslator, JvppReplyConsumer {
- public ItrRemoteLocatorSetCustomizer(@Nonnull final FutureJVppCore futureJVppCore) {
- super(futureJVppCore);
+ public ItrRemoteLocatorSetCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJVppCore, lispStateCheckService);
}
@Override
@@ -44,7 +46,7 @@ public class ItrRemoteLocatorSetCustomizer extends FutureJVppCustomizer implemen
@Nonnull final ItrRemoteLocatorSet dataAfter,
@Nonnull final WriteContext writeContext) throws WriteFailedException {
try {
- addDelItrRemoteLocatorSet(true, dataAfter);
+ addDelItrRemoteLocatorSet(true, dataAfter, writeContext);
} catch (TimeoutException | VppBaseCallException e) {
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
@@ -64,14 +66,16 @@ public class ItrRemoteLocatorSetCustomizer extends FutureJVppCustomizer implemen
@Nonnull final ItrRemoteLocatorSet dataBefore,
@Nonnull final WriteContext writeContext) throws WriteFailedException {
try {
- addDelItrRemoteLocatorSet(false, dataBefore);
+ addDelItrRemoteLocatorSet(false, dataBefore, writeContext);
} catch (TimeoutException | VppBaseCallException e) {
throw new WriteFailedException.DeleteFailedException(id, e);
}
}
- private void addDelItrRemoteLocatorSet(final boolean add, @Nonnull final ItrRemoteLocatorSet data)
+ private void addDelItrRemoteLocatorSet(final boolean add, @Nonnull final ItrRemoteLocatorSet data,
+ @Nonnull final WriteContext context)
throws TimeoutException, VppBaseCallException {
+ lispStateCheckService.checkLispEnabled(context);
LispAddDelMapRequestItrRlocs request = new LispAddDelMapRequestItrRlocs();
request.isAdd = booleanToByte(add);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizer.java
index b83748236..5a606bc37 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizer.java
@@ -22,10 +22,11 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.base.Optional;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.common.translate.util.ReferenceCheck;
import io.fd.hc2vpp.lisp.translate.read.trait.LocatorSetReader;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -54,15 +55,16 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
*
* @see LocatorSet
*/
-public class LocatorSetCustomizer extends FutureJVppCustomizer
+public class LocatorSetCustomizer extends CheckedLispCustomizer
implements ListWriterCustomizer<LocatorSet, LocatorSetKey>, ByteDataTranslator,
LocatorSetReader, ReferenceCheck {
private final NamingContext locatorSetContext;
public LocatorSetCustomizer(@Nonnull final FutureJVppCore futureJvpp,
- @Nonnull final NamingContext locatorSetContext) {
- super(futureJvpp);
+ @Nonnull final NamingContext locatorSetContext,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJvpp, lispStateCheckService);
this.locatorSetContext = checkNotNull(locatorSetContext, "Locator set context cannot be null");
}
@@ -70,6 +72,7 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer
public void writeCurrentAttributes(@Nonnull InstanceIdentifier<LocatorSet> id,
@Nonnull LocatorSet dataAfter,
@Nonnull WriteContext writeContext) throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
checkState(isNonEmptyLocatorSet(writeContext.readAfter(id).get()),
"Creating empty locator-sets is not allowed");
final String locatorSetName = dataAfter.getName();
@@ -96,6 +99,7 @@ public class LocatorSetCustomizer extends FutureJVppCustomizer
public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<LocatorSet> id,
@Nonnull LocatorSet dataBefore,
@Nonnull WriteContext writeContext) throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
final String locatorSetName = dataBefore.getName();
final Optional<EidTable> eidTableData = writeContext.readAfter(InstanceIdentifier.create(Lisp.class)
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizer.java
index 1dac298a3..298b14358 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizer.java
@@ -17,30 +17,31 @@
package io.fd.hc2vpp.lisp.translate.write;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispMapRegisterEnableDisable;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegister;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import javax.annotation.Nonnull;
-
-public class MapRegisterCustomizer extends FutureJVppCustomizer
+public class MapRegisterCustomizer extends CheckedLispCustomizer
implements WriterCustomizer<MapRegister>, ByteDataTranslator, JvppReplyConsumer {
- public MapRegisterCustomizer(@Nonnull FutureJVppCore futureJVppCore) {
- super(futureJVppCore);
+ public MapRegisterCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJVppCore, lispStateCheckService);
}
@Override
public void writeCurrentAttributes(@Nonnull InstanceIdentifier<MapRegister> instanceIdentifier,
@Nonnull MapRegister mapRegister,
@Nonnull WriteContext writeContext) throws WriteFailedException {
- enableDisableMapRegister(mapRegister.isEnabled(), instanceIdentifier);
+ enableDisableMapRegister(mapRegister.isEnabled(), instanceIdentifier, writeContext);
}
@Override
@@ -48,17 +49,19 @@ public class MapRegisterCustomizer extends FutureJVppCustomizer
@Nonnull MapRegister mapRegisterBefore,
@Nonnull MapRegister mapRegisterAfter, @Nonnull
WriteContext writeContext) throws WriteFailedException {
- enableDisableMapRegister(mapRegisterAfter.isEnabled(), instanceIdentifier);
+ enableDisableMapRegister(mapRegisterAfter.isEnabled(), instanceIdentifier, writeContext);
}
@Override
public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<MapRegister> instanceIdentifier,
@Nonnull MapRegister mapRegister,
@Nonnull WriteContext writeContext) throws WriteFailedException {
- enableDisableMapRegister(false, instanceIdentifier);
+ enableDisableMapRegister(false, instanceIdentifier, writeContext);
}
- private void enableDisableMapRegister(final boolean enable, @Nonnull final InstanceIdentifier<MapRegister> id) throws WriteFailedException {
+ private void enableDisableMapRegister(final boolean enable, @Nonnull final InstanceIdentifier<MapRegister> id,
+ @Nonnull final WriteContext context) throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(context);
LispMapRegisterEnableDisable request = new LispMapRegisterEnableDisable();
request.isEnabled = booleanToByte(enable);
getReplyForWrite(getFutureJVpp().lispMapRegisterEnableDisable(request).toCompletableFuture(), id);
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 0e069504d..d61cd0cfb 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
@@ -18,8 +18,9 @@ package io.fd.hc2vpp.lisp.translate.write;
import static com.google.common.base.Preconditions.checkNotNull;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -30,22 +31,20 @@ import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.request.mode.grouping.MapRequestMode;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class MapRequestModeCustomizer extends FutureJVppCustomizer
+public class MapRequestModeCustomizer extends CheckedLispCustomizer
implements WriterCustomizer<MapRequestMode>, JvppReplyConsumer {
- private static final Logger LOG = LoggerFactory.getLogger(MapRequestModeCustomizer.class);
-
- public MapRequestModeCustomizer(@Nonnull FutureJVppCore futureJVppCore) {
- super(futureJVppCore);
+ public MapRequestModeCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJVppCore, lispStateCheckService);
}
@Override
public void writeCurrentAttributes(@Nonnull InstanceIdentifier<MapRequestMode> instanceIdentifier,
@Nonnull MapRequestMode mapRequestMode,
@Nonnull WriteContext writeContext) throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
getReplyForWrite(mapRequestModeRequestFuture(mapRequestMode), instanceIdentifier);
}
@@ -54,6 +53,7 @@ public class MapRequestModeCustomizer extends FutureJVppCustomizer
@Nonnull MapRequestMode mapRequestModeBefore,
@Nonnull MapRequestMode mapRequestModeAfter, @Nonnull WriteContext writeContext)
throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
getReplyForUpdate(mapRequestModeRequestFuture(mapRequestModeAfter), instanceIdentifier,
mapRequestModeBefore, mapRequestModeAfter);
}
@@ -62,8 +62,7 @@ public class MapRequestModeCustomizer extends FutureJVppCustomizer
public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<MapRequestMode> instanceIdentifier,
@Nonnull MapRequestMode mapRequestMode,
@Nonnull WriteContext writeContext) throws WriteFailedException {
- //TODO - after HC2VPP-115 - change to throw UnsupportedOperationException
- LOG.error("Map request mode cannot be deleted, ignoring");
+ throw new UnsupportedOperationException("Map request mode cannot be deleted");
}
private CompletableFuture<LispMapRequestModeReply> mapRequestModeRequestFuture(
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizer.java
index 7873c8da9..94b45ae21 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizer.java
@@ -18,38 +18,40 @@ package io.fd.hc2vpp.lisp.translate.write;
import static com.google.common.base.Preconditions.checkNotNull;
-import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.hc2vpp.common.translate.util.AddressTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
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.LispAddDelMapResolver;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import java.util.concurrent.TimeoutException;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.resolvers.grouping.map.resolvers.MapResolver;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.resolvers.grouping.map.resolvers.MapResolverKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.VppBaseCallException;
-import io.fd.vpp.jvpp.core.dto.LispAddDelMapResolver;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
/**
* Handles updates of {@link MapResolver} list
*/
-public class MapResolverCustomizer extends FutureJVppCustomizer
+public class MapResolverCustomizer extends CheckedLispCustomizer
implements ListWriterCustomizer<MapResolver, MapResolverKey>, AddressTranslator,
JvppReplyConsumer {
- public MapResolverCustomizer(final FutureJVppCore vppApi) {
- super(vppApi);
+ public MapResolverCustomizer(@Nonnull final FutureJVppCore vppApi,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(vppApi, lispStateCheckService);
}
@Override
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<MapResolver> id,
@Nonnull final MapResolver dataAfter, @Nonnull final WriteContext writeContext)
throws WriteFailedException {
-
+ lispStateCheckService.checkLispEnabled(writeContext);
checkNotNull(dataAfter, "Data is null");
checkNotNull(dataAfter.getIpAddress(), "Address is null");
@@ -71,7 +73,7 @@ public class MapResolverCustomizer extends FutureJVppCustomizer
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<MapResolver> id,
@Nonnull final MapResolver dataBefore, @Nonnull final WriteContext writeContext)
throws WriteFailedException {
-
+ lispStateCheckService.checkLispEnabled(writeContext);
checkNotNull(dataBefore, "Data is null");
checkNotNull(dataBefore.getIpAddress(), "Address is null");
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizer.java
index 9697e16bc..ec2b3b37a 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizer.java
@@ -17,32 +17,34 @@
package io.fd.hc2vpp.lisp.translate.write;
import io.fd.hc2vpp.common.translate.util.AddressTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispAddDelMapServer;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.map.servers.MapServer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.map.servers.MapServerKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import javax.annotation.Nonnull;
-
-public class MapServerCustomizer extends FutureJVppCustomizer
+public class MapServerCustomizer extends CheckedLispCustomizer
implements ListWriterCustomizer<MapServer, MapServerKey>, AddressTranslator,
JvppReplyConsumer {
- public MapServerCustomizer(@Nonnull FutureJVppCore futureJVppCore) {
- super(futureJVppCore);
+ public MapServerCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJVppCore, lispStateCheckService);
}
@Override
public void writeCurrentAttributes(@Nonnull InstanceIdentifier<MapServer> instanceIdentifier,
@Nonnull MapServer mapServer,
@Nonnull WriteContext writeContext) throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
addDelMapServer(true, instanceIdentifier, mapServer);
}
@@ -57,6 +59,7 @@ public class MapServerCustomizer extends FutureJVppCustomizer
@Override
public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<MapServer> instanceIdentifier, @Nonnull MapServer mapServer, @Nonnull WriteContext writeContext) throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
addDelMapServer(false, instanceIdentifier, mapServer);
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizer.java
index d3a381490..728de8fca 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizer.java
@@ -16,34 +16,35 @@
package io.fd.hc2vpp.lisp.translate.write;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import io.fd.hc2vpp.common.translate.util.AddressTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispUsePetr;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.use.petr.cfg.grouping.PetrCfg;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import javax.annotation.Nonnull;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-public class PetrCfgCustomizer extends FutureJVppCustomizer
+public class PetrCfgCustomizer extends CheckedLispCustomizer
implements WriterCustomizer<PetrCfg>, AddressTranslator, JvppReplyConsumer {
- public PetrCfgCustomizer(@Nonnull FutureJVppCore futureJVppCore) {
- super(futureJVppCore);
+ public PetrCfgCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJVppCore, lispStateCheckService);
}
@Override
public void writeCurrentAttributes(@Nonnull InstanceIdentifier<PetrCfg> instanceIdentifier,
@Nonnull PetrCfg petrCfg,
@Nonnull WriteContext writeContext) throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
enablePetrCfg(instanceIdentifier, petrCfg);
}
@@ -52,6 +53,7 @@ public class PetrCfgCustomizer extends FutureJVppCustomizer
@Nonnull PetrCfg petrCfgBefore,
@Nonnull PetrCfg petrCfgAfter,
@Nonnull WriteContext writeContext) throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
if (petrCfgAfter.getPetrAddress() != null) {
enablePetrCfg(instanceIdentifier, petrCfgAfter);
} else {
@@ -61,6 +63,7 @@ public class PetrCfgCustomizer extends FutureJVppCustomizer
@Override
public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<PetrCfg> instanceIdentifier, @Nonnull PetrCfg petrCfg, @Nonnull WriteContext writeContext) throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
disablePetrCfg(instanceIdentifier);
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizer.java
index d057c9e83..39986e152 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizer.java
@@ -19,35 +19,39 @@ package io.fd.hc2vpp.lisp.translate.write;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.nio.charset.StandardCharsets.UTF_8;
-import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import java.util.concurrent.TimeoutException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.pitr.cfg.grouping.PitrCfg;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import io.fd.vpp.jvpp.VppBaseCallException;
import io.fd.vpp.jvpp.core.dto.LispPitrSetLocatorSet;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.pitr.cfg.grouping.PitrCfg;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
* Customizer for {@code PitrCfg}
*/
-public class PitrCfgCustomizer extends FutureJVppCustomizer
+public class PitrCfgCustomizer extends CheckedLispCustomizer
implements WriterCustomizer<PitrCfg>, JvppReplyConsumer, ByteDataTranslator {
private static final String DEFAULT_LOCATOR_SET_NAME = "N/A";
- public PitrCfgCustomizer(FutureJVppCore futureJvpp) {
- super(futureJvpp);
+ public PitrCfgCustomizer(@Nonnull final FutureJVppCore futureJvpp,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJvpp, lispStateCheckService);
}
@Override
public void writeCurrentAttributes(InstanceIdentifier<PitrCfg> id, PitrCfg dataAfter, WriteContext writeContext)
throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
checkNotNull(dataAfter, "PitrCfg is null");
checkNotNull(dataAfter.getLocatorSet(), "Locator set name is null");
@@ -61,6 +65,7 @@ public class PitrCfgCustomizer extends FutureJVppCustomizer
@Override
public void updateCurrentAttributes(InstanceIdentifier<PitrCfg> id, PitrCfg dataBefore, PitrCfg dataAfter,
WriteContext writeContext) throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
checkNotNull(dataAfter, "PitrCfg is null");
checkNotNull(dataAfter.getLocatorSet(), "Locator set name is null");
@@ -74,6 +79,7 @@ public class PitrCfgCustomizer extends FutureJVppCustomizer
@Override
public void deleteCurrentAttributes(InstanceIdentifier<PitrCfg> id, PitrCfg dataBefore, WriteContext writeContext)
throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
checkNotNull(dataBefore, "PitrCfg is null");
checkNotNull(dataBefore.getLocatorSet(), "Locator set name is null");
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizer.java
index b240d1d2e..e60563454 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizer.java
@@ -17,29 +17,31 @@
package io.fd.hc2vpp.lisp.translate.write;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispRlocProbeEnableDisable;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.rloc.probing.grouping.RlocProbe;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import javax.annotation.Nonnull;
-
-public class RlocProbeCustomizer extends FutureJVppCustomizer
+public class RlocProbeCustomizer extends CheckedLispCustomizer
implements WriterCustomizer<RlocProbe>, ByteDataTranslator, JvppReplyConsumer {
- public RlocProbeCustomizer(@Nonnull FutureJVppCore futureJVppCore) {
- super(futureJVppCore);
+ public RlocProbeCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJVppCore, lispStateCheckService);
}
@Override
public void writeCurrentAttributes(@Nonnull InstanceIdentifier<RlocProbe> instanceIdentifier,
@Nonnull RlocProbe rlocProbe,
@Nonnull WriteContext writeContext) throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
enableDisableRlocProbe(rlocProbe.isEnabled(), instanceIdentifier);
}
@@ -48,6 +50,7 @@ public class RlocProbeCustomizer extends FutureJVppCustomizer
@Nonnull RlocProbe rlocProbeBefore,
@Nonnull RlocProbe rlocProbeAfter,
@Nonnull WriteContext writeContext) throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
enableDisableRlocProbe(rlocProbeAfter.isEnabled(), instanceIdentifier);
}
@@ -55,6 +58,7 @@ public class RlocProbeCustomizer extends FutureJVppCustomizer
public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<RlocProbe> instanceIdentifier,
@Nonnull RlocProbe rlocProbe,
@Nonnull WriteContext writeContext) throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
enableDisableRlocProbe(false, instanceIdentifier);
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizer.java
index 9effbebe8..05956d998 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizer.java
@@ -19,16 +19,17 @@ package io.fd.hc2vpp.lisp.translate.write;
import static com.google.common.base.Preconditions.checkState;
import com.google.common.base.Optional;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.hc2vpp.lisp.translate.util.CheckedLispCustomizer;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.util.RWUtils;
-
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.VniTable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.VniTableKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,17 +38,19 @@ import org.slf4j.LoggerFactory;
* This customizer serves only as a check if user is not trying to define VniTable <br>
* without mapping to vrf/bd
*/
-public class VniTableCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<VniTable, VniTableKey> {
+public class VniTableCustomizer extends CheckedLispCustomizer implements ListWriterCustomizer<VniTable, VniTableKey> {
private static final Logger LOG = LoggerFactory.getLogger(VniTableCustomizer.class);
- public VniTableCustomizer(FutureJVppCore futureJvpp) {
- super(futureJvpp);
+ public VniTableCustomizer(@Nonnull final FutureJVppCore futureJvpp,
+ @Nonnull final LispStateCheckService lispStateCheckService) {
+ super(futureJvpp, lispStateCheckService);
}
@Override
public void writeCurrentAttributes(InstanceIdentifier<VniTable> id, VniTable dataAfter, WriteContext writeContext)
throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
checkAtLeastOnChildExists(id, writeContext, false);
}
@@ -60,6 +63,7 @@ public class VniTableCustomizer extends FutureJVppCustomizer implements ListWrit
@Override
public void deleteCurrentAttributes(InstanceIdentifier<VniTable> id, VniTable dataBefore, WriteContext writeContext)
throws WriteFailedException {
+ lispStateCheckService.checkLispEnabled(writeContext);
checkAtLeastOnChildExists(id, writeContext, true);
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/EidTableWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/EidTableWriterFactory.java
index 347e13001..9ffd04b8f 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/EidTableWriterFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/EidTableWriterFactory.java
@@ -65,7 +65,7 @@ public final class EidTableWriterFactory extends AbstractLispInfraFactoryBase im
@Override
public void init(final ModifiableWriterRegistryBuilder registry) {
- registry.add(new GenericListWriter<>(VNI_TABLE_ID, new VniTableCustomizer(vppApi)));
+ registry.add(new GenericListWriter<>(VNI_TABLE_ID, new VniTableCustomizer(vppApi, lispStateCheckService)));
registry.add(new GenericWriter<>(VRF_SUBTABLE_ID, new VrfSubtableCustomizer(vppApi)));
registry.add(new GenericWriter<>(BRIDGE_DOMAIN_SUBTABLE_ID,
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 ed7d2122a..46cb9da7b 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
@@ -30,6 +30,7 @@ import io.fd.honeycomb.translate.impl.write.GenericWriter;
import io.fd.honeycomb.translate.write.WriterFactory;
import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.Lisp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegister;
@@ -50,21 +51,26 @@ public final class LispWriterFactory extends AbstractLispInfraFactoryBase implem
@Override
public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
- registry.add(new GenericWriter<>(LISP_INSTANCE_IDENTIFIER, new LispCustomizer(vppApi)));
+ // lisp must be enabled before interfaces
+ // because as a byproduct of enabling lisp, lisp_gpe interface is created
+ // and in scenario when vpp data are lost, it would end up calling
+ // sw_interface_set_flags for non existing interface index
+ registry.addBefore(new GenericWriter<>(LISP_INSTANCE_IDENTIFIER, new LispCustomizer(vppApi)),
+ InstanceIdentifier.create(Interfaces.class));
registry.addAfter(writer(LISP_FEATURE_IDENTIFIER.child(PitrCfg.class),
- new PitrCfgCustomizer(vppApi)), LOCATOR_SET_ID);
+ new PitrCfgCustomizer(vppApi, lispStateCheckService)), LOCATOR_SET_ID);
registry.add(writer(LISP_FEATURE_IDENTIFIER.child(MapRegister.class),
- new MapRegisterCustomizer(vppApi)));
+ new MapRegisterCustomizer(vppApi, lispStateCheckService)));
registry.add(writer(LISP_FEATURE_IDENTIFIER.child(MapRequestMode.class),
- new MapRequestModeCustomizer(vppApi)));
+ new MapRequestModeCustomizer(vppApi, lispStateCheckService)));
registry.add(writer(LISP_FEATURE_IDENTIFIER.child(PetrCfg.class),
- new PetrCfgCustomizer(vppApi)));
+ new PetrCfgCustomizer(vppApi, lispStateCheckService)));
registry.add(writer(LISP_FEATURE_IDENTIFIER.child(RlocProbe.class),
- new RlocProbeCustomizer(vppApi)));
+ new RlocProbeCustomizer(vppApi, lispStateCheckService)));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LocatorSetWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LocatorSetWriterFactory.java
index cc173df60..7c02752f5 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LocatorSetWriterFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LocatorSetWriterFactory.java
@@ -45,7 +45,8 @@ public final class LocatorSetWriterFactory extends AbstractLispInfraFactoryBase
@Override
public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
// LocatorSet must be written before eid table entries, because local mappings under eid-table are referencing it
- registry.addBefore(new GenericListWriter<>(LOCATOR_SET_ID, new LocatorSetCustomizer(vppApi, locatorSetContext)),
+ registry.addBefore(new GenericListWriter<>(LOCATOR_SET_ID,
+ new LocatorSetCustomizer(vppApi, locatorSetContext, lispStateCheckService)),
Arrays.asList(VRF_SUBTABLE_ID.child(LocalMappings.class).child(LocalMapping.class),
BRIDGE_DOMAIN_SUBTABLE_ID.child(LocalMappings.class).child(LocalMapping.class)));
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapResolverWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapResolverWriterFactory.java
index 11fe99d89..b60ee16fe 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapResolverWriterFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapResolverWriterFactory.java
@@ -38,6 +38,6 @@ public final class MapResolverWriterFactory extends AbstractLispInfraFactoryBase
public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
registry.add(new GenericListWriter<>(
LISP_CONFIG_IDENTIFIER.child(LispFeatureData.class).child(MapResolvers.class).child(MapResolver.class),
- new MapResolverCustomizer(vppApi)));
+ new MapResolverCustomizer(vppApi, lispStateCheckService)));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapServerWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapServerWriterFactory.java
index fc0cc4d10..e18b2478f 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapServerWriterFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapServerWriterFactory.java
@@ -32,6 +32,6 @@ public class MapServerWriterFactory extends AbstractLispInfraFactoryBase impleme
public void init(@Nonnull ModifiableWriterRegistryBuilder registry) {
registry.add(new GenericListWriter<>(
LISP_CONFIG_IDENTIFIER.child(LispFeatureData.class).child(MapServers.class).child(MapServer.class),
- new MapServerCustomizer(vppApi)));
+ new MapServerCustomizer(vppApi, lispStateCheckService)));
}
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java
index 77cb77808..1ae56ac49 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
import io.fd.vpp.jvpp.VppCallbackException;
import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocs;
import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocsReply;
@@ -46,7 +45,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class ItrRemoteLocatorSetCustomizerTest
- extends ReaderCustomizerTest<ItrRemoteLocatorSet, ItrRemoteLocatorSetBuilder> {
+ extends LispInitializingReaderCustomizerTest<ItrRemoteLocatorSet, ItrRemoteLocatorSetBuilder> {
private static final String EXPECTED_LOCATOR_SET_NAME = "loc-set";
@@ -61,11 +60,12 @@ public class ItrRemoteLocatorSetCustomizerTest
public void setUp() throws Exception {
validId = InstanceIdentifier.create(ItrRemoteLocatorSet.class);
builder = new ItrRemoteLocatorSetBuilder();
+ mockLispEnabled();
}
@Override
protected ReaderCustomizer<ItrRemoteLocatorSet, ItrRemoteLocatorSetBuilder> initCustomizer() {
- return new ItrRemoteLocatorSetCustomizer(api);
+ return new ItrRemoteLocatorSetCustomizer(api, lispStateCheckService);
}
@Test
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingListReaderCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingListReaderCustomizerTest.java
new file mode 100644
index 000000000..b1af21fca
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingListReaderCustomizerTest.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.lisp.translate.read;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.read.InitializingListReaderCustomizerTest;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import java.util.List;
+import java.util.Objects;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.Identifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public abstract class LispInitializingListReaderCustomizerTest<D extends DataObject & Identifiable<K>, K extends Identifier<D>, B extends Builder<D>>
+ extends InitializingListReaderCustomizerTest<D, K, B> {
+
+ @Mock
+ protected LispStateCheckService lispStateCheckService;
+
+ protected LispInitializingListReaderCustomizerTest(final Class<D> dataObjectClass,
+ final Class<? extends Builder<? extends DataObject>> parentBuilderClass) {
+ super(dataObjectClass, parentBuilderClass);
+ }
+
+ protected void mockLispEnabled() {
+ when(lispStateCheckService.lispEnabled(any(ReadContext.class))).thenReturn(true);
+ }
+
+ @Test
+ public void testNoInteractionsWhenLispDisabledOnReadSpecific() throws ReadFailedException {
+ when(lispStateCheckService.lispEnabled(any(ReadContext.class))).thenReturn(false);
+ final InstanceIdentifier<D> identifier = InstanceIdentifier.create(dataObjectClass);
+ final B builderTouched = getCustomizer().getBuilder(identifier);
+ final B builderUntouched = getCustomizer().getBuilder(identifier);
+ getCustomizer().readCurrentAttributes(identifier, builderTouched, ctx);
+ assertTrue("No interactions with builder expected while lisp is disabled",
+ Objects.equals(builderTouched.build(), builderUntouched.build()));
+ }
+
+ @Test
+ public void testNoInteractionsWhenLispDisabledOnReadAll() throws ReadFailedException {
+ when(lispStateCheckService.lispEnabled(any(ReadContext.class))).thenReturn(false);
+ final InstanceIdentifier<D> identifier = InstanceIdentifier.create(dataObjectClass);
+ final List<K> allIds = getCustomizer().getAllIds(identifier, ctx);
+ assertTrue("No ids should be returned while lisp is disabled", allIds.isEmpty());
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingReaderCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingReaderCustomizerTest.java
new file mode 100644
index 000000000..a686a86d3
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitializingReaderCustomizerTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.lisp.translate.read;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import java.util.Objects;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public abstract class LispInitializingReaderCustomizerTest<D extends DataObject, B extends Builder<D>> extends
+ InitializingReaderCustomizerTest<D, B> {
+
+ @Mock
+ protected LispStateCheckService lispStateCheckService;
+
+ public LispInitializingReaderCustomizerTest(final Class<D> dataObjectClass,
+ final Class<? extends Builder<? extends DataObject>> parentBuilderClass) {
+ super(dataObjectClass, parentBuilderClass);
+ }
+
+ protected void mockLispEnabled() {
+ when(lispStateCheckService.lispEnabled(any(ReadContext.class))).thenReturn(true);
+ }
+
+ @Test
+ public void testNoInteractionsWhileLispDisabled() throws ReadFailedException {
+ when(lispStateCheckService.lispEnabled(any(ReadContext.class))).thenReturn(false);
+ final InstanceIdentifier<D> identifier = InstanceIdentifier.create(dataObjectClass);
+ final B builderTouched = getCustomizer().getBuilder(identifier);
+ final B builderUntouched = getCustomizer().getBuilder(identifier);
+ getCustomizer().readCurrentAttributes(identifier, builderTouched, ctx);
+ assertTrue("No interactions with builder expected while lisp is disabled",
+ Objects.equals(builderTouched.build(), builderUntouched.build()));
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java
index b6773d2b2..82c4ceff2 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java
@@ -16,21 +16,23 @@
package io.fd.hc2vpp.lisp.translate.read;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import io.fd.hc2vpp.common.test.read.InitializingListReaderCustomizerTest;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.test.tools.HoneycombTestRunner;
import io.fd.honeycomb.test.tools.annotations.InjectTestData;
-import io.fd.honeycomb.test.tools.annotations.InjectablesProcessor;
-import io.fd.honeycomb.test.tools.annotations.SchemaContextProvider;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetails;
import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.$YangModuleInfoImpl;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.Lisp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.LispState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureData;
@@ -39,21 +41,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.locator.sets.grouping.locator.sets.LocatorSet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.locator.sets.grouping.locator.sets.LocatorSetBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.locator.sets.grouping.locator.sets.LocatorSetKey;
-import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-
@RunWith(HoneycombTestRunner.class)
public class LocatorSetCustomizerTest
- extends InitializingListReaderCustomizerTest<LocatorSet, LocatorSetKey, LocatorSetBuilder>
+ extends LispInitializingListReaderCustomizerTest<LocatorSet, LocatorSetKey, LocatorSetBuilder>
implements LispInitTest {
private static final String LOC_1_PATH = "/lisp:lisp-state" +
@@ -74,6 +67,7 @@ public class LocatorSetCustomizerTest
defineDumpData();
defineMapping(mappingContext, "loc-set", 1, "locator-set-context");
+ mockLispEnabled();
}
private void defineDumpData() {
@@ -125,6 +119,6 @@ public class LocatorSetCustomizerTest
@Override
protected ReaderCustomizer<LocatorSet, LocatorSetBuilder> initCustomizer() {
- return new LocatorSetCustomizer(api, new NamingContext("loc", "locator-set-context"));
+ return new LocatorSetCustomizer(api, new NamingContext("loc", "locator-set-context"), lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java
index 9dc1913c5..1b582cd4d 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java
@@ -20,7 +20,6 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.ShowLispMapRegisterStateReply;
import org.junit.Before;
@@ -30,7 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegisterBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class MapRegisterCustomizerTest extends InitializingReaderCustomizerTest implements LispInitTest {
+public class MapRegisterCustomizerTest extends LispInitializingReaderCustomizerTest implements LispInitTest {
private static final InstanceIdentifier<MapRegister> STATE_IID = LISP_STATE_FTR_IID.child(MapRegister.class);
private static final InstanceIdentifier<MapRegister> CONFIG_IID = LISP_FTR_IID.child(MapRegister.class);
@@ -44,6 +43,7 @@ public class MapRegisterCustomizerTest extends InitializingReaderCustomizerTest
final ShowLispMapRegisterStateReply reply = new ShowLispMapRegisterStateReply();
reply.isEnabled = 1;
when(api.showLispMapRegisterState(any())).thenReturn(future(reply));
+ mockLispEnabled();
}
@Test
@@ -61,6 +61,6 @@ public class MapRegisterCustomizerTest extends InitializingReaderCustomizerTest
@Override
protected ReaderCustomizer initCustomizer() {
- return new MapRegisterCustomizer(api);
+ return new MapRegisterCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java
index 85e6231f0..6479f992a 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java
@@ -21,19 +21,16 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MapRequestMode.DestinationOnly;
-import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
-import io.fd.honeycomb.test.tools.HoneycombTestRunner;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.ShowLispMapRequestModeReply;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.request.mode.grouping.MapRequestMode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.request.mode.grouping.MapRequestModeBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class MapRequestModeCustomizerTest extends InitializingReaderCustomizerTest implements LispInitTest {
+public class MapRequestModeCustomizerTest extends LispInitializingReaderCustomizerTest implements LispInitTest {
private static final InstanceIdentifier<MapRequestMode> STATE_IID = LISP_STATE_FTR_IID.child(MapRequestMode.class);
private static final InstanceIdentifier<MapRequestMode> CONFIG_IID = LISP_FTR_IID.child(MapRequestMode.class);
@@ -47,6 +44,7 @@ public class MapRequestModeCustomizerTest extends InitializingReaderCustomizerTe
final ShowLispMapRequestModeReply reply = new ShowLispMapRequestModeReply();
reply.mode = ((byte) DestinationOnly.getIntValue());
when(api.showLispMapRequestMode(any())).thenReturn(future(reply));
+ mockLispEnabled();
}
@Test
@@ -64,6 +62,6 @@ public class MapRequestModeCustomizerTest extends InitializingReaderCustomizerTe
@Override
protected ReaderCustomizer initCustomizer() {
- return new MapRequestModeCustomizer(api);
+ return new MapRequestModeCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java
index 5d0be3705..e4a0d9990 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizerTest.java
@@ -23,7 +23,6 @@ import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableList;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest;
import io.fd.vpp.jvpp.core.dto.LispMapResolverDetails;
import io.fd.vpp.jvpp.core.dto.LispMapResolverDetailsReplyDump;
import java.util.List;
@@ -40,7 +39,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class MapResolverCustomizerTest
- extends ListReaderCustomizerTest<MapResolver, MapResolverKey, MapResolverBuilder> {
+ extends LispInitializingListReaderCustomizerTest<MapResolver, MapResolverKey, MapResolverBuilder> {
private static final IpAddress IP_ADDRESS_REVERTED =
new IpAddress(new Ipv4AddressNoZone("1.2.168.192"));
@@ -59,6 +58,7 @@ public class MapResolverCustomizerTest
validId = InstanceIdentifier.create(MapResolvers.class)
.child(MapResolver.class, new MapResolverKey(IP_ADDRESS_REVERTED));
defineDumpData();
+ mockLispEnabled();
}
@Test
@@ -97,6 +97,6 @@ public class MapResolverCustomizerTest
@Override
protected ReaderCustomizer<MapResolver, MapResolverBuilder> initCustomizer() {
- return new MapResolverCustomizer(api);
+ return new MapResolverCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java
index 1af22931e..ace07e078 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.read.InitializingListReaderCustomizerTest;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.LispMapServerDetails;
import io.fd.vpp.jvpp.core.dto.LispMapServerDetailsReplyDump;
@@ -44,7 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class MapServerCustomizerTest
- extends InitializingListReaderCustomizerTest<MapServer, MapServerKey, MapServerBuilder>
+ extends LispInitializingListReaderCustomizerTest<MapServer, MapServerKey, MapServerBuilder>
implements LispInitTest {
private static final MapServerKey
@@ -79,6 +78,7 @@ public class MapServerCustomizerTest
reply.lispMapServerDetails = Arrays.asList(server1, server2, server3);
when(api.lispMapServerDump(any(LispMapServerDump.class))).thenReturn(future(reply));
+ mockLispEnabled();
}
@Test
@@ -107,6 +107,6 @@ public class MapServerCustomizerTest
@Override
protected ReaderCustomizer<MapServer, MapServerBuilder> initCustomizer() {
- return new MapServerCustomizer(api);
+ return new MapServerCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java
index 107523292..4052b161f 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.ShowLispUsePetrReply;
import org.junit.Test;
@@ -32,7 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.use.petr.cfg.grouping.PetrCfgBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class PetrCfgCustomizerTest extends InitializingReaderCustomizerTest implements LispInitTest {
+public class PetrCfgCustomizerTest extends LispInitializingReaderCustomizerTest implements LispInitTest {
private static final InstanceIdentifier<PetrCfg> STATE_IID = LISP_STATE_FTR_IID.child(PetrCfg.class);
private static final InstanceIdentifier<PetrCfg> CONFIG_IID = LISP_FTR_IID.child(PetrCfg.class);
@@ -54,6 +53,11 @@ public class PetrCfgCustomizerTest extends InitializingReaderCustomizerTest impl
when(api.showLispUsePetr(any())).thenReturn(future(reply));
}
+ @Override
+ protected void setUp() throws Exception {
+ mockLispEnabled();
+ }
+
@Test
public void readCurrentAttributesEnabled() throws Exception {
mockEnabledReply();
@@ -79,6 +83,6 @@ public class PetrCfgCustomizerTest extends InitializingReaderCustomizerTest impl
@Override
protected ReaderCustomizer initCustomizer() {
- return new PetrCfgCustomizer(api);
+ return new PetrCfgCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java
index c1ffc17ea..c61c13b49 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PitrCfgCustomizerTest.java
@@ -22,19 +22,17 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
+import io.fd.vpp.jvpp.core.dto.ShowLispPitrReply;
import java.nio.charset.StandardCharsets;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.LispStateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.pitr.cfg.grouping.PitrCfg;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.pitr.cfg.grouping.PitrCfgBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.dto.ShowLispPitrReply;
-public class PitrCfgCustomizerTest extends ReaderCustomizerTest<PitrCfg, PitrCfgBuilder> {
+public class PitrCfgCustomizerTest extends LispInitializingReaderCustomizerTest<PitrCfg, PitrCfgBuilder> {
private static final byte[] LOC_SET_NAME_BYTES = "loc-set".getBytes(StandardCharsets.UTF_8);
@@ -49,6 +47,7 @@ public class PitrCfgCustomizerTest extends ReaderCustomizerTest<PitrCfg, PitrCfg
emptyId = InstanceIdentifier.create(PitrCfg.class);
mockDumpData();
+ mockLispEnabled();
}
@Test
@@ -72,6 +71,6 @@ public class PitrCfgCustomizerTest extends ReaderCustomizerTest<PitrCfg, PitrCfg
@Override
protected ReaderCustomizer<PitrCfg, PitrCfgBuilder> initCustomizer() {
- return new PitrCfgCustomizer(api);
+ return new PitrCfgCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java
index f5d235358..2afe7120f 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java
@@ -20,7 +20,6 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.ShowLispRlocProbeStateReply;
import org.junit.Before;
@@ -30,7 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.rloc.probing.grouping.RlocProbeBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class RlocProbeCustomizerTest extends InitializingReaderCustomizerTest implements LispInitTest {
+public class RlocProbeCustomizerTest extends LispInitializingReaderCustomizerTest implements LispInitTest {
private static final InstanceIdentifier<RlocProbe> STATE_IID = LISP_STATE_FTR_IID.child(RlocProbe.class);
private static final InstanceIdentifier<RlocProbe> CONFIG_IID = LISP_FTR_IID.child(RlocProbe.class);
@@ -44,6 +43,7 @@ public class RlocProbeCustomizerTest extends InitializingReaderCustomizerTest im
final ShowLispRlocProbeStateReply reply = new ShowLispRlocProbeStateReply();
reply.isEnabled = 1;
when(api.showLispRlocProbeState(any())).thenReturn(future(reply));
+ mockLispEnabled();
}
@Test
@@ -62,6 +62,6 @@ public class RlocProbeCustomizerTest extends InitializingReaderCustomizerTest im
@Override
protected ReaderCustomizer initCustomizer() {
- return new RlocProbeCustomizer(api);
+ return new RlocProbeCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java
index c25906e9c..f9610a1aa 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/VniTableCustomizerTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableList;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest;
import io.fd.vpp.jvpp.VppCallbackException;
import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetails;
import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetailsReplyDump;
@@ -42,7 +41,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.VniTableKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class VniTableCustomizerTest extends ListReaderCustomizerTest<VniTable, VniTableKey, VniTableBuilder> {
+public class VniTableCustomizerTest extends LispInitializingListReaderCustomizerTest<VniTable, VniTableKey, VniTableBuilder> {
private InstanceIdentifier<VniTable> validId;
@@ -53,6 +52,7 @@ public class VniTableCustomizerTest extends ListReaderCustomizerTest<VniTable, V
@Before
public void init() {
validId = InstanceIdentifier.create(EidTable.class).child(VniTable.class, new VniTableKey(12L));
+ mockLispEnabled();
}
@Test
@@ -116,6 +116,6 @@ public class VniTableCustomizerTest extends ListReaderCustomizerTest<VniTable, V
@Override
protected ReaderCustomizer<VniTable, VniTableBuilder> initCustomizer() {
- return new VniTableCustomizer(api);
+ return new VniTableCustomizer(api, lispStateCheckService);
}
} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImplTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImplTest.java
new file mode 100644
index 000000000..d5a351ca8
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/service/LispStateCheckServiceImplTest.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.lisp.translate.service;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import com.google.common.base.Optional;
+import io.fd.hc2vpp.common.test.util.FutureProducer;
+import io.fd.honeycomb.translate.ModificationCache;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.vpp.jvpp.core.dto.ShowLispStatusReply;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.LispBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class LispStateCheckServiceImplTest implements FutureProducer {
+
+ private LispStateCheckService impl;
+
+ @Mock
+ private FutureJVppCore vppApi;
+
+ @Mock
+ private WriteContext writeContext;
+
+ @Mock
+ private ReadContext readContext;
+
+ @Before
+ public void init() {
+ initMocks(this);
+ impl = new LispStateCheckServiceImpl(vppApi);
+ when(readContext.getModificationCache()).thenReturn(new ModificationCache());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testCheckLispEnabledNoConfig() throws Exception {
+ when(writeContext.readAfter(InstanceIdentifier.create(Lisp.class))).thenReturn(Optional.absent());
+ impl.checkLispEnabled(writeContext);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testCheckLispEnabledDisabledConfig() throws Exception {
+ when(writeContext.readAfter(InstanceIdentifier.create(Lisp.class)))
+ .thenReturn(Optional.of(new LispBuilder().setEnable(false).build()));
+ impl.checkLispEnabled(writeContext);
+ }
+
+ @Test
+ public void testCheckLispEnabledEnabledConfig() throws Exception {
+ // no exception should be thrown here
+ when(writeContext.readAfter(InstanceIdentifier.create(Lisp.class)))
+ .thenReturn(Optional.of(new LispBuilder().setEnable(true).build()));
+ impl.checkLispEnabled(writeContext);
+ }
+
+ @Test
+ public void testLispEnabledDisabledDump() throws Exception {
+ when(vppApi.showLispStatus(any())).thenReturn(future(new ShowLispStatusReply()));
+ assertFalse(impl.lispEnabled(readContext));
+ }
+
+ @Test
+ public void testLispEnabledEnabledDump() throws Exception {
+ final ShowLispStatusReply reply = new ShowLispStatusReply();
+ reply.featureStatus = 1;
+ when(vppApi.showLispStatus(any())).thenReturn(future(reply));
+ assertTrue(impl.lispEnabled(readContext));
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java
index 22d1298a7..e11ec4262 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
-import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.VppCallbackException;
@@ -44,7 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.itr.remote.locator.sets.grouping.ItrRemoteLocatorSetBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class ItrRemoteLocatorSetCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
+public class ItrRemoteLocatorSetCustomizerTest extends LispWriterCustomizerTest implements ByteDataTranslator {
private static final String VALID_NAME = "loc-set";
@@ -58,7 +57,7 @@ public class ItrRemoteLocatorSetCustomizerTest extends WriterCustomizerTest impl
@Before
public void setUpTest() throws Exception {
initMocks(this);
- customizer = new ItrRemoteLocatorSetCustomizer(api);
+ customizer = new ItrRemoteLocatorSetCustomizer(api, lispStateCheckService);
validId = InstanceIdentifier.create(ItrRemoteLocatorSet.class);
validData = new ItrRemoteLocatorSetBuilder().setRemoteLocatorSetName(VALID_NAME).build();
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispWriterCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispWriterCustomizerTest.java
new file mode 100644
index 000000000..a2d772159
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LispWriterCustomizerTest.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.lisp.translate.write;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.hc2vpp.lisp.translate.service.LispStateCheckService;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.mockito.Mock;
+
+public abstract class LispWriterCustomizerTest extends WriterCustomizerTest{
+
+ @Mock
+ protected LispStateCheckService lispStateCheckService;
+
+ protected void mockLispDisabled(){
+ doThrow(IllegalArgumentException.class)
+ .when(lispStateCheckService).checkLispEnabled(any(WriteContext.class));
+ }
+
+
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java
index 65544903b..50cba9dd5 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java
@@ -24,11 +24,11 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
-import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispAddDelLocatorSet;
@@ -55,7 +55,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.locator.sets.grouping.locator.sets.locator.set.InterfaceBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class LocatorSetCustomizerTest extends WriterCustomizerTest {
+public class LocatorSetCustomizerTest extends LispWriterCustomizerTest {
private static final InstanceIdentifier<EidTable>
EID_TABLE_ID = InstanceIdentifier.create(Lisp.class)
@@ -68,9 +68,13 @@ public class LocatorSetCustomizerTest extends WriterCustomizerTest {
private LocatorSetCustomizer customizer;
+ private final InstanceIdentifier<LocatorSet> EMPTY_ID = InstanceIdentifier.create(LocatorSet.class);
+ private final LocatorSet EMPTY_DATA = new LocatorSetBuilder().build();
+
@Override
public void setUpTest() {
- customizer = new LocatorSetCustomizer(api, new NamingContext("locator-set", "locator-set-context"));
+ customizer = new LocatorSetCustomizer(api, new NamingContext("locator-set", "locator-set-context"),
+ lispStateCheckService);
}
@Test(expected = NullPointerException.class)
@@ -197,6 +201,30 @@ public class LocatorSetCustomizerTest extends WriterCustomizerTest {
fail("testDeleteReferenced should have failed");
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
private static Optional<EidTable> eidTableData() {
return Optional.of(new EidTableBuilder()
.setVniTable(
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java
index 0eb5d1148..30ab07cb8 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapRegisterCustomizerTest.java
@@ -17,13 +17,15 @@
package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispMapRegisterEnableDisable;
import io.fd.vpp.jvpp.core.dto.LispMapRegisterEnableDisableReply;
import org.junit.Test;
@@ -33,7 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegisterBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class MapRegisterCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
+public class MapRegisterCustomizerTest extends LispWriterCustomizerTest implements ByteDataTranslator {
private static final InstanceIdentifier<MapRegister> ID = InstanceIdentifier.create(MapRegister.class);
private MapRegisterCustomizer customizer;
@@ -42,10 +44,13 @@ public class MapRegisterCustomizerTest extends WriterCustomizerTest implements B
@Captor
private ArgumentCaptor<LispMapRegisterEnableDisable> requestCaptor;
+ private InstanceIdentifier<MapRegister> EMPTY_ID = InstanceIdentifier.create(MapRegister.class);
+ private MapRegister EMPTY_DATA = new MapRegisterBuilder().setEnabled(false).build();
+
@Override
protected void setUpTest() throws Exception {
- customizer = new MapRegisterCustomizer(api);
+ customizer = new MapRegisterCustomizer(api, lispStateCheckService);
enabledRegister = new MapRegisterBuilder()
.setEnabled(true)
@@ -83,6 +88,42 @@ public class MapRegisterCustomizerTest extends WriterCustomizerTest implements B
verifyRequest(false);
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testUpdateLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
private void verifyRequest(final boolean enabled) {
verify(api, times(1)).lispMapRegisterEnableDisable(requestCaptor.capture());
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 d66097ad2..66384a495 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
@@ -17,14 +17,16 @@
package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MapRequestMode.DestinationOnly;
import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MapRequestMode.SourceDestination;
-import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispMapRequestMode;
import io.fd.vpp.jvpp.core.dto.LispMapRequestModeReply;
import org.junit.Test;
@@ -34,7 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.request.mode.grouping.MapRequestModeBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class MapRequestModeCustomizerTest extends WriterCustomizerTest {
+public class MapRequestModeCustomizerTest extends LispWriterCustomizerTest {
private static final InstanceIdentifier<MapRequestMode> ID = InstanceIdentifier.create(MapRequestMode.class);
private MapRequestModeCustomizer customizer;
@@ -43,10 +45,12 @@ public class MapRequestModeCustomizerTest extends WriterCustomizerTest {
@Captor
private ArgumentCaptor<LispMapRequestMode> requestCaptor;
+ private InstanceIdentifier<MapRequestMode> EMPTY_ID = InstanceIdentifier.create(MapRequestMode.class);
+ private MapRequestMode EMPTY_DATA = new MapRequestModeBuilder().build();
@Override
protected void setUpTest() throws Exception {
- customizer = new MapRequestModeCustomizer(api);
+ customizer = new MapRequestModeCustomizer(api, lispStateCheckService);
sourceDestinationMode = new MapRequestModeBuilder()
.setMode(SourceDestination)
.build();
@@ -73,6 +77,30 @@ public class MapRequestModeCustomizerTest extends WriterCustomizerTest {
verify(api, times(0)).lispMapRequestMode(any());
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testUpdateLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
private void verifyModeRequest(
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MapRequestMode mode) {
verify(api, times(1)).lispMapRequestMode(requestCaptor.capture());
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
index 474e20f65..76017a439 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
@@ -17,12 +17,13 @@
package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispAddDelMapResolver;
@@ -34,15 +35,18 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.resolvers.grouping.map.resolvers.MapResolver;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.resolvers.grouping.map.resolvers.MapResolverBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class MapResolverCustomizerTest extends WriterCustomizerTest implements Ipv4Translator {
+public class MapResolverCustomizerTest extends LispWriterCustomizerTest implements Ipv4Translator {
private MapResolverCustomizer customizer;
+ private InstanceIdentifier<MapResolver> EMPTY_ID = InstanceIdentifier.create(MapResolver.class);
+ private MapResolver EMPTY_DATA = new MapResolverBuilder().build();
@Override
public void setUpTest() {
- customizer = new MapResolverCustomizer(api);
+ customizer = new MapResolverCustomizer(api, lispStateCheckService);
}
private void whenLispAddDelMapResolverThenSuccess() {
@@ -100,4 +104,27 @@ public class MapResolverCustomizerTest extends WriterCustomizerTest implements I
assertEquals("192.168.2.1", arrayToIpv4AddressNoZone(request.ipAddress).getValue());
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java
index b69a44e68..a13905847 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java
@@ -18,12 +18,13 @@ package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispAddDelMapServer;
@@ -40,7 +41,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.map.servers.MapServerKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class MapServerCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
+public class MapServerCustomizerTest extends LispWriterCustomizerTest implements ByteDataTranslator {
private static final MapServerKey MAP_SERVER_KEY = new MapServerKey(
new IpAddress(new Ipv4Address("192.168.2.1")));
@@ -49,13 +50,15 @@ public class MapServerCustomizerTest extends WriterCustomizerTest implements Byt
private MapServerCustomizer customizer;
private MapServer data;
+ private InstanceIdentifier<MapServer> EMPTY_ID = InstanceIdentifier.create(MapServer.class);
+ private MapServer EMPTY_DATA = new MapServerBuilder().build();
@Captor
private ArgumentCaptor<LispAddDelMapServer> requestCaptor;
@Override
protected void setUpTest() throws Exception {
- customizer = new MapServerCustomizer(api);
+ customizer = new MapServerCustomizer(api, lispStateCheckService);
data = new MapServerBuilder()
.setIpAddress(MAP_SERVER_KEY.getIpAddress())
.build();
@@ -86,6 +89,30 @@ public class MapServerCustomizerTest extends WriterCustomizerTest implements Byt
verifyRequest(false);
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
private void verifyRequest(final boolean add) {
verify(api, times(1)).lispAddDelMapServer(requestCaptor.capture());
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java
index bd7475bb1..40660a727 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PetrCfgCustomizerTest.java
@@ -19,12 +19,14 @@ package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispUsePetr;
import io.fd.vpp.jvpp.core.dto.LispUsePetrReply;
import java.util.Arrays;
@@ -37,7 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.use.petr.cfg.grouping.PetrCfgBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class PetrCfgCustomizerTest extends WriterCustomizerTest {
+public class PetrCfgCustomizerTest extends LispWriterCustomizerTest {
private static final InstanceIdentifier<PetrCfg> ID = InstanceIdentifier.create(PetrCfg.class);
@@ -47,10 +49,12 @@ public class PetrCfgCustomizerTest extends WriterCustomizerTest {
@Captor
private ArgumentCaptor<LispUsePetr> requestCaptor;
+ private InstanceIdentifier<PetrCfg> EMPTY_ID = InstanceIdentifier.create(PetrCfg.class);
+ private PetrCfg EMPTY_DATA = new PetrCfgBuilder().build();
@Override
public void setUpTest() throws Exception {
- customizer = new PetrCfgCustomizer(api);
+ customizer = new PetrCfgCustomizer(api, lispStateCheckService);
enabledCfg = new PetrCfgBuilder().setPetrAddress(new IpAddress(new Ipv4Address("192.168.2.1"))).build();
disabledCfg = new PetrCfgBuilder().build();
when(api.lispUsePetr(any(LispUsePetr.class))).thenReturn(future(new LispUsePetrReply()));
@@ -80,6 +84,42 @@ public class PetrCfgCustomizerTest extends WriterCustomizerTest {
verifyDisabledInvoked();
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testUpdateLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
private void verifyEnabledInvoked() {
verify(api, times(1)).lispUsePetr(requestCaptor.capture());
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java
index 477509179..ae1b145da 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/PitrCfgCustomizerTest.java
@@ -17,13 +17,14 @@
package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispPitrSetLocatorSet;
import io.fd.vpp.jvpp.core.dto.LispPitrSetLocatorSetReply;
@@ -32,15 +33,18 @@ import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.pitr.cfg.grouping.PitrCfg;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.pitr.cfg.grouping.PitrCfgBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class PitrCfgCustomizerTest extends WriterCustomizerTest {
+public class PitrCfgCustomizerTest extends LispWriterCustomizerTest {
private PitrCfgCustomizer customizer;
+ private InstanceIdentifier<PitrCfg> EMPTY_ID = InstanceIdentifier.create(PitrCfg.class);
+ private PitrCfg EMPTY_DATA = new PitrCfgBuilder().build();
@Override
public void setUpTest() {
- customizer = new PitrCfgCustomizer(api);
+ customizer = new PitrCfgCustomizer(api, lispStateCheckService);
}
private void whenLispPitrSetLocatorSetThenSuccess() {
@@ -114,4 +118,40 @@ public class PitrCfgCustomizerTest extends WriterCustomizerTest {
assertEquals("Locator", new String(request.lsName));
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testUpdateLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java
index 829853e66..e2a6b3e9f 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RlocProbeCustomizerTest.java
@@ -17,13 +17,15 @@
package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.LispRlocProbeEnableDisable;
import io.fd.vpp.jvpp.core.dto.LispRlocProbeEnableDisableReply;
import org.junit.Test;
@@ -33,7 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.rloc.probing.grouping.RlocProbeBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class RlocProbeCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
+public class RlocProbeCustomizerTest extends LispWriterCustomizerTest implements ByteDataTranslator {
private static final InstanceIdentifier<RlocProbe> ID = InstanceIdentifier.create(RlocProbe.class);
private RlocProbeCustomizer customizer;
@@ -42,10 +44,12 @@ public class RlocProbeCustomizerTest extends WriterCustomizerTest implements Byt
@Captor
private ArgumentCaptor<LispRlocProbeEnableDisable> requestCaptor;
+ private InstanceIdentifier<RlocProbe> EMPTY_ID = InstanceIdentifier.create(RlocProbe.class);
+ private RlocProbe EMPTY_DATA = new RlocProbeBuilder().build();
@Override
protected void setUpTest() throws Exception {
- customizer = new RlocProbeCustomizer(api);
+ customizer = new RlocProbeCustomizer(api, lispStateCheckService);
enabledProbe = rlocProbe(true);
disabledProbe = rlocProbe(false);
when(api.lispRlocProbeEnableDisable(any(LispRlocProbeEnableDisable.class)))
@@ -76,6 +80,42 @@ public class RlocProbeCustomizerTest extends WriterCustomizerTest implements Byt
verifyRequest(false);
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testUpdateLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.updateCurrentAttributes(EMPTY_ID, EMPTY_DATA,EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
private static RlocProbe rlocProbe(final boolean enabled) {
return new RlocProbeBuilder().setEnabled(enabled).build();
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java
index 531907025..1bf4b772f 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizerTest.java
@@ -18,12 +18,12 @@ package io.fd.hc2vpp.lisp.translate.write;
import static org.junit.Assert.fail;
+import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.base.Optional;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.VniTable;
@@ -31,16 +31,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.vni.table.VrfSubtableBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class VniTableCustomizerTest extends WriterCustomizerTest {
+public class VniTableCustomizerTest extends LispWriterCustomizerTest {
private VniTableCustomizer customizer;
private InstanceIdentifier<VniTable> validId;
private VniTable validData;
+ private InstanceIdentifier<VniTable> EMPTY_ID = InstanceIdentifier.create(VniTable.class);
+ private VniTable EMPTY_DATA = new VniTableBuilder().build();
@Before
public void init() {
initMocks(this);
- customizer = new VniTableCustomizer(api);
+ customizer = new VniTableCustomizer(api, lispStateCheckService);
validId = InstanceIdentifier.create(VniTable.class);
validData = new VniTableBuilder()
@@ -85,6 +87,30 @@ public class VniTableCustomizerTest extends WriterCustomizerTest {
customizer.deleteCurrentAttributes(validId, validData, writeContext);
}
+ @Test
+ public void testWriteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.writeCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
+ @Test
+ public void testDeleteLispDisabled() throws WriteFailedException {
+ mockLispDisabled();
+ try {
+ customizer.deleteCurrentAttributes(EMPTY_ID, EMPTY_DATA, writeContext);
+ } catch (IllegalArgumentException e) {
+ verifyZeroInteractions(api);
+ return;
+ }
+ fail("Test should have thrown IllegalArgumentException");
+ }
+
private void whenReadBeforeReturnValid() {
when(writeContext.readBefore(validId)).thenReturn(Optional.of(validData));
}