HC-256: support for iOAM - Proof Of Transit 68/4268/3
authorSagar Srivastav <[email protected]>
Fri, 25 Nov 2016 06:17:48 +0000 (22:17 -0800)
committerMarek Gradzki <[email protected]>
Wed, 14 Dec 2016 11:17:46 +0000 (11:17 +0000)
Change-Id: Ib4260b9b11dbca7016b7b85763d9186d7add0f53
Signed-off-by: Sagar Srivastav <[email protected]>
15 files changed:
ioam/api/src/main/yang/sfc-ioam-sb-pot.yang [new file with mode: 0644]
ioam/impl/pom.xml
ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/VppIoamModule.java
ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizer.java [new file with mode: 0644]
ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizer.java
ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/VppIoamWriterFactory.java
ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/TraceProfileReaderCustomizer.java
ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/VppIoamReaderFactory.java
ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoampotCustomizer.java [new file with mode: 0755]
ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamtraceCustomizer.java [moved from ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamCustomizer.java with 63% similarity]
ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java [new file with mode: 0644]
ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java [moved from ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamProvider.java with 85% similarity]
ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/VppIoamModuleTest.java
ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizerTest.java [new file with mode: 0644]
ioam/impl/src/test/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizerTest.java

diff --git a/ioam/api/src/main/yang/sfc-ioam-sb-pot.yang b/ioam/api/src/main/yang/sfc-ioam-sb-pot.yang
new file mode 100644 (file)
index 0000000..ff39b25
--- /dev/null
@@ -0,0 +1,168 @@
+module sfc-ioam-sb-pot {
+
+  yang-version 1;
+
+  namespace "urn:cisco:params:xml:ns:yang:sfc-ioam-sb-pot";
+
+  prefix sfc-ioam-sb-pot;
+
+  organization "Cisco Systems, Inc.";
+  contact
+    "Shwetha Bhandari <[email protected]>
+     Srihari Raghavan <[email protected]>";
+
+  description
+    "This module contains a collection of YANG definitions for
+     managing in-band OAM based proof of transit configuration
+     parameters.  (https://github.com/ciscodevnet/ioam).
+     The model is meant for proof of transit
+     and is targetted for south-bound deployment nodes.";
+
+  revision 2016-06-15 {
+    description
+      "Initial revision.";
+    reference
+      "";
+  }
+
+  typedef profile-index-range {
+    type int32 {
+      range "0 .. 1";
+    }
+    description
+      "Range used for the profile index. Currently restricted to
+       0 or 1 to identify the two profiles.";
+  }
+
+  identity path-identifier-identity {
+    description
+      "Base identity for path identifier type.";
+  }
+
+  identity path-identifier-type-acl {
+    base "path-identifier-identity";
+    description
+      "ACL path identifier type.";
+  }
+
+  typedef path-identifier-type {
+    type identityref {
+      base path-identifier-identity;
+    }
+    description
+      "Path Identifier Identity type.";
+  }
+
+  grouping pot-profile {
+    description "A grouping for proof of transit profiles.";
+    list pot-profile-list {
+      key "index";
+      ordered-by user;
+      description "A set of pot profiles.";
+
+      leaf index {
+        type profile-index-range;
+        mandatory true;
+        description
+          "Proof of transit profile index.";
+      }
+
+      leaf prime-number {
+        type uint64;
+        mandatory true;
+        description
+          "Prime number used for module math computation";
+      }
+
+      leaf secret-share {
+        type uint64;
+        mandatory true;
+        description
+          "Share of the secret of polynomial 1 used in computation";
+      }
+
+      leaf public-polynomial {
+        type uint64;
+        mandatory true;
+        description
+          "Public polynomial";
+      }
+
+      leaf lpc {
+        type uint64;
+        mandatory true;
+        description
+          "Lagrange Polynomial Coefficient";
+      }
+
+      leaf validator {
+        type boolean;
+        default "false";
+        description
+          "True if the node is a verifier node";
+      }
+
+      leaf validator-key {
+        type uint64;
+        description
+          "Secret key for validating the path, constant of poly 1";
+      }
+
+      leaf bitmask {
+        type uint64;
+        default 4294967295;
+        description
+          "Number of bits as mask used in random value generation.
+           32-bits of mask is default.";
+      }
+    }
+  }
+
+  container pot-profiles {
+    description "A group of proof of transit profiles.";
+
+    list pot-profile-set {
+      key "name";
+      ordered-by user;
+      description
+        "Set of proof of transit profiles that group parameters
+         required to classify and compute proof of transit
+         metadata at a node";
+
+      leaf name {
+        type string;
+        mandatory true;
+        description
+          "Unique identifier for each proof of transit profile";
+      }
+
+      leaf path-identifier {
+        type string;
+        description
+           "The path identifier could be an ACL or others associated
+            to classify and apply this profile";
+      }
+
+      leaf path-identifier-type-value {
+        type path-identifier-type;
+        default path-identifier-type-acl;
+        description
+          "Defines how to interpret the path-identifier.";
+      }
+
+      leaf active-profile-index {
+        type profile-index-range;
+        description
+          "Proof of transit profile index that is currently active.
+           Will be set in the first hop of the path or chain.
+           Other nodes will not use this field.";
+      }
+
+      uses pot-profile;
+
+    /*** list: end ***/
+    }
+  /*** Container: end ***/
+  }
+/*** module: end ***/
+}
\ No newline at end of file
index 85d728c..95366aa 100644 (file)
         <artifactId>jvpp-ioam-trace</artifactId>
         <version>${ioam.version}</version>
     </dependency>
+    <dependency>
+      <groupId>io.fd.vpp</groupId>
+      <artifactId>jvpp-ioam-pot</artifactId>
+      <version>${ioam.version}</version>
+    </dependency>
     <dependency>
       <groupId>io.fd.hc2vpp.common</groupId>
       <artifactId>vpp-translate-utils</artifactId>
index a378a06..204d003 100755 (executable)
@@ -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 (file)
index 0000000..6d80493
--- /dev/null
@@ -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);
+    }
+}
index bab92fc..1234794 100755 (executable)
  */
 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;
index a577395..f4b2cea 100755 (executable)
@@ -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)));
+
     }
 }
index d378385..dee207b 100644 (file)
@@ -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);
index 8c34f54..83fd566 100644 (file)
@@ -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 (executable)
index 0000000..f59f91e
--- /dev/null
@@ -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;
+    }
+}
@@ -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 (file)
index 0000000..bd560a7
--- /dev/null
@@ -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);
+        }
+    }
+}
+
@@ -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);
index 68b8a87..c11ee2d 100644 (file)
 
 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 (file)
index 0000000..eccfd5d
--- /dev/null
@@ -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);
+    }
+}
index c7065c0..334a736 100644 (file)
@@ -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;
         }