summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd
diff options
context:
space:
mode:
authorTibor Sirovatka <tsirovat@cisco.com>2016-05-30 16:52:57 +0200
committerTibor Sirovatka <tsirovat@cisco.com>2016-06-09 08:40:25 +0200
commit744551ed3b657da9f6c8d06bfed4dba4c9fc7700 (patch)
tree364de07c9a5eb1f4f5289f1624576eb5beeb1894 /v3po/v3po2vpp/src/main/java/io/fd
parent8014d193008a60ef3857f14d57d931973daa7cc4 (diff)
HONEYCOMB-67 Introduce exception handling into JVPP
VppApiInvocationException replaced by VPP VPPBaseCallException(s) VppInvocationException - send request failed VppCallbackException - operation had failed (negative result) Change-Id: I897afead8d65ef1240e657116a0610850c62348f Signed-off-by: Tibor Sirovatka <tsirovat@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterconnectionWriteUtils.java55
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java31
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/L2Customizer.java24
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java46
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java31
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java68
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceL2Customizer.java18
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java64
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java69
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java77
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java52
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/Ipv4Customizer.java77
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java32
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java92
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java73
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java11
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/RewriteCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java78
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java93
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java109
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java117
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java102
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java54
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java23
26 files changed, 687 insertions, 715 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterconnectionWriteUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterconnectionWriteUtils.java
index 1463ca9e5..917d2e7ee 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterconnectionWriteUtils.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterconnectionWriteUtils.java
@@ -21,7 +21,6 @@ import static java.util.Objects.requireNonNull;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.concurrent.CompletionStage;
@@ -31,6 +30,7 @@ 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.rev150105.l2.base.attributes.interconnection.XconnectBased;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceSetL2Bridge;
import org.openvpp.jvpp.dto.SwInterfaceSetL2BridgeReply;
import org.openvpp.jvpp.dto.SwInterfaceSetL2Xconnect;
@@ -61,27 +61,31 @@ final class InterconnectionWriteUtils {
void setInterconnection(final InstanceIdentifier<? extends DataObject> id, final int swIfIndex,
final String ifcName,
final Interconnection ic, final WriteContext writeContext)
- throws VppApiInvocationException, WriteFailedException {
- if (ic == null) { // TODO in case of update we should delete interconnection
- LOG.trace("Interconnection is not set. Skipping");
- } else if (ic instanceof XconnectBased) {
- setXconnectBasedL2(swIfIndex, ifcName, (XconnectBased) ic, writeContext);
- } else if (ic instanceof BridgeBased) {
- setBridgeBasedL2(swIfIndex, ifcName, (BridgeBased) ic, writeContext);
- } else {
- // FIXME how does choice extensibility work
- // FIXME it is not even possible to create a dedicated customizer for Interconnection, since it's not a DataObject
- // FIXME we might need a choice customizer
- // THis choice is already from augment, so its probably not possible to augment augmented choice
- LOG.error("Unable to handle Interconnection of type {}", ic.getClass());
- throw new WriteFailedException(id, "Unable to handle Interconnection of type " + ic.getClass());
+ throws WriteFailedException {
+ try {
+ if (ic == null) { // TODO in case of update we should delete interconnection
+ LOG.trace("Interconnection is not set. Skipping");
+ } else if (ic instanceof XconnectBased) {
+ setXconnectBasedL2(swIfIndex, ifcName, (XconnectBased) ic, writeContext);
+ } else if (ic instanceof BridgeBased) {
+ setBridgeBasedL2(swIfIndex, ifcName, (BridgeBased) ic, writeContext);
+ } else {
+ // FIXME how does choice extensibility work
+ // FIXME it is not even possible to create a dedicated customizer for Interconnection, since it's not a DataObject
+ // FIXME we might need a choice customizer
+ // THis choice is already from augment, so its probably not possible to augment augmented choice
+ LOG.error("Unable to handle Interconnection of type {}", ic.getClass());
+ throw new WriteFailedException(id, "Unable to handle Interconnection of type " + ic.getClass());
+ }
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to update bridge/xconnect based interconnection flags for: {}, interconnection: {}", ifcName, ic);
+ throw new WriteFailedException(id, "Unable to handle Interconnection of type " + ic.getClass(), e);
}
}
private void setBridgeBasedL2(final int swIfIndex, final String ifcName, final BridgeBased bb,
final WriteContext writeContext)
- throws VppApiInvocationException {
-
+ throws VppBaseCallException {
LOG.debug("Setting bridge based interconnection(bridge-domain={}) for interface: {}", bb.getBridgeDomain(),
ifcName);
@@ -101,12 +105,7 @@ final class InterconnectionWriteUtils {
final SwInterfaceSetL2BridgeReply reply =
TranslateUtils.getReply(swInterfaceSetL2BridgeReplyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.warn("Failed to update bridge based interconnection flags for: {}, interconnection: {}", ifcName, bb);
- throw new VppApiInvocationException("swInterfaceSetL2Bridge", reply.context, reply.retval);
- } else {
- LOG.debug("Bridge based interconnection updated successfully for: {}, interconnection: {}", ifcName, bb);
- }
+ LOG.debug("Bridge based interconnection updated successfully for: {}, interconnection: {}", ifcName, bb);
}
private SwInterfaceSetL2Bridge getL2BridgeRequest(final int swIfIndex, final int bdId, final byte shg,
@@ -122,7 +121,7 @@ final class InterconnectionWriteUtils {
private void setXconnectBasedL2(final int swIfIndex, final String ifcName, final XconnectBased ic,
final WriteContext writeContext)
- throws VppApiInvocationException {
+ throws VppBaseCallException {
String outSwIfName = ic.getXconnectOutgoingInterface();
LOG.debug("Setting xconnect based interconnection(outgoing ifc={}) for interface: {}", outSwIfName, ifcName);
@@ -136,13 +135,7 @@ final class InterconnectionWriteUtils {
.swInterfaceSetL2Xconnect(getL2XConnectRequest(swIfIndex, outSwIfIndex, (byte) 1 /* enable */));
final SwInterfaceSetL2XconnectReply reply =
TranslateUtils.getReply(swInterfaceSetL2XconnectReplyCompletionStage.toCompletableFuture());
-
- if (reply.retval < 0) {
- LOG.warn("Failed to update xconnect based interconnection flags for: {}, interconnection: {}", ifcName, ic);
- throw new VppApiInvocationException("swInterfaceSetL2Xconnect", reply.context, reply.retval);
- } else {
- LOG.debug("Xconnect based interconnection updated successfully for: {}, interconnection: {}", ifcName, ic);
- }
+ LOG.debug("Xconnect based interconnection updated successfully for: {}, interconnection: {}", ifcName, ic);
}
private SwInterfaceSetL2Xconnect getL2XConnectRequest(final int rxIfc, final int txIfc,
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java
index 3a4638d90..81f5c7dd2 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceCustomizer.java
@@ -18,26 +18,27 @@ package io.fd.honeycomb.v3po.translate.v3po.interfaces;
import com.google.common.base.Optional;
import io.fd.honeycomb.v3po.translate.spi.write.ListWriterCustomizer;
-import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
+import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
-import java.util.List;
-import java.util.concurrent.CompletionStage;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceSetFlags;
import org.openvpp.jvpp.dto.SwInterfaceSetFlagsReply;
import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.util.List;
+import java.util.concurrent.CompletionStage;
+
/**
* Ietf interface write customizer that only caches interface objects for child writers
*/
@@ -59,7 +60,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWri
try {
setInterface(id, dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
+ } catch (VppBaseCallException e) {
LOG.warn("Update of VppInterfaceAugment failed", e);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
@@ -74,7 +75,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWri
try {
updateInterface(id, dataBefore, dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
+ } catch (VppBaseCallException e) {
LOG.warn("Update of VppInterfaceAugment failed", e);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
}
@@ -98,13 +99,13 @@ public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWri
private void setInterface(final InstanceIdentifier<Interface> id, final Interface swIf,
final WriteContext writeContext)
- throws VppApiInvocationException, WriteFailedException {
+ throws VppBaseCallException {
LOG.debug("Setting interface: {} to: {}", id, swIf);
setInterfaceAttributes(swIf, swIf.getName(), writeContext);
}
private void setInterfaceAttributes(final Interface swIf, final String swIfName, final WriteContext writeContext)
- throws VppApiInvocationException {
+ throws VppBaseCallException {
setInterfaceFlags(swIfName, interfaceContext.getIndex(swIfName, writeContext.getMappingContext()),
swIf.isEnabled() ? (byte) 1 : (byte) 0);
@@ -112,27 +113,21 @@ public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWri
private void updateInterface(final InstanceIdentifier<Interface> id,
final Interface dataBefore,
- final Interface dataAfter, final WriteContext writeContext) throws VppApiInvocationException {
+ final Interface dataAfter, final WriteContext writeContext) throws VppBaseCallException {
LOG.debug("Updating interface:{} to: {}", id, dataAfter);
setInterfaceAttributes(dataAfter, dataAfter.getName(), writeContext);
}
private void setInterfaceFlags(final String swIfName, final int swIfIndex, final byte enabled)
- throws VppApiInvocationException {
+ throws VppBaseCallException {
final CompletionStage<SwInterfaceSetFlagsReply> swInterfaceSetFlagsReplyFuture = getFutureJVpp().swInterfaceSetFlags(
getSwInterfaceSetFlagsInput(swIfIndex, enabled, (byte) 0 /* deleted */));
LOG.debug("Updating interface flags for: {}, index: {}, enabled: {}", swIfName, swIfIndex, enabled);
SwInterfaceSetFlagsReply reply = TranslateUtils.getReply(swInterfaceSetFlagsReplyFuture.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.warn("Failed to update interface flags for: {}, index: {}, enabled: {}", swIfName, swIfIndex,
- enabled);
- throw new VppApiInvocationException("swInterfaceSetFlags", reply.context, reply.retval);
- } else {
- LOG.debug("Interface flags updated successfully for: {}, index: {}, enabled: {}, ctxId: {}",
+ LOG.debug("Interface flags updated successfully for: {}, index: {}, enabled: {}, ctxId: {}",
swIfName, swIfIndex, enabled, reply.context);
- }
}
private SwInterfaceSetFlags getSwInterfaceSetFlagsInput(final int swIfIndex, final byte enabled, final byte deleted) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/L2Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/L2Customizer.java
index c4c6ecc0a..099e721ab 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/L2Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/L2Customizer.java
@@ -20,19 +20,23 @@ import com.google.common.base.Optional;
import io.fd.honeycomb.v3po.translate.spi.write.ChildWriterCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.L2;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.util.concurrent.CompletionStage;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
public class L2Customizer extends FutureJVppCustomizer implements ChildWriterCustomizer<L2> {
private static final Logger LOG = LoggerFactory.getLogger(L2Customizer.class);
@@ -59,12 +63,7 @@ public class L2Customizer extends FutureJVppCustomizer implements ChildWriterCus
final String ifcName = id.firstKeyOf(Interface.class).getName();
final int swIfc = interfaceContext.getIndex(ifcName, writeContext.getMappingContext());
- try {
- setL2(id, swIfc, ifcName, dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
- LOG.warn("Write of L2 failed", e);
- throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
- }
+ setL2(id, swIfc, ifcName, dataAfter, writeContext);
}
@Override
@@ -75,12 +74,7 @@ public class L2Customizer extends FutureJVppCustomizer implements ChildWriterCus
final String ifcName = id.firstKeyOf(Interface.class).getName();
final int swIfc = interfaceContext.getIndex(ifcName, writeContext.getMappingContext());
// TODO handle update properly (if possible)
- try {
- setL2(id, swIfc, ifcName, dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
- LOG.warn("Update of L2 failed", e);
- throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
- }
+ setL2(id, swIfc, ifcName, dataAfter, writeContext);
}
@Override
@@ -91,7 +85,7 @@ public class L2Customizer extends FutureJVppCustomizer implements ChildWriterCus
private void setL2(final InstanceIdentifier<L2> id, final int swIfIndex, final String ifcName, final L2 l2,
final WriteContext writeContext)
- throws VppApiInvocationException, WriteFailedException {
+ throws WriteFailedException {
LOG.debug("Setting L2 for interface: {}", ifcName);
// Nothing besides interconnection here
icWriteUtils.setInterconnection(id, swIfIndex, ifcName, l2.getInterconnection(), writeContext);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java
index 2309344c8..f07d163b4 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RewriteCustomizer.java
@@ -16,22 +16,12 @@
package io.fd.honeycomb.v3po.translate.v3po.interfaces;
-import static io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils.booleanToByte;
-
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.fd.honeycomb.v3po.translate.spi.write.ChildWriterCustomizer;
-import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.v3po.translate.v3po.util.SubInterfaceUtils;
-import io.fd.honeycomb.v3po.translate.v3po.util.TagRewriteOperation;
-import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
+import io.fd.honeycomb.v3po.translate.v3po.util.*;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
-import java.util.List;
-import java.util.concurrent.CompletionStage;
-import javax.annotation.Nonnull;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527._802dot1q;
@@ -42,12 +32,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.tag.rewrite.PushTags;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.L2InterfaceVlanTagRewrite;
import org.openvpp.jvpp.dto.L2InterfaceVlanTagRewriteReply;
import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.util.List;
+import java.util.concurrent.CompletionStage;
+
+import static io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils.booleanToByte;
+
/**
* Writer Customizer responsible for vlan tag rewrite.<br> Sends {@code l2_interface_vlan_tag_rewrite} message to
* VPP.<br> Equivalent of invoking {@code vppctl set interface l2 tag-rewrite} command.
@@ -75,10 +72,11 @@ public class RewriteCustomizer extends FutureJVppCustomizer implements ChildWrit
public void writeCurrentAttributes(final InstanceIdentifier<Rewrite> id, final Rewrite dataAfter,
final WriteContext writeContext)
throws WriteFailedException.CreateFailedException {
-
+ final String subifName = getSubInterfaceName(id);
try {
- setTagRewrite(getSubInterfaceName(id), dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
+ setTagRewrite(subifName, dataAfter, writeContext);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to write interface {}(id=): {}", subifName, writeContext, dataAfter);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
}
@@ -89,7 +87,7 @@ public class RewriteCustomizer extends FutureJVppCustomizer implements ChildWrit
}
private void setTagRewrite(final String ifname, final Rewrite rewrite, final WriteContext writeContext)
- throws VppApiInvocationException {
+ throws VppBaseCallException {
final int swIfIndex = interfaceContext.getIndex(ifname, writeContext.getMappingContext());
LOG.debug("Setting tag rewrite for interface {}(id=): {}", ifname, swIfIndex, rewrite);
@@ -98,12 +96,7 @@ public class RewriteCustomizer extends FutureJVppCustomizer implements ChildWrit
final L2InterfaceVlanTagRewriteReply reply =
TranslateUtils.getReply(replyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.debug("Failed to set tag rewrite for interface {}(id=): {}", ifname, swIfIndex, rewrite);
- throw new VppApiInvocationException("l2InterfaceVlanTagRewrite", reply.context, reply.retval);
- } else {
- LOG.debug("Tag rewrite for interface {}(id=) set successfully: {}", ifname, swIfIndex, rewrite);
- }
+ LOG.debug("Tag rewrite for interface {}(id=) set successfully: {}", ifname, swIfIndex, rewrite);
}
private L2InterfaceVlanTagRewrite getTagRewriteRequest(final int swIfIndex, final Rewrite rewrite) {
@@ -142,9 +135,11 @@ public class RewriteCustomizer extends FutureJVppCustomizer implements ChildWrit
@Nonnull final Rewrite dataBefore,
@Nonnull final Rewrite dataAfter, @Nonnull final WriteContext writeContext)
throws WriteFailedException {
+ final String subifName = getSubInterfaceName(id);
try {
- setTagRewrite(getSubInterfaceName(id), dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
+ setTagRewrite(subifName, dataAfter, writeContext);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to update interface {}(id=): {}", subifName, writeContext, dataAfter);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
}
}
@@ -153,12 +148,13 @@ public class RewriteCustomizer extends FutureJVppCustomizer implements ChildWrit
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Rewrite> id,
@Nonnull final Rewrite dataBefore, @Nonnull final WriteContext writeContext)
throws WriteFailedException.DeleteFailedException {
+ final String subifName = getSubInterfaceName(id);
try {
- final String subifName = getSubInterfaceName(id);
LOG.debug("Disabling tag rewrite for interface {}", subifName);
final Rewrite rewrite = new RewriteBuilder().build(); // rewrite without push and pops will cause delete
setTagRewrite(subifName, rewrite, writeContext);
- } catch (VppApiInvocationException e) {
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to delete interface {}(id=): {}", subifName, writeContext, dataBefore);
throw new WriteFailedException.DeleteFailedException(id, e);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java
index 74aee7ae5..0621fc2e3 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/RoutingCustomizer.java
@@ -20,23 +20,24 @@ import com.google.common.base.Optional;
import io.fd.honeycomb.v3po.translate.spi.write.ChildWriterCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
-import java.util.concurrent.CompletionStage;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.Routing;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceSetTable;
import org.openvpp.jvpp.dto.SwInterfaceSetTableReply;
import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.util.concurrent.CompletionStage;
+
public class RoutingCustomizer extends FutureJVppCustomizer implements ChildWriterCustomizer<Routing> {
private static final Logger LOG = LoggerFactory.getLogger(RoutingCustomizer.class);
@@ -59,10 +60,11 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements ChildWrit
@Nonnull final Routing dataAfter, @Nonnull final WriteContext writeContext)
throws WriteFailedException.CreateFailedException {
+ final String ifName = id.firstKeyOf(Interface.class).getName();
try {
- setRouting(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
- LOG.warn("Update of Routing failed", e);
+ setRouting(ifName, dataAfter, writeContext);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to set routing for interface: {}, {}, vxlan: {}", ifName, writeContext, dataAfter);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
}
@@ -73,11 +75,12 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements ChildWrit
@Nonnull final WriteContext writeContext)
throws WriteFailedException.UpdateFailedException {
+ final String ifName = id.firstKeyOf(Interface.class).getName();
try {
// TODO handle updates properly
- setRouting(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
- LOG.warn("Update of Routing failed", e);
+ setRouting(ifName, dataAfter, writeContext);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to update routing for interface: {}, {}, vxlan: {}", ifName, writeContext, dataAfter);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
}
}
@@ -88,7 +91,7 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements ChildWrit
// TODO implement delete
}
- private void setRouting(final String name, final Routing rt, final WriteContext writeContext) throws VppApiInvocationException {
+ private void setRouting(final String name, final Routing rt, final WriteContext writeContext) throws VppBaseCallException {
final int swIfc = interfaceContext.getIndex(name, writeContext.getMappingContext());
LOG.debug("Setting routing for interface: {}, {}. Routing: {}", name, swIfc, rt);
@@ -101,12 +104,7 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements ChildWrit
getFutureJVpp().swInterfaceSetTable(getInterfaceSetTableRequest(swIfc, (byte) 0, /* isIpv6 */ vrfId));
final SwInterfaceSetTableReply reply =
TranslateUtils.getReply(swInterfaceSetTableReplyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.debug("Failed to set routing for interface: {}, {}, vxlan: {}", name, swIfc, rt);
- throw new VppApiInvocationException("swInterfaceSetTable", reply.context, reply.retval);
- } else {
- LOG.debug("Routing set successfully for interface: {}, {}, routing: {}", name, swIfc, rt);
- }
+ LOG.debug("Routing set successfully for interface: {}, {}, routing: {}", name, swIfc, rt);
}
}
@@ -117,5 +115,4 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements ChildWrit
swInterfaceSetTable.vrfId = vrfId;
return swInterfaceSetTable;
}
-
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java
index cb0a2c3df..7d24fdd7b 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceCustomizer.java
@@ -16,24 +16,14 @@
package io.fd.honeycomb.v3po.translate.v3po.interfaces;
-import static com.google.common.base.Preconditions.checkState;
-import static io.fd.honeycomb.v3po.translate.v3po.util.SubInterfaceUtils.getSubInterfaceName;
-import static io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils.booleanToByte;
-
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.fd.honeycomb.v3po.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
-import java.util.List;
-import java.util.Objects;
-import java.util.concurrent.CompletionStage;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.CVlan;
import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.Dot1qVlanId;
import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.SVlan;
@@ -50,6 +40,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.tags.Tag;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.CreateSubif;
import org.openvpp.jvpp.dto.CreateSubifReply;
import org.openvpp.jvpp.dto.SwInterfaceSetFlags;
@@ -58,6 +49,16 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.CompletionStage;
+
+import static com.google.common.base.Preconditions.checkState;
+import static io.fd.honeycomb.v3po.translate.v3po.util.SubInterfaceUtils.getSubInterfaceName;
+import static io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils.booleanToByte;
+
/**
* Writer Customizer responsible for sub interface creation.<br> Sends {@code create_subif} message to VPP.<br>
* Equivalent of invoking {@code vppclt create subif} command.
@@ -87,31 +88,27 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
throws WriteFailedException.CreateFailedException {
try {
createSubInterface(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to create sub interface for: {}, subInterface: {}", id.firstKeyOf(Interface.class).getName(), dataAfter);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
}
private void createSubInterface(@Nonnull final String superIfName,
- @Nonnull final SubInterface subInterface, final WriteContext writeContext)
- throws VppApiInvocationException {
+ @Nonnull final SubInterface subInterface,
+ final WriteContext writeContext) throws VppBaseCallException {
final int superIfIndex = interfaceContext.getIndex(superIfName, writeContext.getMappingContext());
- LOG.debug("Creating sub interface of {}(id={}): subInterface={}", superIfName, superIfIndex, subInterface);
final CompletionStage<CreateSubifReply> createSubifReplyCompletionStage =
- getFutureJVpp().createSubif(getCreateSubifRequest(subInterface, superIfIndex));
+ getFutureJVpp().createSubif(getCreateSubifRequest(subInterface, superIfIndex));
final CreateSubifReply reply =
- TranslateUtils.getReply(createSubifReplyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.debug("Failed to create sub interface for: {}, subInterface: {}", superIfName, subInterface);
- throw new VppApiInvocationException("createSubif", reply.context, reply.retval);
- } else {
- setInterfaceState(reply.swIfIndex, booleanToByte(subInterface.isEnabled()));
- interfaceContext.addName(reply.swIfIndex,
- getSubInterfaceName(superIfName, Math.toIntExact(subInterface.getIdentifier())),
- writeContext.getMappingContext());
- LOG.debug("Sub interface created successfully for: {}, subInterface: {}", superIfName, subInterface);
- }
+ TranslateUtils.getReply(createSubifReplyCompletionStage.toCompletableFuture());
+
+ setInterfaceState(reply.swIfIndex, booleanToByte(subInterface.isEnabled()));
+ interfaceContext.addName(reply.swIfIndex,
+ getSubInterfaceName(superIfName, Math.toIntExact(subInterface.getIdentifier())),
+ writeContext.getMappingContext());
+ LOG.debug("Sub interface created successfully for: {}, subInterface: {}", superIfName, subInterface);
}
private CreateSubif getCreateSubifRequest(@Nonnull final SubInterface subInterface, final int swIfIndex) {
@@ -196,17 +193,19 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
LOG.debug("No state update will be performed. Ignoring config");
return; // TODO shouldn't we throw exception here (if there will be dedicated L2 customizer)?
}
+ final String subIfaceName = getSubInterfaceName(id.firstKeyOf(Interface.class).getName(),
+ Math.toIntExact(dataAfter.getIdentifier()));
try {
- final String subIfaceName = getSubInterfaceName(id.firstKeyOf(Interface.class).getName(),
- Math.toIntExact(dataAfter.getIdentifier()));
setInterfaceState(interfaceContext.getIndex(subIfaceName, writeContext.getMappingContext()),
booleanToByte(dataAfter.isEnabled()));
- } catch (VppApiInvocationException e) {
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to update interface state for: interface if={}, enabled: {}",
+ subIfaceName, booleanToByte(dataAfter.isEnabled()));
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
}
}
- private void setInterfaceState(final int swIfIndex, final byte enabled) throws VppApiInvocationException {
+ private void setInterfaceState(final int swIfIndex, final byte enabled) throws VppBaseCallException {
final SwInterfaceSetFlags swInterfaceSetFlags = new SwInterfaceSetFlags();
swInterfaceSetFlags.swIfIndex = swIfIndex;
swInterfaceSetFlags.adminUpDown = enabled;
@@ -217,13 +216,8 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
LOG.debug("Updating interface state for: interface if={}, enabled: {}", swIfIndex, enabled);
SwInterfaceSetFlagsReply reply = TranslateUtils.getReply(swInterfaceSetFlagsReplyFuture.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.warn("Failed to update interface state for: interface if={}, enabled: {}", swIfIndex, enabled);
- throw new VppApiInvocationException("swInterfaceSetFlags", reply.context, reply.retval);
- } else {
- LOG.debug("Interface state updated successfully for: {}, index: {}, enabled: {}, ctxId: {}",
- swIfIndex, enabled, reply.context);
- }
+ LOG.debug("Interface state updated successfully for: {}, index: {}, enabled: {}, ctxId: {}",
+ swIfIndex, enabled, reply.context);
}
@Override
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceL2Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceL2Customizer.java
index a1957f5a0..c621612c7 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceL2Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/SubInterfaceL2Customizer.java
@@ -21,7 +21,6 @@ import io.fd.honeycomb.v3po.translate.spi.write.ChildWriterCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.SubInterfaceUtils;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import javax.annotation.Nonnull;
@@ -32,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.L2;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,12 +64,7 @@ public class SubInterfaceL2Customizer extends FutureJVppCustomizer implements Ch
throws WriteFailedException {
final String subInterfaceName = getSubInterfaceName(id);
final int subInterfaceIndex = interfaceContext.getIndex(subInterfaceName, writeContext.getMappingContext());
- try {
- setL2(id, subInterfaceIndex, subInterfaceName, dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
- LOG.warn("Write of L2 failed", e);
- throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
- }
+ setL2(id, subInterfaceIndex, subInterfaceName, dataAfter, writeContext);
}
private String getSubInterfaceName(@Nonnull final InstanceIdentifier<L2> id) {
@@ -87,12 +82,7 @@ public class SubInterfaceL2Customizer extends FutureJVppCustomizer implements Ch
final String subInterfaceName = getSubInterfaceName(id);
final int subInterfaceIndex = interfaceContext.getIndex(subInterfaceName, writeContext.getMappingContext());
// TODO handle update properly (if possible)
- try {
- setL2(id, subInterfaceIndex, subInterfaceName, dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
- LOG.warn("Update of L2 failed", e);
- throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
- }
+ setL2(id, subInterfaceIndex, subInterfaceName, dataAfter, writeContext);
}
@Override
@@ -103,7 +93,7 @@ public class SubInterfaceL2Customizer extends FutureJVppCustomizer implements Ch
private void setL2(final InstanceIdentifier<L2> id, final int swIfIndex, final String ifcName, final L2 l2,
final WriteContext writeContext)
- throws VppApiInvocationException, WriteFailedException {
+ throws WriteFailedException {
LOG.debug("Setting L2 for sub-interface: {}", ifcName);
icWriterUtils.setInterconnection(id, swIfIndex, ifcName, l2.getInterconnection(), writeContext);
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java
index 5f98ade94..2046caf1f 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizer.java
@@ -19,12 +19,9 @@ package io.fd.honeycomb.v3po.translate.v3po.interfaces;
import com.google.common.base.Optional;
import io.fd.honeycomb.v3po.translate.v3po.util.AbstractInterfaceTypeCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
-import java.util.concurrent.CompletionStage;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
@@ -32,16 +29,15 @@ 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.rev150105.interfaces._interface.Tap;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.openvpp.jvpp.dto.TapConnect;
-import org.openvpp.jvpp.dto.TapConnectReply;
-import org.openvpp.jvpp.dto.TapDelete;
-import org.openvpp.jvpp.dto.TapDeleteReply;
-import org.openvpp.jvpp.dto.TapModify;
-import org.openvpp.jvpp.dto.TapModifyReply;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.dto.*;
import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.util.concurrent.CompletionStage;
+
public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
private static final Logger LOG = LoggerFactory.getLogger(TapCustomizer.class);
@@ -68,10 +64,11 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
protected final void writeInterface(@Nonnull final InstanceIdentifier<Tap> id, @Nonnull final Tap dataAfter,
@Nonnull final WriteContext writeContext)
throws WriteFailedException.CreateFailedException {
+ final String ifcName = id.firstKeyOf(Interface.class).getName();
try {
- createTap(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
- LOG.warn("Write of Tap failed", e);
+ createTap(ifcName, dataAfter, writeContext);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to set tap interface: {}, tap: {}", ifcName, dataAfter, e);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
}
@@ -91,8 +88,8 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
try {
modifyTap(ifcName, index, dataAfter);
- } catch (VppApiInvocationException e) {
- LOG.warn("Write of Tap failed", e);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to set tap interface: {}, tap: {}", ifcName, dataAfter, e);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
}
}
@@ -112,58 +109,43 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> {
try {
deleteTap(ifcName, index, dataBefore, writeContext);
- } catch (VppApiInvocationException e) {
- LOG.warn("Delete of Tap failed", e);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to delete tap interface: {}, tap: {}", ifcName, e);
throw new WriteFailedException.DeleteFailedException(id, e);
}
}
- private void createTap(final String swIfName, final Tap tap, final WriteContext writeContext) throws VppApiInvocationException {
+ private void createTap(final String swIfName, final Tap tap, final WriteContext writeContext) throws VppBaseCallException {
LOG.debug("Setting tap interface: {}. Tap: {}", swIfName, tap);
final CompletionStage<TapConnectReply> tapConnectFuture =
getFutureJVpp().tapConnect(getTapConnectRequest(tap.getTapName(), tap.getMac(), tap.getDeviceInstance()));
final TapConnectReply reply =
TranslateUtils.getReply(tapConnectFuture.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.warn("Failed to set tap interface: {}, tap: {}", swIfName, tap);
- throw new VppApiInvocationException("tap_connect", reply.context, reply.retval);
- } else {
- LOG.debug("Tap set successfully for: {}, tap: {}", swIfName, tap);
- // Add new interface to our interface context
- interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
- }
+ LOG.debug("Tap set successfully for: {}, tap: {}", swIfName, tap);
+ // Add new interface to our interface context
+ interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
}
- private void modifyTap(final String swIfName, final int index, final Tap tap) throws VppApiInvocationException {
+ private void modifyTap(final String swIfName, final int index, final Tap tap) throws VppBaseCallException {
LOG.debug("Modifying tap interface: {}. Tap: {}", swIfName, tap);
final CompletionStage<TapModifyReply> vxlanAddDelTunnelReplyCompletionStage =
getFutureJVpp().tapModify(getTapModifyRequest(tap.getTapName(), index, tap.getMac(), tap.getDeviceInstance()));
final TapModifyReply reply =
TranslateUtils.getReply(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.warn("Failed to modify tap interface: {}, tap: {}", swIfName, tap);
- throw new VppApiInvocationException("tap_modify", reply.context, reply.retval);
- } else {
- LOG.debug("Tap modified successfully for: {}, tap: {}", swIfName, tap);
- }
+ LOG.debug("Tap modified successfully for: {}, tap: {}", swIfName, tap);
}
private void deleteTap(final String swIfName, final int index, final Tap dataBefore,
final WriteContext writeContext)
- throws VppApiInvocationException {
+ throws VppBaseCallException {
LOG.debug("Deleting tap interface: {}. Tap: {}", swIfName, dataBefore);
final CompletionStage<TapDeleteReply> vxlanAddDelTunnelReplyCompletionStage =
getFutureJVpp().tapDelete(getTapDeleteRequest(index));
final TapDeleteReply reply =
TranslateUtils.getReply(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.warn("Failed to delete tap interface: {}, tap: {}", swIfName, dataBefore);
- throw new VppApiInvocationException("tap_modify", reply.context, reply.retval);
- } else {
- LOG.debug("Tap deleted successfully for: {}, tap: {}", swIfName, dataBefore);
- // Remove deleted interface from interface context
- interfaceContext.removeName(swIfName, writeContext.getMappingContext());
- }
+ LOG.debug("Tap deleted successfully for: {}, tap: {}", swIfName, dataBefore);
+ // Remove deleted interface from interface context
+ interfaceContext.removeName(swIfName, writeContext.getMappingContext());
}
private TapConnect getTapConnectRequest(final String tapName, final PhysAddress mac, final Long deviceInstance) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java
index 6c45e98ac..ae25354fc 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizer.java
@@ -20,12 +20,9 @@ import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.fd.honeycomb.v3po.translate.v3po.util.AbstractInterfaceTypeCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
-import java.util.concurrent.CompletionStage;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUserRole;
@@ -33,16 +30,15 @@ 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.rev150105.interfaces._interface.VhostUser;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.openvpp.jvpp.dto.CreateVhostUserIf;
-import org.openvpp.jvpp.dto.CreateVhostUserIfReply;
-import org.openvpp.jvpp.dto.DeleteVhostUserIf;
-import org.openvpp.jvpp.dto.DeleteVhostUserIfReply;
-import org.openvpp.jvpp.dto.ModifyVhostUserIf;
-import org.openvpp.jvpp.dto.ModifyVhostUserIfReply;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.dto.*;
import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.util.concurrent.CompletionStage;
+
/**
* Writer Customizer responsible for passing vhost user interface CRD operations to VPP
*/
@@ -72,28 +68,25 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
protected final void writeInterface(@Nonnull final InstanceIdentifier<VhostUser> id,
@Nonnull final VhostUser dataAfter, @Nonnull final WriteContext writeContext)
throws WriteFailedException.CreateFailedException {
+ final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- createVhostUserIf(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
- } catch (VppApiInvocationException | IllegalInterfaceTypeException e) {
+ createVhostUserIf(swIfName, dataAfter, writeContext);
+ } catch (VppBaseCallException | IllegalInterfaceTypeException e) {
+ LOG.debug("Failed to create vhost user interface: {}, vhostUser: {}", swIfName, dataAfter);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
}
- private void createVhostUserIf(final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppApiInvocationException {
+ private void createVhostUserIf(final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppBaseCallException {
LOG.debug("Creating vhost user interface: name={}, vhostUser={}", swIfName, vhostUser);
+
final CompletionStage<CreateVhostUserIfReply> createVhostUserIfReplyCompletionStage =
getFutureJVpp().createVhostUserIf(getCreateVhostUserIfRequest(vhostUser));
-
final CreateVhostUserIfReply reply =
TranslateUtils.getReply(createVhostUserIfReplyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.debug("Failed to create vhost user interface: {}, vhostUser: {}", swIfName, vhostUser);
- throw new VppApiInvocationException("createVhostUserIf", reply.context, reply.retval);
- } else {
- LOG.debug("Vhost user interface created successfully for: {}, vhostUser: {}", swIfName, vhostUser);
- // Add new interface to our interface context
- interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
- }
+ LOG.debug("Vhost user interface created successfully for: {}, vhostUser: {}", swIfName, vhostUser);
+ // Add new interface to our interface context
+ interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
}
private CreateVhostUserIf getCreateVhostUserIfRequest(final VhostUser vhostUser) {
@@ -112,14 +105,16 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
@Nonnull final VhostUser dataBefore, @Nonnull final VhostUser dataAfter,
@Nonnull final WriteContext writeContext)
throws WriteFailedException.UpdateFailedException {
+ final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- modifyVhostUserIf(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
+ modifyVhostUserIf(swIfName, dataAfter, writeContext);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to update vhost user interface: {}, vhostUser: {}", swIfName, dataAfter);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
}
}
- private void modifyVhostUserIf(final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppApiInvocationException {
+ private void modifyVhostUserIf(final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppBaseCallException {
LOG.debug("Updating vhost user interface: name={}, vhostUser={}", swIfName, vhostUser);
final CompletionStage<ModifyVhostUserIfReply> modifyVhostUserIfReplyCompletionStage =
getFutureJVpp()
@@ -127,12 +122,7 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
final ModifyVhostUserIfReply reply =
TranslateUtils.getReply(modifyVhostUserIfReplyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.debug("Failed to update vhost user interface: {}, vhostUser: {}", swIfName, vhostUser);
- throw new VppApiInvocationException("modifyVhostUserIf", reply.context, reply.retval);
- } else {
- LOG.debug("Vhost user interface updated successfully for: {}, vhostUser: {}", swIfName, vhostUser);
- }
+ LOG.debug("Vhost user interface updated successfully for: {}, vhostUser: {}", swIfName, vhostUser);
}
private ModifyVhostUserIf getModifyVhostUserIfRequest(final VhostUser vhostUser, final int swIfIndex) {
@@ -149,28 +139,25 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<VhostUser> id,
@Nonnull final VhostUser dataBefore, @Nonnull final WriteContext writeContext)
throws WriteFailedException.DeleteFailedException {
+ final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- deleteVhostUserIf(id.firstKeyOf(Interface.class).getName(), dataBefore, writeContext);
- } catch (VppApiInvocationException e) {
+ deleteVhostUserIf(swIfName, dataBefore, writeContext);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to delete vhost user interface: {}, vhostUser: {}", swIfName, dataBefore);
throw new WriteFailedException.DeleteFailedException(id, e);
}
}
- private void deleteVhostUserIf(final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppApiInvocationException {
+ private void deleteVhostUserIf(final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) throws VppBaseCallException {
LOG.debug("Deleting vhost user interface: name={}, vhostUser={}", swIfName, vhostUser);
final CompletionStage<DeleteVhostUserIfReply> deleteVhostUserIfReplyCompletionStage =
getFutureJVpp().deleteVhostUserIf(getDeleteVhostUserIfRequest(interfaceContext.getIndex(swIfName, writeContext.getMappingContext())));
final DeleteVhostUserIfReply reply =
TranslateUtils.getReply(deleteVhostUserIfReplyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.debug("Failed to delete vhost user interface: {}, vhostUser: {}", swIfName, vhostUser);
- throw new VppApiInvocationException("modifyVhostUserIf", reply.context, reply.retval);
- } else {
- LOG.debug("Vhost user interface deleted successfully for: {}, vhostUser: {}", swIfName, vhostUser);
- // Remove interface from our interface context
- interfaceContext.removeName(swIfName, writeContext.getMappingContext());
- }
+ LOG.debug("Vhost user interface deleted successfully for: {}, vhostUser: {}", swIfName, vhostUser);
+ // Remove interface from our interface context
+ interfaceContext.removeName(swIfName, writeContext.getMappingContext());
}
private DeleteVhostUserIf getDeleteVhostUserIfRequest(final int swIfIndex) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java
index 5b2be71cc..77489eca2 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizer.java
@@ -16,19 +16,13 @@
package io.fd.honeycomb.v3po.translate.v3po.interfaces;
-import static com.google.common.base.Preconditions.checkArgument;
-
import com.google.common.base.Optional;
import com.google.common.net.InetAddresses;
import io.fd.honeycomb.v3po.translate.v3po.util.AbstractInterfaceTypeCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
-import java.net.InetAddress;
-import java.util.concurrent.CompletionStage;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
@@ -37,12 +31,19 @@ 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.rev150105.interfaces._interface.Vxlan;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.VxlanAddDelTunnel;
import org.openvpp.jvpp.dto.VxlanAddDelTunnelReply;
import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.net.InetAddress;
+import java.util.concurrent.CompletionStage;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
// TODO extract common code from all Interface type specific writer customizers into a superclass
public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
@@ -70,10 +71,11 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
protected final void writeInterface(@Nonnull final InstanceIdentifier<Vxlan> id, @Nonnull final Vxlan dataAfter,
@Nonnull final WriteContext writeContext)
throws WriteFailedException.CreateFailedException {
+ final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- createVxlanTunnel(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
- } catch (VppApiInvocationException | IllegalInterfaceTypeException e) {
- LOG.warn("Write of Vxlan failed", e);
+ createVxlanTunnel(swIfName, dataAfter, writeContext);
+ } catch (VppBaseCallException | IllegalInterfaceTypeException e) {
+ LOG.debug("Failed to set vxlan tunnel for interface: {}, vxlan: {}", swIfName, dataAfter);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
}
@@ -90,15 +92,16 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Vxlan> id, @Nonnull final Vxlan dataBefore,
@Nonnull final WriteContext writeContext)
throws WriteFailedException.DeleteFailedException {
+ final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- deleteVxlanTunnel(id.firstKeyOf(Interface.class).getName(), dataBefore, writeContext);
- } catch (VppApiInvocationException e) {
- LOG.warn("Delete of Vxlan tunnel failed", e);
+ deleteVxlanTunnel(swIfName, dataBefore, writeContext);
+ } catch (VppBaseCallException e) {
+ LOG.debug("Failed to delete vxlan tunnel for interface: {}, vxlan: {}", swIfName, dataBefore);
throw new WriteFailedException.DeleteFailedException(id, e);
}
}
- private void createVxlanTunnel(final String swIfName, final Vxlan vxlan, final WriteContext writeContext) throws VppApiInvocationException {
+ private void createVxlanTunnel(final String swIfName, final Vxlan vxlan, final WriteContext writeContext) throws VppBaseCallException {
final byte isIpv6 = (byte) (isIpv6(vxlan) ? 1 : 0);
final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc()));
final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst()));
@@ -113,27 +116,22 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
final VxlanAddDelTunnelReply reply =
TranslateUtils.getReply(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.debug("Failed to set vxlan tunnel for interface: {}, vxlan: {}", swIfName, vxlan);
- throw new VppApiInvocationException("vxlanAddDelTunnel", reply.context, reply.retval);
- } else {
- LOG.debug("Vxlan tunnel set successfully for: {}, vxlan: {}", swIfName, vxlan);
- if(interfaceContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) {
- // VPP keeps vxlan tunnels present even after they are delete(reserving ID for next tunnel)
- // This may cause inconsistencies in mapping context when configuring tunnels like this:
- // 1. Add tunnel 2. Delete tunnel 3. Read interfaces (reserved mapping e.g. vxlan_tunnel0 -> 6
- // will get into mapping context) 4. Add tunnel (this will add another mapping with the same
- // reserved ID and context is invalid)
- // That's why a check has to be performed here removing mapping vxlan_tunnel0 -> 6 mapping and storing
- // new name for that ID
- final String formerName = interfaceContext.getName(reply.swIfIndex, writeContext.getMappingContext());
- LOG.debug("Removing updated mapping of a vxlan tunnel, id: {}, former name: {}, new name: {}",
- reply.swIfIndex, formerName, swIfName);
- interfaceContext.removeName(formerName, writeContext.getMappingContext());
- }
- // Add new interface to our interface context
- interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
+ LOG.debug("Vxlan tunnel set successfully for: {}, vxlan: {}", swIfName, vxlan);
+ if(interfaceContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) {
+ // VPP keeps vxlan tunnels present even after they are delete(reserving ID for next tunnel)
+ // This may cause inconsistencies in mapping context when configuring tunnels like this:
+ // 1. Add tunnel 2. Delete tunnel 3. Read interfaces (reserved mapping e.g. vxlan_tunnel0 -> 6
+ // will get into mapping context) 4. Add tunnel (this will add another mapping with the same
+ // reserved ID and context is invalid)
+ // That's why a check has to be performed here removing mapping vxlan_tunnel0 -> 6 mapping and storing
+ // new name for that ID
+ final String formerName = interfaceContext.getName(reply.swIfIndex, writeContext.getMappingContext());
+ LOG.debug("Removing updated mapping of a vxlan tunnel, id: {}, former name: {}, new name: {}",
+ reply.swIfIndex, formerName, swIfName);
+ interfaceContext.removeName(formerName, writeContext.getMappingContext());
}
+ // Add new interface to our interface context
+ interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
}
private boolean isIpv6(final Vxlan vxlan) {
@@ -152,7 +150,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
return addr.getIpv4Address() == null ? addr.getIpv6Address().getValue() : addr.getIpv4Address().getValue();
}
- private void deleteVxlanTunnel(final String swIfName, final Vxlan vxlan, final WriteContext writeContext) throws VppApiInvocationException {
+ private void deleteVxlanTunnel(final String swIfName, final Vxlan vxlan, final WriteContext writeContext) throws VppBaseCallException {
final byte isIpv6 = (byte) (isIpv6(vxlan) ? 1 : 0);
final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc()));
final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst()));
@@ -167,14 +165,9 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> {
final VxlanAddDelTunnelReply reply =
TranslateUtils.getReply(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.debug("Failed to delete vxlan tunnel for interface: {}, vxlan: {}", swIfName, vxlan);
- throw new VppApiInvocationException("vxlanAddDelTunnel", reply.context, reply.retval);
- } else {
- LOG.debug("Vxlan tunnel deleted successfully for: {}, vxlan: {}", swIfName, vxlan);
- // Remove interface from our interface context
- interfaceContext.removeName(swIfName, writeContext.getMappingContext());
- }
+ LOG.debug("Vxlan tunnel deleted successfully for: {}, vxlan: {}", swIfName, vxlan);
+ // Remove interface from our interface context
+ interfaceContext.removeName(swIfName, writeContext.getMappingContext());
}
private static VxlanAddDelTunnel getVxlanTunnelRequest(final byte isAdd, final byte[] srcAddr, final byte[] dstAddr,
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java
index 7d9641122..216d354b4 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanGpeCustomizer.java
@@ -22,7 +22,6 @@ import com.google.common.base.Optional;
import com.google.common.net.InetAddresses;
import io.fd.honeycomb.v3po.translate.v3po.util.AbstractInterfaceTypeCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
@@ -37,6 +36,7 @@ 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.rev150105.interfaces._interface.VxlanGpe;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.VxlanGpeAddDelTunnel;
import org.openvpp.jvpp.dto.VxlanGpeAddDelTunnelReply;
import org.openvpp.jvpp.future.FutureJVpp;
@@ -70,10 +70,11 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
protected final void writeInterface(@Nonnull final InstanceIdentifier<VxlanGpe> id, @Nonnull final VxlanGpe dataAfter,
@Nonnull final WriteContext writeContext)
throws WriteFailedException.CreateFailedException {
+ final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- createVxlanGpeTunnel(id.firstKeyOf(Interface.class).getName(), dataAfter, writeContext);
- } catch (VppApiInvocationException | IllegalInterfaceTypeException e) {
- LOG.warn("Write of VxlanGpe failed", e);
+ createVxlanGpeTunnel(swIfName, dataAfter, writeContext);
+ } catch (VppBaseCallException | IllegalInterfaceTypeException e) {
+ LOG.warn("Failed to set VxlanGpe tunnel for interface: {}, VxlanGpe: {}", swIfName, dataAfter);
throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
}
}
@@ -90,15 +91,16 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<VxlanGpe> id, @Nonnull final VxlanGpe dataBefore,
@Nonnull final WriteContext writeContext)
throws WriteFailedException.DeleteFailedException {
+ final String swIfName = id.firstKeyOf(Interface.class).getName();
try {
- deleteVxlanGpeTunnel(id.firstKeyOf(Interface.class).getName(), dataBefore, writeContext);
- } catch (VppApiInvocationException e) {
- LOG.warn("Delete of VxlanGpe tunnel failed", e);
+ deleteVxlanGpeTunnel(swIfName, dataBefore, writeContext);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to delete VxlanGpe tunnel for interface: {}, VxlanGpe: {}", swIfName, dataBefore);
throw new WriteFailedException.DeleteFailedException(id, e);
}
}
- private void createVxlanGpeTunnel(final String swIfName, final VxlanGpe VxlanGpe, final WriteContext writeContext) throws VppApiInvocationException {
+ private void createVxlanGpeTunnel(final String swIfName, final VxlanGpe VxlanGpe, final WriteContext writeContext) throws VppBaseCallException {
final byte isIpv6 = (byte) (isIpv6(VxlanGpe) ? 1 : 0);
final InetAddress Local = InetAddresses.forString(getAddressString(VxlanGpe.getLocal()));
final InetAddress Remote = InetAddresses.forString(getAddressString(VxlanGpe.getRemote()));
@@ -115,20 +117,15 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
final VxlanGpeAddDelTunnelReply reply =
TranslateUtils.getReply(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.debug("Failed to set VxlanGpe tunnel for interface: {}, VxlanGpe: {}", swIfName, VxlanGpe);
- throw new VppApiInvocationException("VxlanGpeAddDelTunnel", reply.context, reply.retval);
- } else {
- LOG.debug("VxlanGpe tunnel set successfully for: {}, VxlanGpe: {}", swIfName, VxlanGpe);
- if(interfaceContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) {
- final String formerName = interfaceContext.getName(reply.swIfIndex, writeContext.getMappingContext());
- LOG.debug("Removing updated mapping of a vxlan-gpe tunnel, id: {}, former name: {}, new name: {}",
- reply.swIfIndex, formerName, swIfName);
- interfaceContext.removeName(formerName, writeContext.getMappingContext());
- }
- // Add new interface to our interface context
- interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
+ LOG.debug("VxlanGpe tunnel set successfully for: {}, VxlanGpe: {}", swIfName, VxlanGpe);
+ if(interfaceContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) {
+ final String formerName = interfaceContext.getName(reply.swIfIndex, writeContext.getMappingContext());
+ LOG.debug("Removing updated mapping of a vxlan-gpe tunnel, id: {}, former name: {}, new name: {}",
+ reply.swIfIndex, formerName, swIfName);
+ interfaceContext.removeName(formerName, writeContext.getMappingContext());
}
+ // Add new interface to our interface context
+ interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
}
private boolean isIpv6(final VxlanGpe VxlanGpe) {
@@ -147,7 +144,7 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
return addr.getIpv4Address() == null ? addr.getIpv6Address().getValue() : addr.getIpv4Address().getValue();
}
- private void deleteVxlanGpeTunnel(final String swIfName, final VxlanGpe VxlanGpe, final WriteContext writeContext) throws VppApiInvocationException {
+ private void deleteVxlanGpeTunnel(final String swIfName, final VxlanGpe VxlanGpe, final WriteContext writeContext) throws VppBaseCallException {
final byte isIpv6 = (byte) (isIpv6(VxlanGpe) ? 1 : 0);
final InetAddress local = InetAddresses.forString(getAddressString(VxlanGpe.getLocal()));
final InetAddress remote = InetAddresses.forString(getAddressString(VxlanGpe.getRemote()));
@@ -164,14 +161,9 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
final VxlanGpeAddDelTunnelReply reply =
TranslateUtils.getReply(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.debug("Failed to delete VxlanGpe tunnel for interface: {}, VxlanGpe: {}", swIfName, VxlanGpe);
- throw new VppApiInvocationException("VxlanGpeAddDelTunnel", reply.context, reply.retval);
- } else {
- LOG.debug("VxlanGpe tunnel deleted successfully for: {}, VxlanGpe: {}", swIfName, VxlanGpe);
- // Remove interface from our interface context
- interfaceContext.removeName(swIfName, writeContext.getMappingContext());
- }
+ LOG.debug("VxlanGpe tunnel deleted successfully for: {}, VxlanGpe: {}", swIfName, VxlanGpe);
+ // Remove interface from our interface context
+ interfaceContext.removeName(swIfName, writeContext.getMappingContext());
}
private static VxlanGpeAddDelTunnel getVxlanGpeTunnelRequest(final byte isAdd, final byte[] local, final byte[] remote,
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/Ipv4Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/Ipv4Customizer.java
index fb891f838..5e00dd9b3 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/Ipv4Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/ip/Ipv4Customizer.java
@@ -16,19 +16,13 @@
package io.fd.honeycomb.v3po.translate.v3po.interfaces.ip;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import com.google.common.base.Optional;
import io.fd.honeycomb.v3po.translate.spi.write.ChildWriterCustomizer;
-import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
+import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
-import java.util.concurrent.CompletionStage;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface1;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv4;
@@ -38,12 +32,19 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev14061
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.address.subnet.PrefixLength;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceAddDelAddress;
import org.openvpp.jvpp.dto.SwInterfaceAddDelAddressReply;
import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.util.concurrent.CompletionStage;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
public class Ipv4Customizer extends FutureJVppCustomizer implements ChildWriterCustomizer<Ipv4> {
private static final Logger LOG = LoggerFactory.getLogger(Ipv4Customizer.class);
@@ -66,13 +67,8 @@ public class Ipv4Customizer extends FutureJVppCustomizer implements ChildWriterC
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Ipv4> id,
@Nonnull final Ipv4 dataAfter, @Nonnull final WriteContext writeContext)
throws WriteFailedException {
- try {
- final String ifcName = id.firstKeyOf(Interface.class).getName();
- setIpv4(id, ifcName, dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
- LOG.warn("Create of Ipv4 failed", e);
- throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
- }
+ final String ifcName = id.firstKeyOf(Interface.class).getName();
+ setIpv4(id, ifcName, dataAfter, writeContext);
}
@Override
@@ -83,12 +79,7 @@ public class Ipv4Customizer extends FutureJVppCustomizer implements ChildWriterC
final String ifcName = id.firstKeyOf(Interface.class).getName();
// TODO handle update in a better way
- try {
- setIpv4(id, ifcName, dataAfter, writeContext);
- } catch (VppApiInvocationException e) {
- LOG.warn("Update of Ipv4 failed", e);
- throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
- }
+ setIpv4(id, ifcName, dataAfter, writeContext);
}
@Override
@@ -99,14 +90,14 @@ public class Ipv4Customizer extends FutureJVppCustomizer implements ChildWriterC
private void setIpv4(final InstanceIdentifier<Ipv4> id, final String name, final Ipv4 ipv4,
final WriteContext writeContext)
- throws WriteFailedException, VppApiInvocationException {
+ throws WriteFailedException {
final int swIfc = interfaceContext.getIndex(name, writeContext.getMappingContext());
for (Address ipv4Addr : ipv4.getAddress()) {
Subnet subnet = ipv4Addr.getSubnet();
if (subnet instanceof PrefixLength) {
- setPrefixLengthSubnet(name, swIfc, ipv4Addr, (PrefixLength) subnet);
+ setPrefixLengthSubnet(id, name, swIfc, ipv4Addr, (PrefixLength) subnet);
} else if (subnet instanceof Netmask) {
setNetmaskSubnet();
} else {
@@ -125,35 +116,36 @@ public class Ipv4Customizer extends FutureJVppCustomizer implements ChildWriterC
throw new UnsupportedOperationException("Unimplemented");
}
- private void setPrefixLengthSubnet(final String name, final int swIfc, final Address ipv4Addr,
- final PrefixLength subnet) throws VppApiInvocationException {
- Short plen = subnet.getPrefixLength();
- LOG.debug("Setting Subnet(prefix-length) for interface: {}, {}. Subnet: {}, Ipv4: {}", name, swIfc, subnet,
- ipv4Addr);
+ private void setPrefixLengthSubnet(final InstanceIdentifier<Ipv4> id, final String name, final int swIfc,
+ final Address ipv4Addr, final PrefixLength subnet)
+ throws WriteFailedException {
+ try {
+ Short plen = subnet.getPrefixLength();
+ LOG.debug("Setting Subnet(prefix-length) for interface: {}, {}. Subnet: {}, Ipv4: {}", name, swIfc, subnet,
+ ipv4Addr);
- byte[] addr = TranslateUtils.ipv4AddressNoZoneToArray(ipv4Addr.getIp());
+ byte[] addr = TranslateUtils.ipv4AddressNoZoneToArray(ipv4Addr.getIp());
- checkArgument(plen > 0, "Invalid length");
- checkNotNull(addr, "Null address");
+ checkArgument(plen > 0, "Invalid length");
+ checkNotNull(addr, "Null address");
- final CompletionStage<SwInterfaceAddDelAddressReply> swInterfaceAddDelAddressReplyCompletionStage =
- getFutureJVpp().swInterfaceAddDelAddress(getSwInterfaceAddDelAddressRequest(
- swIfc, (byte) 1 /* isAdd */, (byte) 0 /* isIpv6 */, (byte) 0 /* delAll */, plen.byteValue(), addr));
+ final CompletionStage<SwInterfaceAddDelAddressReply> swInterfaceAddDelAddressReplyCompletionStage =
+ getFutureJVpp().swInterfaceAddDelAddress(getSwInterfaceAddDelAddressRequest(
+ swIfc, (byte) 1 /* isAdd */, (byte) 0 /* isIpv6 */, (byte) 0 /* delAll */, plen.byteValue(), addr));
- final SwInterfaceAddDelAddressReply reply =
- TranslateUtils.getReply(swInterfaceAddDelAddressReplyCompletionStage.toCompletableFuture());
+ final SwInterfaceAddDelAddressReply reply =
+ TranslateUtils.getReply(swInterfaceAddDelAddressReplyCompletionStage.toCompletableFuture());
- if (reply.retval < 0) {
- LOG.warn("Failed to set Subnet(prefix-length) for interface: {}, {}, Subnet: {}, Ipv4: {}", name, swIfc,
- subnet, ipv4Addr);
- throw new VppApiInvocationException("swInterfaceAddDelAddress", reply.context, reply.retval);
- } else {
LOG.debug("Subnet(prefix-length) set successfully for interface: {}, {}, Subnet: {}, Ipv4: {}", name,
- swIfc, subnet, ipv4Addr);
+ swIfc, subnet, ipv4Addr);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to set Subnet(prefix-length) for interface: {}, {}, Subnet: {}, Ipv4: {}", name, swIfc,
+ subnet, ipv4Addr);
+ throw new WriteFailedException(id, "Unable to handle subnet of type " + subnet.getClass(), e);
}
}
- private SwInterfaceAddDelAddress getSwInterfaceAddDelAddressRequest(final int swIfc, final byte isAdd, final byte ipv6,
+private SwInterfaceAddDelAddress getSwInterfaceAddDelAddressRequest(final int swIfc, final byte isAdd, final byte ipv6,
final byte deleteAll,
final byte length, final byte[] addr) {
final SwInterfaceAddDelAddress swInterfaceAddDelAddress = new SwInterfaceAddDelAddress();
@@ -165,5 +157,4 @@ public class Ipv4Customizer extends FutureJVppCustomizer implements ChildWriterC
swInterfaceAddDelAddress.addressLength = length;
return swInterfaceAddDelAddress;
}
-
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java
index e1c3e2df6..5bbf33935 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java
@@ -66,7 +66,7 @@ public class EthernetCustomizer extends FutureJVppCustomizer
@Nonnull final ReadContext ctx) throws ReadFailedException {
final InterfaceKey key = id.firstKeyOf(Interface.class);
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), key.getName(),
+ final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), id, key.getName(),
interfaceContext.getIndex(key.getName(), ctx.getMappingContext()), ctx.getModificationCache());
if(iface.linkMtu != 0) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java
index 886549ac3..f5c0e5972 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java
@@ -29,6 +29,8 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.Interconnection;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.interconnection.BridgeBasedBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.BridgeDomainDetails;
import org.openvpp.jvpp.dto.BridgeDomainDetailsReplyDump;
import org.openvpp.jvpp.dto.BridgeDomainDump;
@@ -59,15 +61,15 @@ final class InterconnectionReadUtils {
}
@Nullable
- Interconnection readInterconnection(@Nonnull final String ifaceName, @Nonnull final ReadContext ctx)
+ Interconnection readInterconnection(@Nonnull final InstanceIdentifier<?> id, @Nonnull final String ifaceName, @Nonnull final ReadContext ctx)
throws ReadFailedException {
final int ifaceId = interfaceContext.getIndex(ifaceName, ctx.getMappingContext());
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(futureJvpp, ifaceName,
+ final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(futureJvpp, id, ifaceName,
ifaceId, ctx.getModificationCache());
LOG.debug("Interface details for interface: {}, details: {}", ifaceName, iface);
- final BridgeDomainDetailsReplyDump dumpReply = getDumpReply();
+ final BridgeDomainDetailsReplyDump dumpReply = getDumpReply(id);
final Optional<BridgeDomainSwIfDetails> bdForInterface = getBridgeDomainForInterface(ifaceId, dumpReply);
if (bdForInterface.isPresent()) {
final BridgeDomainSwIfDetails bdSwIfDetails = bdForInterface.get();
@@ -107,15 +109,19 @@ final class InterconnectionReadUtils {
return reply.bridgeDomainDetails.stream().filter(a -> a.bdId == bdId).findFirst();
}
- private BridgeDomainDetailsReplyDump getDumpReply() {
- // We need to perform full bd dump, because there is no way
- // to ask VPP for BD details given interface id/name (TODO add it to vpp.api?)
- // TODO cache dump result
- final BridgeDomainDump request = new BridgeDomainDump();
- request.bdId = -1;
-
- final CompletableFuture<BridgeDomainDetailsReplyDump> bdCompletableFuture =
- futureJvpp.bridgeDomainSwIfDump(request).toCompletableFuture();
- return TranslateUtils.getReply(bdCompletableFuture);
+ private BridgeDomainDetailsReplyDump getDumpReply(@Nonnull final InstanceIdentifier<?> id) throws ReadFailedException {
+ try {
+ // We need to perform full bd dump, because there is no way
+ // to ask VPP for BD details given interface id/name (TODO add it to vpp.api?)
+ // TODO cache dump result
+ final BridgeDomainDump request = new BridgeDomainDump();
+ request.bdId = -1;
+
+ final CompletableFuture<BridgeDomainDetailsReplyDump> bdCompletableFuture =
+ futureJvpp.bridgeDomainSwIfDump(request).toCompletableFuture();
+ return TranslateUtils.getReply(bdCompletableFuture);
+ } catch (VppBaseCallException e) {
+ throw new ReadFailedException(id,e);
+ }
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java
index d54929ea1..d83030d6e 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java
@@ -23,13 +23,6 @@ import io.fd.honeycomb.v3po.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesStateBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus;
@@ -39,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceDetails;
import org.openvpp.jvpp.dto.SwInterfaceDetailsReplyDump;
import org.openvpp.jvpp.dto.SwInterfaceDump;
@@ -46,6 +40,14 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+
/**
* Customizer for reading ietf-interfaces:interfaces-state/interface
*/
@@ -75,7 +77,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
final InterfaceKey key = id.firstKeyOf(id.getTargetType());
// Pass cached details from getAllIds to getDetails to avoid additional dumps
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), key.getName(),
+ final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), id, key.getName(),
interfaceContext.getIndex(key.getName(), ctx.getMappingContext()), ctx.getModificationCache());
LOG.debug("Interface details for interface: {}, details: {}", key.getName(), iface);
@@ -105,41 +107,47 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
@Override
public List<InterfaceKey> getAllIds(@Nonnull final InstanceIdentifier<Interface> id,
@Nonnull final ReadContext context) throws ReadFailedException {
- LOG.trace("Dumping all interfaces to get all IDs");
-
- final SwInterfaceDump request = new SwInterfaceDump();
- request.nameFilter = "".getBytes();
- request.nameFilterValid = 0;
-
- final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture =
- getFutureJVpp().swInterfaceDump(request).toCompletableFuture();
- final SwInterfaceDetailsReplyDump ifaces = TranslateUtils.getReply(swInterfaceDetailsReplyDumpCompletableFuture);
-
- if (null == ifaces || null == ifaces.swInterfaceDetails) {
- LOG.debug("No interfaces found in VPP");
- return Collections.emptyList();
+ try {
+ final List<InterfaceKey> interfacesKeys;
+ LOG.trace("Dumping all interfaces to get all IDs");
+
+ final SwInterfaceDump request = new SwInterfaceDump();
+ request.nameFilter = "".getBytes();
+ request.nameFilterValid = 0;
+
+ final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture =
+ getFutureJVpp().swInterfaceDump(request).toCompletableFuture();
+ final SwInterfaceDetailsReplyDump ifaces = TranslateUtils.getReply(swInterfaceDetailsReplyDumpCompletableFuture);
+
+ if (null == ifaces || null == ifaces.swInterfaceDetails) {
+ LOG.debug("No interfaces found in VPP");
+ return Collections.emptyList();
+ }
+
+ // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
+ context.getModificationCache().put(DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream()
+ .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)));
+
+ interfacesKeys = ifaces.swInterfaceDetails.stream()
+ .filter(elt -> elt != null)
+ .map((elt) -> {
+ // Store interface name from VPP in context if not yet present
+ if (!interfaceContext.containsName(elt.swIfIndex, context.getMappingContext())) {
+ interfaceContext.addName(elt.swIfIndex, TranslateUtils.toString(elt.interfaceName), context.getMappingContext());
+ }
+ LOG.trace("Interface with name: {}, VPP name: {} and index: {} found in VPP",
+ interfaceContext.getName(elt.swIfIndex, context.getMappingContext()), elt.interfaceName, elt.swIfIndex);
+
+ return new InterfaceKey(interfaceContext.getName(elt.swIfIndex, context.getMappingContext()));
+ })
+ .collect(Collectors.toList());
+
+ LOG.debug("Interfaces found in VPP: {}", interfacesKeys);
+ return interfacesKeys;
+ } catch (VppBaseCallException e) {
+ LOG.warn("getAllIds exception :" + e.toString());
+ throw new ReadFailedException( id, e);
}
-
- // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
- context.getModificationCache().put(DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream()
- .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)));
-
- final List<InterfaceKey> interfacesKeys = ifaces.swInterfaceDetails.stream()
- .filter(elt -> elt != null)
- .map((elt) -> {
- // Store interface name from VPP in context if not yet present
- if (!interfaceContext.containsName(elt.swIfIndex, context.getMappingContext())) {
- interfaceContext.addName(elt.swIfIndex, TranslateUtils.toString(elt.interfaceName), context.getMappingContext());
- }
- LOG.trace("Interface with name: {}, VPP name: {} and index: {} found in VPP",
- interfaceContext.getName(elt.swIfIndex, context.getMappingContext()), elt.interfaceName, elt.swIfIndex);
-
- return new InterfaceKey(interfaceContext.getName(elt.swIfIndex, context.getMappingContext()));
- })
- .collect(Collectors.toList());
-
- LOG.debug("Interfaces found in VPP: {}", interfacesKeys);
- return interfacesKeys;
}
@Override
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java
index a61c3890e..ba0a99147 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java
@@ -16,27 +16,20 @@
package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceCustomizer.getCachedInterfaceDump;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.base.Preconditions;
import io.fd.honeycomb.v3po.translate.ModificationCache;
+import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.util.RWUtils;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import java.math.BigInteger;
-import java.util.Map;
-import java.util.concurrent.CompletionStage;
-import java.util.stream.Collector;
-import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Gauge64;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanGpeTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceDetails;
import org.openvpp.jvpp.dto.SwInterfaceDetailsReplyDump;
import org.openvpp.jvpp.dto.SwInterfaceDump;
@@ -44,6 +37,18 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.math.BigInteger;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.CompletionStage;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceCustomizer.getCachedInterfaceDump;
+import static java.util.Objects.requireNonNull;
+
public final class InterfaceUtils {
private static final Logger LOG = LoggerFactory.getLogger(InterfaceUtils.class);
@@ -110,7 +115,7 @@ public final class InterfaceUtils {
* @throws IllegalArgumentException if vppPhysAddress.length < 6
*/
public static String vppPhysAddrToYang(@Nonnull final byte[] vppPhysAddress) {
- requireNonNull(vppPhysAddress, "Empty physical address bytes");
+ Objects.requireNonNull(vppPhysAddress, "Empty physical address bytes");
Preconditions.checkArgument(PHYSICAL_ADDRESS_LENGTH <= vppPhysAddress.length,
"Invalid physical address size %s, expected >= 6", vppPhysAddress.length);
StringBuilder physAddr = new StringBuilder();
@@ -151,17 +156,21 @@ public final class InterfaceUtils {
* Queries VPP for interface description given interface key.
*
* @param futureJvpp VPP Java Future API
+ * @param id InstanceIdentifier, which is passed in ReadFailedException
* @param name interface name
* @param index VPP index of the interface
* @param ctx per-tx scope context containing cached dump with all the interfaces. If the cache is not
* available or outdated, another dump will be performed.
* @return SwInterfaceDetails DTO or null if interface was not found
* @throws IllegalArgumentException If interface cannot be found
+ * @throws ReadFailedException If read operation had failed
*/
@Nonnull
public static SwInterfaceDetails getVppInterfaceDetails(@Nonnull final FutureJVpp futureJvpp,
+ @Nonnull final InstanceIdentifier<?> id,
@Nonnull final String name, final int index,
- @Nonnull final ModificationCache ctx) {
+ @Nonnull final ModificationCache ctx)
+ throws ReadFailedException {
requireNonNull(futureJvpp, "futureJvpp should not be null");
requireNonNull(name, "name should not be null");
requireNonNull(ctx, "ctx should not be null");
@@ -177,27 +186,33 @@ public final class InterfaceUtils {
return allInterfaces.get(index);
}
- CompletionStage<SwInterfaceDetailsReplyDump> requestFuture = futureJvpp.swInterfaceDump(request);
- SwInterfaceDetailsReplyDump ifaces = TranslateUtils.getReply(requestFuture.toCompletableFuture());
- if (null == ifaces || null == ifaces.swInterfaceDetails || ifaces.swInterfaceDetails.isEmpty()) {
- request.nameFilterValid = 0;
+ SwInterfaceDetailsReplyDump ifaces = null;
+ try {
+ CompletionStage<SwInterfaceDetailsReplyDump> requestFuture = futureJvpp.swInterfaceDump(request);
+ ifaces = TranslateUtils.getReply(requestFuture.toCompletableFuture());
+ if (null == ifaces || null == ifaces.swInterfaceDetails || ifaces.swInterfaceDetails.isEmpty()) {
+ request.nameFilterValid = 0;
- LOG.warn("VPP returned null instead of interface by key {} and its not cached", name);
- LOG.warn("Iterating through all the interfaces to find interface: {}", name);
+ LOG.warn("VPP returned null instead of interface by key {} and its not cached", name);
+ LOG.warn("Iterating through all the interfaces to find interface: {}", name);
- // Or else just perform full dump and do inefficient filtering
- requestFuture = futureJvpp.swInterfaceDump(request);
- ifaces = TranslateUtils.getReply(requestFuture.toCompletableFuture());
+ // Or else just perform full dump and do inefficient filtering
+ requestFuture = futureJvpp.swInterfaceDump(request);
+ ifaces = TranslateUtils.getReply(requestFuture.toCompletableFuture());
- // Update the cache
- allInterfaces.clear();
- allInterfaces
- .putAll(ifaces.swInterfaceDetails.stream().collect(Collectors.toMap(d -> d.swIfIndex, d -> d)));
+ // Update the cache
+ allInterfaces.clear();
+ allInterfaces
+ .putAll(ifaces.swInterfaceDetails.stream().collect(Collectors.toMap(d -> d.swIfIndex, d -> d)));
- if (allInterfaces.containsKey(index)) {
- return allInterfaces.get(index);
+ if (allInterfaces.containsKey(index)) {
+ return allInterfaces.get(index);
+ }
+ throw new IllegalArgumentException("Unable to find interface " + name);
}
- throw new IllegalArgumentException("Unable to find interface " + name);
+ } catch (VppBaseCallException e) {
+ LOG.warn("getVppInterfaceDetails exception :", e);
+ throw new ReadFailedException(id);
}
// SwInterfaceDump's name filter does prefix match, so we need additional filtering:
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java
index 63e51389c..e1496e36b 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java
@@ -21,7 +21,6 @@ import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentationBuilder;
@@ -34,6 +33,12 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+
+import static com.google.common.base.Preconditions.checkState;
+
/**
* Customizer for reading ietf-interfaces:interfaces-state/interface/iface_name/v3po:l2
*/
@@ -63,10 +68,10 @@ public class L2Customizer extends FutureJVppCustomizer implements ChildReaderCus
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<L2> id, @Nonnull final L2Builder builder,
@Nonnull final ReadContext ctx) throws ReadFailedException {
+
LOG.debug("Reading attributes for L2: {}", id);
final InterfaceKey key = id.firstKeyOf(Interface.class);
final String ifaceName = key.getName();
-
- builder.setInterconnection(icReadUtils.readInterconnection(ifaceName, ctx));
+ builder.setInterconnection(icReadUtils.readInterconnection(id, ifaceName, ctx));
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/RewriteCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/RewriteCustomizer.java
index 143fb4d68..4600395be 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/RewriteCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/RewriteCustomizer.java
@@ -87,7 +87,7 @@ public class RewriteCustomizer extends FutureJVppCustomizer
final String subInterfaceName = getSubInterfaceName(id);
LOG.debug("Reading attributes for sub interface: {}", subInterfaceName);
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), subInterfaceName,
+ final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), id, subInterfaceName,
interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()), ctx.getModificationCache());
LOG.debug("VPP sub-interface details: {}", ReflectionToStringBuilder.toString(iface));
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
index 5adb43874..998b188d0 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
@@ -62,6 +62,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceDetails;
import org.openvpp.jvpp.dto.SwInterfaceDetailsReplyDump;
import org.openvpp.jvpp.dto.SwInterfaceDump;
@@ -89,43 +90,46 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
@Override
public List<SubInterfaceKey> getAllIds(@Nonnull final InstanceIdentifier<SubInterface> id,
@Nonnull final ReadContext context) throws ReadFailedException {
- // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
- // to fill in the context with initial ifc mapping
- final InterfaceKey key = id.firstKeyOf(Interface.class);
- final String ifaceName = key.getName();
- final int ifaceId = interfaceContext.getIndex(ifaceName, context.getMappingContext());
-
- // TODO if we know that full dump was already performed we could use cache
- // (checking if getCachedInterfaceDump() returns non empty map is not enough, because
- // we could be part of particular iface state read
- final SwInterfaceDump request = new SwInterfaceDump();
- request.nameFilter = "".getBytes();
- request.nameFilterValid = 0;
-
- final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture =
- getFutureJVpp().swInterfaceDump(request).toCompletableFuture();
- final SwInterfaceDetailsReplyDump ifaces =
- TranslateUtils.getReply(swInterfaceDetailsReplyDumpCompletableFuture);
-
- if (null == ifaces || null == ifaces.swInterfaceDetails) {
- LOG.warn("Looking for sub-interfaces, but no interfaces found in VPP");
- return Collections.emptyList();
- }
-
- // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
- context.getModificationCache().put(DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream()
- .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)));
-
- final List<SubInterfaceKey> interfacesKeys = ifaces.swInterfaceDetails.stream()
- .filter(elt -> elt != null)
- // accept only sub-interfaces for current iface:
- .filter(elt -> elt.subId != 0 && elt.supSwIfIndex == ifaceId)
- .map(details -> new SubInterfaceKey(new Long(details.subId)))
- .collect(Collectors.toList());
-
- LOG.debug("Sub-interfaces of {} found in VPP: {}", ifaceName, interfacesKeys);
+ try {
+ // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
+ // to fill in the context with initial ifc mapping
+ final InterfaceKey key = id.firstKeyOf(Interface.class);
+ final String ifaceName = key.getName();
+ final int ifaceId = interfaceContext.getIndex(ifaceName, context.getMappingContext());
+
+ // TODO if we know that full dump was already performed we could use cache
+ // (checking if getCachedInterfaceDump() returns non empty map is not enough, because
+ // we could be part of particular iface state read
+ final SwInterfaceDump request = new SwInterfaceDump();
+ request.nameFilter = "".getBytes();
+ request.nameFilterValid = 0;
+
+ final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture =
+ getFutureJVpp().swInterfaceDump(request).toCompletableFuture();
+ final SwInterfaceDetailsReplyDump ifaces =
+ TranslateUtils.getReply(swInterfaceDetailsReplyDumpCompletableFuture);
+
+ if (null == ifaces || null == ifaces.swInterfaceDetails) {
+ LOG.warn("Looking for sub-interfaces, but no interfaces found in VPP");
+ return Collections.emptyList();
+ }
- return interfacesKeys;
+ // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
+ context.getModificationCache().put(DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream()
+ .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)));
+
+ final List<SubInterfaceKey> interfacesKeys = ifaces.swInterfaceDetails.stream()
+ .filter(elt -> elt != null)
+ // accept only sub-interfaces for current iface:
+ .filter(elt -> elt.subId != 0 && elt.supSwIfIndex == ifaceId)
+ .map(details -> new SubInterfaceKey(new Long(details.subId)))
+ .collect(Collectors.toList());
+
+ LOG.debug("Sub-interfaces of {} found in VPP: {}", ifaceName, interfacesKeys);
+ return interfacesKeys;
+ } catch (VppBaseCallException e) {
+ throw new ReadFailedException(id,e);
+ }
}
@Override
@@ -147,7 +151,7 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
final String subInterfaceName = getSubInterfaceName(id);
LOG.debug("Reading attributes for sub interface: {}", subInterfaceName);
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), subInterfaceName,
+ final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), id, subInterfaceName,
interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()), ctx.getModificationCache());
LOG.debug("VPP sub-interface details: {}", ReflectionToStringBuilder.toString(iface));
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java
index baff29466..0c6d50b76 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java
@@ -72,6 +72,6 @@ public class SubInterfaceL2Customizer extends FutureJVppCustomizer implements Ch
final SubInterfaceKey subInterfacekey = id.firstKeyOf(SubInterface.class);
final String subInterfaceName = getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue());
- builder.setInterconnection(icReadUtils.readInterconnection(subInterfaceName, ctx));
+ builder.setInterconnection(icReadUtils.readInterconnection(id, subInterfaceName, ctx));
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java
index d4fe30b57..44256956c 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java
@@ -16,20 +16,12 @@
package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
-import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
-
import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletionStage;
-import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentationBuilder;
@@ -38,6 +30,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceTapDetails;
import org.openvpp.jvpp.dto.SwInterfaceTapDetailsReplyDump;
import org.openvpp.jvpp.dto.SwInterfaceTapDump;
@@ -45,6 +38,15 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletionStage;
+import java.util.stream.Collectors;
+
+import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
+
public class TapCustomizer extends FutureJVppCustomizer
implements ChildReaderCustomizer<Tap, TapBuilder> {
@@ -73,44 +75,49 @@ public class TapCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Tap> id,
@Nonnull final TapBuilder builder,
@Nonnull final ReadContext ctx) throws ReadFailedException {
- final InterfaceKey key = id.firstKeyOf(Interface.class);
- // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
- // to fill in the context with initial ifc mapping
- final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
- if (!isInterfaceOfType(ctx.getModificationCache(), index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap.class)) {
- return;
- }
-
- LOG.debug("Reading attributes for tap interface: {}", key.getName());
-
- @SuppressWarnings("unchecked")
- Map<Integer, SwInterfaceTapDetails> mappedTaps =
- (Map<Integer, SwInterfaceTapDetails>) ctx.getModificationCache().get(DUMPED_TAPS_CONTEXT_KEY);
-
- if(mappedTaps == null) {
- // Full Tap dump has to be performed here, no filter or anything is here to help so at least we cache it
- final SwInterfaceTapDump request = new SwInterfaceTapDump();
- final CompletionStage<SwInterfaceTapDetailsReplyDump> swInterfaceTapDetailsReplyDumpCompletionStage =
- getFutureJVpp().swInterfaceTapDump(request);
- final SwInterfaceTapDetailsReplyDump reply =
- TranslateUtils.getReply(swInterfaceTapDetailsReplyDumpCompletionStage.toCompletableFuture());
-
- if(null == reply || null == reply.swInterfaceTapDetails) {
- mappedTaps = Collections.emptyMap();
- } else {
- final List<SwInterfaceTapDetails> swInterfaceTapDetails = reply.swInterfaceTapDetails;
- // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
- mappedTaps = swInterfaceTapDetails.stream()
- .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
+ try {
+ final InterfaceKey key = id.firstKeyOf(Interface.class);
+ // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
+ // to fill in the context with initial ifc mapping
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ if (!isInterfaceOfType(ctx.getModificationCache(), index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap.class)) {
+ return;
}
- ctx.getModificationCache().put(DUMPED_TAPS_CONTEXT_KEY, mappedTaps);
- }
+ LOG.debug("Reading attributes for tap interface: {}", key.getName());
+
+ @SuppressWarnings("unchecked")
+ Map<Integer, SwInterfaceTapDetails> mappedTaps =
+ (Map<Integer, SwInterfaceTapDetails>) ctx.getModificationCache().get(DUMPED_TAPS_CONTEXT_KEY);
+
+ if(mappedTaps == null) {
+ // Full Tap dump has to be performed here, no filter or anything is here to help so at least we cache it
+ final SwInterfaceTapDump request = new SwInterfaceTapDump();
+ final CompletionStage<SwInterfaceTapDetailsReplyDump> swInterfaceTapDetailsReplyDumpCompletionStage =
+ getFutureJVpp().swInterfaceTapDump(request);
+ final SwInterfaceTapDetailsReplyDump reply =
+ TranslateUtils.getReply(swInterfaceTapDetailsReplyDumpCompletionStage.toCompletableFuture());
+
+ if(null == reply || null == reply.swInterfaceTapDetails) {
+ mappedTaps = Collections.emptyMap();
+ } else {
+ final List<SwInterfaceTapDetails> swInterfaceTapDetails = reply.swInterfaceTapDetails;
+ // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
+ mappedTaps = swInterfaceTapDetails.stream()
+ .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
+ }
+
+ ctx.getModificationCache().put(DUMPED_TAPS_CONTEXT_KEY, mappedTaps);
+ }
- final SwInterfaceTapDetails swInterfaceTapDetails = mappedTaps.get(index);
- LOG.trace("Tap interface: {} attributes returned from VPP: {}", key.getName(), swInterfaceTapDetails);
+ final SwInterfaceTapDetails swInterfaceTapDetails = mappedTaps.get(index);
+ LOG.trace("Tap interface: {} attributes returned from VPP: {}", key.getName(), swInterfaceTapDetails);
- builder.setTapName(TranslateUtils.toString(swInterfaceTapDetails.devName));
- LOG.debug("Tap interface: {}, id: {} attributes read as: {}", key.getName(), index, builder);
+ builder.setTapName(TranslateUtils.toString(swInterfaceTapDetails.devName));
+ LOG.debug("Tap interface: {}, id: {} attributes read as: {}", key.getName(), index, builder);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to readCurrentAttributes for: {}", id);
+ throw new ReadFailedException(id);
+ }
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java
index de7514524..7085392f6 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java
@@ -16,21 +16,12 @@
package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
-import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
-
import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import java.math.BigInteger;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletionStage;
-import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUserRole;
@@ -40,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceVhostUserDetails;
import org.openvpp.jvpp.dto.SwInterfaceVhostUserDetailsReplyDump;
import org.openvpp.jvpp.dto.SwInterfaceVhostUserDump;
@@ -47,6 +39,16 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletionStage;
+import java.util.stream.Collectors;
+
+import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
+
public class VhostUserCustomizer extends FutureJVppCustomizer
implements ChildReaderCustomizer<VhostUser, VhostUserBuilder> {
@@ -75,51 +77,56 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<VhostUser> id,
@Nonnull final VhostUserBuilder builder,
@Nonnull final ReadContext ctx) throws ReadFailedException {
- final InterfaceKey key = id.firstKeyOf(Interface.class);
- // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
- // to fill in the context with initial ifc mapping
- final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
- if (!isInterfaceOfType(ctx.getModificationCache(), index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class)) {
- return;
- }
+ try {
+ final InterfaceKey key = id.firstKeyOf(Interface.class);
+ // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
+ // to fill in the context with initial ifc mapping
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ if (!isInterfaceOfType(ctx.getModificationCache(), index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class)) {
+ return;
+ }
- LOG.debug("Reading attributes for vhpost user interface: {}", key.getName());
-
- @SuppressWarnings("unchecked")
- Map<Integer, SwInterfaceVhostUserDetails> mappedVhostUsers =
- (Map<Integer, SwInterfaceVhostUserDetails>) ctx.getModificationCache().get(DUMPED_VHOST_USERS_CONTEXT_KEY);
-
- if(mappedVhostUsers == null) {
- // Full VhostUser dump has to be performed here, no filter or anything is here to help so at least we cache it
- final SwInterfaceVhostUserDump request = new SwInterfaceVhostUserDump();
- final CompletionStage<SwInterfaceVhostUserDetailsReplyDump> swInterfaceVhostUserDetailsReplyDumpCompletionStage =
- getFutureJVpp().swInterfaceVhostUserDump(request);
- final SwInterfaceVhostUserDetailsReplyDump reply =
- TranslateUtils.getReply(swInterfaceVhostUserDetailsReplyDumpCompletionStage.toCompletableFuture());
-
- if(null == reply || null == reply.swInterfaceVhostUserDetails) {
- mappedVhostUsers = Collections.emptyMap();
- } else {
- final List<SwInterfaceVhostUserDetails> swInterfaceVhostUserDetails = reply.swInterfaceVhostUserDetails;
- // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
- mappedVhostUsers = swInterfaceVhostUserDetails.stream()
- .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
+ LOG.debug("Reading attributes for vhpost user interface: {}", key.getName());
+
+ @SuppressWarnings("unchecked")
+ Map<Integer, SwInterfaceVhostUserDetails> mappedVhostUsers =
+ (Map<Integer, SwInterfaceVhostUserDetails>) ctx.getModificationCache().get(DUMPED_VHOST_USERS_CONTEXT_KEY);
+
+ if(mappedVhostUsers == null) {
+ // Full VhostUser dump has to be performed here, no filter or anything is here to help so at least we cache it
+ final SwInterfaceVhostUserDump request = new SwInterfaceVhostUserDump();
+ final CompletionStage<SwInterfaceVhostUserDetailsReplyDump> swInterfaceVhostUserDetailsReplyDumpCompletionStage =
+ getFutureJVpp().swInterfaceVhostUserDump(request);
+ final SwInterfaceVhostUserDetailsReplyDump reply =
+ TranslateUtils.getReply(swInterfaceVhostUserDetailsReplyDumpCompletionStage.toCompletableFuture());
+
+ if(null == reply || null == reply.swInterfaceVhostUserDetails) {
+ mappedVhostUsers = Collections.emptyMap();
+ } else {
+ final List<SwInterfaceVhostUserDetails> swInterfaceVhostUserDetails = reply.swInterfaceVhostUserDetails;
+ // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
+ mappedVhostUsers = swInterfaceVhostUserDetails.stream()
+ .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
+ }
+
+ ctx.getModificationCache().put(DUMPED_VHOST_USERS_CONTEXT_KEY, mappedVhostUsers);
}
- ctx.getModificationCache().put(DUMPED_VHOST_USERS_CONTEXT_KEY, mappedVhostUsers);
+ // Relying here that parent InterfaceCustomizer was invoked first to fill in the context with initial ifc mapping
+ final SwInterfaceVhostUserDetails swInterfaceVhostUserDetails = mappedVhostUsers.get(index);
+ LOG.trace("Vhost user interface: {} attributes returned from VPP: {}", key.getName(), swInterfaceVhostUserDetails);
+
+ builder.setRole(swInterfaceVhostUserDetails.isServer == 1 ? VhostUserRole.Server : VhostUserRole.Client);
+ builder.setFeatures(BigInteger.valueOf(swInterfaceVhostUserDetails.features));
+ builder.setNumMemoryRegions((long) swInterfaceVhostUserDetails.numRegions);
+ builder.setSocket(TranslateUtils.toString(swInterfaceVhostUserDetails.sockFilename));
+ builder.setVirtioNetHdrSize((long) swInterfaceVhostUserDetails.virtioNetHdrSz);
+ builder.setConnectError(Integer.toString(swInterfaceVhostUserDetails.sockErrno));
+
+ LOG.debug("Vhost user interface: {}, id: {} attributes read as: {}", key.getName(), index, builder);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to readCurrentAttributes for: {}", id);
+ throw new ReadFailedException(id);
}
-
- // Relying here that parent InterfaceCustomizer was invoked first to fill in the context with initial ifc mapping
- final SwInterfaceVhostUserDetails swInterfaceVhostUserDetails = mappedVhostUsers.get(index);
- LOG.trace("Vhost user interface: {} attributes returned from VPP: {}", key.getName(), swInterfaceVhostUserDetails);
-
- builder.setRole(swInterfaceVhostUserDetails.isServer == 1 ? VhostUserRole.Server : VhostUserRole.Client);
- builder.setFeatures(BigInteger.valueOf(swInterfaceVhostUserDetails.features));
- builder.setNumMemoryRegions((long) swInterfaceVhostUserDetails.numRegions);
- builder.setSocket(TranslateUtils.toString(swInterfaceVhostUserDetails.sockFilename));
- builder.setVirtioNetHdrSize((long) swInterfaceVhostUserDetails.virtioNetHdrSz);
- builder.setConnectError(Integer.toString(swInterfaceVhostUserDetails.sockErrno));
-
- LOG.debug("Vhost user interface: {}, id: {} attributes read as: {}", key.getName(), index, builder);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java
index b870fe260..41f4b6edc 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java
@@ -16,19 +16,12 @@
package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
-import static com.google.common.base.Preconditions.checkState;
-
import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.concurrent.CompletionStage;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
@@ -42,6 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.VxlanTunnelDetails;
import org.openvpp.jvpp.dto.VxlanTunnelDetailsReplyDump;
import org.openvpp.jvpp.dto.VxlanTunnelDump;
@@ -49,6 +43,14 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+import java.util.concurrent.CompletionStage;
+
+import static com.google.common.base.Preconditions.checkState;
+
public class VxlanCustomizer extends FutureJVppCustomizer
implements ChildReaderCustomizer<Vxlan, VxlanBuilder> {
@@ -76,57 +78,62 @@ public class VxlanCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Vxlan> id,
@Nonnull final VxlanBuilder builder,
@Nonnull final ReadContext ctx) throws ReadFailedException {
- final InterfaceKey key = id.firstKeyOf(Interface.class);
- // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
- // to fill in the context with initial ifc mapping
- final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
- if (!InterfaceUtils.isInterfaceOfType(ctx.getModificationCache(), index, VxlanTunnel.class)) {
- return;
- }
+ try {
+ final InterfaceKey key = id.firstKeyOf(Interface.class);
+ // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
+ // to fill in the context with initial ifc mapping
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ if (!InterfaceUtils.isInterfaceOfType(ctx.getModificationCache(), index, VxlanTunnel.class)) {
+ return;
+ }
- LOG.debug("Reading attributes for vxlan tunnel: {}", key.getName());
- // Dump just a single
- final VxlanTunnelDump request = new VxlanTunnelDump();
- request.swIfIndex = index;
-
- final CompletionStage<VxlanTunnelDetailsReplyDump> swInterfaceVxlanDetailsReplyDumpCompletionStage =
- getFutureJVpp().vxlanTunnelDump(request);
- final VxlanTunnelDetailsReplyDump reply =
- TranslateUtils.getReply(swInterfaceVxlanDetailsReplyDumpCompletionStage.toCompletableFuture());
-
- // VPP keeps vxlan tunnel interfaces even after they were deleted (optimization)
- // However there ar no longer any vxlan tunnel specific fields assigned to it and this call
- // returns nothing
- if (reply == null || reply.vxlanTunnelDetails == null || reply.vxlanTunnelDetails.isEmpty()) {
- LOG.debug(
- "Vxlan tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
- "after delete", key.getName(), index);
- return;
- }
+ LOG.debug("Reading attributes for vxlan tunnel: {}", key.getName());
+ // Dump just a single
+ final VxlanTunnelDump request = new VxlanTunnelDump();
+ request.swIfIndex = index;
+
+ final CompletionStage<VxlanTunnelDetailsReplyDump> swInterfaceVxlanDetailsReplyDumpCompletionStage =
+ getFutureJVpp().vxlanTunnelDump(request);
+ final VxlanTunnelDetailsReplyDump reply =
+ TranslateUtils.getReply(swInterfaceVxlanDetailsReplyDumpCompletionStage.toCompletableFuture());
+
+ // VPP keeps vxlan tunnel interfaces even after they were deleted (optimization)
+ // However there ar no longer any vxlan tunnel specific fields assigned to it and this call
+ // returns nothing
+ if (reply == null || reply.vxlanTunnelDetails == null || reply.vxlanTunnelDetails.isEmpty()) {
+ LOG.debug(
+ "Vxlan tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
+ "after delete", key.getName(), index);
+ return;
+ }
+
+ checkState(reply.vxlanTunnelDetails.size() == 1,
+ "Unexpected number of returned vxlan tunnels: {} for tunnel: {}", reply.vxlanTunnelDetails, key.getName());
+ LOG.trace("Vxlan tunnel: {} attributes returned from VPP: {}", key.getName(), reply);
- checkState(reply.vxlanTunnelDetails.size() == 1,
- "Unexpected number of returned vxlan tunnels: {} for tunnel: {}", reply.vxlanTunnelDetails, key.getName());
- LOG.trace("Vxlan tunnel: {} attributes returned from VPP: {}", key.getName(), reply);
-
- final VxlanTunnelDetails swInterfaceVxlanDetails = reply.vxlanTunnelDetails.get(0);
- if (swInterfaceVxlanDetails.isIpv6 == 1) {
- final Ipv6Address dstIpv6 =
- new Ipv6Address(parseAddress(swInterfaceVxlanDetails.dstAddress).getHostAddress());
- builder.setDst(new IpAddress(dstIpv6));
- final Ipv6Address srcIpv6 =
- new Ipv6Address(parseAddress(swInterfaceVxlanDetails.srcAddress).getHostAddress());
- builder.setSrc(new IpAddress(srcIpv6));
- } else {
- final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanDetails.dstAddress, 0, 4);
- final Ipv4Address dstIpv4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress());
- builder.setDst(new IpAddress(dstIpv4));
- final byte[] srcBytes = Arrays.copyOfRange(swInterfaceVxlanDetails.srcAddress, 0, 4);
- final Ipv4Address srcIpv4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress());
- builder.setSrc(new IpAddress(srcIpv4));
+ final VxlanTunnelDetails swInterfaceVxlanDetails = reply.vxlanTunnelDetails.get(0);
+ if (swInterfaceVxlanDetails.isIpv6 == 1) {
+ final Ipv6Address dstIpv6 =
+ new Ipv6Address(parseAddress(swInterfaceVxlanDetails.dstAddress).getHostAddress());
+ builder.setDst(new IpAddress(dstIpv6));
+ final Ipv6Address srcIpv6 =
+ new Ipv6Address(parseAddress(swInterfaceVxlanDetails.srcAddress).getHostAddress());
+ builder.setSrc(new IpAddress(srcIpv6));
+ } else {
+ final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanDetails.dstAddress, 0, 4);
+ final Ipv4Address dstIpv4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress());
+ builder.setDst(new IpAddress(dstIpv4));
+ final byte[] srcBytes = Arrays.copyOfRange(swInterfaceVxlanDetails.srcAddress, 0, 4);
+ final Ipv4Address srcIpv4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress());
+ builder.setSrc(new IpAddress(srcIpv4));
+ }
+ builder.setEncapVrfId((long) swInterfaceVxlanDetails.encapVrfId);
+ builder.setVni( new VxlanVni((long) swInterfaceVxlanDetails.vni));
+ LOG.debug("Vxlan tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to readCurrentAttributes for: {}", id);
+ throw new ReadFailedException( id, e );
}
- builder.setEncapVrfId((long) swInterfaceVxlanDetails.encapVrfId);
- builder.setVni(new VxlanVni((long) swInterfaceVxlanDetails.vni));
- LOG.debug("Vxlan tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder);
}
@Nonnull
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java
index 254b83961..d364eca1a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java
@@ -43,6 +43,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.VppCallbackException;
+import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.dto.VxlanGpeTunnelDetails;
import org.openvpp.jvpp.dto.VxlanGpeTunnelDetailsReplyDump;
import org.openvpp.jvpp.dto.VxlanGpeTunnelDump;
@@ -77,59 +80,64 @@ public class VxlanGpeCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<VxlanGpe> id,
@Nonnull final VxlanGpeBuilder builder,
@Nonnull final ReadContext ctx) throws ReadFailedException {
- final InterfaceKey key = id.firstKeyOf(Interface.class);
- // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
- // to fill in the context with initial ifc mapping
- final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
- if (!InterfaceUtils.isInterfaceOfType(ctx.getModificationCache(), index, VxlanGpeTunnel.class)) {
- return;
- }
+ try {
+ final InterfaceKey key = id.firstKeyOf(Interface.class);
+ // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
+ // to fill in the context with initial ifc mapping
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ if (!InterfaceUtils.isInterfaceOfType(ctx.getModificationCache(), index, VxlanGpeTunnel.class)) {
+ return;
+ }
- LOG.debug("Reading attributes for VxlanGpe tunnel: {}", key.getName());
- // Dump just a single
- final VxlanGpeTunnelDump request = new VxlanGpeTunnelDump();
- request.swIfIndex = index;
+ LOG.debug("Reading attributes for VxlanGpe tunnel: {}", key.getName());
+ // Dump just a single
+ final VxlanGpeTunnelDump request = new VxlanGpeTunnelDump();
+ request.swIfIndex = index;
- final CompletionStage<VxlanGpeTunnelDetailsReplyDump> swInterfaceVxlanGpeDetailsReplyDumpCompletionStage =
- getFutureJVpp().vxlanGpeTunnelDump(request);
- final VxlanGpeTunnelDetailsReplyDump reply =
- TranslateUtils.getReply(swInterfaceVxlanGpeDetailsReplyDumpCompletionStage.toCompletableFuture());
+ final CompletionStage<VxlanGpeTunnelDetailsReplyDump> swInterfaceVxlanGpeDetailsReplyDumpCompletionStage =
+ getFutureJVpp().vxlanGpeTunnelDump(request);
+ final VxlanGpeTunnelDetailsReplyDump reply =
+ TranslateUtils.getReply(swInterfaceVxlanGpeDetailsReplyDumpCompletionStage.toCompletableFuture());
- // VPP keeps VxlanGpe tunnel interfaces even after they were deleted (optimization)
- // However there are no longer any VxlanGpe tunnel specific fields assigned to it and this call
- // returns nothing
- if (reply == null || reply.vxlanGpeTunnelDetails == null || reply.vxlanGpeTunnelDetails.isEmpty()) {
- LOG.debug(
- "VxlanGpe tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
- "after delete", key.getName(), index);
- return;
- }
+ // VPP keeps VxlanGpe tunnel interfaces even after they were deleted (optimization)
+ // However there are no longer any VxlanGpe tunnel specific fields assigned to it and this call
+ // returns nothing
+ if (reply == null || reply.vxlanGpeTunnelDetails == null || reply.vxlanGpeTunnelDetails.isEmpty()) {
+ LOG.debug(
+ "VxlanGpe tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
+ "after delete", key.getName(), index);
+ return;
+ }
- checkState(reply.vxlanGpeTunnelDetails.size() == 1,
- "Unexpected number of returned VxlanGpe tunnels: {} for tunnel: {}", reply.vxlanGpeTunnelDetails, key.getName());
- LOG.trace("VxlanGpe tunnel: {} attributes returned from VPP: {}", key.getName(), reply);
+ checkState(reply.vxlanGpeTunnelDetails.size() == 1,
+ "Unexpected number of returned VxlanGpe tunnels: {} for tunnel: {}", reply.vxlanGpeTunnelDetails, key.getName());
+ LOG.trace("VxlanGpe tunnel: {} attributes returned from VPP: {}", key.getName(), reply);
- final VxlanGpeTunnelDetails swInterfaceVxlanGpeDetails = reply.vxlanGpeTunnelDetails.get(0);
- if (swInterfaceVxlanGpeDetails.isIpv6 == 1) {
- final Ipv6Address remote6 =
- new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.remote).getHostAddress());
- builder.setRemote(new IpAddress(remote6));
- final Ipv6Address local6 =
- new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.local).getHostAddress());
- builder.setLocal(new IpAddress(local6));
- } else {
- final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanGpeDetails.remote, 0, 4);
- final Ipv4Address remote4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress());
- builder.setRemote(new IpAddress(remote4));
- final byte[] srcBytes = Arrays.copyOfRange(swInterfaceVxlanGpeDetails.local, 0, 4);
- final Ipv4Address local4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress());
- builder.setLocal(new IpAddress(local4));
- }
- builder.setVni(new VxlanGpeVni((long) swInterfaceVxlanGpeDetails.vni));
+ final VxlanGpeTunnelDetails swInterfaceVxlanGpeDetails = reply.vxlanGpeTunnelDetails.get(0);
+ if (swInterfaceVxlanGpeDetails.isIpv6 == 1) {
+ final Ipv6Address remote6 =
+ new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.remote).getHostAddress());
+ builder.setRemote(new IpAddress(remote6));
+ final Ipv6Address local6 =
+ new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.local).getHostAddress());
+ builder.setLocal(new IpAddress(local6));
+ } else {
+ final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanGpeDetails.remote, 0, 4);
+ final Ipv4Address remote4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress());
+ builder.setRemote(new IpAddress(remote4));
+ final byte[] srcBytes = Arrays.copyOfRange(swInterfaceVxlanGpeDetails.local, 0, 4);
+ final Ipv4Address local4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress());
+ builder.setLocal(new IpAddress(local4));
+ }
+ builder.setVni(new VxlanGpeVni((long) swInterfaceVxlanGpeDetails.vni));
builder.setNextProtocol(VxlanGpeNextProtocol.forValue(swInterfaceVxlanGpeDetails.protocol));
- builder.setEncapVrfId((long) swInterfaceVxlanGpeDetails.encapVrfId);
- builder.setDecapVrfId((long) swInterfaceVxlanGpeDetails.decapVrfId);
- LOG.debug("VxlanGpe tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder);
+ builder.setEncapVrfId((long) swInterfaceVxlanGpeDetails.encapVrfId);
+ builder.setDecapVrfId((long) swInterfaceVxlanGpeDetails.decapVrfId);
+ LOG.debug("VxlanGpe tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to readCurrentAttributes for: {}", id);
+ throw new ReadFailedException( id, e );
+ }
}
@Nonnull
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java
index 750ff575e..a8f13c635 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizer.java
@@ -16,32 +16,33 @@
package io.fd.honeycomb.v3po.translate.v3po.vpp;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.fd.honeycomb.v3po.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
-import java.util.List;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.BridgeDomains;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainKey;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.BridgeDomainAddDel;
import org.openvpp.jvpp.dto.BridgeDomainAddDelReply;
import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
public class BridgeDomainCustomizer
extends FutureJVppCustomizer
implements ListWriterCustomizer<BridgeDomain, BridgeDomainKey> {
@@ -64,7 +65,8 @@ public class BridgeDomainCustomizer
}
private BridgeDomainAddDelReply addOrUpdateBridgeDomain(final int bdId, @Nonnull final BridgeDomain bd)
- throws VppApiInvocationException {
+ throws VppBaseCallException {
+ final BridgeDomainAddDelReply reply;
final BridgeDomainAddDel request = new BridgeDomainAddDel();
request.bdId = bdId;
request.flood = booleanToByte(bd.isFlood());
@@ -74,15 +76,8 @@ public class BridgeDomainCustomizer
request.arpTerm = booleanToByte(bd.isArpTermination());
request.isAdd = ADD_OR_UPDATE_BD;
- final BridgeDomainAddDelReply reply =
- TranslateUtils.getReply(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture());
- if (reply.retval < 0) {
- LOG.warn("Bridge domain {} (id={}) add/update failed", bd.getName(), bdId);
- throw new VppApiInvocationException("bridgeDomainAddDel", reply.context, reply.retval);
- } else {
- LOG.debug("Bridge domain {} (id={}) add/update successful", bd.getName(), bdId);
- }
-
+ reply = TranslateUtils.getReply(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture());
+ LOG.debug("Bridge domain {} (id={}) add/update successful", bd.getName(), bdId);
return reply;
}
@@ -102,7 +97,7 @@ public class BridgeDomainCustomizer
}
addOrUpdateBridgeDomain(index, dataBefore);
bdContext.addName(index, bdName, ctx.getMappingContext());
- } catch (VppApiInvocationException e) {
+ } catch (VppBaseCallException e) {
LOG.warn("Failed to create bridge domain", e);
throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
}
@@ -119,20 +114,19 @@ public class BridgeDomainCustomizer
@Nonnull final BridgeDomain dataBefore,
@Nonnull final WriteContext ctx) throws WriteFailedException.DeleteFailedException {
LOG.debug("deleteCurrentAttributes: id={}, dataBefore={}, ctx={}", id, dataBefore, ctx);
-
final String bdName = id.firstKeyOf(BridgeDomain.class).getName();
- int bdId = bdContext.getIndex(bdName, ctx.getMappingContext());
- final BridgeDomainAddDel request = new BridgeDomainAddDel();
- request.bdId = bdId;
+ int bdId = bdId = bdContext.getIndex(bdName, ctx.getMappingContext());
+ try {
- final BridgeDomainAddDelReply reply =
- TranslateUtils.getReply(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture());
- if (reply.retval < 0) {
- LOG.warn("Bridge domain {} (id={}) delete failed", bdName, bdId);
- throw new WriteFailedException.DeleteFailedException(id,
- new VppApiInvocationException("bridgeDomainAddDel", reply.context, reply.retval));
- } else {
+ final BridgeDomainAddDel request = new BridgeDomainAddDel();
+ request.bdId = bdId;
+
+ final BridgeDomainAddDelReply reply =
+ TranslateUtils.getReply(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture());
LOG.debug("Bridge domain {} (id={}) deleted successfully", bdName, bdId);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Bridge domain {} (id={}) delete failed", bdName, bdId);
+ throw new WriteFailedException.DeleteFailedException(id,e);
}
}
@@ -149,7 +143,7 @@ public class BridgeDomainCustomizer
try {
addOrUpdateBridgeDomain(bdContext.getIndex(bdName, ctx.getMappingContext()), dataAfter);
- } catch (VppApiInvocationException e) {
+ } catch (VppBaseCallException e) {
LOG.warn("Failed to create bridge domain", e);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java
index 8122fd245..5dc6596ad 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VersionCustomizer.java
@@ -29,6 +29,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.VppCallbackException;
+import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.dto.ShowVersion;
import org.openvpp.jvpp.dto.ShowVersionReply;
import org.openvpp.jvpp.future.FutureJVpp;
@@ -60,15 +63,19 @@ public final class VersionCustomizer
@Override
public void readCurrentAttributes(@Nonnull InstanceIdentifier<Version> id, @Nonnull final VersionBuilder builder,
@Nonnull final ReadContext context) throws ReadFailedException {
- // Execute with timeout
- final CompletionStage<ShowVersionReply> showVersionFuture = getFutureJVpp().showVersion(new ShowVersion());
- final ShowVersionReply reply = TranslateUtils.getReply(showVersionFuture.toCompletableFuture(), id,
- DEFAULT_TIMEOUT_IN_SECONDS);
+ try {
+ // Execute with timeout
+ final CompletionStage<ShowVersionReply> showVersionFuture = getFutureJVpp().showVersion(new ShowVersion());
+ final ShowVersionReply reply = TranslateUtils.getReply(showVersionFuture.toCompletableFuture(), id,
+ DEFAULT_TIMEOUT_IN_SECONDS);
- builder.setBranch(TranslateUtils.toString(reply.version));
- builder.setName(TranslateUtils.toString(reply.program));
- builder.setBuildDate(TranslateUtils.toString(reply.buildDate));
- builder.setBuildDirectory(TranslateUtils.toString(reply.buildDirectory));
+ builder.setBranch(TranslateUtils.toString(reply.version));
+ builder.setName(TranslateUtils.toString(reply.program));
+ builder.setBuildDate(TranslateUtils.toString(reply.buildDate));
+ builder.setBuildDirectory(TranslateUtils.toString(reply.buildDirectory));
+ } catch (VppBaseCallException e) {
+ throw new ReadFailedException(id);
+ }
}
}