summaryrefslogtreecommitdiffstats
path: root/ioam/impl/src
diff options
context:
space:
mode:
authorSagar Srivastav <sagsriva@cisco.com>2016-11-24 22:17:48 -0800
committerMarek Gradzki <mgradzki@cisco.com>2016-12-14 11:17:46 +0000
commit179623414d44d6d85ced60b0e99a2c47a7e0bbf6 (patch)
tree08f6408c7e80147d4d643fe9392874f8d9ed65cf /ioam/impl/src
parent480bb5e951a9fe19b4b306d1e27ca74d717394c9 (diff)
HC-256: support for iOAM - Proof Of Transit
Change-Id: Ib4260b9b11dbca7016b7b85763d9186d7add0f53 Signed-off-by: Sagar Srivastav <sagsriva@cisco.com>
Diffstat (limited to 'ioam/impl/src')
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/VppIoamModule.java25
-rw-r--r--ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizer.java149
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizer.java36
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/VppIoamWriterFactory.java27
-rw-r--r--ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/TraceProfileReaderCustomizer.java11
-rw-r--r--ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/VppIoamReaderFactory.java4
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoampotCustomizer.java45
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamtraceCustomizer.java (renamed from ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamCustomizer.java)18
-rw-r--r--ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java61
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java (renamed from ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamProvider.java)15
-rw-r--r--ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/VppIoamModuleTest.java39
-rw-r--r--ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizerTest.java193
-rw-r--r--ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizerTest.java29
13 files changed, 560 insertions, 92 deletions
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/VppIoamModule.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/VppIoamModule.java
index a378a0669..204d003c9 100755
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/VppIoamModule.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/VppIoamModule.java
@@ -20,11 +20,14 @@ import com.google.inject.AbstractModule;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
-import io.fd.hc2vpp.vppioam.impl.config.VppIoamWriterFactory;
import io.fd.hc2vpp.vppioam.impl.oper.VppIoamReaderFactory;
-import io.fd.hc2vpp.vppioam.impl.util.JVppIoamProvider;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.write.WriterFactory;
+import io.fd.hc2vpp.vppioam.impl.config.VppIoamWriterFactory;
+import io.fd.hc2vpp.vppioam.impl.util.JVppIoamPotProvider;
+import io.fd.hc2vpp.vppioam.impl.util.JVppIoamTraceProvider;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampot;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampotFacade;
import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtrace;
import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
import org.slf4j.Logger;
@@ -36,28 +39,32 @@ import org.slf4j.LoggerFactory;
public final class VppIoamModule extends AbstractModule {
private static final Logger LOG = LoggerFactory.getLogger(VppIoamModule.class);
- private final Class<? extends Provider<FutureJVppIoamtraceFacade>> jvppIoamProviderClass;
+ private final Class<? extends Provider<FutureJVppIoamtraceFacade>> jvppIoamTraceProviderClass;
+ private final Class<? extends Provider<FutureJVppIoampotFacade>> jvppIoamPotProviderClass;
public VppIoamModule() {
- this(JVppIoamProvider.class);
+ this(JVppIoamTraceProvider.class, JVppIoamPotProvider.class);
}
@VisibleForTesting
- VppIoamModule(Class<? extends Provider<FutureJVppIoamtraceFacade>> jvppIoamProvider) {
- this.jvppIoamProviderClass = jvppIoamProvider;
+ VppIoamModule(Class<? extends Provider<FutureJVppIoamtraceFacade>> jvppIoamTraceProvider,
+ Class<? extends Provider<FutureJVppIoampotFacade>> jvppIoamPotProviderClass) {
+ this.jvppIoamTraceProviderClass = jvppIoamTraceProvider;
+ this.jvppIoamPotProviderClass = jvppIoamPotProviderClass;
}
@Override
protected void configure() {
- LOG.debug("Installing iOAM module");
+ LOG.info("Installing iOAM module");
// Bind to Plugin's JVPP.
- bind(FutureJVppIoamtrace.class).toProvider(jvppIoamProviderClass).in(Singleton.class);
+ bind(FutureJVppIoamtrace.class).toProvider(jvppIoamTraceProviderClass).in(Singleton.class);
+ bind(FutureJVppIoampot.class).toProvider(jvppIoamPotProviderClass).in(Singleton.class);
// Below are classes picked up by HC framework
Multibinder.newSetBinder(binder(), WriterFactory.class).addBinding().to(VppIoamWriterFactory.class);
Multibinder.newSetBinder(binder(), ReaderFactory.class).addBinding().to(VppIoamReaderFactory.class);
- LOG.debug("Module iOAM successfully configured");
+ LOG.info("Module iOAM successfully configured");
}
}
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizer.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizer.java
new file mode 100644
index 000000000..6d80493a3
--- /dev/null
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizer.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2016 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.vppioam.impl.config;
+
+
+import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.vppioam.impl.util.FutureJVppIoampotCustomizer;
+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.ioampot.dto.PotProfileAdd;
+import io.fd.vpp.jvpp.ioampot.dto.PotProfileAddReply;
+import io.fd.vpp.jvpp.ioampot.dto.PotProfileDel;
+import io.fd.vpp.jvpp.ioampot.dto.PotProfileDelReply;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampot;
+import java.nio.charset.StandardCharsets;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profile.PotProfileList;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profiles.PotProfileSet;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profiles.PotProfileSetKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class IoamPotWriterCustomizer extends FutureJVppIoampotCustomizer implements
+ ListWriterCustomizer<PotProfileSet,PotProfileSetKey>, JvppReplyConsumer {
+
+ private static final Logger LOG = LoggerFactory.getLogger(IoamPotWriterCustomizer.class);
+
+ public IoamPotWriterCustomizer(@Nonnull FutureJVppIoampot futureJVppIoampot) {
+ super(futureJVppIoampot);
+ }
+
+
+ /**
+ * Handle write operation. C from CRUD.
+ *
+ * @param id Identifier(from root) of data being written
+ * @param dataAfter New data to be written
+ * @param writeContext Write context can be used to store any useful information and then utilized by other customizers
+ * @throws WriteFailedException if write was unsuccessful
+ */
+ @Override
+ public void writeCurrentAttributes(@Nonnull InstanceIdentifier<PotProfileSet> id,
+ @Nonnull PotProfileSet dataAfter, @Nonnull WriteContext writeContext)
+ throws WriteFailedException {
+ try {
+ addPotProfile(dataAfter,id);
+ } catch (WriteFailedException exCreate) {
+ LOG.error("Add POT profile failed", exCreate);
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, exCreate);
+ }
+
+ LOG.info("POT profile added iid={}, added {}", id, dataAfter);
+ }
+
+ /**
+ * Handle update operation. U from CRUD.
+ *
+ * @param id Identifier(from root) of data being written
+ * @param dataBefore Old data
+ * @param dataAfter New, updated data
+ * @param writeContext Write context can be used to store any useful information and then utilized by other customizers
+ * @throws WriteFailedException if update was unsuccessful
+ */
+ @Override
+ public void updateCurrentAttributes(@Nonnull InstanceIdentifier<PotProfileSet> id,
+ @Nonnull PotProfileSet dataBefore, @Nonnull PotProfileSet dataAfter,
+ @Nonnull WriteContext writeContext) throws WriteFailedException {
+ try {
+ delPotProfile(dataBefore,id);
+ addPotProfile(dataAfter,id);
+ } catch (WriteFailedException exUpdate) {
+ LOG.error("Update POT Profile failed", exUpdate);
+ throw new WriteFailedException.UpdateFailedException(id,dataBefore,dataAfter,exUpdate);
+ }
+
+ LOG.info("POT profile updated iid={}, added {}", id, dataAfter);
+ }
+
+ /**
+ * Handle delete operation. D from CRUD.
+ *
+ * @param id Identifier(from root) of data being written
+ * @param dataBefore Old data being deleted
+ * @param writeContext Write context can be used to store any useful information and then utilized by other customizers
+ * @throws WriteFailedException if delete was unsuccessful
+ */
+ @Override
+ public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<PotProfileSet> id,
+ @Nonnull PotProfileSet dataBefore, @Nonnull WriteContext writeContext)
+ throws WriteFailedException {
+ try {
+ delPotProfile(dataBefore,id);
+ } catch (WriteFailedException exDelete) {
+ LOG.error("Del POT Profile failed", exDelete);
+ throw new WriteFailedException.DeleteFailedException(id, exDelete);
+ }
+
+ LOG.info("POT profile deleted iid={}, added {}", id, dataBefore);
+ }
+
+ private void addPotProfile(PotProfileSet potProfileSet, InstanceIdentifier<PotProfileSet> id) throws WriteFailedException{
+ for(PotProfileList potProfileList:potProfileSet.getPotProfileList()) {
+ writePotProfileList(potProfileList,potProfileSet.getName(),id);
+ }
+ }
+
+ private PotProfileAddReply writePotProfileList(PotProfileList potProfileList, String name,
+ InstanceIdentifier<PotProfileSet> id) throws WriteFailedException{
+ PotProfileAdd request = new PotProfileAdd();
+ request.id = potProfileList.getIndex().getValue().byteValue();
+ request.validator = (byte) (potProfileList.isValidator() ? 1 : 0);
+ request.secretKey = 1;
+ request.secretShare = potProfileList.getSecretShare().longValue();
+ request.prime = potProfileList.getPrimeNumber().longValue();
+ request.secretKey = potProfileList.getValidatorKey().longValue();
+ request.maxBits = 64;
+ request.lpc = potProfileList.getLpc().longValue();
+ request.polynomialPublic = potProfileList.getPublicPolynomial().longValue();
+ request.listNameLen = (byte) name.getBytes(StandardCharsets.UTF_8).length;
+ request.listName = name.getBytes(StandardCharsets.UTF_8);
+
+ return getReplyForWrite(getFutureJVppIoampot().potProfileAdd(request).toCompletableFuture(), id);
+ }
+
+ private PotProfileDelReply delPotProfile(PotProfileSet potProfileSet, InstanceIdentifier<PotProfileSet> id)
+ throws WriteFailedException{
+ PotProfileDel request = new PotProfileDel();
+ request.listNameLen = (byte)potProfileSet.getName().getBytes(StandardCharsets.UTF_8).length;
+ request.listName = potProfileSet.getName().getBytes(StandardCharsets.UTF_8);
+
+ return getReplyForWrite(getFutureJVppIoampot().potProfileDel(request).toCompletableFuture(),id);
+ }
+}
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizer.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizer.java
index bab92fc5d..12347946f 100755
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizer.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizer.java
@@ -15,29 +15,20 @@
*/
package io.fd.hc2vpp.vppioam.impl.config;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-import io.fd.hc2vpp.vppioam.impl.util.FutureJVppIoamCustomizer;
-import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.vppioam.impl.util.FutureJVppIoamtraceCustomizer;
+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.ioamtrace.dto.TraceProfileAdd;
import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileAddReply;
import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileDel;
import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileDelReply;
import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtrace;
-
import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.IoamTraceConfig;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.ioam.trace.config.TraceConfig;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.ioam.trace.config.TraceConfig.TraceOp;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.ioam.trace.config.trace.config.NodeInterfaces;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.ioam.trace.config.TraceConfigKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.ioam.trace.config.trace.config.NodeInterfaces;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,13 +36,13 @@ import org.slf4j.LoggerFactory;
/**
* Writer customizer responsible for Ioam Trace create/delete.
*/
-public class IoamTraceWriterCustomizer extends FutureJVppIoamCustomizer
+public class IoamTraceWriterCustomizer extends FutureJVppIoamtraceCustomizer
implements ListWriterCustomizer<TraceConfig, TraceConfigKey>, ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(IoamTraceWriterCustomizer.class);
- public IoamTraceWriterCustomizer(@Nonnull final FutureJVppIoamtrace futureJVppIoam) {
- super(futureJVppIoam);
+ public IoamTraceWriterCustomizer(@Nonnull FutureJVppIoamtrace futureJVppIoamtrace) {
+ super(futureJVppIoamtrace);
}
@Override
@@ -61,7 +52,7 @@ public class IoamTraceWriterCustomizer extends FutureJVppIoamCustomizer
throws WriteFailedException {
try {
- addTraceConfig(dataCurr, writeContext, id);
+ addTraceConfig(dataCurr, id);
} catch (Exception exCreate) {
LOG.error("Add Trace Configuration failed", exCreate);
throw new WriteFailedException.CreateFailedException(id, dataCurr, exCreate);
@@ -77,7 +68,7 @@ public class IoamTraceWriterCustomizer extends FutureJVppIoamCustomizer
@Nonnull final WriteContext ctx) throws WriteFailedException {
try {
deleteTraceConfig(dataBefore, id);
- addTraceConfig(dataAfter, ctx, id);
+ addTraceConfig(dataAfter, id);
} catch (Exception exUpdate) {
LOG.error("Update Trace Configuration failed", exUpdate);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, exUpdate);
@@ -101,18 +92,17 @@ public class IoamTraceWriterCustomizer extends FutureJVppIoamCustomizer
}
public TraceProfileAddReply addTraceConfig(TraceConfig traceConfig,
- WriteContext ctx,
final InstanceIdentifier<TraceConfig> id) throws Exception {
TraceProfileAdd traceProfileAdd = new TraceProfileAdd();
- traceProfileAdd.traceType = (byte) traceConfig.getTraceType().byteValue(); //trace type
- traceProfileAdd.numElts = (byte) traceConfig.getTraceNumElt().byteValue(); //num of elts
+ traceProfileAdd.traceType = traceConfig.getTraceType().byteValue(); //trace type
+ traceProfileAdd.numElts = traceConfig.getTraceNumElt().byteValue(); //num of elts
traceProfileAdd.traceTsp = (byte) traceConfig.getTraceTsp().getIntValue(); // tsp
- traceProfileAdd.appData = (int) traceConfig.getTraceAppData().intValue(); // appdata
- traceProfileAdd.nodeId = (int) traceConfig.getNodeId().intValue(); // nodeid
+ traceProfileAdd.appData = traceConfig.getTraceAppData().intValue(); // appdata
+ traceProfileAdd.nodeId = traceConfig.getNodeId().intValue(); // nodeid
/* Write to VPP */
- final TraceProfileAddReply reply = getReplyForWrite((getFutureJVppIoam().
+ final TraceProfileAddReply reply = getReplyForWrite((getFutureJVppIoamtrace().
traceProfileAdd(traceProfileAdd).
toCompletableFuture()), id);
return reply;
@@ -123,7 +113,7 @@ public class IoamTraceWriterCustomizer extends FutureJVppIoamCustomizer
TraceProfileDel del = new TraceProfileDel();
/* Write to VPP */
- TraceProfileDelReply reply = getReplyForWrite((getFutureJVppIoam().
+ TraceProfileDelReply reply = getReplyForWrite((getFutureJVppIoamtrace().
traceProfileDel(del).toCompletableFuture()), id);
return reply;
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/VppIoamWriterFactory.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/VppIoamWriterFactory.java
index a5773956c..f4b2cea19 100755
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/VppIoamWriterFactory.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/VppIoamWriterFactory.java
@@ -20,27 +20,40 @@ import com.google.inject.Inject;
import io.fd.honeycomb.translate.impl.write.GenericListWriter;
import io.fd.honeycomb.translate.write.WriterFactory;
import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
-import javax.annotation.Nonnull;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampot;
+import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtrace;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.IoamTraceConfig;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.ioam.trace.config.TraceConfig;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.PotProfiles;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profiles.PotProfileSet;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtrace;
+
+import javax.annotation.Nonnull;
public class VppIoamWriterFactory implements WriterFactory {
@Nonnull
- private final FutureJVppIoamtrace jvppIoam;
+ private final FutureJVppIoamtrace jVppIoamtrace;
+ @Nonnull
+ private final FutureJVppIoampot jVppIoampot;
@Inject
- public VppIoamWriterFactory(@Nonnull final FutureJVppIoamtrace jvppIoam) {
- this.jvppIoam = jvppIoam;
+ public VppIoamWriterFactory(@Nonnull final FutureJVppIoamtrace jVppIoamtrace,
+ @Nonnull final FutureJVppIoampot jVppIoampot) {
+ this.jVppIoamtrace = jVppIoamtrace;
+ this.jVppIoampot = jVppIoampot;
}
@Override
public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
- // TraceConfig
+ // Trace Config
final InstanceIdentifier<TraceConfig> trId =
InstanceIdentifier.create(IoamTraceConfig.class).child(TraceConfig.class);
- registry.add(new GenericListWriter<>(trId, new IoamTraceWriterCustomizer(jvppIoam)));
+ registry.add(new GenericListWriter<>(trId, new IoamTraceWriterCustomizer(jVppIoamtrace)));
+ // POT Config
+ final InstanceIdentifier<PotProfileSet> potId =
+ InstanceIdentifier.create(PotProfiles.class).child(PotProfileSet.class);
+ registry.add(new GenericListWriter<>(potId, new IoamPotWriterCustomizer(jVppIoampot)));
+
}
}
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/TraceProfileReaderCustomizer.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/TraceProfileReaderCustomizer.java
index d378385ef..dee207b48 100644
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/TraceProfileReaderCustomizer.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/TraceProfileReaderCustomizer.java
@@ -17,7 +17,7 @@ package io.fd.hc2vpp.vppioam.impl.oper;
import com.google.common.collect.Lists;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
-import io.fd.hc2vpp.vppioam.impl.util.FutureJVppIoamCustomizer;
+import io.fd.hc2vpp.vppioam.impl.util.FutureJVppIoamtraceCustomizer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -37,13 +37,14 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class TraceProfileReaderCustomizer extends FutureJVppIoamCustomizer
+public class TraceProfileReaderCustomizer extends FutureJVppIoamtraceCustomizer
implements InitializingListReaderCustomizer<TraceConfig, TraceConfigKey, TraceConfigBuilder>, JvppReplyConsumer{
private static final Logger LOG = LoggerFactory.getLogger(TraceProfileReaderCustomizer.class);
- public TraceProfileReaderCustomizer(@Nonnull FutureJVppIoamtrace futureJVppIoam) {
- super(futureJVppIoam);
+ public TraceProfileReaderCustomizer(@Nonnull FutureJVppIoamtrace futureJVppIoamtrace) {
+
+ super(futureJVppIoamtrace);
}
/**
@@ -88,7 +89,7 @@ public class TraceProfileReaderCustomizer extends FutureJVppIoamCustomizer
LOG.debug("reading attribute for trace config {}",id);
final TraceProfileShowConfig request = new TraceProfileShowConfig();
- TraceProfileShowConfigReply reply = getReplyForRead(getFutureJVppIoam().traceProfileShowConfig(request)
+ TraceProfileShowConfigReply reply = getReplyForRead(getFutureJVppIoamtrace().traceProfileShowConfig(request)
.toCompletableFuture(),id);
if(reply == null) {
LOG.debug("{} returned null as reply from vpp",id);
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/VppIoamReaderFactory.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/VppIoamReaderFactory.java
index 8c34f54e5..83fd5667a 100644
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/VppIoamReaderFactory.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/VppIoamReaderFactory.java
@@ -32,6 +32,7 @@ public class VppIoamReaderFactory implements ReaderFactory {
@Inject
VppIoamReaderFactory(FutureJVppIoamtrace jVppIoamtrace){
+
this.jVppIoamtrace = jVppIoamtrace;
}
@@ -49,6 +50,7 @@ public class VppIoamReaderFactory implements ReaderFactory {
//TraceConfig
final InstanceIdentifier<TraceConfig> traceConfigId = ioamTraceConfigId.child(TraceConfig.class);
- registry.add(new GenericInitListReader<>(traceConfigId,new TraceProfileReaderCustomizer(jVppIoamtrace)));
+ registry.add(new GenericInitListReader<>(traceConfigId,
+ new TraceProfileReaderCustomizer(jVppIoamtrace)));
}
}
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoampotCustomizer.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoampotCustomizer.java
new file mode 100755
index 000000000..f59f91e18
--- /dev/null
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoampotCustomizer.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 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.vppioam.impl.util;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Preconditions;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampot;
+import javax.annotation.Nonnull;
+
+/**
+ * Abstract utility to hold the IoamApi reference.
+ */
+@Beta
+public abstract class FutureJVppIoampotCustomizer {
+
+ private final FutureJVppIoampot futureJVppIoampot;
+
+ public FutureJVppIoampotCustomizer(@Nonnull final FutureJVppIoampot futureJVppIoampot) {
+ this.futureJVppIoampot = Preconditions.checkNotNull(futureJVppIoampot,
+ "futureJVppIoampot should not be null");
+ }
+
+ /**
+ * Get Ioam POT Api reference
+ *
+ * @return Ioam POT Api reference
+ */
+ public FutureJVppIoampot getFutureJVppIoampot() {
+ return futureJVppIoampot;
+ }
+}
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamCustomizer.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamtraceCustomizer.java
index a93ea379c..8a5d2833c 100755
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamCustomizer.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamtraceCustomizer.java
@@ -25,21 +25,21 @@ import javax.annotation.Nonnull;
* Abstract utility to hold the IoamApi reference.
*/
@Beta
-public abstract class FutureJVppIoamCustomizer {
+public abstract class FutureJVppIoamtraceCustomizer {
- private final FutureJVppIoamtrace futureJVppIoam;
+ private final FutureJVppIoamtrace futureJVppIoamtrace;
- public FutureJVppIoamCustomizer(@Nonnull final FutureJVppIoamtrace futureJVppIoam) {
- this.futureJVppIoam = Preconditions.checkNotNull(futureJVppIoam,
- "futureJVppIoam should not be null");
+ public FutureJVppIoamtraceCustomizer(@Nonnull final FutureJVppIoamtrace futureJVppIoamtrace) {
+ this.futureJVppIoamtrace = Preconditions.checkNotNull(futureJVppIoamtrace,
+ "futureJVppIoamtrace should not be null");
}
/**
- * Get IoamApi reference
+ * Get Ioam Trace Api reference
*
- * @return IoamApi reference
+ * @return Ioam trace Api reference
*/
- public FutureJVppIoamtrace getFutureJVppIoam() {
- return futureJVppIoam;
+ public FutureJVppIoamtrace getFutureJVppIoamtrace() {
+ return futureJVppIoamtrace;
}
}
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java
new file mode 100644
index 000000000..bd560a762
--- /dev/null
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016 Cisco and 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.vppioam.impl.util;
+
+import com.google.inject.Inject;
+import io.fd.honeycomb.infra.distro.ProviderTrait;
+import io.fd.vpp.jvpp.JVppRegistry;
+import io.fd.vpp.jvpp.ioampot.JVppIoampotImpl;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampotFacade;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+/**
+ * Provides future API for jvpp-ioam plugin. Must be a singleton due to shutdown hook usage.
+ * Registers shutdown hook to free plugin's resources on shutdown.
+ */
+public final class JVppIoamPotProvider extends ProviderTrait<FutureJVppIoampotFacade> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(JVppIoamPotProvider.class);
+
+ @Inject
+ private JVppRegistry registry;
+
+ @Override
+ protected FutureJVppIoampotFacade create() {
+ try {
+ final JVppIoampotImpl jVppIoamPot = new JVppIoampotImpl();
+ // Free jvpp-ioam plugin's resources on shutdown
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ LOG.info("Unloading jvpp-ioam-pot plugin");
+ jVppIoamPot.close();
+ LOG.info("Successfully unloaded jvpp-ioam-pot plugin");
+ }
+ });
+
+ LOG.info("Successfully loaded jvpp-ioam-pot plugin");
+ return new FutureJVppIoampotFacade(registry, jVppIoamPot);
+ } catch (IOException e) {
+ throw new IllegalStateException("Unable to open VPP management connection", e);
+ }
+ }
+}
+
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamProvider.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java
index 0b5e3e79e..697cd1255 100755
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamProvider.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java
@@ -18,20 +18,21 @@ package io.fd.hc2vpp.vppioam.impl.util;
import com.google.inject.Inject;
import io.fd.honeycomb.infra.distro.ProviderTrait;
-import java.io.IOException;
import io.fd.vpp.jvpp.JVppRegistry;
-import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
import io.fd.vpp.jvpp.ioamtrace.JVppIoamtraceImpl;
+import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+
/**
* Provides future API for jvpp-ioam plugin. Must be a singleton due to shutdown hook usage.
* Registers shutdown hook to free plugin's resources on shutdown.
*/
-public final class JVppIoamProvider extends ProviderTrait<FutureJVppIoamtraceFacade> {
+public final class JVppIoamTraceProvider extends ProviderTrait<FutureJVppIoamtraceFacade> {
- private static final Logger LOG = LoggerFactory.getLogger(JVppIoamProvider.class);
+ private static final Logger LOG = LoggerFactory.getLogger(JVppIoamTraceProvider.class);
@Inject
private JVppRegistry registry;
@@ -44,13 +45,13 @@ public final class JVppIoamProvider extends ProviderTrait<FutureJVppIoamtraceFac
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
- LOG.info("Unloading jvpp-ioam plugin");
+ LOG.info("Unloading jvpp-ioam-trace plugin");
jVppIoamTr.close();
- LOG.info("Successfully unloaded jvpp-ioam plugin");
+ LOG.info("Successfully unloaded jvpp-ioam-trace plugin");
}
});
- LOG.info("Successfully loaded jvpp-ioam plugin");
+ LOG.info("Successfully loaded jvpp-ioam-trace plugin");
return new FutureJVppIoamtraceFacade(registry, jVppIoamTr);
} catch (IOException e) {
throw new IllegalStateException("Unable to open VPP management connection", e);
diff --git a/ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/VppIoamModuleTest.java b/ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/VppIoamModuleTest.java
index 68b8a87c7..c11ee2dc4 100644
--- a/ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/VppIoamModuleTest.java
+++ b/ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/VppIoamModuleTest.java
@@ -16,14 +16,6 @@
package io.fd.hc2vpp.vppioam.impl;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.Matchers.empty;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.MockitoAnnotations.initMocks;
-
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -34,15 +26,24 @@ import io.fd.honeycomb.translate.impl.read.registry.CompositeReaderRegistryBuild
import io.fd.honeycomb.translate.impl.write.registry.FlatWriterRegistryBuilder;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.write.WriterFactory;
-import java.util.HashSet;
-import java.util.Set;
+import io.fd.vpp.jvpp.JVppRegistry;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampotFacade;
+import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
-import io.fd.vpp.jvpp.JVppRegistry;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.Matchers.empty;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.MockitoAnnotations.initMocks;
public class VppIoamModuleTest {
@@ -72,7 +73,7 @@ public class VppIoamModuleTest {
initMocks(this);
- Guice.createInjector(new VppIoamModule(MockJVppIoamProvider.class), BoundFieldModule.of(this)).injectMembers(this);
+ Guice.createInjector(new VppIoamModule(MockJVppIoamTraceProvider.class,MockJVppIoamPotProvider.class), BoundFieldModule.of(this)).injectMembers(this);
}
@Test
@@ -94,13 +95,19 @@ public class VppIoamModuleTest {
assertNotNull(registryBuilder.build());
}
-
- private static final class MockJVppIoamProvider implements Provider<FutureJVppIoamtraceFacade> {
-
+ private static final class MockJVppIoamTraceProvider implements Provider<FutureJVppIoamtraceFacade> {
@Override
public FutureJVppIoamtraceFacade get() {
return mock(FutureJVppIoamtraceFacade.class);
}
}
+
+ private static final class MockJVppIoamPotProvider implements Provider<FutureJVppIoampotFacade> {
+
+ @Override
+ public FutureJVppIoampotFacade get() {
+ return mock(FutureJVppIoampotFacade.class);
+ }
+ }
}
diff --git a/ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizerTest.java b/ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizerTest.java
new file mode 100644
index 000000000..eccfd5d50
--- /dev/null
+++ b/ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizerTest.java
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2016 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.vppioam.impl.config;
+
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.ioampot.dto.PotProfileAdd;
+import io.fd.vpp.jvpp.ioampot.dto.PotProfileAddReply;
+import io.fd.vpp.jvpp.ioampot.dto.PotProfileDel;
+import io.fd.vpp.jvpp.ioampot.dto.PotProfileDelReply;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampot;
+import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.PotProfiles;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.ProfileIndexRange;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profile.PotProfileList;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profile.PotProfileListBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profile.PotProfileListKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profiles.PotProfileSet;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profiles.PotProfileSetBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profiles.PotProfileSetKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+
+public class IoamPotWriterCustomizerTest extends WriterCustomizerTest {
+
+ @Mock
+ protected FutureJVppIoampot jVppIoampot;
+
+ private IoamPotWriterCustomizer customizer;
+
+ private static final String POT_TEST_NAME = "dummy";
+
+ @Override
+ public void setUpTest() throws Exception {
+ customizer = new IoamPotWriterCustomizer(jVppIoampot);
+ }
+
+ private static PotProfileList generatePotProfileList() {
+ final PotProfileListBuilder builder= new PotProfileListBuilder();
+ builder.setIndex(new ProfileIndexRange(1));
+ builder.setBitmask(new BigInteger("1"));
+ builder.setKey(new PotProfileListKey(new ProfileIndexRange(1)));
+ builder.setLpc(new BigInteger("1233"));
+ builder.setPrimeNumber(new BigInteger("1001"));
+ builder.setPublicPolynomial(new BigInteger("1234"));
+ builder.setSecretShare(new BigInteger("1234"));
+ builder.setValidator(true);
+ builder.setValidatorKey(new BigInteger("1"));
+ return builder.build();
+ }
+
+ private static PotProfileSet generatePotProfileSet(){
+ ArrayList<PotProfileList> potProfiles = new ArrayList<>();
+ potProfiles.add(generatePotProfileList());
+ PotProfileSetBuilder builder = new PotProfileSetBuilder();
+ builder.setActiveProfileIndex(new ProfileIndexRange(1));
+ builder.setName(POT_TEST_NAME);
+ builder.setPotProfileList(potProfiles);
+ builder.setPathIdentifier("ACL");
+ return builder.build();
+ }
+
+ private static InstanceIdentifier<PotProfileSet> getPotProfileSetId(String name) {
+ return InstanceIdentifier.create(PotProfiles.class)
+ .child(PotProfileSet.class, new PotProfileSetKey(name));
+ }
+
+ private void whenPotAddThenSuccess() {
+ final PotProfileAddReply reply = new PotProfileAddReply();
+ reply.context = 1;
+ doReturn(future(reply)).when(jVppIoampot).potProfileAdd(any(PotProfileAdd.class));
+ }
+
+ private void whenPotAddThenFailure() {
+ doReturn(failedFuture()).when(jVppIoampot).potProfileAdd(any(PotProfileAdd.class));
+ }
+
+ private void whenPotDelThenSuccess() {
+ final PotProfileDelReply reply = new PotProfileDelReply();
+ reply.context = 1;
+ doReturn(future(reply)).when(jVppIoampot).potProfileDel(any(PotProfileDel.class));
+ }
+
+ private void whenPotDelThenFailure() {
+ doReturn(failedFuture()).when(jVppIoampot).potProfileDel(any(PotProfileDel.class));
+ }
+
+ private static PotProfileAdd generatePotProfileAdd() {
+ PotProfileAdd request = new PotProfileAdd();
+ request.id = 1;
+ request.validator = 1;
+ request.secretKey = 1;
+ request.secretShare = 1234;
+ request.prime = 1001;
+ request.maxBits = 64;
+ request.lpc = 1233;
+ request.polynomialPublic = 1234;
+ request.listNameLen = (byte)POT_TEST_NAME.getBytes(StandardCharsets.UTF_8).length;
+ request.listName = POT_TEST_NAME.getBytes(StandardCharsets.UTF_8);
+
+ return request;
+ }
+
+ private static PotProfileDel generatePotProfileDel(String name) {
+ final PotProfileDel request = new PotProfileDel();
+ request.listName = name.getBytes(StandardCharsets.UTF_8);
+ request.listNameLen = (byte)name.getBytes(StandardCharsets.UTF_8).length;
+
+ return request;
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ final PotProfileSet potProfileSet = generatePotProfileSet();
+ final InstanceIdentifier<PotProfileSet> id = getPotProfileSetId(POT_TEST_NAME);
+
+ whenPotAddThenSuccess();
+
+ customizer.writeCurrentAttributes(id, potProfileSet, writeContext);
+
+ verify(jVppIoampot).potProfileAdd(generatePotProfileAdd());
+ }
+
+ @Test
+ public void testCreateFailed() throws Exception {
+ final PotProfileSet potProfileSet = generatePotProfileSet();
+ final InstanceIdentifier<PotProfileSet> id = getPotProfileSetId(POT_TEST_NAME);
+
+ whenPotAddThenFailure();
+
+ try {
+ customizer.writeCurrentAttributes(id, potProfileSet, writeContext);
+ } catch (WriteFailedException e) {
+ verify(jVppIoampot).potProfileAdd(generatePotProfileAdd());
+
+ return;
+ }
+ fail("WriteFailedException.CreateFailedException was expected");
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+ final PotProfileSet potProfileSet = generatePotProfileSet();
+ final InstanceIdentifier<PotProfileSet> id = getPotProfileSetId(POT_TEST_NAME);
+
+ whenPotDelThenSuccess();
+
+ customizer.deleteCurrentAttributes(id, potProfileSet, writeContext);
+
+ verify(jVppIoampot).potProfileDel(generatePotProfileDel(POT_TEST_NAME));
+ }
+
+ @Test
+ public void testDeleteFailed() throws Exception {
+ final PotProfileSet potProfileSet = generatePotProfileSet();
+ final InstanceIdentifier<PotProfileSet> id = getPotProfileSetId(POT_TEST_NAME);
+
+ whenPotDelThenFailure();
+
+ try {
+ customizer.deleteCurrentAttributes(id, potProfileSet, writeContext);
+ } catch (WriteFailedException e) {
+ verify(jVppIoampot).potProfileDel(generatePotProfileDel(POT_TEST_NAME));
+ return;
+ }
+ fail("WriteFailedException.DeleteFailedException was expected");
+
+ customizer.deleteCurrentAttributes(id, potProfileSet, writeContext);
+ }
+}
diff --git a/ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizerTest.java b/ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizerTest.java
index c7065c0d5..334a73661 100644
--- a/ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizerTest.java
+++ b/ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizerTest.java
@@ -38,13 +38,12 @@ import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.r
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.ioam.trace.config.TraceConfigKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
public class IoamTraceWriterCustomizerTest extends WriterCustomizerTest {
private static final String TRACE_NAME = "trace_test";
@Mock
- protected FutureJVppIoamtrace jvppIoam;
+ protected FutureJVppIoamtrace jvppIoamtrace;
private IoamTraceWriterCustomizer customizer;
@@ -53,12 +52,12 @@ public class IoamTraceWriterCustomizerTest extends WriterCustomizerTest {
builder.setTraceConfigName(name);
builder.setKey(new TraceConfigKey(name));
builder.setAclName(name);
- builder.setTraceType(new Short("31"));
- builder.setTraceNumElt(new Short("4"));
+ builder.setTraceType(Short.valueOf("31"));
+ builder.setTraceNumElt(Short.valueOf("4"));
builder.setTraceTsp(TraceTsp.Milliseconds);
builder.setTraceOp(TraceOp.Add);
- builder.setTraceAppData(new Long("123"));
- builder.setNodeId(new Long("1"));
+ builder.setTraceAppData(Long.valueOf("123"));
+ builder.setNodeId(Long.valueOf("1"));
return builder.build();
}
@@ -87,27 +86,27 @@ public class IoamTraceWriterCustomizerTest extends WriterCustomizerTest {
@Override
public void setUpTest() throws Exception {
- customizer = new IoamTraceWriterCustomizer(jvppIoam);
+ customizer = new IoamTraceWriterCustomizer(jvppIoamtrace);
}
private void whenTraceAddThenSuccess() {
final TraceProfileAddReply reply = new TraceProfileAddReply();
reply.context = 1;
- doReturn(future(reply)).when(jvppIoam).traceProfileAdd(any(TraceProfileAdd.class));
+ doReturn(future(reply)).when(jvppIoamtrace).traceProfileAdd(any(TraceProfileAdd.class));
}
private void whenTraceAddThenFailure() {
- doReturn(failedFuture()).when(jvppIoam).traceProfileAdd(any(TraceProfileAdd.class));
+ doReturn(failedFuture()).when(jvppIoamtrace).traceProfileAdd(any(TraceProfileAdd.class));
}
private void whenTraceDelThenSuccess() {
final TraceProfileDelReply reply = new TraceProfileDelReply();
reply.context = 1;
- doReturn(future(reply)).when(jvppIoam).traceProfileDel(any(TraceProfileDel.class));
+ doReturn(future(reply)).when(jvppIoamtrace).traceProfileDel(any(TraceProfileDel.class));
}
private void whenTraceDelThenFailure() {
- doReturn(failedFuture()).when(jvppIoam).traceProfileDel(any(TraceProfileDel.class));
+ doReturn(failedFuture()).when(jvppIoamtrace).traceProfileDel(any(TraceProfileDel.class));
}
@Test
@@ -119,7 +118,7 @@ public class IoamTraceWriterCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, traceConfig, writeContext);
- verify(jvppIoam).traceProfileAdd(generateTraceProfileAdd());
+ verify(jvppIoamtrace).traceProfileAdd(generateTraceProfileAdd());
}
@Test
@@ -133,7 +132,7 @@ public class IoamTraceWriterCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, traceConfig, writeContext);
} catch (WriteFailedException e) {
//assertTrue(e.getCause() instanceof VppBaseCallException);
- verify(jvppIoam).traceProfileAdd(generateTraceProfileAdd());
+ verify(jvppIoamtrace).traceProfileAdd(generateTraceProfileAdd());
return;
}
@@ -150,7 +149,7 @@ public class IoamTraceWriterCustomizerTest extends WriterCustomizerTest {
customizer.deleteCurrentAttributes(id, traceConfig, writeContext);
- verify(jvppIoam).traceProfileDel(generateTraceProfileDel());
+ verify(jvppIoamtrace).traceProfileDel(generateTraceProfileDel());
}
@Test
@@ -165,7 +164,7 @@ public class IoamTraceWriterCustomizerTest extends WriterCustomizerTest {
customizer.deleteCurrentAttributes(id, traceConfig, writeContext);
} catch (WriteFailedException e) {
//assertTrue(e.getCause() instanceof VppBaseCallException);
- verify(jvppIoam).traceProfileDel(generateTraceProfileDel());
+ verify(jvppIoamtrace).traceProfileDel(generateTraceProfileDel());
return;
}