summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfaces')
-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
12 files changed, 258 insertions, 354 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;
}
-
}