From 75f108e2b610fa981e1a03882249a23e09289289 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Thu, 10 Aug 2017 13:17:01 +0200 Subject: Adapt hc2vpp to changes to interface events api Requires https://gerrit.fd.io/r/#/c/7925/ Change-Id: If627983bfcb0bf36ec1aa34ec863280e1f1bee36 Signed-off-by: Marek Gradzki --- .../v3po/interfaces/InterfaceCustomizer.java | 8 ++--- .../InterfaceChangeNotificationProducer.java | 40 +++++++++++----------- 2 files changed, 22 insertions(+), 26 deletions(-) (limited to 'v3po/v3po2vpp/src/main') diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizer.java index 336a66152..10c8478c4 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizer.java @@ -99,8 +99,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer private void setInterfaceFlags(final InstanceIdentifier id, final String swIfName, final int swIfIndex, final byte enabled) throws WriteFailedException { final CompletionStage swInterfaceSetFlagsReplyFuture = - getFutureJVpp().swInterfaceSetFlags( - getSwInterfaceSetFlagsInput(swIfIndex, enabled, (byte) 0 /* deleted */)); + getFutureJVpp().swInterfaceSetFlags(getSwInterfaceSetFlagsInput(swIfIndex, enabled)); LOG.debug("Updating interface flags for: {}, index: {}, enabled: {}", swIfName, swIfIndex, enabled); @@ -109,13 +108,10 @@ public class InterfaceCustomizer extends FutureJVppCustomizer swIfName, swIfIndex, enabled); } - private SwInterfaceSetFlags getSwInterfaceSetFlagsInput(final int swIfIndex, final byte enabled, - final byte deleted) { + private SwInterfaceSetFlags getSwInterfaceSetFlagsInput(final int swIfIndex, final byte enabled) { final SwInterfaceSetFlags swInterfaceSetFlags = new SwInterfaceSetFlags(); swInterfaceSetFlags.swIfIndex = swIfIndex; swInterfaceSetFlags.adminUpDown = enabled; - swInterfaceSetFlags.linkUpDown = enabled; - swInterfaceSetFlags.deleted = deleted; return swInterfaceSetFlags; } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/notification/InterfaceChangeNotificationProducer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/notification/InterfaceChangeNotificationProducer.java index ffab221ee..8ad7debb5 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/notification/InterfaceChangeNotificationProducer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/notification/InterfaceChangeNotificationProducer.java @@ -20,11 +20,16 @@ import com.google.common.base.Optional; import com.google.common.collect.Lists; import com.google.inject.Inject; import com.google.inject.name.Named; +import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.notification.ManagedNotificationProducer; import io.fd.honeycomb.notification.NotificationCollector; import io.fd.honeycomb.translate.MappingContext; -import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; -import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.core.dto.SwInterfaceEventNotification; +import io.fd.vpp.jvpp.core.dto.WantInterfaceEvents; +import io.fd.vpp.jvpp.core.dto.WantInterfaceEventsReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.ArrayList; import java.util.Collection; import java.util.concurrent.CompletionStage; @@ -39,11 +44,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.InterfaceStateChangeBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.InterfaceStatus; import org.opendaylight.yangtools.yang.binding.Notification; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsNotification; -import io.fd.vpp.jvpp.core.dto.WantInterfaceEvents; -import io.fd.vpp.jvpp.core.dto.WantInterfaceEventsReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -76,25 +76,25 @@ public final class InterfaceChangeNotificationProducer implements ManagedNotific LOG.trace("Starting interface notifications"); enableDisableIfcNotifications(1); LOG.debug("Interface notifications started successfully"); - notificationListenerReg = jvpp.getNotificationRegistry().registerSwInterfaceSetFlagsNotificationCallback( - swInterfaceSetFlagsNotification -> { - LOG.trace("Interface notification received: {}", swInterfaceSetFlagsNotification); + notificationListenerReg = jvpp.getNotificationRegistry().registerSwInterfaceEventNotificationCallback( + swInterfaceEventNotification -> { + LOG.trace("Interface notification received: {}", swInterfaceEventNotification); // TODO HONEYCOMB-166 this should be lazy - collector.onNotification(transformNotification(swInterfaceSetFlagsNotification)); + collector.onNotification(transformNotification(swInterfaceEventNotification)); } ); } - private Notification transformNotification(final SwInterfaceSetFlagsNotification swInterfaceSetFlagsNotification) { - if (swInterfaceSetFlagsNotification.deleted == 1) { - return new InterfaceDeletedBuilder().setName(getIfcName(swInterfaceSetFlagsNotification)).build(); + private Notification transformNotification(final SwInterfaceEventNotification swInterfaceEventNotification) { + if (swInterfaceEventNotification.deleted == 1) { + return new InterfaceDeletedBuilder().setName(getIfcName(swInterfaceEventNotification)).build(); } else { return new InterfaceStateChangeBuilder() - .setName(getIfcName(swInterfaceSetFlagsNotification)) - .setAdminStatus(swInterfaceSetFlagsNotification.adminUpDown == 1 + .setName(getIfcName(swInterfaceEventNotification)) + .setAdminStatus(swInterfaceEventNotification.adminUpDown == 1 ? InterfaceStatus.Up : InterfaceStatus.Down) - .setOperStatus(swInterfaceSetFlagsNotification.linkUpDown == 1 + .setOperStatus(swInterfaceEventNotification.linkUpDown == 1 ? InterfaceStatus.Up : InterfaceStatus.Down) .build(); @@ -108,12 +108,12 @@ public final class InterfaceChangeNotificationProducer implements ManagedNotific *

* In case mapping is not available, index is used as name. */ - private InterfaceNameOrIndex getIfcName(final SwInterfaceSetFlagsNotification swInterfaceSetFlagsNotification) { + private InterfaceNameOrIndex getIfcName(final SwInterfaceEventNotification swInterfaceEventNotification) { final Optional optionalName = - interfaceContext.getNameIfPresent(swInterfaceSetFlagsNotification.swIfIndex, mappingContext); + interfaceContext.getNameIfPresent(swInterfaceEventNotification.swIfIndex, mappingContext); return optionalName.isPresent() ? new InterfaceNameOrIndex(optionalName.get()) - : new InterfaceNameOrIndex((long) swInterfaceSetFlagsNotification.swIfIndex); + : new InterfaceNameOrIndex((long) swInterfaceEventNotification.swIfIndex); } @Override -- cgit 1.2.3-korg