summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizer.java8
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/notification/InterfaceChangeNotificationProducer.java40
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizerTest.java2
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/notification/InterfaceChangeNotificationProducerTest.java32
4 files changed, 38 insertions, 44 deletions
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<Interface> id, final String swIfName, final int swIfIndex,
final byte enabled) throws WriteFailedException {
final CompletionStage<SwInterfaceSetFlagsReply> 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
* <p/>
* 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<String> 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
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizerTest.java
index 311889d1a..d33211842 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizerTest.java
@@ -107,9 +107,7 @@ public class InterfaceCustomizerTest extends WriterCustomizerTest implements Byt
private SwInterfaceSetFlags expectedRequest(final boolean enabled) {
final SwInterfaceSetFlags request = new SwInterfaceSetFlags();
- request.deleted = 0;
request.adminUpDown = booleanToByte(enabled);
- request.linkUpDown = booleanToByte(enabled);
request.swIfIndex = IF_INDEX;
return request;
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/notification/InterfaceChangeNotificationProducerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/notification/InterfaceChangeNotificationProducerTest.java
index 4751162f4..7605d42ac 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/notification/InterfaceChangeNotificationProducerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/notification/InterfaceChangeNotificationProducerTest.java
@@ -22,11 +22,17 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import io.fd.honeycomb.notification.NotificationCollector;
-import io.fd.honeycomb.translate.MappingContext;
+import io.fd.hc2vpp.common.test.util.FutureProducer;
import io.fd.hc2vpp.common.test.util.NamingContextHelper;
import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.hc2vpp.common.test.util.FutureProducer;
+import io.fd.honeycomb.notification.NotificationCollector;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.vpp.jvpp.core.callback.SwInterfaceEventNotificationCallback;
+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 io.fd.vpp.jvpp.core.notification.CoreNotificationRegistry;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -34,12 +40,6 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.InterfaceStateChange;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.InterfaceStatus;
-import io.fd.vpp.jvpp.core.callback.SwInterfaceSetFlagsNotificationCallback;
-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 io.fd.vpp.jvpp.core.notification.CoreNotificationRegistry;
public class InterfaceChangeNotificationProducerTest implements FutureProducer, NamingContextHelper {
@@ -59,14 +59,14 @@ public class InterfaceChangeNotificationProducerTest implements FutureProducer,
@Mock
private AutoCloseable notificationListenerReg;
- private ArgumentCaptor<SwInterfaceSetFlagsNotificationCallback> callbackArgumentCaptor;
+ private ArgumentCaptor<SwInterfaceEventNotificationCallback> callbackArgumentCaptor;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
doReturn(notificationRegistry).when(jVpp).getNotificationRegistry();
- callbackArgumentCaptor = ArgumentCaptor.forClass(SwInterfaceSetFlagsNotificationCallback.class);
- doReturn(notificationListenerReg).when(notificationRegistry).registerSwInterfaceSetFlagsNotificationCallback(
+ callbackArgumentCaptor = ArgumentCaptor.forClass(SwInterfaceEventNotificationCallback.class);
+ doReturn(notificationListenerReg).when(notificationRegistry).registerSwInterfaceEventNotificationCallback(
callbackArgumentCaptor.capture());
defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
doReturn(future(new WantInterfaceEventsReply())).when(jVpp).wantInterfaceEvents(any(WantInterfaceEvents.class));
@@ -80,8 +80,8 @@ public class InterfaceChangeNotificationProducerTest implements FutureProducer,
interfaceChangeNotificationProducer.start(collector);
verify(jVpp).wantInterfaceEvents(any(WantInterfaceEvents.class));
verify(jVpp).getNotificationRegistry();
- verify(notificationRegistry).registerSwInterfaceSetFlagsNotificationCallback(any(
- SwInterfaceSetFlagsNotificationCallback.class));
+ verify(notificationRegistry).registerSwInterfaceEventNotificationCallback(any(
+ SwInterfaceEventNotificationCallback.class));
interfaceChangeNotificationProducer.stop();
verify(jVpp, times(2)).wantInterfaceEvents(any(WantInterfaceEvents.class));
@@ -95,12 +95,12 @@ public class InterfaceChangeNotificationProducerTest implements FutureProducer,
interfaceChangeNotificationProducer.start(collector);
- final SwInterfaceSetFlagsNotification swInterfaceSetFlagsNotification = new SwInterfaceSetFlagsNotification();
+ final SwInterfaceEventNotification swInterfaceSetFlagsNotification = new SwInterfaceEventNotification();
swInterfaceSetFlagsNotification.deleted = 0;
swInterfaceSetFlagsNotification.swIfIndex = IFACE_ID;
swInterfaceSetFlagsNotification.adminUpDown = 1;
swInterfaceSetFlagsNotification.linkUpDown = 1;
- callbackArgumentCaptor.getValue().onSwInterfaceSetFlagsNotification(swInterfaceSetFlagsNotification);
+ callbackArgumentCaptor.getValue().onSwInterfaceEventNotification(swInterfaceSetFlagsNotification);
final ArgumentCaptor<InterfaceStateChange> notificationCaptor =
ArgumentCaptor.forClass(InterfaceStateChange.class);
verify(collector).onNotification(notificationCaptor.capture());