diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2016-10-06 08:54:02 +0200 |
---|---|---|
committer | Jan Srnicek <jsrnicek@cisco.com> | 2016-10-06 08:54:02 +0200 |
commit | fb6666efe7b6009528e98702efc66e9118011174 (patch) | |
tree | e7dd2b205552c1a756f7f8410fc11536162db9aa /v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces | |
parent | cf15cfe3593ec4c02cdb1121649bf95d19814e0c (diff) |
HONEYCOMB-236 - Unified read/write exceptions
Change-Id: Idde761d0c0c2c4d96555ef94dbdaa87fad889493
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces')
23 files changed, 265 insertions, 483 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizer.java index 82152cecf..8911d1e0c 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizer.java @@ -22,9 +22,11 @@ import com.google.common.net.InetAddresses; import io.fd.honeycomb.translate.vpp.util.AbstractInterfaceTypeCustomizer; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.GreAddDelTunnel; +import io.fd.vpp.jvpp.core.dto.GreAddDelTunnelReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.net.InetAddress; import java.util.concurrent.CompletionStage; import javax.annotation.Nonnull; @@ -34,10 +36,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces. import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.GreTunnel; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.Gre; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.GreAddDelTunnel; -import io.fd.vpp.jvpp.core.dto.GreAddDelTunnelReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -72,12 +70,8 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen @Nonnull final WriteContext writeContext) throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); - try { - createGreTunnel(id, swIfName, dataAfter, writeContext); - } catch (VppBaseCallException | IllegalInterfaceTypeException e) { - LOG.warn("Failed to set gre tunnel for interface: {}, gre: {}", swIfName, dataAfter, e); - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } + + createGreTunnel(id, swIfName, dataAfter, writeContext); } @Override @@ -93,16 +87,11 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen @Nonnull final WriteContext writeContext) throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); - try { - deleteGreTunnel(id, swIfName, dataBefore, writeContext); - } catch (VppBaseCallException e) { - LOG.debug("Failed to delete gre tunnel for interface: {}, gre: {}", swIfName, dataBefore); - throw new WriteFailedException.DeleteFailedException(id, e); - } + deleteGreTunnel(id, swIfName, dataBefore, writeContext); } private void createGreTunnel(final InstanceIdentifier<Gre> id, final String swIfName, final Gre gre, - final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { + final WriteContext writeContext) throws WriteFailedException { final byte isIpv6 = (byte) (isIpv6(gre) ? 1 : 0); @@ -117,7 +106,7 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen dstAddress.getAddress(), outerFibId, isIpv6)); final GreAddDelTunnelReply reply = - getReplyForWrite(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); + getReplyForCreate(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id, gre); LOG.debug("Gre tunnel set successfully for: {}, gre: {}", swIfName, gre); if (interfaceContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) { // VPP keeps gre tunnels present even after they are delete(reserving ID for next tunnel) @@ -155,7 +144,7 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen } private void deleteGreTunnel(final InstanceIdentifier<Gre> id, final String swIfName, final Gre gre, - final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { + final WriteContext writeContext) throws WriteFailedException { final byte isIpv6 = (byte) (isIpv6(gre) ? 1 : 0); @@ -169,7 +158,7 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen getFutureJVpp().greAddDelTunnel(getGreTunnelRequest((byte) 0 /* is add */, srcAddress.getAddress(), dstAddress.getAddress(), outerFibId, isIpv6)); - getReplyForWrite(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); + getReplyForDelete(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Gre tunnel deleted successfully for: {}, gre: {}", swIfName, gre); // Remove interface from our interface context interfaceContext.removeName(swIfName, writeContext.getMappingContext()); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterconnectionWriteUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterconnectionWriteUtils.java index 38e8554b1..ac5526861 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterconnectionWriteUtils.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterconnectionWriteUtils.java @@ -21,9 +21,13 @@ import static java.util.Objects.requireNonNull; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Bridge; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2BridgeReply; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Xconnect; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2XconnectReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.concurrent.CompletionStage; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.Interconnection; @@ -31,12 +35,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.interconnection.XconnectBased; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Bridge; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2BridgeReply; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Xconnect; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2XconnectReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,51 +60,40 @@ final class InterconnectionWriteUtils implements JvppReplyConsumer { void setInterconnection(final InstanceIdentifier<? extends DataObject> id, final int swIfIndex, final String ifcName, final Interconnection ic, final WriteContext writeContext) 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(id, swIfIndex, ifcName, (XconnectBased) ic, writeContext, (byte) 1 /*enable*/); - } else if (ic instanceof BridgeBased) { - setBridgeBasedL2(id, swIfIndex, ifcName, (BridgeBased) ic, writeContext, (byte) 1 /*enable*/); - } else { - // Choices&cases are not data objects, so they cannot have a dedicated Reader/Writer - // This choice is already from augment, so its 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); + + 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(id, swIfIndex, ifcName, (XconnectBased) ic, writeContext, (byte) 1 /*enable*/); + } else if (ic instanceof BridgeBased) { + setBridgeBasedL2(id, swIfIndex, ifcName, (BridgeBased) ic, writeContext, (byte) 1 /*enable*/); + } else { + // Choices&cases are not data objects, so they cannot have a dedicated Reader/Writer + // This choice is already from augment, so its 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()); } } void deleteInterconnection(final InstanceIdentifier<? extends DataObject> id, final int swIfIndex, final String ifcName, final Interconnection ic, final WriteContext writeContext) 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(id, swIfIndex, ifcName, (XconnectBased) ic, writeContext, (byte) 0 /*disable*/); - } else if (ic instanceof BridgeBased) { - setBridgeBasedL2(id, swIfIndex, ifcName, (BridgeBased) ic, writeContext, (byte) 0 /*disable*/); - } else { - LOG.error("Unable to delete Interconnection of type {}", ic.getClass()); - throw new WriteFailedException(id, "Unable to delete Interconnection of type " + ic.getClass()); - } - } catch (VppBaseCallException e) { - LOG.warn("Failed to delete bridge/xconnect based interconnection flags for: {}, interconnection: {}", - ifcName, ic); - throw new WriteFailedException(id, "Unable to delete Interconnection of type " + ic.getClass(), e); + + 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(id, swIfIndex, ifcName, (XconnectBased) ic, writeContext, (byte) 0 /*disable*/); + } else if (ic instanceof BridgeBased) { + setBridgeBasedL2(id, swIfIndex, ifcName, (BridgeBased) ic, writeContext, (byte) 0 /*disable*/); + } else { + LOG.error("Unable to delete Interconnection of type {}", ic.getClass()); + throw new WriteFailedException(id, "Unable to delete Interconnection of type " + ic.getClass()); } } private void setBridgeBasedL2(final InstanceIdentifier<? extends DataObject> id, final int swIfIndex, final String ifcName, final BridgeBased bb, - final WriteContext writeContext, final byte enabled) - throws VppBaseCallException, WriteTimeoutException { + final WriteContext writeContext, final byte enabled) throws WriteFailedException { LOG.debug("Setting bridge based interconnection(bridge-domain={}) for interface: {}", bb.getBridgeDomain(), ifcName); @@ -144,8 +131,7 @@ final class InterconnectionWriteUtils implements JvppReplyConsumer { private void setXconnectBasedL2(final InstanceIdentifier<? extends DataObject> id, final int swIfIndex, final String ifcName, final XconnectBased ic, - final WriteContext writeContext, final byte enabled) - throws VppBaseCallException, WriteTimeoutException { + final WriteContext writeContext, final byte enabled) throws WriteFailedException { String outSwIfName = ic.getXconnectOutgoingInterface(); LOG.debug("Setting xconnect based interconnection(outgoing ifc={}) for interface: {}", outSwIfName, ifcName); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceCustomizer.java index 8c4f5080c..17b48f628 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/InterfaceCustomizer.java @@ -20,18 +20,16 @@ import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlags; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; 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.interfaces.rev140508.interfaces.InterfaceKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlags; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,12 +53,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer @Nonnull final WriteContext writeContext) throws WriteFailedException { - try { - setInterface(id, dataAfter, writeContext); - } catch (VppBaseCallException e) { - LOG.warn("Update of VppInterfaceAugment failed", e); - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } + setInterface(id, dataAfter, writeContext); } @Override @@ -69,13 +62,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer @Nonnull final Interface dataAfter, @Nonnull final WriteContext writeContext) throws WriteFailedException { - - try { - updateInterface(id, dataBefore, dataAfter, writeContext); - } catch (VppBaseCallException e) { - LOG.warn("Update of VppInterfaceAugment failed", e); - throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e); - } + updateInterface(id, dataBefore, dataAfter, writeContext); } @Override @@ -86,15 +73,14 @@ public class InterfaceCustomizer extends FutureJVppCustomizer } private void setInterface(final InstanceIdentifier<Interface> id, final Interface swIf, - final WriteContext writeContext) - throws VppBaseCallException, WriteTimeoutException { + final WriteContext writeContext) throws WriteFailedException { LOG.debug("Setting interface: {} to: {}", id, swIf); setInterfaceAttributes(id, swIf, swIf.getName(), writeContext); } private void setInterfaceAttributes(final InstanceIdentifier<Interface> id, final Interface swIf, final String swIfName, final WriteContext writeContext) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { setInterfaceFlags(id, swIfName, interfaceContext.getIndex(swIfName, writeContext.getMappingContext()), swIf.isEnabled() @@ -105,14 +91,13 @@ public class InterfaceCustomizer extends FutureJVppCustomizer private void updateInterface(final InstanceIdentifier<Interface> id, final Interface dataBefore, final Interface dataAfter, final WriteContext writeContext) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { LOG.debug("Updating interface:{} to: {}", id, dataAfter); setInterfaceAttributes(id, dataAfter, dataAfter.getName(), writeContext); } private void setInterfaceFlags(final InstanceIdentifier<Interface> id, final String swIfName, final int swIfIndex, - final byte enabled) - throws VppBaseCallException, WriteTimeoutException { + final byte enabled) throws WriteFailedException { final CompletionStage<SwInterfaceSetFlagsReply> swInterfaceSetFlagsReplyFuture = getFutureJVpp().swInterfaceSetFlags( getSwInterfaceSetFlagsInput(swIfIndex, enabled, (byte) 0 /* deleted */)); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizer.java index fd118a9c6..3cd1eb99c 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizer.java @@ -22,17 +22,16 @@ import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.ProxyArpAddDel; +import io.fd.vpp.jvpp.core.dto.ProxyArpAddDelReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.net.InetAddress; -import java.util.concurrent.CompletionStage; +import java.util.concurrent.Future; import javax.annotation.Nonnull; 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.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.ProxyArp; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.ProxyArpAddDel; -import io.fd.vpp.jvpp.core.dto.ProxyArpAddDelReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,13 +47,7 @@ public class ProxyArpCustomizer extends FutureJVppCustomizer implements WriterCu public void writeCurrentAttributes(@Nonnull InstanceIdentifier<ProxyArp> id, @Nonnull ProxyArp dataAfter, @Nonnull WriteContext writeContext) throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); - - try { - setProxyArp(id, swIfName, dataAfter, (byte) 1 /* 1 is add */); - } catch (VppBaseCallException e) { - LOG.error("Failed to set Proxy ARP settings: {}, for interface: {}", dataAfter, swIfName); - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } + createProxyArp(getProxyArpRequestFuture(id, swIfName, dataAfter, (byte) 1 /* 1 is add */), id, dataAfter); } @Override @@ -70,27 +63,32 @@ public class ProxyArpCustomizer extends FutureJVppCustomizer implements WriterCu @Nonnull WriteContext writeContext) throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); - try { - setProxyArp(id, swIfName, dataBefore, (byte) 0 /* 0 is delete */); - } catch (VppBaseCallException e) { - LOG.debug("Failed to delete Proxy ARP settings: {}, for interface: {}", dataBefore, swIfName); - throw new WriteFailedException.DeleteFailedException(id, e); - } + deleteProxyArp(getProxyArpRequestFuture(id, swIfName, dataBefore, (byte) 0 /* 0 is delete */), id); } - private void setProxyArp(InstanceIdentifier<ProxyArp> id, String swIfName, ProxyArp proxyArp, byte operation) - throws VppBaseCallException, WriteFailedException { + private Future<ProxyArpAddDelReply> getProxyArpRequestFuture(InstanceIdentifier<ProxyArp> id, String swIfName, + ProxyArp proxyArp, byte operation) + throws WriteFailedException { LOG.debug("Setting Proxy ARP settings for interface: {}", swIfName); final InetAddress srcAddress = InetAddresses.forString(getv4AddressString(proxyArp.getLowAddr())); final InetAddress dstAddress = InetAddresses.forString(getv4AddressString(proxyArp.getHighAddr())); final int vrfId = proxyArp.getVrfId().intValue(); - final CompletionStage<ProxyArpAddDelReply> proxyArpAddDelReplyCompletionStage = - getFutureJVpp().proxyArpAddDel(getProxyArpConfRequest(operation, srcAddress.getAddress(), - dstAddress.getAddress(), vrfId)); + return getFutureJVpp().proxyArpAddDel( + getProxyArpConfRequest(operation, srcAddress.getAddress(), dstAddress.getAddress(), vrfId)) + .toCompletableFuture(); + } + + private void createProxyArp(final Future<ProxyArpAddDelReply> future, final InstanceIdentifier<ProxyArp> identifier, + final ProxyArp data) + throws WriteFailedException { + final ProxyArpAddDelReply reply = getReplyForCreate(future, identifier, data); + LOG.debug("Proxy ARP setting create successful, with reply context:", reply.context); + } - final ProxyArpAddDelReply reply = - getReplyForWrite(proxyArpAddDelReplyCompletionStage.toCompletableFuture(), id); - LOG.debug("Proxy ARP setting applied, with reply context:", reply.context); + private void deleteProxyArp(final Future<ProxyArpAddDelReply> future, final InstanceIdentifier<ProxyArp> identifier) + throws WriteFailedException { + final ProxyArpAddDelReply reply = getReplyForDelete(future, identifier); + LOG.debug("Proxy ARP setting delete successful, with reply context:", reply.context); } private static ProxyArpAddDel getProxyArpConfRequest(final byte isAdd, final byte[] lAddr, final byte[] hAddr, diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizer.java index 0156129d8..f6d007618 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizer.java @@ -24,9 +24,11 @@ import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.NamingContext; import io.fd.honeycomb.translate.vpp.util.SubInterfaceUtils; import io.fd.honeycomb.translate.vpp.util.TagRewriteOperation; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.L2InterfaceVlanTagRewrite; +import io.fd.vpp.jvpp.core.dto.L2InterfaceVlanTagRewriteReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.List; import java.util.concurrent.CompletionStage; import javax.annotation.Nonnull; @@ -37,10 +39,6 @@ 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.RewriteBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.tag.rewrite.PushTags; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.L2InterfaceVlanTagRewrite; -import io.fd.vpp.jvpp.core.dto.L2InterfaceVlanTagRewriteReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,12 +63,7 @@ public class RewriteCustomizer extends FutureJVppCustomizer final WriteContext writeContext) throws WriteFailedException { final String subifName = getSubInterfaceName(id); - try { - setTagRewrite(id, subifName, dataAfter, writeContext); - } catch (VppBaseCallException e) { - LOG.warn("Failed to write interface {}(id=): {}", subifName, writeContext, dataAfter); - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } + setTagRewrite(id, subifName, dataAfter, writeContext); } private static String getSubInterfaceName(final InstanceIdentifier<Rewrite> id) { @@ -79,8 +72,7 @@ public class RewriteCustomizer extends FutureJVppCustomizer } private void setTagRewrite(final InstanceIdentifier<Rewrite> id, final String ifname, final Rewrite rewrite, - final WriteContext writeContext) - throws VppBaseCallException, WriteTimeoutException { + final WriteContext writeContext) throws WriteFailedException { final int swIfIndex = interfaceContext.getIndex(ifname, writeContext.getMappingContext()); LOG.debug("Setting tag rewrite for interface {}(id=): {}", ifname, swIfIndex, rewrite); @@ -128,12 +120,7 @@ public class RewriteCustomizer extends FutureJVppCustomizer @Nonnull final Rewrite dataAfter, @Nonnull final WriteContext writeContext) throws WriteFailedException { final String subifName = getSubInterfaceName(id); - try { - setTagRewrite(id, subifName, dataAfter, writeContext); - } catch (VppBaseCallException e) { - LOG.warn("Failed to update interface {}(id=): {}", subifName, writeContext, dataAfter); - throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e); - } + setTagRewrite(id, subifName, dataAfter, writeContext); } @Override @@ -141,13 +128,9 @@ public class RewriteCustomizer extends FutureJVppCustomizer @Nonnull final Rewrite dataBefore, @Nonnull final WriteContext writeContext) throws WriteFailedException { final String subifName = getSubInterfaceName(id); - try { - LOG.debug("Disabling tag rewrite for interface {}", subifName); - final Rewrite rewrite = new RewriteBuilder().build(); // rewrite without push and pops will cause delete - setTagRewrite(id, subifName, rewrite, writeContext); - } catch (VppBaseCallException e) { - LOG.warn("Failed to delete interface {}(id=): {}", subifName, writeContext, dataBefore); - throw new WriteFailedException.DeleteFailedException(id, e); - } + + LOG.debug("Disabling tag rewrite for interface {}", subifName); + final Rewrite rewrite = new RewriteBuilder().build(); // rewrite without push and pops will cause delete + setTagRewrite(id, subifName, rewrite, writeContext); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java index 8b93f7551..3eeb8995e 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizer.java @@ -20,10 +20,8 @@ import io.fd.honeycomb.translate.spi.write.WriterCustomizer; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.core.dto.SwInterfaceSetTable; import io.fd.vpp.jvpp.core.dto.SwInterfaceSetTableReply; import io.fd.vpp.jvpp.core.future.FutureJVppCore; @@ -51,12 +49,7 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements WriterCus throws WriteFailedException { final String ifName = id.firstKeyOf(Interface.class).getName(); - try { - setRouting(id, 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); - } + setRouting(id, ifName, dataAfter, writeContext); } @Override @@ -66,12 +59,7 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements WriterCus throws WriteFailedException { final String ifName = id.firstKeyOf(Interface.class).getName(); - try { - setRouting(id, 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); - } + setRouting(id, ifName, dataAfter, writeContext); } @Override @@ -79,16 +67,11 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements WriterCus @Nonnull final Routing dataBefore, @Nonnull final WriteContext writeContext) throws WriteFailedException { final String ifName = id.firstKeyOf(Interface.class).getName(); - try { - disableRouting(id, ifName, writeContext); - } catch (VppBaseCallException e) { - LOG.warn("Failed to disable routing for interface: {}, {}", ifName, writeContext); - throw new WriteFailedException.DeleteFailedException(id, e); - } + disableRouting(id, ifName, writeContext); } private void setRouting(final InstanceIdentifier<Routing> id, final String name, final Routing rt, - final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { + final WriteContext writeContext) throws WriteFailedException { final int swIfc = interfaceContext.getIndex(name, writeContext.getMappingContext()); LOG.debug("Setting routing for interface: {}, {}. Routing: {}", name, swIfc, rt); @@ -110,11 +93,11 @@ public class RoutingCustomizer extends FutureJVppCustomizer implements WriterCus * default value 0 */ private void disableRouting(final InstanceIdentifier<Routing> id, final String name, - final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { + final WriteContext writeContext) throws WriteFailedException { final int swIfc = interfaceContext.getIndex(name, writeContext.getMappingContext()); LOG.debug("Disabling routing for interface: {}, {}.", name, swIfc); - getReplyForWrite(getFutureJVpp() + getReplyForDelete(getFutureJVpp() .swInterfaceSetTable(getInterfaceSetTableRequest(swIfc, (byte) 0, 0)).toCompletableFuture(), id); LOG.debug("Routing for interface: {}, {} successfully disabled", name, swIfc); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizer.java index dd345e723..c2515621c 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizer.java @@ -26,9 +26,13 @@ import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.CreateSubif; +import io.fd.vpp.jvpp.core.dto.CreateSubifReply; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlags; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.concurrent.CompletionStage; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -45,12 +49,6 @@ 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.match.attributes.match.type.vlan.tagged.VlanTagged; 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.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.CreateSubif; -import io.fd.vpp.jvpp.core.dto.CreateSubifReply; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlags; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,24 +73,18 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer @Nonnull final SubInterface dataAfter, @Nonnull final WriteContext writeContext) throws WriteFailedException { final String superIfName = id.firstKeyOf(Interface.class).getName(); - try { - createSubInterface(id, superIfName, dataAfter, writeContext); - } catch (VppBaseCallException e) { - LOG.warn("Failed to create sub interface for: {}, subInterface: {}", superIfName, dataAfter); - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } + createSubInterface(id, superIfName, dataAfter, writeContext); } private void createSubInterface(final InstanceIdentifier<SubInterface> id, @Nonnull final String superIfName, - @Nonnull final SubInterface subInterface, - final WriteContext writeContext) throws VppBaseCallException, - WriteTimeoutException { + @Nonnull final SubInterface subInterface, final WriteContext writeContext) + throws WriteFailedException { final int superIfIndex = interfaceContext.getIndex(superIfName, writeContext.getMappingContext()); final CompletionStage<CreateSubifReply> createSubifReplyCompletionStage = getFutureJVpp().createSubif(getCreateSubifRequest(subInterface, superIfIndex)); final CreateSubifReply reply = - getReplyForWrite(createSubifReplyCompletionStage.toCompletableFuture(), id); + getReplyForCreate(createSubifReplyCompletionStage.toCompletableFuture(), id, subInterface); setInterfaceState(id, reply.swIfIndex, booleanToByte(subInterface.isEnabled())); interfaceContext.addName(reply.swIfIndex, @@ -170,18 +162,12 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer throws WriteFailedException { final String subIfaceName = getSubInterfaceName(id.firstKeyOf(Interface.class).getName(), Math.toIntExact(dataAfter.getIdentifier())); - try { - setInterfaceState(id, interfaceContext.getIndex(subIfaceName, writeContext.getMappingContext()), - booleanToByte(dataAfter.isEnabled())); - } 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); - } + setInterfaceState(id, interfaceContext.getIndex(subIfaceName, writeContext.getMappingContext()), + booleanToByte(dataAfter.isEnabled())); } private void setInterfaceState(final InstanceIdentifier<SubInterface> id, final int swIfIndex, final byte enabled) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { final SwInterfaceSetFlags swInterfaceSetFlags = new SwInterfaceSetFlags(); swInterfaceSetFlags.swIfIndex = swIfIndex; swInterfaceSetFlags.adminUpDown = enabled; diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizer.java index 08cdaddc3..09a764136 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizer.java @@ -20,17 +20,8 @@ import io.fd.honeycomb.translate.vpp.util.AbstractInterfaceTypeCustomizer; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.MacTranslator; import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.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; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.Tap; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.core.dto.TapConnect; import io.fd.vpp.jvpp.core.dto.TapConnectReply; import io.fd.vpp.jvpp.core.dto.TapDelete; @@ -38,6 +29,13 @@ import io.fd.vpp.jvpp.core.dto.TapDeleteReply; import io.fd.vpp.jvpp.core.dto.TapModify; import io.fd.vpp.jvpp.core.dto.TapModifyReply; import io.fd.vpp.jvpp.core.future.FutureJVppCore; +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; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.Tap; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,12 +59,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> implemen @Nonnull final WriteContext writeContext) throws WriteFailedException { final String ifcName = id.firstKeyOf(Interface.class).getName(); - try { - createTap(id, ifcName, dataAfter, writeContext); - } catch (VppBaseCallException e) { - LOG.warn("Failed to set tap interface: {}, tap: {}", ifcName, dataAfter, e); - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } + createTap(id, ifcName, dataAfter, writeContext); } @Override @@ -82,12 +75,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> implemen throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e); } - try { - modifyTap(id, ifcName, index, dataAfter); - } catch (VppBaseCallException e) { - LOG.warn("Failed to set tap interface: {}, tap: {}", ifcName, dataAfter, e); - throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e); - } + modifyTap(id, ifcName, index, dataBefore, dataAfter); } @Override @@ -103,45 +91,38 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> implemen throw new WriteFailedException.DeleteFailedException(id, e); } - try { - deleteTap(id, ifcName, index, dataBefore, writeContext); - } catch (VppBaseCallException e) { - LOG.warn("Failed to delete tap interface: {}, tap: {}", ifcName, dataBefore.getTapName(), e); - throw new WriteFailedException.DeleteFailedException(id, e); - } + deleteTap(id, ifcName, index, dataBefore, writeContext); } private void createTap(final InstanceIdentifier<Tap> id, final String swIfName, final Tap tap, - final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { + final WriteContext writeContext) throws WriteFailedException { LOG.debug("Setting tap interface: {}. Tap: {}", swIfName, tap); - final CompletionStage<TapConnectReply> tapConnectFuture = - getFutureJVpp() - .tapConnect(getTapConnectRequest(tap.getTapName(), tap.getMac(), tap.getDeviceInstance())); - final TapConnectReply reply = - getReplyForWrite(tapConnectFuture.toCompletableFuture(), id); + final CompletionStage<TapConnectReply> tapConnectFuture = getFutureJVpp() + .tapConnect(getTapConnectRequest(tap.getTapName(), tap.getMac(), tap.getDeviceInstance())); + final TapConnectReply reply = getReplyForCreate(tapConnectFuture.toCompletableFuture(), id, tap); 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 InstanceIdentifier<Tap> id, final String swIfName, final int index, final Tap tap) - throws VppBaseCallException, WriteTimeoutException { - LOG.debug("Modifying tap interface: {}. Tap: {}", swIfName, tap); + private void modifyTap(final InstanceIdentifier<Tap> id, final String swIfName, final int index, + final Tap tapBefore, final Tap tapAfter) throws WriteFailedException { + LOG.debug("Modifying tap interface: {}. Tap: {}", swIfName, tapAfter); final CompletionStage<TapModifyReply> vxlanAddDelTunnelReplyCompletionStage = getFutureJVpp() - .tapModify(getTapModifyRequest(tap.getTapName(), index, tap.getMac(), tap.getDeviceInstance())); - getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); - LOG.debug("Tap modified successfully for: {}, tap: {}", swIfName, tap); + .tapModify(getTapModifyRequest(tapAfter.getTapName(), index, tapAfter.getMac(), + tapAfter.getDeviceInstance())); + getReplyForUpdate(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id, tapBefore, tapAfter); + LOG.debug("Tap modified successfully for: {}, tap: {}", swIfName, tapAfter); } private void deleteTap(final InstanceIdentifier<Tap> id, final String swIfName, final int index, - final Tap dataBefore, - final WriteContext writeContext) - throws VppBaseCallException, WriteTimeoutException { + final Tap dataBefore, final WriteContext writeContext) + throws WriteFailedException { LOG.debug("Deleting tap interface: {}. Tap: {}", swIfName, dataBefore); final CompletionStage<TapDeleteReply> vxlanAddDelTunnelReplyCompletionStage = getFutureJVpp().tapDelete(getTapDeleteRequest(index)); - getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); + getReplyForDelete(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Tap deleted successfully for: {}, tap: {}", swIfName, dataBefore); // Remove deleted interface from interface context interfaceContext.removeName(swIfName, writeContext.getMappingContext()); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizer.java index a906655f1..d0703747a 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizer.java @@ -21,17 +21,8 @@ import io.fd.honeycomb.translate.vpp.util.AbstractInterfaceTypeCustomizer; import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.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; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VhostUser; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.core.dto.CreateVhostUserIf; import io.fd.vpp.jvpp.core.dto.CreateVhostUserIfReply; import io.fd.vpp.jvpp.core.dto.DeleteVhostUserIf; @@ -39,6 +30,13 @@ import io.fd.vpp.jvpp.core.dto.DeleteVhostUserIfReply; import io.fd.vpp.jvpp.core.dto.ModifyVhostUserIf; import io.fd.vpp.jvpp.core.dto.ModifyVhostUserIfReply; import io.fd.vpp.jvpp.core.future.FutureJVppCore; +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; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VhostUser; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,23 +64,18 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs @Nonnull final VhostUser dataAfter, @Nonnull final WriteContext writeContext) throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); - try { - createVhostUserIf(id, 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); - } + createVhostUserIf(id, swIfName, dataAfter, writeContext); } private void createVhostUserIf(final InstanceIdentifier<VhostUser> id, final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { LOG.debug("Creating vhost user interface: name={}, vhostUser={}", swIfName, vhostUser); final CompletionStage<CreateVhostUserIfReply> createVhostUserIfReplyCompletionStage = getFutureJVpp().createVhostUserIf(getCreateVhostUserIfRequest(vhostUser)); final CreateVhostUserIfReply reply = - getReplyForWrite(createVhostUserIfReplyCompletionStage.toCompletableFuture(), id); + getReplyForCreate(createVhostUserIfReplyCompletionStage.toCompletableFuture(), id, vhostUser); 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()); @@ -106,25 +99,21 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs @Nonnull final WriteContext writeContext) throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); - try { - modifyVhostUserIf(id, 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); - } + modifyVhostUserIf(id, swIfName, dataBefore, dataAfter, writeContext); } private void modifyVhostUserIf(final InstanceIdentifier<VhostUser> id, final String swIfName, - final VhostUser vhostUser, final WriteContext writeContext) - throws VppBaseCallException, WriteTimeoutException { - LOG.debug("Updating vhost user interface: name={}, vhostUser={}", swIfName, vhostUser); + final VhostUser vhostUserBefore, final VhostUser vhostUserAfter, + final WriteContext writeContext) throws WriteFailedException { + LOG.debug("Updating vhost user interface: name={}, vhostUser={}", swIfName, vhostUserAfter); final CompletionStage<ModifyVhostUserIfReply> modifyVhostUserIfReplyCompletionStage = getFutureJVpp() - .modifyVhostUserIf(getModifyVhostUserIfRequest(vhostUser, + .modifyVhostUserIf(getModifyVhostUserIfRequest(vhostUserAfter, interfaceContext.getIndex(swIfName, writeContext.getMappingContext()))); - getReplyForWrite(modifyVhostUserIfReplyCompletionStage.toCompletableFuture(), id); - LOG.debug("Vhost user interface updated successfully for: {}, vhostUser: {}", swIfName, vhostUser); + getReplyForUpdate(modifyVhostUserIfReplyCompletionStage.toCompletableFuture(), id, vhostUserBefore, + vhostUserAfter); + LOG.debug("Vhost user interface updated successfully for: {}, vhostUser: {}", swIfName, vhostUserAfter); } private ModifyVhostUserIf getModifyVhostUserIfRequest(final VhostUser vhostUser, final int swIfIndex) { @@ -143,23 +132,18 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs @Nonnull final VhostUser dataBefore, @Nonnull final WriteContext writeContext) throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); - try { - deleteVhostUserIf(id, swIfName, dataBefore, writeContext); - } catch (VppBaseCallException e) { - LOG.warn("Failed to delete vhost user interface: {}, vhostUser: {}", swIfName, dataBefore); - throw new WriteFailedException.DeleteFailedException(id, e); - } + deleteVhostUserIf(id, swIfName, dataBefore, writeContext); } private void deleteVhostUserIf(final InstanceIdentifier<VhostUser> id, final String swIfName, final VhostUser vhostUser, final WriteContext writeContext) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { LOG.debug("Deleting vhost user interface: name={}, vhostUser={}", swIfName, vhostUser); final CompletionStage<DeleteVhostUserIfReply> deleteVhostUserIfReplyCompletionStage = getFutureJVpp().deleteVhostUserIf(getDeleteVhostUserIfRequest( interfaceContext.getIndex(swIfName, writeContext.getMappingContext()))); - getReplyForWrite(deleteVhostUserIfReplyCompletionStage.toCompletableFuture(), id); + getReplyForDelete(deleteVhostUserIfReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Vhost user interface deleted successfully for: {}, vhostUser: {}", swIfName, vhostUser); // Remove interface from our interface context interfaceContext.removeName(swIfName, writeContext.getMappingContext()); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizer.java index 35500c178..497d25050 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizer.java @@ -23,9 +23,11 @@ import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager; import io.fd.honeycomb.translate.vpp.util.AbstractInterfaceTypeCustomizer; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnel; +import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnelReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.net.InetAddress; import java.util.concurrent.CompletionStage; import javax.annotation.Nonnull; @@ -35,10 +37,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces. 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.interfaces._interface.Vxlan; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnel; -import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnelReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,12 +65,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl @Nonnull final WriteContext writeContext) throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); - try { - createVxlanTunnel(id, 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); - } + createVxlanTunnel(id, swIfName, dataAfter, writeContext); } @Override @@ -88,16 +81,12 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl @Nonnull final WriteContext writeContext) throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); - try { - deleteVxlanTunnel(id, swIfName, dataBefore, writeContext); - } catch (VppBaseCallException e) { - LOG.debug("Failed to delete vxlan tunnel for interface: {}, vxlan: {}", swIfName, dataBefore); - throw new WriteFailedException.DeleteFailedException(id, e); - } + deleteVxlanTunnel(id, swIfName, dataBefore, writeContext); } private void createVxlanTunnel(final InstanceIdentifier<Vxlan> id, final String swIfName, final Vxlan vxlan, - final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { + final WriteContext writeContext) + throws WriteFailedException { final byte isIpv6 = (byte) (isIpv6(vxlan) ? 1 : 0); @@ -113,7 +102,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl dstAddress.getAddress(), encapVrfId, -1, vni, isIpv6)); final VxlanAddDelTunnelReply reply = - getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); + getReplyForCreate(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id, vxlan); LOG.debug("Vxlan tunnel set successfully for: {}, vxlan: {}", swIfName, vxlan); if (interfaceNamingContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) { // VPP keeps vxlan tunnels present even after they are delete(reserving ID for next tunnel) @@ -160,7 +149,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl } private void deleteVxlanTunnel(final InstanceIdentifier<Vxlan> id, final String swIfName, final Vxlan vxlan, - final WriteContext writeContext) throws VppBaseCallException, WriteTimeoutException { + final WriteContext writeContext) throws WriteFailedException { final byte isIpv6 = (byte) (isIpv6(vxlan) ? 1 : 0); @@ -175,7 +164,7 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl getFutureJVpp().vxlanAddDelTunnel(getVxlanTunnelRequest((byte) 0 /* is add */, srcAddress.getAddress(), dstAddress.getAddress(), encapVrfId, -1, vni, isIpv6)); - getReplyForWrite(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); + getReplyForDelete(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); LOG.debug("Vxlan tunnel deleted successfully for: {}, vxlan: {}", swIfName, vxlan); final int index = interfaceNamingContext.getIndex(swIfName, writeContext.getMappingContext()); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizer.java index 4a83f9223..744d5f909 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizer.java @@ -23,9 +23,11 @@ import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager; import io.fd.honeycomb.translate.vpp.util.AbstractInterfaceTypeCustomizer; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.VxlanGpeAddDelTunnel; +import io.fd.vpp.jvpp.core.dto.VxlanGpeAddDelTunnelReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.net.InetAddress; import java.util.concurrent.CompletionStage; import javax.annotation.Nonnull; @@ -35,10 +37,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces. 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.interfaces._interface.VxlanGpe; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.VxlanGpeAddDelTunnel; -import io.fd.vpp.jvpp.core.dto.VxlanGpeAddDelTunnelReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,12 +65,7 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe @Nonnull final WriteContext writeContext) throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); - try { - createVxlanGpeTunnel(id, 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); - } + createVxlanGpeTunnel(id, swIfName, dataAfter, writeContext); } @Override @@ -90,17 +83,12 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe @Nonnull final WriteContext writeContext) throws WriteFailedException { final String swIfName = id.firstKeyOf(Interface.class).getName(); - try { - deleteVxlanGpeTunnel(id, swIfName, dataBefore, writeContext); - } catch (VppBaseCallException e) { - LOG.warn("Failed to delete VxlanGpe tunnel for interface: {}, VxlanGpe: {}", swIfName, dataBefore); - throw new WriteFailedException.DeleteFailedException(id, e); - } + deleteVxlanGpeTunnel(id, swIfName, dataBefore, writeContext); } private void createVxlanGpeTunnel(final InstanceIdentifier<VxlanGpe> id, final String swIfName, final VxlanGpe vxlanGpe, final WriteContext writeContext) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { final byte isIpv6 = (byte) (isIpv6(vxlanGpe) ? 1 : 0); @@ -118,7 +106,7 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe Remote.getAddress(), vni, protocol, encapVrfId, decapVrfId, isIpv6)); final VxlanGpeAddDelTunnelReply reply = - getReplyForWrite(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); + getReplyForCreate(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id, vxlanGpe); LOG.debug("VxlanGpe tunnel set successfully for: {}, VxlanGpe: {}", swIfName, vxlanGpe); if (interfaceNamingContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) { final String formerName = interfaceNamingContext.getName(reply.swIfIndex, writeContext.getMappingContext()); @@ -160,7 +148,7 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe private void deleteVxlanGpeTunnel(final InstanceIdentifier<VxlanGpe> id, final String swIfName, final VxlanGpe vxlanGpe, final WriteContext writeContext) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { final byte isIpv6 = (byte) (isIpv6(vxlanGpe) ? 1 : 0); @@ -177,9 +165,7 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe getFutureJVpp() .vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 0 /* is delete */, local.getAddress(), remote.getAddress(), vni, protocol, encapVrfId, decapVrfId, isIpv6)); - - getReplyForWrite(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); - + getReplyForDelete(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id); final int index = interfaceNamingContext.getIndex(swIfName, writeContext.getMappingContext()); // Mark this interface as disabled to not include it in operational reads // because VPP will keep the interface there diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AbstractAceWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AbstractAceWriter.java index 882c00a36..eed22a63b 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AbstractAceWriter.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AbstractAceWriter.java @@ -23,6 +23,7 @@ import com.google.common.annotations.VisibleForTesting; import io.fd.honeycomb.translate.util.RWUtils; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; +import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSession; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSessionReply; @@ -113,7 +114,7 @@ abstract class AbstractAceWriter<T extends AceType> implements AceWriter, JvppRe public final void write(@Nonnull final InstanceIdentifier<?> id, @Nonnull final List<Ace> aces, final InterfaceMode mode, @Nonnull final InputAclSetInterface request, @Nonnegative final int vlanTags) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { final PacketHandling action = aces.stream().map(ace -> ace.getActions().getPacketHandling()).distinct() .collect(SINGLE_ITEM_COLLECTOR); @@ -133,7 +134,7 @@ abstract class AbstractAceWriter<T extends AceType> implements AceWriter, JvppRe private int createClassifyTable(@Nonnull final InstanceIdentifier<?> id, @Nonnull final ClassifyAddDelTable request) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { final CompletionStage<ClassifyAddDelTableReply> cs = futureJVppCore.classifyAddDelTable(request); final ClassifyAddDelTableReply reply = getReplyForWrite(cs.toCompletableFuture(), id); @@ -142,7 +143,7 @@ abstract class AbstractAceWriter<T extends AceType> implements AceWriter, JvppRe private void createClassifySession(@Nonnull final InstanceIdentifier<?> id, @Nonnull final ClassifyAddDelSession request) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { final CompletionStage<ClassifyAddDelSessionReply> cs = futureJVppCore.classifyAddDelSession(request); getReplyForWrite(cs.toCompletableFuture(), id); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceWriter.java index 2be3e09f6..2e22ed1a0 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceWriter.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceWriter.java @@ -17,6 +17,7 @@ package io.fd.honeycomb.translate.v3po.interfaces.acl.ingress; import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; +import io.fd.honeycomb.translate.write.WriteFailedException; import java.util.List; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; @@ -42,5 +43,5 @@ interface AceWriter { */ void write(@Nonnull final InstanceIdentifier<?> id, @Nonnull final List<Ace> aces, final InterfaceMode mode, @Nonnull final InputAclSetInterface request, @Nonnegative final int vlanTags) - throws VppBaseCallException, WriteTimeoutException; + throws WriteFailedException; } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AclCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AclCustomizer.java index a423a456f..30b60c6ff 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AclCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AclCustomizer.java @@ -22,10 +22,8 @@ import io.fd.honeycomb.translate.spi.write.WriterCustomizer; import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.core.future.FutureJVppCore; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; @@ -53,40 +51,33 @@ public class AclCustomizer extends FutureJVppCustomizer implements WriterCustomi @Override public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, @Nonnull final Ingress dataAfter, @Nonnull final WriteContext writeContext) throws WriteFailedException { - try { - setAcl(true, id, dataAfter, writeContext); - } catch (VppBaseCallException e) { - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } + setAcl(true, id, dataAfter, writeContext); } @Override - public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, @Nonnull final Ingress dataBefore, + public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, + @Nonnull final Ingress dataBefore, @Nonnull final Ingress dataAfter, @Nonnull final WriteContext writeContext) - throws WriteFailedException { + throws WriteFailedException { throw new UnsupportedOperationException("Acl update is not supported. Please delete Acl container first."); } @Override - public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, @Nonnull final Ingress dataBefore, + public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, + @Nonnull final Ingress dataBefore, @Nonnull final WriteContext writeContext) throws WriteFailedException { - try { - setAcl(false, id, dataBefore, writeContext); - } catch (VppBaseCallException e) { - throw new WriteFailedException.DeleteFailedException(id, e); - } + setAcl(false, id, dataBefore, writeContext); } private void setAcl(final boolean isAdd, @Nonnull final InstanceIdentifier<Ingress> id, @Nonnull final Ingress acl, - @Nonnull final WriteContext writeContext) - throws VppBaseCallException, WriteTimeoutException { + @Nonnull final WriteContext writeContext) throws WriteFailedException { final String ifName = id.firstKeyOf(Interface.class).getName(); final int ifIndex = interfaceContext.getIndex(ifName, writeContext.getMappingContext()); LOG.debug("Setting ACL(isAdd={}) on interface={}(id={}): {}", isAdd, ifName, ifIndex, acl); inputAclSetInterface(getFutureJVpp(), isAdd, id, acl, ifIndex, classifyTableContext, - writeContext.getMappingContext()); + writeContext.getMappingContext()); LOG.debug("Successfully set ACL(isAdd={}) on interface={}(id={}): {}", isAdd, ifName, ifIndex, acl); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AclWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AclWriter.java index 8c3333476..01ae61d06 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AclWriter.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AclWriter.java @@ -23,6 +23,7 @@ import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager; +import io.fd.honeycomb.translate.write.WriteFailedException; import java.util.concurrent.CompletionStage; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; @@ -42,8 +43,7 @@ interface AclWriter extends ByteDataTranslator, JvppReplyConsumer { @Nonnull final InstanceIdentifier<?> id, @Nonnull final AclBaseAttributes acl, @Nonnegative final int ifIndex, @Nonnull final VppClassifierContextManager classifyTableContext, - @Nonnull final MappingContext mappingContext) - throws VppBaseCallException, WriteTimeoutException { + @Nonnull final MappingContext mappingContext) throws WriteFailedException { final InputAclSetInterface request = new InputAclSetInterface(); request.isAdd = booleanToByte(isAdd); request.swIfIndex = ifIndex; diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAClWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAClWriter.java index 91c7794d3..1ac9ff2b8 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAClWriter.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAClWriter.java @@ -22,10 +22,8 @@ import com.google.common.base.Optional; import com.google.common.base.Preconditions; import io.fd.honeycomb.translate.v3po.interfaces.acl.IetfAclWriter; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTable; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTableReply; import io.fd.vpp.jvpp.core.dto.ClassifyTableByInterface; @@ -92,30 +90,26 @@ public final class IetfAClWriter implements JvppReplyConsumer { } void deleteAcl(@Nonnull final InstanceIdentifier<?> id, final int swIfIndex) - throws WriteTimeoutException, WriteFailedException.DeleteFailedException { + throws WriteFailedException { final ClassifyTableByInterface request = new ClassifyTableByInterface(); request.swIfIndex = swIfIndex; - try { - final CompletionStage<ClassifyTableByInterfaceReply> cs = jvpp.classifyTableByInterface(request); - final ClassifyTableByInterfaceReply reply = getReplyForWrite(cs.toCompletableFuture(), id); + final CompletionStage<ClassifyTableByInterfaceReply> cs = jvpp.classifyTableByInterface(request); + final ClassifyTableByInterfaceReply reply = getReplyForDelete(cs.toCompletableFuture(), id); - // We unassign and remove all ACL-related classify tables for given interface (we assume we are the only - // classify table manager) + // We unassign and remove all ACL-related classify tables for given interface (we assume we are the only + // classify table manager) - unassignClassifyTables(id, reply); + unassignClassifyTables(id, reply); - removeClassifyTable(id, reply.l2TableId); - removeClassifyTable(id, reply.ip4TableId); - removeClassifyTable(id, reply.ip6TableId); - } catch (VppBaseCallException e) { - throw new WriteFailedException.DeleteFailedException(id, e); - } + removeClassifyTable(id, reply.l2TableId); + removeClassifyTable(id, reply.ip4TableId); + removeClassifyTable(id, reply.ip6TableId); } private void unassignClassifyTables(@Nonnull final InstanceIdentifier<?> id, final ClassifyTableByInterfaceReply currentState) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { final InputAclSetInterface request = new InputAclSetInterface(); request.isAdd = 0; request.swIfIndex = currentState.swIfIndex; @@ -124,11 +118,11 @@ public final class IetfAClWriter implements JvppReplyConsumer { request.ip6TableIndex = currentState.ip6TableId; final CompletionStage<InputAclSetInterfaceReply> inputAclSetInterfaceReplyCompletionStage = jvpp.inputAclSetInterface(request); - getReplyForWrite(inputAclSetInterfaceReplyCompletionStage.toCompletableFuture(), id); + getReplyForDelete(inputAclSetInterfaceReplyCompletionStage.toCompletableFuture(), id); } private void removeClassifyTable(@Nonnull final InstanceIdentifier<?> id, final int tableIndex) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { if (tableIndex == -1) { return; // classify table id is absent @@ -136,19 +130,19 @@ public final class IetfAClWriter implements JvppReplyConsumer { final ClassifyAddDelTable request = new ClassifyAddDelTable(); request.tableIndex = tableIndex; final CompletionStage<ClassifyAddDelTableReply> cs = jvpp.classifyAddDelTable(request); - getReplyForWrite(cs.toCompletableFuture(), id); + getReplyForDelete(cs.toCompletableFuture(), id); } void write(@Nonnull final InstanceIdentifier<?> id, final int swIfIndex, @Nonnull final List<Acl> acls, @Nullable final InterfaceMode mode, @Nonnull final WriteContext writeContext) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { write(id, swIfIndex, mode, acls, writeContext, 0); } void write(@Nonnull final InstanceIdentifier<?> id, final int swIfIndex, final InterfaceMode mode, @Nonnull final List<Acl> acls, @Nonnull final WriteContext writeContext, @Nonnegative final int numberOfTags) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { // filter ACE entries and group by AceType final Map<AclType, List<Ace>> acesByType = acls.stream() diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAclCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAclCustomizer.java index b10dc362b..c9cd66ec2 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAclCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAclCustomizer.java @@ -23,7 +23,6 @@ import io.fd.honeycomb.translate.spi.write.WriterCustomizer; import io.fd.honeycomb.translate.vpp.util.NamingContext; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.vpp.jvpp.VppBaseCallException; 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.ietf.acl.base.attributes.AccessLists; @@ -60,20 +59,16 @@ public class IetfAclCustomizer implements WriterCustomizer<Ingress> { final AccessLists accessLists = dataAfter.getAccessLists(); checkArgument(accessLists != null && accessLists.getAcl() != null, - "ietf-acl container does not define acl list"); + "ietf-acl container does not define acl list"); - try { - aclWriter.write(id, ifIndex, accessLists.getAcl(), accessLists.getMode(), writeContext); - } catch (VppBaseCallException e) { - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } + aclWriter.write(id, ifIndex, accessLists.getAcl(), accessLists.getMode(), writeContext); } @Override public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, @Nonnull final Ingress dataBefore, @Nonnull final Ingress dataAfter, @Nonnull final WriteContext writeContext) - throws WriteFailedException { + throws WriteFailedException { LOG.debug("ACLs update: removing previously configured ACLs"); deleteCurrentAttributes(id, dataBefore, writeContext); LOG.debug("ACLs update: adding updated ACLs"); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/SubInterfaceAclCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/SubInterfaceAclCustomizer.java index e71770121..80e43aa29 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/SubInterfaceAclCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/SubInterfaceAclCustomizer.java @@ -23,10 +23,8 @@ import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.NamingContext; import io.fd.honeycomb.translate.vpp.util.SubInterfaceUtils; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.core.future.FutureJVppCore; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; @@ -42,7 +40,7 @@ import org.slf4j.LoggerFactory; * Customizer for enabling/disabling ingress ACLs on given sub-interface. */ public class SubInterfaceAclCustomizer extends FutureJVppCustomizer - implements WriterCustomizer<Ingress>, AclWriter { + implements WriterCustomizer<Ingress>, AclWriter { private static final Logger LOG = LoggerFactory.getLogger(SubInterfaceAclCustomizer.class); private final NamingContext interfaceContext; @@ -59,44 +57,37 @@ public class SubInterfaceAclCustomizer extends FutureJVppCustomizer @Override public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, @Nonnull final Ingress dataAfter, @Nonnull final WriteContext writeContext) throws WriteFailedException { - try { - setAcl(true, id, dataAfter, writeContext); - } catch (VppBaseCallException e) { - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } + setAcl(true, id, dataAfter, writeContext); } @Override - public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, @Nonnull final Ingress dataBefore, + public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, + @Nonnull final Ingress dataBefore, @Nonnull final Ingress dataAfter, @Nonnull final WriteContext writeContext) - throws WriteFailedException { + throws WriteFailedException { throw new UnsupportedOperationException("Acl update is not supported. Please delete Acl container first."); } @Override - public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, @Nonnull final Ingress dataBefore, + public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, + @Nonnull final Ingress dataBefore, @Nonnull final WriteContext writeContext) throws WriteFailedException { - try { - setAcl(false, id, dataBefore, writeContext); - } catch (VppBaseCallException e) { - throw new WriteFailedException.DeleteFailedException(id, e); - } + setAcl(false, id, dataBefore, writeContext); } private void setAcl(final boolean isAdd, @Nonnull final InstanceIdentifier<Ingress> id, @Nonnull final Ingress acl, - @Nonnull final WriteContext writeContext) - throws VppBaseCallException, WriteTimeoutException { + @Nonnull final WriteContext writeContext) throws WriteFailedException { final InterfaceKey parentInterfacekey = id.firstKeyOf(Interface.class); final SubInterfaceKey subInterfacekey = id.firstKeyOf(SubInterface.class); final String subInterfaceName = SubInterfaceUtils - .getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue()); + .getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue()); final int subInterfaceIndex = interfaceContext.getIndex(subInterfaceName, writeContext.getMappingContext()); LOG.debug("Setting ACL(isAdd={}) on sub-interface={}(id={}): {}", - isAdd, subInterfaceName, subInterfaceIndex, acl); + isAdd, subInterfaceName, subInterfaceIndex, acl); inputAclSetInterface(getFutureJVpp(), isAdd, id, acl, subInterfaceIndex, classifyTableContext, - writeContext.getMappingContext()); + writeContext.getMappingContext()); LOG.debug("Successfully set ACL(isAdd={}) on sub-interface={}(id={}): {}", - isAdd, subInterfaceName, subInterfaceIndex, acl); + isAdd, subInterfaceName, subInterfaceIndex, acl); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/SubInterfaceIetfAclCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/SubInterfaceIetfAclCustomizer.java index c9068d797..ae40714e3 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/SubInterfaceIetfAclCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/SubInterfaceIetfAclCustomizer.java @@ -27,7 +27,6 @@ import io.fd.honeycomb.translate.vpp.util.NamingContext; import io.fd.honeycomb.translate.vpp.util.SubInterfaceUtils; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.vpp.jvpp.VppBaseCallException; 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.interfaces.rev140508.interfaces.InterfaceKey; @@ -62,7 +61,7 @@ public class SubInterfaceIetfAclCustomizer implements WriterCustomizer<Ingress> final InterfaceKey parentInterfacekey = id.firstKeyOf(Interface.class); final SubInterfaceKey subInterfacekey = id.firstKeyOf(SubInterface.class); return SubInterfaceUtils - .getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue()); + .getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue()); } @Override @@ -74,19 +73,15 @@ public class SubInterfaceIetfAclCustomizer implements WriterCustomizer<Ingress> final AccessLists accessLists = dataAfter.getAccessLists(); checkArgument(accessLists != null && accessLists.getAcl() != null, - "ietf-acl container does not define acl list"); + "ietf-acl container does not define acl list"); final Optional<SubInterface> subInterfaceOptional = - writeContext.readAfter(id.firstIdentifierOf(SubInterface.class)); + writeContext.readAfter(id.firstIdentifierOf(SubInterface.class)); checkState(subInterfaceOptional.isPresent(), "Could not read SubInterface data object for %s", id); final SubInterface subInterface = subInterfaceOptional.get(); - try { - aclWriter.write(id, subInterfaceIndex, accessLists.getMode(), accessLists.getAcl(), writeContext, + aclWriter.write(id, subInterfaceIndex, accessLists.getMode(), accessLists.getAcl(), writeContext, getNumberOfTags(subInterface.getTags())); - } catch (VppBaseCallException e) { - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } } @Override @@ -103,7 +98,7 @@ public class SubInterfaceIetfAclCustomizer implements WriterCustomizer<Ingress> @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, @Nonnull final Ingress dataBefore, @Nonnull final WriteContext writeContext) - throws WriteFailedException { + throws WriteFailedException { final String subInterfaceName = getSubInterfaceName(id); final int subInterfaceIndex = interfaceContext.getIndex(subInterfaceName, writeContext.getMappingContext()); LOG.debug("Removing ACLs for sub-interface={}(id={}): {}", subInterfaceName, subInterfaceIndex, dataBefore); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizer.java index bd2360317..2cec90695 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizer.java @@ -27,6 +27,7 @@ import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.NamingContext; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; 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.interfaces._interface.Ipv4; @@ -37,8 +38,6 @@ 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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -125,39 +124,28 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer @Nonnull final String interfaceName, final int interfaceIndex, @Nonnull final Address address, @Nonnull final Netmask subnet) throws WriteFailedException { - try { - LOG.debug("Setting Subnet(subnet-mask) for interface: {}(id={}). Subnet: {}, address: {}", - interfaceName, interfaceIndex, subnet, address); - - final DottedQuad netmask = subnet.getNetmask(); - checkNotNull(netmask, "netmask value should not be null"); - - final byte subnetLength = getSubnetMaskLength(netmask.getValue()); - addDelAddress(getFutureJVpp(), add, id, interfaceIndex, address.getIp(), subnetLength); - } catch (VppBaseCallException e) { - LOG.warn("Failed to set Subnet(subnet-mask) for interface: {}(id={}). Subnet: {}, address: {}", - interfaceName, interfaceIndex, subnet, address); - throw new WriteFailedException(id, "Unable to handle subnet of type " + subnet.getClass(), e); - } + + LOG.debug("Setting Subnet(subnet-mask) for interface: {}(id={}). Subnet: {}, address: {}", + interfaceName, interfaceIndex, subnet, address); + + final DottedQuad netmask = subnet.getNetmask(); + checkNotNull(netmask, "netmask value should not be null"); + + final byte subnetLength = getSubnetMaskLength(netmask.getValue()); + addDelAddress(getFutureJVpp(), add, id, interfaceIndex, address.getIp(), subnetLength); } private void setPrefixLengthSubnet(final boolean add, @Nonnull final InstanceIdentifier<Address> id, @Nonnull final String interfaceName, final int interfaceIndex, @Nonnull final Address address, @Nonnull final PrefixLength subnet) throws WriteFailedException { - try { - LOG.debug("Setting Subnet(prefix-length) for interface: {}(id={}). Subnet: {}, address: {}", - interfaceName, interfaceIndex, subnet, address); - - addDelAddress(getFutureJVpp(), add, id, interfaceIndex, address.getIp(), - subnet.getPrefixLength().byteValue()); - - LOG.debug("Subnet(prefix-length) set successfully for interface: {}(id={}). Subnet: {}, address: {}", - interfaceName, interfaceIndex, subnet, address); - } catch (VppBaseCallException e) { - LOG.warn("Failed to set Subnet(prefix-length) for interface: {}(id={}). Subnet: {}, address: {}", - interfaceName, interfaceIndex, subnet, address); - throw new WriteFailedException(id, "Unable to handle subnet of type " + subnet.getClass(), e); - } + LOG.debug("Setting Subnet(prefix-length) for interface: {}(id={}). Subnet: {}, address: {}", + interfaceName, interfaceIndex, subnet, address); + + addDelAddress(getFutureJVpp(), add, id, interfaceIndex, address.getIp(), + subnet.getPrefixLength().byteValue()); + + LOG.debug("Subnet(prefix-length) set successfully for interface: {}(id={}). Subnet: {}, address: {}", + interfaceName, interfaceIndex, subnet, address); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizer.java index 4bcbf126f..be4ef28cf 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizer.java @@ -27,18 +27,16 @@ import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.IpNeighborAddDel; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; 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.interfaces._interface.Ipv4; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Neighbor; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.NeighborKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.IpNeighborAddDel; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,13 +73,9 @@ public class Ipv4NeighbourCustomizer extends FutureJVppCustomizer "Mapping does not contains mapping for provider interface name ".concat(interfaceName)); LOG.debug("Parent interface index found"); - try { - addDelNeighbourAndReply(id, true, - interfaceContext.getIndex(interfaceName, mappingContext), dataAfter); - LOG.info("Neighbour successfully written"); - } catch (VppBaseCallException e) { - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } + addDelNeighbourAndReply(id, true, + interfaceContext.getIndex(interfaceName, mappingContext), dataAfter); + LOG.info("Neighbour successfully written"); } @Override @@ -107,18 +101,14 @@ public class Ipv4NeighbourCustomizer extends FutureJVppCustomizer "Mapping does not contains mapping for provider interface name %s", interfaceName); LOG.debug("Parent interface[{}] index found", interfaceName); - try { - addDelNeighbourAndReply(id, false, - interfaceContext.getIndex(interfaceName, mappingContext), dataBefore); - LOG.info("Neighbour {} successfully deleted", id); - } catch (VppBaseCallException e) { - throw new WriteFailedException.DeleteFailedException(id, e); - } + + addDelNeighbourAndReply(id, false, + interfaceContext.getIndex(interfaceName, mappingContext), dataBefore); + LOG.info("Neighbour {} successfully deleted", id); } private void addDelNeighbourAndReply(InstanceIdentifier<Neighbor> id, boolean add, int parentInterfaceIndex, - Neighbor data) - throws VppBaseCallException, WriteTimeoutException { + Neighbor data) throws WriteFailedException { IpNeighborAddDel request = new IpNeighborAddDel(); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4Writer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4Writer.java index c823e77b1..788deab3b 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4Writer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4Writer.java @@ -22,16 +22,15 @@ import static com.google.common.base.Preconditions.checkNotNull; import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; import io.fd.honeycomb.translate.vpp.util.Ipv4Translator; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; +import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddress; +import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddressReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.concurrent.CompletionStage; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddress; -import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddressReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; /** * Utility class providing Ipv4 CUD support. @@ -46,7 +45,7 @@ public interface Ipv4Writer extends ByteDataTranslator, Ipv4Translator, JvppRepl final InstanceIdentifier<?> id, @Nonnegative final int ifaceId, @Nonnull final Ipv4AddressNoZone address, @Nonnegative final byte prefixLength) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { checkArgument(prefixLength > 0, "Invalid prefix length"); checkNotNull(address, "address should not be null"); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizer.java index eb8525949..9b786917d 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizer.java @@ -24,6 +24,7 @@ import io.fd.honeycomb.translate.vpp.util.NamingContext; import io.fd.honeycomb.translate.vpp.util.SubInterfaceUtils; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; 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.interfaces.rev140508.interfaces.InterfaceKey; @@ -36,8 +37,6 @@ 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.ip4.attributes.ipv4.address.subnet.Netmask; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.ipv4.address.subnet.PrefixLength; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -105,40 +104,28 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer @Nonnull final String subInterfaceName, final int subInterfaceIndex, @Nonnull final Address address, @Nonnull final Netmask subnet) throws WriteFailedException { - try { - LOG.debug("Setting Subnet(subnet-mask) for sub-interface: {}(id={}). Subnet: {}, address: {}", - subInterfaceName, subInterfaceIndex, subnet, address); - final DottedQuad netmask = subnet.getNetmask(); - checkNotNull(netmask, "netmask value should not be null"); + LOG.debug("Setting Subnet(subnet-mask) for sub-interface: {}(id={}). Subnet: {}, address: {}", + subInterfaceName, subInterfaceIndex, subnet, address); - final byte subnetLength = getSubnetMaskLength(netmask.getValue()); - addDelAddress(getFutureJVpp(), add, id, subInterfaceIndex, address.getIp(), subnetLength); + final DottedQuad netmask = subnet.getNetmask(); + checkNotNull(netmask, "netmask value should not be null"); - } catch (VppBaseCallException e) { - LOG.warn("Failed to set Subnet(subnet-mask) for sub-interface: {}(id={}). Subnet: {}, address: {}", - subInterfaceName, subInterfaceIndex, subnet, address); - throw new WriteFailedException(id, "Unable to handle subnet of type " + subnet.getClass(), e); - } + final byte subnetLength = getSubnetMaskLength(netmask.getValue()); + addDelAddress(getFutureJVpp(), add, id, subInterfaceIndex, address.getIp(), subnetLength); } private void setPrefixLengthSubnet(final boolean add, @Nonnull final InstanceIdentifier<Address> id, @Nonnull final String subInterfaceName, final int subInterfaceIndex, @Nonnull final Address address, @Nonnull final PrefixLength subnet) throws WriteFailedException { - try { - LOG.debug("Setting Subnet(prefix-length) for sub-interface: {}(id={}). Subnet: {}, address: {}", - subInterfaceName, subInterfaceIndex, subnet, address); - - addDelAddress(getFutureJVpp(), add, id, subInterfaceIndex, address.getIp(), - subnet.getPrefixLength().byteValue()); - - LOG.debug("Subnet(prefix-length) set successfully for sub-interface: {}(id={}). Subnet: {}, address: {}", - subInterfaceName, subInterfaceIndex, subnet, address); - } catch (VppBaseCallException e) { - LOG.warn("Failed to set Subnet(prefix-length) for sub-interface: {}(id={}). Subnet: {}, address: {}", - subInterfaceName, subInterfaceIndex, subnet, address); - throw new WriteFailedException(id, "Unable to handle subnet of type " + subnet.getClass(), e); - } + LOG.debug("Setting Subnet(prefix-length) for sub-interface: {}(id={}). Subnet: {}, address: {}", + subInterfaceName, subInterfaceIndex, subnet, address); + + addDelAddress(getFutureJVpp(), add, id, subInterfaceIndex, address.getIp(), + subnet.getPrefixLength().byteValue()); + + LOG.debug("Subnet(prefix-length) set successfully for sub-interface: {}(id={}). Subnet: {}, address: {}", + subInterfaceName, subInterfaceIndex, subnet, address); } } |