diff options
Diffstat (limited to 'ioam/impl/src/main/java')
8 files changed, 87 insertions, 67 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 228653c1c..4c143131c 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 @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package io.fd.hc2vpp.vppioam.impl; import com.google.common.annotations.VisibleForTesting; @@ -36,7 +37,7 @@ import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** +/* * Glue code necessary for Honeycomb distribution to pick up the plugin classes */ public final class VppIoamModule extends AbstractModule { diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamExportWriterCustomizer.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamExportWriterCustomizer.java index 2172750d4..1d90b0e85 100644 --- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamExportWriterCustomizer.java +++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamExportWriterCustomizer.java @@ -36,8 +36,8 @@ public class IoamExportWriterCustomizer extends FutureJVppIoamexportCustomizer private static final Logger LOG = LoggerFactory.getLogger(IoamExportWriterCustomizer.class); - public IoamExportWriterCustomizer(FutureJVppIoamexport jVppIoamexport){ - super(jVppIoamexport); + public IoamExportWriterCustomizer(FutureJVppIoamexport jVppIoamExport){ + super(jVppIoamExport); } @Override @@ -67,10 +67,11 @@ public class IoamExportWriterCustomizer extends FutureJVppIoamexportCustomizer private IoamExportIp6EnableDisableReply addExportProfile(IoamExport ioamExport, InstanceIdentifier<IoamExport> id) throws WriteFailedException { IoamExportIp6EnableDisable request = new IoamExportIp6EnableDisable(); - if (ioamExport.isDisable()==null) + if (ioamExport.isDisable() == null) { request.isDisable = 1; - else - request.isDisable = (byte)(ioamExport.isDisable()?1:0); + } else { + request.isDisable = (byte)(ioamExport.isDisable() ? 1 : 0); + } request.srcAddress = ipv4AddressNoZoneToArray(ioamExport.getSourceAddress().getValue()); request.collectorAddress = ipv4AddressNoZoneToArray(ioamExport.getCollectorAddress().getValue()); return getReplyForCreate(getFutureJVppIoamexport() 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 index 7df956e68..19b1069ee 100644 --- 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 @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package io.fd.hc2vpp.vppioam.impl.config; @@ -114,8 +115,9 @@ public class IoamPotWriterCustomizer extends FutureJVppIoampotCustomizer impleme LOG.info("POT profile deleted iid={}, added {}", id, dataBefore); } - private void addPotProfile(PotProfileSet potProfileSet, InstanceIdentifier<PotProfileSet> id) throws WriteFailedException{ - for(PotProfileList potProfileList:potProfileSet.getPotProfileList()) { + private void addPotProfile(PotProfileSet potProfileSet, + InstanceIdentifier<PotProfileSet> id) throws WriteFailedException { + for ( PotProfileList potProfileList : potProfileSet.getPotProfileList()) { writePotProfileList(potProfileList,potProfileSet.getName(),id); } } @@ -123,18 +125,18 @@ public class IoamPotWriterCustomizer extends FutureJVppIoampotCustomizer impleme 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.secretShare = potProfileList.getSecretShare().longValue(); - request.prime = potProfileList.getPrimeNumber().longValue(); - request.secretKey = potProfileList.isValidator() ? potProfileList.getValidatorKey().longValue() : 0; - request.maxBits = potProfileList.getNumberOfBits().byteValue(); - 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); + request.id = potProfileList.getIndex().getValue().byteValue(); + request.validator = (byte) (potProfileList.isValidator() ? 1 : 0); + request.secretShare = potProfileList.getSecretShare().longValue(); + request.prime = potProfileList.getPrimeNumber().longValue(); + request.secretKey = potProfileList.isValidator() ? potProfileList.getValidatorKey().longValue() : 0; + request.maxBits = potProfileList.getNumberOfBits().byteValue(); + 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) 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 12347946f..a8478b931 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 @@ -13,6 +13,7 @@ * 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.ByteDataTranslator; @@ -92,7 +93,7 @@ public class IoamTraceWriterCustomizer extends FutureJVppIoamtraceCustomizer } public TraceProfileAddReply addTraceConfig(TraceConfig traceConfig, - final InstanceIdentifier<TraceConfig> id) throws Exception { + final InstanceIdentifier<TraceConfig> id) throws Exception { TraceProfileAdd traceProfileAdd = new TraceProfileAdd(); traceProfileAdd.traceType = traceConfig.getTraceType().byteValue(); //trace type @@ -102,9 +103,9 @@ public class IoamTraceWriterCustomizer extends FutureJVppIoamtraceCustomizer traceProfileAdd.nodeId = traceConfig.getNodeId().intValue(); // nodeid /* Write to VPP */ - final TraceProfileAddReply reply = getReplyForWrite((getFutureJVppIoamtrace(). - traceProfileAdd(traceProfileAdd). - toCompletableFuture()), id); + final TraceProfileAddReply reply = getReplyForWrite((getFutureJVppIoamtrace() + .traceProfileAdd(traceProfileAdd) + .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 ba105eb39..5728327fa 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 @@ -38,19 +38,19 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class VppIoamWriterFactory implements WriterFactory { @Nonnull - private final FutureJVppIoamtrace jVppIoamtrace; + private final FutureJVppIoamtrace jVppIoamTrace; @Nonnull - private final FutureJVppIoampot jVppIoampot; + private final FutureJVppIoampot jVppIoamPot; @Nonnull - private final FutureJVppIoamexport jVppIoamexport; + private final FutureJVppIoamexport jVppIoamExport; @Inject - public VppIoamWriterFactory(@Nonnull final FutureJVppIoamtrace jVppIoamtrace, - @Nonnull final FutureJVppIoampot jVppIoampot, - @Nonnull final FutureJVppIoamexport jVppIoamexport) { - this.jVppIoamtrace = jVppIoamtrace; - this.jVppIoampot = jVppIoampot; - this.jVppIoamexport = jVppIoamexport; + public VppIoamWriterFactory(@Nonnull final FutureJVppIoamtrace jVppIoamTrace, + @Nonnull final FutureJVppIoampot jVppIoamPot, + @Nonnull final FutureJVppIoamexport jVppIoamExport) { + this.jVppIoamTrace = jVppIoamTrace; + this.jVppIoamPot = jVppIoamPot; + this.jVppIoamExport = jVppIoamExport; } @Override @@ -60,17 +60,17 @@ public class VppIoamWriterFactory implements WriterFactory { InstanceIdentifier.create(IoamTraceConfig.class).child(TraceConfig.class); registry.subtreeAdd(Sets.newHashSet(InstanceIdentifier.create(TraceConfig.class) .child(NodeInterfaces.class)), - new GenericListWriter<>(trId, new IoamTraceWriterCustomizer(jVppIoamtrace))); + new GenericListWriter<>(trId, new IoamTraceWriterCustomizer(jVppIoamTrace))); // POT Config final InstanceIdentifier<PotProfileSet> potId = InstanceIdentifier.create(PotProfiles.class).child(PotProfileSet.class); registry.subtreeAdd(Sets.newHashSet(InstanceIdentifier.create(PotProfileSet.class) .child(PotProfileList.class)), - new GenericListWriter<>(potId, new IoamPotWriterCustomizer(jVppIoampot))); + new GenericListWriter<>(potId, new IoamPotWriterCustomizer(jVppIoamPot))); //Export Config final InstanceIdentifier<IoamExport> exportId = InstanceIdentifier.create(IoamExport.class); - registry.add(new GenericWriter<>(exportId,new IoamExportWriterCustomizer(jVppIoamexport))); + registry.add(new GenericWriter<>(exportId,new IoamExportWriterCustomizer(jVppIoamExport))); } } diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/PotProfileReaderCustomizer.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/PotProfileReaderCustomizer.java index 860fc07df..f9d229a9c 100644 --- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/PotProfileReaderCustomizer.java +++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/PotProfileReaderCustomizer.java @@ -46,8 +46,8 @@ public class PotProfileReaderCustomizer extends FutureJVppIoampotCustomizer impl private static final Logger LOG = LoggerFactory.getLogger(PotProfileReaderCustomizer.class); - public PotProfileReaderCustomizer(FutureJVppIoampot futureJVppIoampot){ - super(futureJVppIoampot); + public PotProfileReaderCustomizer(FutureJVppIoampot futureJVppIoamPot) { + super(futureJVppIoamPot); } @Nonnull @@ -101,7 +101,7 @@ public class PotProfileReaderCustomizer extends FutureJVppIoampotCustomizer impl final PotProfileShowConfigDetails details = reply.potProfileShowConfigDetails.get(0); - builder.setValidator(details.validator==1); + builder.setValidator(details.validator == 1); builder.setValidatorKey(BigInteger.valueOf(details.secretKey)); builder.setSecretShare(BigInteger.valueOf(details.secretShare)); builder.setPrimeNumber(BigInteger.valueOf(details.prime)); @@ -110,13 +110,13 @@ public class PotProfileReaderCustomizer extends FutureJVppIoampotCustomizer impl builder.setLpc(BigInteger.valueOf(details.lpc)); builder.setNumberOfBits(getMaxBitsfromBitmask(BigInteger.valueOf(details.bitMask))); - LOG.info("Item {} successfully read: {}",instanceIdentifier,builder.build()); + LOG.info("Item {} successfully read: {}",instanceIdentifier, builder.build()); } - private static short getMaxBitsfromBitmask (BigInteger bitmask){ + private static short getMaxBitsfromBitmask (BigInteger bitmask) { short numOfBits = 0; - while ((bitmask.and(BigInteger.ONE)).equals(BigInteger.ONE)){ - bitmask=bitmask.shiftRight(1); + while ((bitmask.and(BigInteger.ONE)).equals(BigInteger.ONE)) { + bitmask = bitmask.shiftRight(1); numOfBits++; } return numOfBits; 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 dee207b48..a6bb1ff76 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 @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package io.fd.hc2vpp.vppioam.impl.oper; import com.google.common.collect.Lists; @@ -50,7 +51,7 @@ public class TraceProfileReaderCustomizer extends FutureJVppIoamtraceCustomizer /** * Creates new builder that will be used to build read value. * - * @param id + * @param id Identifier */ @Nonnull @Override @@ -89,17 +90,18 @@ public class TraceProfileReaderCustomizer extends FutureJVppIoamtraceCustomizer LOG.debug("reading attribute for trace config {}",id); final TraceProfileShowConfig request = new TraceProfileShowConfig(); - TraceProfileShowConfigReply reply = getReplyForRead(getFutureJVppIoamtrace().traceProfileShowConfig(request) + TraceProfileShowConfigReply reply = getReplyForRead (getFutureJVppIoamtrace().traceProfileShowConfig(request) .toCompletableFuture(),id); - if(reply == null) { + if (reply == null) { LOG.debug("{} returned null as reply from vpp",id); return; } - if(reply.traceType == 0){ + if (reply.traceType == 0) { LOG.debug("{} no configured trace config found",id); return; } + builder.setNodeId((long) reply.nodeId); builder.setTraceAppData((long) reply.appData); builder.setTraceNumElt((short) reply.numElts); @@ -112,8 +114,8 @@ public class TraceProfileReaderCustomizer extends FutureJVppIoamtraceCustomizer /** * Merge read data into provided parent builder. * - * @param parentBuilder - * @param readValue + * @param parentBuilder Parent Builder + * @param readValue Read Value */ @Override public void merge(@Nonnull Builder<? extends DataObject> parentBuilder, @Nonnull TraceConfig readValue) { @@ -123,6 +125,11 @@ public class TraceProfileReaderCustomizer extends FutureJVppIoamtraceCustomizer builder.setTraceConfig(traceConfigs); } + @Override + public void merge(@Nonnull final Builder<? extends DataObject> builder, @Nonnull final List<TraceConfig> list) { + ((IoamTraceConfigBuilder) builder).setTraceConfig(list); + } + @Nonnull @Override public List<TraceConfigKey> getAllIds(@Nonnull final InstanceIdentifier<TraceConfig> instanceIdentifier, @@ -133,9 +140,4 @@ public class TraceProfileReaderCustomizer extends FutureJVppIoamtraceCustomizer return Lists.newArrayList(new TraceConfigKey("trace config")); } - - @Override - public void merge(@Nonnull final Builder<? extends DataObject> builder, @Nonnull final List<TraceConfig> list) { - ((IoamTraceConfigBuilder) builder).setTraceConfig(list); - } } 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 ece73fa8c..1f6250f3d 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 @@ -13,9 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package io.fd.hc2vpp.vppioam.impl.oper; import io.fd.honeycomb.translate.impl.read.GenericInitListReader; +import io.fd.honeycomb.translate.impl.read.GenericListReader; import io.fd.honeycomb.translate.read.ReaderFactory; import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampot; @@ -27,33 +29,41 @@ import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev170112.PotProfilesBuilder; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev170112.pot.profile.PotProfileList; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev170112.pot.profiles.PotProfileSet; +import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev170112.pot.profiles.PotProfileSetBuilder; +import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev170112.pot.profiles.PotProfileSetKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import javax.annotation.Nonnull; import javax.inject.Inject; +import java.util.Arrays; +import java.util.List; + public class VppIoamReaderFactory implements ReaderFactory { @Nonnull - FutureJVppIoamtrace jVppIoamtrace; + FutureJVppIoamtrace jVppIoamTrace; @Nonnull - FutureJVppIoampot jVppIoampot; + FutureJVppIoampot jVppIoamPot; @Inject - VppIoamReaderFactory(FutureJVppIoamtrace jVppIoamtrace, FutureJVppIoampot jVppIoampot){ + VppIoamReaderFactory(FutureJVppIoamtrace jVppIoamTrace, FutureJVppIoampot jVppIoamPot){ - this.jVppIoamtrace = jVppIoamtrace; - this.jVppIoampot = jVppIoampot; + this.jVppIoamTrace = jVppIoamTrace; + this.jVppIoamPot = jVppIoamPot; } /** * Initialize 1 or more readers and add them to provided registry. * - * @param registry + * @param registry Registry */ @Override public void init(@Nonnull ModifiableReaderRegistryBuilder registry) { + final PotProfileSetKey STATIC_INSTANCE_KEY = new PotProfileSetKey("static-pot-profile-instance"); + final List<PotProfileSetKey> staticKeys = Arrays.asList(STATIC_INSTANCE_KEY); + //IoamTraceConfig (Structural) final InstanceIdentifier<IoamTraceConfig> ioamTraceConfigId = InstanceIdentifier.create(IoamTraceConfig.class); registry.addStructuralReader(ioamTraceConfigId, IoamTraceConfigBuilder.class); @@ -61,20 +71,23 @@ public class VppIoamReaderFactory implements ReaderFactory { //TraceConfig final InstanceIdentifier<TraceConfig> traceConfigId = ioamTraceConfigId.child(TraceConfig.class); registry.add(new GenericInitListReader<>(traceConfigId, - new TraceProfileReaderCustomizer(jVppIoamtrace))); + new TraceProfileReaderCustomizer(jVppIoamTrace))); //PotProfiles (Structural) final InstanceIdentifier<PotProfiles> potProfilesInstanceIdentifier = InstanceIdentifier.create(PotProfiles.class); registry.addStructuralReader(potProfilesInstanceIdentifier, PotProfilesBuilder.class); + //PotProfileSet (Structural) - final InstanceIdentifier<PotProfileSet> potProfileSetInstanceIdentifier = + final InstanceIdentifier<PotProfileSet> potProfileSetInstanceIdentifier = potProfilesInstanceIdentifier.child(PotProfileSet.class); - //TODO - temporary disabled till HC2VPP-63 is resolved - //registry.addStructuralReader(potProfileSetInstanceIdentifier, PotProfileSetBuilder.class); + + registry.addStructuralListReader(potProfileSetInstanceIdentifier, PotProfileSetBuilder.class, staticKeys); + //PotProfileList - final InstanceIdentifier<PotProfileList> potProfileListInstanceIdentifier= potProfileSetInstanceIdentifier.child(PotProfileList.class); - registry.add(new GenericInitListReader<>(potProfileListInstanceIdentifier, - new PotProfileReaderCustomizer(jVppIoampot))); + final InstanceIdentifier<PotProfileList> potProfileListInstanceIdentifier = + potProfileSetInstanceIdentifier.child(PotProfileList.class); + registry.add(new GenericInitListReader<>(potProfileListInstanceIdentifier, + new PotProfileReaderCustomizer(jVppIoamPot))); } } |