diff options
Diffstat (limited to 'v3po/v3po2vpp/src')
54 files changed, 904 insertions, 1272 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); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizer.java index d142a8e55..58e0d8bb7 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizer.java @@ -23,6 +23,10 @@ import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.NamingContext; +import io.fd.vpp.jvpp.core.dto.GreTunnelDetails; +import io.fd.vpp.jvpp.core.dto.GreTunnelDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.GreTunnelDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Arrays; @@ -40,11 +44,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.GreTunnelDetails; -import io.fd.vpp.jvpp.core.dto.GreTunnelDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.GreTunnelDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,60 +74,55 @@ public class GreCustomizer extends FutureJVppCustomizer public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Gre> id, @Nonnull final GreBuilder builder, @Nonnull final ReadContext ctx) throws ReadFailedException { - try { - final InterfaceKey key = id.firstKeyOf(Interface.class); - final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext()); - if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, GreTunnel.class, LOG)) { - return; - } + final InterfaceKey key = id.firstKeyOf(Interface.class); + final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext()); + if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, GreTunnel.class, LOG)) { + return; + } - LOG.debug("Reading attributes for gre tunnel: {}", key.getName()); - // Dump just a single - final GreTunnelDump request = new GreTunnelDump(); - request.swIfIndex = index; + LOG.debug("Reading attributes for gre tunnel: {}", key.getName()); + // Dump just a single + final GreTunnelDump request = new GreTunnelDump(); + request.swIfIndex = index; - final CompletionStage<GreTunnelDetailsReplyDump> swInterfaceGreDetailsReplyDumpCompletionStage = - getFutureJVpp().greTunnelDump(request); - final GreTunnelDetailsReplyDump reply = - getReplyForRead(swInterfaceGreDetailsReplyDumpCompletionStage.toCompletableFuture(), id); + final CompletionStage<GreTunnelDetailsReplyDump> swInterfaceGreDetailsReplyDumpCompletionStage = + getFutureJVpp().greTunnelDump(request); + final GreTunnelDetailsReplyDump reply = + getReplyForRead(swInterfaceGreDetailsReplyDumpCompletionStage.toCompletableFuture(), id); - // VPP keeps gre tunnel interfaces even after they were deleted (optimization) - // However there ar no longer any gre tunnel specific fields assigned to it and this call - // returns nothing - if (reply == null || reply.greTunnelDetails == null || reply.greTunnelDetails.isEmpty()) { - LOG.debug( - "Gre tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" + - "after delete", key.getName(), index); - return; - } + // VPP keeps gre tunnel interfaces even after they were deleted (optimization) + // However there ar no longer any gre tunnel specific fields assigned to it and this call + // returns nothing + if (reply == null || reply.greTunnelDetails == null || reply.greTunnelDetails.isEmpty()) { + LOG.debug( + "Gre tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" + + "after delete", key.getName(), index); + return; + } - checkState(reply.greTunnelDetails.size() == 1, - "Unexpected number of returned gre tunnels: {} for tunnel: {}", reply.greTunnelDetails, - key.getName()); - LOG.trace("Gre tunnel: {} attributes returned from VPP: {}", key.getName(), reply); + checkState(reply.greTunnelDetails.size() == 1, + "Unexpected number of returned gre tunnels: {} for tunnel: {}", reply.greTunnelDetails, + key.getName()); + LOG.trace("Gre tunnel: {} attributes returned from VPP: {}", key.getName(), reply); - final GreTunnelDetails swInterfaceGreDetails = reply.greTunnelDetails.get(0); - if (swInterfaceGreDetails.isIpv6 == 1) { - final Ipv6Address dstIpv6 = - new Ipv6Address(parseAddress(swInterfaceGreDetails.dstAddress).getHostAddress()); - builder.setDst(new IpAddress(dstIpv6)); - final Ipv6Address srcIpv6 = - new Ipv6Address(parseAddress(swInterfaceGreDetails.srcAddress).getHostAddress()); - builder.setSrc(new IpAddress(srcIpv6)); - } else { - final byte[] dstBytes = Arrays.copyOfRange(swInterfaceGreDetails.dstAddress, 0, 4); - final Ipv4Address dstIpv4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress()); - builder.setDst(new IpAddress(dstIpv4)); - final byte[] srcBytes = Arrays.copyOfRange(swInterfaceGreDetails.srcAddress, 0, 4); - final Ipv4Address srcIpv4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress()); - builder.setSrc(new IpAddress(srcIpv4)); - } - builder.setOuterFibId((long) swInterfaceGreDetails.outerFibId); - LOG.debug("Gre tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder); - } catch (VppBaseCallException e) { - LOG.warn("Failed to readCurrentAttributes for: {}", id, e); - throw new ReadFailedException(id, e); + final GreTunnelDetails swInterfaceGreDetails = reply.greTunnelDetails.get(0); + if (swInterfaceGreDetails.isIpv6 == 1) { + final Ipv6Address dstIpv6 = + new Ipv6Address(parseAddress(swInterfaceGreDetails.dstAddress).getHostAddress()); + builder.setDst(new IpAddress(dstIpv6)); + final Ipv6Address srcIpv6 = + new Ipv6Address(parseAddress(swInterfaceGreDetails.srcAddress).getHostAddress()); + builder.setSrc(new IpAddress(srcIpv6)); + } else { + final byte[] dstBytes = Arrays.copyOfRange(swInterfaceGreDetails.dstAddress, 0, 4); + final Ipv4Address dstIpv4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress()); + builder.setDst(new IpAddress(dstIpv4)); + final byte[] srcBytes = Arrays.copyOfRange(swInterfaceGreDetails.srcAddress, 0, 4); + final Ipv4Address srcIpv4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress()); + builder.setSrc(new IpAddress(srcIpv4)); } + builder.setOuterFibId((long) swInterfaceGreDetails.outerFibId); + LOG.debug("Gre tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder); } @Nonnull diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterconnectionReadUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterconnectionReadUtils.java index 2177c7460..c8e07a82f 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterconnectionReadUtils.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterconnectionReadUtils.java @@ -22,6 +22,12 @@ import static java.util.Objects.requireNonNull; import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.vpp.util.NamingContext; +import io.fd.vpp.jvpp.core.dto.BridgeDomainDetails; +import io.fd.vpp.jvpp.core.dto.BridgeDomainDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.BridgeDomainDump; +import io.fd.vpp.jvpp.core.dto.BridgeDomainSwIfDetails; +import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.Optional; import java.util.concurrent.CompletableFuture; import javax.annotation.Nonnull; @@ -29,13 +35,6 @@ import javax.annotation.Nullable; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.Interconnection; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.interconnection.BridgeBasedBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.BridgeDomainDetails; -import io.fd.vpp.jvpp.core.dto.BridgeDomainDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.BridgeDomainDump; -import io.fd.vpp.jvpp.core.dto.BridgeDomainSwIfDetails; -import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -112,18 +111,15 @@ final class InterconnectionReadUtils implements InterfaceDataTranslator { private BridgeDomainDetailsReplyDump getDumpReply(@Nonnull final InstanceIdentifier<?> id) throws ReadFailedException { - try { - // We need to perform full bd dump, because there is no way - // to ask VPP for BD details given interface id/name (TODO HONEYCOMB-190 add it to vpp.api?) - // TODO HONEYCOMB-190 cache dump result - final BridgeDomainDump request = new BridgeDomainDump(); - request.bdId = -1; - - final CompletableFuture<BridgeDomainDetailsReplyDump> bdCompletableFuture = - futureJVppCore.bridgeDomainSwIfDump(request).toCompletableFuture(); - return getReplyForRead(bdCompletableFuture, id); - } catch (VppBaseCallException e) { - throw new ReadFailedException(id, e); - } + // We need to perform full bd dump, because there is no way + // to ask VPP for BD details given interface id/name (TODO HONEYCOMB-190 add it to vpp.api?) + // TODO HONEYCOMB-190 cache dump result + final BridgeDomainDump request = new BridgeDomainDump(); + request.bdId = -1; + + final CompletableFuture<BridgeDomainDetailsReplyDump> bdCompletableFuture = + futureJVppCore.bridgeDomainSwIfDump(request).toCompletableFuture(); + return getReplyForRead(bdCompletableFuture, id); + } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizer.java index 7fcb995db..3093f08a7 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizer.java @@ -25,6 +25,10 @@ import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager; import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.NamingContext; +import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails; +import io.fd.vpp.jvpp.core.dto.SwInterfaceDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.SwInterfaceDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -42,11 +46,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces. import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails; -import io.fd.vpp.jvpp.core.dto.SwInterfaceDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.SwInterfaceDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -136,71 +135,66 @@ public class InterfaceCustomizer extends FutureJVppCustomizer @Override public List<InterfaceKey> getAllIds(@Nonnull final InstanceIdentifier<Interface> id, @Nonnull final ReadContext context) throws ReadFailedException { - try { - final List<InterfaceKey> interfacesKeys; - LOG.trace("Dumping all interfaces to get all IDs"); - - final SwInterfaceDump request = new SwInterfaceDump(); - request.nameFilter = "".getBytes(); - request.nameFilterValid = 0; - - final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture = - getFutureJVpp().swInterfaceDump(request).toCompletableFuture(); - final SwInterfaceDetailsReplyDump ifaces = - getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, id); - - if (null == ifaces || null == ifaces.swInterfaceDetails) { - LOG.debug("No interfaces for :{} found in VPP", id); - return Collections.emptyList(); - } - - // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes - context.getModificationCache().put(DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream() - .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails))); - - final MappingContext mappingCtx = context.getMappingContext(); - final Set<Integer> interfacesIdxs = ifaces.swInterfaceDetails.stream() - .filter(elt -> elt != null) - // Filter out disabled interfaces, dont read them - // This also prevents child readers in being invoked such as vxlan (which relies on disabling interfaces) - .filter(elt -> !interfaceDisableContext - .isInterfaceDisabled(elt.swIfIndex, mappingCtx)) - .map((elt) -> { - // Store interface name from VPP in context if not yet present - if (!interfaceNamingContext.containsName(elt.swIfIndex, mappingCtx)) { - interfaceNamingContext.addName(elt.swIfIndex, toString(elt.interfaceName), - mappingCtx); - } - LOG.trace("Interface with name: {}, VPP name: {} and index: {} found in VPP", - interfaceNamingContext.getName(elt.swIfIndex, mappingCtx), - elt.interfaceName, - elt.swIfIndex); - - return elt; - }) - // filter out sub-interfaces - .filter(InterfaceCustomizer::isRegularInterface) - .map(elt -> elt.swIfIndex) - .collect(Collectors.toSet()); - - // Clean disabled interfaces list - interfaceDisableContext.getDisabledInterfaces(mappingCtx).stream() - // Find indices not currently in VPP - .filter(interfacesIdxs::contains) - // Remove from disabled list ... not disabled if not existing - .forEach(idx -> interfaceDisableContext.removeDisabledInterface(idx, mappingCtx)); - - // Transform indices to keys - interfacesKeys = interfacesIdxs.stream() - .map(index -> new InterfaceKey(interfaceNamingContext.getName(index, context.getMappingContext()))) - .collect(Collectors.toList()); - - LOG.debug("Interfaces found in VPP: {}", interfacesKeys); - return interfacesKeys; - } catch (VppBaseCallException e) { - LOG.warn("getAllIds for id :{} failed with exception ", id, e); - throw new ReadFailedException(id, e); + final List<InterfaceKey> interfacesKeys; + LOG.trace("Dumping all interfaces to get all IDs"); + + final SwInterfaceDump request = new SwInterfaceDump(); + request.nameFilter = "".getBytes(); + request.nameFilterValid = 0; + + final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture = + getFutureJVpp().swInterfaceDump(request).toCompletableFuture(); + final SwInterfaceDetailsReplyDump ifaces = + getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, id); + + if (null == ifaces || null == ifaces.swInterfaceDetails) { + LOG.debug("No interfaces for :{} found in VPP", id); + return Collections.emptyList(); } + + // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes + context.getModificationCache().put(DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream() + .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails))); + + final MappingContext mappingCtx = context.getMappingContext(); + final Set<Integer> interfacesIdxs = ifaces.swInterfaceDetails.stream() + .filter(elt -> elt != null) + // Filter out disabled interfaces, dont read them + // This also prevents child readers in being invoked such as vxlan (which relies on disabling interfaces) + .filter(elt -> !interfaceDisableContext + .isInterfaceDisabled(elt.swIfIndex, mappingCtx)) + .map((elt) -> { + // Store interface name from VPP in context if not yet present + if (!interfaceNamingContext.containsName(elt.swIfIndex, mappingCtx)) { + interfaceNamingContext.addName(elt.swIfIndex, toString(elt.interfaceName), + mappingCtx); + } + LOG.trace("Interface with name: {}, VPP name: {} and index: {} found in VPP", + interfaceNamingContext.getName(elt.swIfIndex, mappingCtx), + elt.interfaceName, + elt.swIfIndex); + + return elt; + }) + // filter out sub-interfaces + .filter(InterfaceCustomizer::isRegularInterface) + .map(elt -> elt.swIfIndex) + .collect(Collectors.toSet()); + + // Clean disabled interfaces list + interfaceDisableContext.getDisabledInterfaces(mappingCtx).stream() + // Find indices not currently in VPP + .filter(interfacesIdxs::contains) + // Remove from disabled list ... not disabled if not existing + .forEach(idx -> interfaceDisableContext.removeDisabledInterface(idx, mappingCtx)); + + // Transform indices to keys + interfacesKeys = interfacesIdxs.stream() + .map(index -> new InterfaceKey(interfaceNamingContext.getName(index, context.getMappingContext()))) + .collect(Collectors.toList()); + + LOG.debug("Interfaces found in VPP: {}", interfacesKeys); + return interfacesKeys; } @Override diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceDataTranslator.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceDataTranslator.java index 81012e21e..2cc8ce250 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceDataTranslator.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceDataTranslator.java @@ -24,6 +24,10 @@ import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.util.RWUtils; import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; +import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails; +import io.fd.vpp.jvpp.core.dto.SwInterfaceDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.SwInterfaceDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.math.BigInteger; import java.util.Map; import java.util.Objects; @@ -41,11 +45,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.VxlanGpeTunnel; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails; -import io.fd.vpp.jvpp.core.dto.SwInterfaceDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.SwInterfaceDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; public interface InterfaceDataTranslator extends ByteDataTranslator, JvppReplyConsumer { @@ -195,32 +194,28 @@ public interface InterfaceDataTranslator extends ByteDataTranslator, JvppReplyCo } SwInterfaceDetailsReplyDump ifaces; - try { - CompletionStage<SwInterfaceDetailsReplyDump> requestFuture = futureJVppCore.swInterfaceDump(request); - ifaces = getReplyForRead(requestFuture.toCompletableFuture(), id); - if (null == ifaces || null == ifaces.swInterfaceDetails || ifaces.swInterfaceDetails.isEmpty()) { - request.nameFilterValid = 0; - callerLogger.warn("VPP returned null instead of interface by key {} and its not cached", name); - callerLogger.warn("Iterating through all the interfaces to find interface: {}", name); + CompletionStage<SwInterfaceDetailsReplyDump> requestFuture = futureJVppCore.swInterfaceDump(request); + ifaces = getReplyForRead(requestFuture.toCompletableFuture(), id); + if (null == ifaces || null == ifaces.swInterfaceDetails || ifaces.swInterfaceDetails.isEmpty()) { + request.nameFilterValid = 0; - // Or else just perform full dump and do inefficient filtering - requestFuture = futureJVppCore.swInterfaceDump(request); - ifaces = getReplyForRead(requestFuture.toCompletableFuture(), id); + callerLogger.warn("VPP returned null instead of interface by key {} and its not cached", name); + callerLogger.warn("Iterating through all the interfaces to find interface: {}", name); + + // Or else just perform full dump and do inefficient filtering + requestFuture = futureJVppCore.swInterfaceDump(request); + ifaces = getReplyForRead(requestFuture.toCompletableFuture(), id); - // Update the cache - allInterfaces.clear(); - allInterfaces - .putAll(ifaces.swInterfaceDetails.stream().collect(Collectors.toMap(d -> d.swIfIndex, d -> d))); + // Update the cache + allInterfaces.clear(); + allInterfaces + .putAll(ifaces.swInterfaceDetails.stream().collect(Collectors.toMap(d -> d.swIfIndex, d -> d))); - if (allInterfaces.containsKey(index)) { - return allInterfaces.get(index); - } - throw new IllegalArgumentException("Unable to find interface " + name); + if (allInterfaces.containsKey(index)) { + return allInterfaces.get(index); } - } catch (VppBaseCallException e) { - callerLogger.warn("getVppInterfaceDetails for id :{} and name :{} failed with exception :", id, name, e); - throw new ReadFailedException(id, e); + throw new IllegalArgumentException("Unable to find interface " + name); } // SwInterfaceDump's name filter does prefix match, so we need additional filtering: @@ -263,8 +258,8 @@ public interface InterfaceDataTranslator extends ByteDataTranslator, JvppReplyCo /** * Check interface type. Uses interface details from VPP to determine. Uses {@link - * #getVppInterfaceDetails(FutureJVppCore, InstanceIdentifier, String, int, ModificationCache, Logger)} internally so - * tries to utilize cache before asking VPP. + * #getVppInterfaceDetails(FutureJVppCore, InstanceIdentifier, String, int, ModificationCache, Logger)} internally + * so tries to utilize cache before asking VPP. */ default boolean isInterfaceOfType(@Nonnull final FutureJVppCore jvpp, @Nonnull final ModificationCache cache, diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizer.java index e618f81e3..a253d0828 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizer.java @@ -26,6 +26,10 @@ import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; 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.vpp.jvpp.core.dto.SwInterfaceDetails; +import io.fd.vpp.jvpp.core.dto.SwInterfaceDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.SwInterfaceDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -59,11 +63,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails; -import io.fd.vpp.jvpp.core.dto.SwInterfaceDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.SwInterfaceDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -110,47 +109,43 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer @Override public List<SubInterfaceKey> getAllIds(@Nonnull final InstanceIdentifier<SubInterface> id, @Nonnull final ReadContext context) throws ReadFailedException { - try { - // Relying here that parent InterfaceCustomizer was invoked first (PREORDER) - // to fill in the context with initial ifc mapping - final InterfaceKey key = id.firstKeyOf(Interface.class); - final String ifaceName = key.getName(); - final int ifaceId = interfaceContext.getIndex(ifaceName, context.getMappingContext()); - - // TODO HONEYCOMB-189 if we know that full dump was already performed we could use cache - // (checking if getCachedInterfaceDump() returns non empty map is not enough, because - // we could be part of particular iface state read - final SwInterfaceDump request = new SwInterfaceDump(); - request.nameFilter = "".getBytes(); - request.nameFilterValid = 0; - - final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture = - getFutureJVpp().swInterfaceDump(request).toCompletableFuture(); - final SwInterfaceDetailsReplyDump ifaces = - getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, id); - - if (null == ifaces || null == ifaces.swInterfaceDetails) { - LOG.warn("Looking for sub-interfaces, but no interfaces found in VPP"); - return Collections.emptyList(); - } - - // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes - context.getModificationCache() - .put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream() - .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails))); - - final List<SubInterfaceKey> interfacesKeys = ifaces.swInterfaceDetails.stream() - .filter(elt -> elt != null) - // accept only sub-interfaces for current iface: - .filter(elt -> elt.subId != 0 && elt.supSwIfIndex == ifaceId) - .map(details -> new SubInterfaceKey(new Long(details.subId))) - .collect(Collectors.toList()); - - LOG.debug("Sub-interfaces of {} found in VPP: {}", ifaceName, interfacesKeys); - return interfacesKeys; - } catch (VppBaseCallException e) { - throw new ReadFailedException(id, e); + // Relying here that parent InterfaceCustomizer was invoked first (PREORDER) + // to fill in the context with initial ifc mapping + final InterfaceKey key = id.firstKeyOf(Interface.class); + final String ifaceName = key.getName(); + final int ifaceId = interfaceContext.getIndex(ifaceName, context.getMappingContext()); + + // TODO HONEYCOMB-189 if we know that full dump was already performed we could use cache + // (checking if getCachedInterfaceDump() returns non empty map is not enough, because + // we could be part of particular iface state read + final SwInterfaceDump request = new SwInterfaceDump(); + request.nameFilter = "".getBytes(); + request.nameFilterValid = 0; + + final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture = + getFutureJVpp().swInterfaceDump(request).toCompletableFuture(); + final SwInterfaceDetailsReplyDump ifaces = + getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, id); + + if (null == ifaces || null == ifaces.swInterfaceDetails) { + LOG.warn("Looking for sub-interfaces, but no interfaces found in VPP"); + return Collections.emptyList(); } + + // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes + context.getModificationCache() + .put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream() + .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails))); + + final List<SubInterfaceKey> interfacesKeys = ifaces.swInterfaceDetails.stream() + .filter(elt -> elt != null) + // accept only sub-interfaces for current iface: + .filter(elt -> elt.subId != 0 && elt.supSwIfIndex == ifaceId) + .map(details -> new SubInterfaceKey(new Long(details.subId))) + .collect(Collectors.toList()); + + LOG.debug("Sub-interfaces of {} found in VPP: {}", ifaceName, interfacesKeys); + return interfacesKeys; } @Override diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/TapCustomizer.java index c61777423..e2cea64cd 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/TapCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/TapCustomizer.java @@ -22,6 +22,10 @@ import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; 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.vpp.jvpp.core.dto.SwInterfaceTapDetails; +import io.fd.vpp.jvpp.core.dto.SwInterfaceTapDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.SwInterfaceTapDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.Collections; import java.util.List; import java.util.Map; @@ -36,11 +40,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.SwInterfaceTapDetails; -import io.fd.vpp.jvpp.core.dto.SwInterfaceTapDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.SwInterfaceTapDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -72,48 +71,44 @@ public class TapCustomizer extends FutureJVppCustomizer public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Tap> id, @Nonnull final TapBuilder builder, @Nonnull final ReadContext ctx) throws ReadFailedException { - try { - final InterfaceKey key = id.firstKeyOf(Interface.class); - final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext()); - if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, - org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap.class, LOG)) { - return; - } - LOG.debug("Reading attributes for tap interface: {}", key.getName()); - - @SuppressWarnings("unchecked") - Map<Integer, SwInterfaceTapDetails> mappedTaps = - (Map<Integer, SwInterfaceTapDetails>) ctx.getModificationCache().get(DUMPED_TAPS_CONTEXT_KEY); - - if (mappedTaps == null) { - // Full Tap dump has to be performed here, no filter or anything is here to help so at least we cache it - final SwInterfaceTapDump request = new SwInterfaceTapDump(); - final CompletionStage<SwInterfaceTapDetailsReplyDump> swInterfaceTapDetailsReplyDumpCompletionStage = - getFutureJVpp().swInterfaceTapDump(request); - final SwInterfaceTapDetailsReplyDump reply = - getReplyForRead(swInterfaceTapDetailsReplyDumpCompletionStage.toCompletableFuture(), id); - - if (null == reply || null == reply.swInterfaceTapDetails) { - mappedTaps = Collections.emptyMap(); - } else { - final List<SwInterfaceTapDetails> swInterfaceTapDetails = reply.swInterfaceTapDetails; - // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes - mappedTaps = swInterfaceTapDetails.stream() - .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)); - } - - ctx.getModificationCache().put(DUMPED_TAPS_CONTEXT_KEY, mappedTaps); - } + final InterfaceKey key = id.firstKeyOf(Interface.class); + final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext()); + if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap.class, LOG)) { + return; + } - final SwInterfaceTapDetails swInterfaceTapDetails = mappedTaps.get(index); - LOG.trace("Tap interface: {} attributes returned from VPP: {}", key.getName(), swInterfaceTapDetails); + LOG.debug("Reading attributes for tap interface: {}", key.getName()); + + @SuppressWarnings("unchecked") + Map<Integer, SwInterfaceTapDetails> mappedTaps = + (Map<Integer, SwInterfaceTapDetails>) ctx.getModificationCache().get(DUMPED_TAPS_CONTEXT_KEY); + + if (mappedTaps == null) { + // Full Tap dump has to be performed here, no filter or anything is here to help so at least we cache it + final SwInterfaceTapDump request = new SwInterfaceTapDump(); + final CompletionStage<SwInterfaceTapDetailsReplyDump> swInterfaceTapDetailsReplyDumpCompletionStage = + getFutureJVpp().swInterfaceTapDump(request); + final SwInterfaceTapDetailsReplyDump reply = + getReplyForRead(swInterfaceTapDetailsReplyDumpCompletionStage.toCompletableFuture(), id); + + if (null == reply || null == reply.swInterfaceTapDetails) { + mappedTaps = Collections.emptyMap(); + } else { + final List<SwInterfaceTapDetails> swInterfaceTapDetails = reply.swInterfaceTapDetails; + // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes + mappedTaps = swInterfaceTapDetails.stream() + .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)); + } - builder.setTapName(toString(swInterfaceTapDetails.devName)); - LOG.debug("Tap interface: {}, id: {} attributes read as: {}", key.getName(), index, builder); - } catch (VppBaseCallException e) { - LOG.warn("Failed to readCurrentAttributes for: {}", id, e); - throw new ReadFailedException(id, e); + ctx.getModificationCache().put(DUMPED_TAPS_CONTEXT_KEY, mappedTaps); } + + final SwInterfaceTapDetails swInterfaceTapDetails = mappedTaps.get(index); + LOG.trace("Tap interface: {} attributes returned from VPP: {}", key.getName(), swInterfaceTapDetails); + + builder.setTapName(toString(swInterfaceTapDetails.devName)); + LOG.debug("Tap interface: {}, id: {} attributes read as: {}", key.getName(), index, builder); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VhostUserCustomizer.java index 0781a3f77..7d575a9b0 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VhostUserCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VhostUserCustomizer.java @@ -22,6 +22,10 @@ import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; 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.vpp.jvpp.core.dto.SwInterfaceVhostUserDetails; +import io.fd.vpp.jvpp.core.dto.SwInterfaceVhostUserDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.SwInterfaceVhostUserDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.math.BigInteger; import java.util.Collections; import java.util.List; @@ -38,11 +42,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.SwInterfaceVhostUserDetails; -import io.fd.vpp.jvpp.core.dto.SwInterfaceVhostUserDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.SwInterfaceVhostUserDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,63 +74,59 @@ public class VhostUserCustomizer extends FutureJVppCustomizer public void readCurrentAttributes(@Nonnull final InstanceIdentifier<VhostUser> id, @Nonnull final VhostUserBuilder builder, @Nonnull final ReadContext ctx) throws ReadFailedException { - try { - final InterfaceKey key = id.firstKeyOf(Interface.class); - final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext()); - if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, - org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class, - LOG)) { - return; - } - LOG.debug("Reading attributes for vhpost user interface: {}", key.getName()); - - @SuppressWarnings("unchecked") - Map<Integer, SwInterfaceVhostUserDetails> mappedVhostUsers = - (Map<Integer, SwInterfaceVhostUserDetails>) ctx.getModificationCache() - .get(DUMPED_VHOST_USERS_CONTEXT_KEY); - - if (mappedVhostUsers == null) { - // Full VhostUser dump has to be performed here, no filter or anything is here to help so at least we cache it - final SwInterfaceVhostUserDump request = new SwInterfaceVhostUserDump(); - final CompletionStage<SwInterfaceVhostUserDetailsReplyDump> - swInterfaceVhostUserDetailsReplyDumpCompletionStage = - getFutureJVpp().swInterfaceVhostUserDump(request); - final SwInterfaceVhostUserDetailsReplyDump reply = - getReplyForRead(swInterfaceVhostUserDetailsReplyDumpCompletionStage.toCompletableFuture(), id); - - if (null == reply || null == reply.swInterfaceVhostUserDetails) { - mappedVhostUsers = Collections.emptyMap(); - } else { - final List<SwInterfaceVhostUserDetails> swInterfaceVhostUserDetails = - reply.swInterfaceVhostUserDetails; - // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes - mappedVhostUsers = swInterfaceVhostUserDetails.stream() - .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)); - } - - ctx.getModificationCache().put(DUMPED_VHOST_USERS_CONTEXT_KEY, mappedVhostUsers); + final InterfaceKey key = id.firstKeyOf(Interface.class); + final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext()); + if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class, + LOG)) { + return; + } + + LOG.debug("Reading attributes for vhpost user interface: {}", key.getName()); + + @SuppressWarnings("unchecked") + Map<Integer, SwInterfaceVhostUserDetails> mappedVhostUsers = + (Map<Integer, SwInterfaceVhostUserDetails>) ctx.getModificationCache() + .get(DUMPED_VHOST_USERS_CONTEXT_KEY); + + if (mappedVhostUsers == null) { + // Full VhostUser dump has to be performed here, no filter or anything is here to help so at least we cache it + final SwInterfaceVhostUserDump request = new SwInterfaceVhostUserDump(); + final CompletionStage<SwInterfaceVhostUserDetailsReplyDump> + swInterfaceVhostUserDetailsReplyDumpCompletionStage = + getFutureJVpp().swInterfaceVhostUserDump(request); + final SwInterfaceVhostUserDetailsReplyDump reply = + getReplyForRead(swInterfaceVhostUserDetailsReplyDumpCompletionStage.toCompletableFuture(), id); + + if (null == reply || null == reply.swInterfaceVhostUserDetails) { + mappedVhostUsers = Collections.emptyMap(); + } else { + final List<SwInterfaceVhostUserDetails> swInterfaceVhostUserDetails = + reply.swInterfaceVhostUserDetails; + // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes + mappedVhostUsers = swInterfaceVhostUserDetails.stream() + .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)); } - // Relying here that parent InterfaceCustomizer was invoked first to fill in the context with initial ifc mapping - final SwInterfaceVhostUserDetails swInterfaceVhostUserDetails = mappedVhostUsers.get(index); - LOG.trace("Vhost user interface: {} attributes returned from VPP: {}", key.getName(), - swInterfaceVhostUserDetails); - - builder.setRole(swInterfaceVhostUserDetails.isServer == 1 - ? VhostUserRole.Server - : VhostUserRole.Client); - builder.setFeatures(BigInteger.valueOf(swInterfaceVhostUserDetails.features)); - builder.setNumMemoryRegions((long) swInterfaceVhostUserDetails.numRegions); - builder.setSocket(toString(swInterfaceVhostUserDetails.sockFilename)); - builder.setVirtioNetHdrSize((long) swInterfaceVhostUserDetails.virtioNetHdrSz); - // TODO: map error code to meaningful message after VPP-436 is done - builder.setConnectError(Integer.toString(swInterfaceVhostUserDetails.sockErrno)); - - LOG.debug("Vhost user interface: {}, id: {} attributes read as: {}", key.getName(), index, builder); - } catch (VppBaseCallException e) { - LOG.warn("Failed to readCurrentAttributes for: {}", id, e); - throw new ReadFailedException(id, e); + ctx.getModificationCache().put(DUMPED_VHOST_USERS_CONTEXT_KEY, mappedVhostUsers); } + + // Relying here that parent InterfaceCustomizer was invoked first to fill in the context with initial ifc mapping + final SwInterfaceVhostUserDetails swInterfaceVhostUserDetails = mappedVhostUsers.get(index); + LOG.trace("Vhost user interface: {} attributes returned from VPP: {}", key.getName(), + swInterfaceVhostUserDetails); + + builder.setRole(swInterfaceVhostUserDetails.isServer == 1 + ? VhostUserRole.Server + : VhostUserRole.Client); + builder.setFeatures(BigInteger.valueOf(swInterfaceVhostUserDetails.features)); + builder.setNumMemoryRegions((long) swInterfaceVhostUserDetails.numRegions); + builder.setSocket(toString(swInterfaceVhostUserDetails.sockFilename)); + builder.setVirtioNetHdrSize((long) swInterfaceVhostUserDetails.virtioNetHdrSz); + // TODO: map error code to meaningful message after VPP-436 is done + builder.setConnectError(Integer.toString(swInterfaceVhostUserDetails.sockErrno)); + + LOG.debug("Vhost user interface: {}, id: {} attributes read as: {}", key.getName(), index, builder); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizer.java index 579136085..555d48c81 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizer.java @@ -24,6 +24,10 @@ import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; 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.vpp.jvpp.core.dto.VxlanTunnelDetails; +import io.fd.vpp.jvpp.core.dto.VxlanTunnelDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.VxlanTunnelDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Arrays; @@ -42,11 +46,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.VxlanTunnelDetails; -import io.fd.vpp.jvpp.core.dto.VxlanTunnelDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.VxlanTunnelDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -77,61 +76,57 @@ public class VxlanCustomizer extends FutureJVppCustomizer public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Vxlan> id, @Nonnull final VxlanBuilder builder, @Nonnull final ReadContext ctx) throws ReadFailedException { - try { - final InterfaceKey key = id.firstKeyOf(Interface.class); - final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext()); - if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, VxlanTunnel.class, LOG)) { - return; - } - - LOG.debug("Reading attributes for vxlan tunnel: {}", key.getName()); - // Dump just a single - final VxlanTunnelDump request = new VxlanTunnelDump(); - request.swIfIndex = index; - - final CompletionStage<VxlanTunnelDetailsReplyDump> swInterfaceVxlanDetailsReplyDumpCompletionStage = - getFutureJVpp().vxlanTunnelDump(request); - final VxlanTunnelDetailsReplyDump reply = - getReplyForRead(swInterfaceVxlanDetailsReplyDumpCompletionStage.toCompletableFuture(), id); - - // VPP keeps vxlan tunnel interfaces even after they were deleted (optimization) - // However there ar no longer any vxlan tunnel specific fields assigned to it and this call - // returns nothing - if (reply == null || reply.vxlanTunnelDetails == null || reply.vxlanTunnelDetails.isEmpty()) { - LOG.debug( - "Vxlan tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" + - "after delete", key.getName(), index); - return; - } - - checkState(reply.vxlanTunnelDetails.size() == 1, - "Unexpected number of returned vxlan tunnels: {} for tunnel: {}", reply.vxlanTunnelDetails, - key.getName()); - LOG.trace("Vxlan tunnel: {} attributes returned from VPP: {}", key.getName(), reply); - - final VxlanTunnelDetails swInterfaceVxlanDetails = reply.vxlanTunnelDetails.get(0); - if (swInterfaceVxlanDetails.isIpv6 == 1) { - final Ipv6Address dstIpv6 = - new Ipv6Address(parseAddress(swInterfaceVxlanDetails.dstAddress).getHostAddress()); - builder.setDst(new IpAddress(dstIpv6)); - final Ipv6Address srcIpv6 = - new Ipv6Address(parseAddress(swInterfaceVxlanDetails.srcAddress).getHostAddress()); - builder.setSrc(new IpAddress(srcIpv6)); - } else { - final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanDetails.dstAddress, 0, 4); - final Ipv4Address dstIpv4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress()); - builder.setDst(new IpAddress(dstIpv4)); - final byte[] srcBytes = Arrays.copyOfRange(swInterfaceVxlanDetails.srcAddress, 0, 4); - final Ipv4Address srcIpv4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress()); - builder.setSrc(new IpAddress(srcIpv4)); - } - builder.setEncapVrfId((long) swInterfaceVxlanDetails.encapVrfId); - builder.setVni(new VxlanVni((long) swInterfaceVxlanDetails.vni)); - LOG.debug("Vxlan tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder); - } catch (VppBaseCallException e) { - LOG.warn("Failed to readCurrentAttributes for: {}", id); - throw new ReadFailedException(id, e); + + final InterfaceKey key = id.firstKeyOf(Interface.class); + final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext()); + if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, VxlanTunnel.class, LOG)) { + return; + } + + LOG.debug("Reading attributes for vxlan tunnel: {}", key.getName()); + // Dump just a single + final VxlanTunnelDump request = new VxlanTunnelDump(); + request.swIfIndex = index; + + final CompletionStage<VxlanTunnelDetailsReplyDump> swInterfaceVxlanDetailsReplyDumpCompletionStage = + getFutureJVpp().vxlanTunnelDump(request); + final VxlanTunnelDetailsReplyDump reply = + getReplyForRead(swInterfaceVxlanDetailsReplyDumpCompletionStage.toCompletableFuture(), id); + + // VPP keeps vxlan tunnel interfaces even after they were deleted (optimization) + // However there ar no longer any vxlan tunnel specific fields assigned to it and this call + // returns nothing + if (reply == null || reply.vxlanTunnelDetails == null || reply.vxlanTunnelDetails.isEmpty()) { + LOG.debug( + "Vxlan tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" + + "after delete", key.getName(), index); + return; + } + + checkState(reply.vxlanTunnelDetails.size() == 1, + "Unexpected number of returned vxlan tunnels: {} for tunnel: {}", reply.vxlanTunnelDetails, + key.getName()); + LOG.trace("Vxlan tunnel: {} attributes returned from VPP: {}", key.getName(), reply); + + final VxlanTunnelDetails swInterfaceVxlanDetails = reply.vxlanTunnelDetails.get(0); + if (swInterfaceVxlanDetails.isIpv6 == 1) { + final Ipv6Address dstIpv6 = + new Ipv6Address(parseAddress(swInterfaceVxlanDetails.dstAddress).getHostAddress()); + builder.setDst(new IpAddress(dstIpv6)); + final Ipv6Address srcIpv6 = + new Ipv6Address(parseAddress(swInterfaceVxlanDetails.srcAddress).getHostAddress()); + builder.setSrc(new IpAddress(srcIpv6)); + } else { + final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanDetails.dstAddress, 0, 4); + final Ipv4Address dstIpv4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress()); + builder.setDst(new IpAddress(dstIpv4)); + final byte[] srcBytes = Arrays.copyOfRange(swInterfaceVxlanDetails.srcAddress, 0, 4); + final Ipv4Address srcIpv4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress()); + builder.setSrc(new IpAddress(srcIpv4)); } + builder.setEncapVrfId((long) swInterfaceVxlanDetails.encapVrfId); + builder.setVni(new VxlanVni((long) swInterfaceVxlanDetails.vni)); + LOG.debug("Vxlan tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder); } @Nonnull diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizer.java index 8ea95c190..764054d55 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizer.java @@ -24,6 +24,10 @@ import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; 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.vpp.jvpp.core.dto.VxlanGpeTunnelDetails; +import io.fd.vpp.jvpp.core.dto.VxlanGpeTunnelDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.VxlanGpeTunnelDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Arrays; @@ -43,11 +47,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.VxlanGpeTunnelDetails; -import io.fd.vpp.jvpp.core.dto.VxlanGpeTunnelDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.VxlanGpeTunnelDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -78,64 +77,60 @@ public class VxlanGpeCustomizer extends FutureJVppCustomizer public void readCurrentAttributes(@Nonnull final InstanceIdentifier<VxlanGpe> id, @Nonnull final VxlanGpeBuilder builder, @Nonnull final ReadContext ctx) throws ReadFailedException { - try { - final InterfaceKey key = id.firstKeyOf(Interface.class); - final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext()); - if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, VxlanGpeTunnel.class, LOG)) { - return; - } - - LOG.debug("Reading attributes for VxlanGpe tunnel: {}", key.getName()); - // Dump just a single - final VxlanGpeTunnelDump request = new VxlanGpeTunnelDump(); - request.swIfIndex = index; - - final CompletionStage<VxlanGpeTunnelDetailsReplyDump> swInterfaceVxlanGpeDetailsReplyDumpCompletionStage = - getFutureJVpp().vxlanGpeTunnelDump(request); - final VxlanGpeTunnelDetailsReplyDump reply = - getReplyForRead(swInterfaceVxlanGpeDetailsReplyDumpCompletionStage.toCompletableFuture(), - id); - - // VPP keeps VxlanGpe tunnel interfaces even after they were deleted (optimization) - // However there are no longer any VxlanGpe tunnel specific fields assigned to it and this call - // returns nothing - if (reply == null || reply.vxlanGpeTunnelDetails == null || reply.vxlanGpeTunnelDetails.isEmpty()) { - LOG.debug( - "VxlanGpe tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" + - "after delete", key.getName(), index); - return; - } - - checkState(reply.vxlanGpeTunnelDetails.size() == 1, - "Unexpected number of returned VxlanGpe tunnels: {} for tunnel: {}", reply.vxlanGpeTunnelDetails, - key.getName()); - LOG.trace("VxlanGpe tunnel: {} attributes returned from VPP: {}", key.getName(), reply); - - final VxlanGpeTunnelDetails swInterfaceVxlanGpeDetails = reply.vxlanGpeTunnelDetails.get(0); - if (swInterfaceVxlanGpeDetails.isIpv6 == 1) { - final Ipv6Address remote6 = - new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.remote).getHostAddress()); - builder.setRemote(new IpAddress(remote6)); - final Ipv6Address local6 = - new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.local).getHostAddress()); - builder.setLocal(new IpAddress(local6)); - } else { - final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanGpeDetails.remote, 0, 4); - final Ipv4Address remote4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress()); - builder.setRemote(new IpAddress(remote4)); - final byte[] srcBytes = Arrays.copyOfRange(swInterfaceVxlanGpeDetails.local, 0, 4); - final Ipv4Address local4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress()); - builder.setLocal(new IpAddress(local4)); - } - builder.setVni(new VxlanGpeVni((long) swInterfaceVxlanGpeDetails.vni)); - builder.setNextProtocol(VxlanGpeNextProtocol.forValue(swInterfaceVxlanGpeDetails.protocol)); - builder.setEncapVrfId((long) swInterfaceVxlanGpeDetails.encapVrfId); - builder.setDecapVrfId((long) swInterfaceVxlanGpeDetails.decapVrfId); - LOG.debug("VxlanGpe tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder); - } catch (VppBaseCallException e) { - LOG.warn("Failed to readCurrentAttributes for: {}", id); - throw new ReadFailedException(id, e); + + final InterfaceKey key = id.firstKeyOf(Interface.class); + final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext()); + if (!isInterfaceOfType(getFutureJVpp(), ctx.getModificationCache(), id, index, VxlanGpeTunnel.class, LOG)) { + return; + } + + LOG.debug("Reading attributes for VxlanGpe tunnel: {}", key.getName()); + // Dump just a single + final VxlanGpeTunnelDump request = new VxlanGpeTunnelDump(); + request.swIfIndex = index; + + final CompletionStage<VxlanGpeTunnelDetailsReplyDump> swInterfaceVxlanGpeDetailsReplyDumpCompletionStage = + getFutureJVpp().vxlanGpeTunnelDump(request); + final VxlanGpeTunnelDetailsReplyDump reply = + getReplyForRead(swInterfaceVxlanGpeDetailsReplyDumpCompletionStage.toCompletableFuture(), + id); + + // VPP keeps VxlanGpe tunnel interfaces even after they were deleted (optimization) + // However there are no longer any VxlanGpe tunnel specific fields assigned to it and this call + // returns nothing + if (reply == null || reply.vxlanGpeTunnelDetails == null || reply.vxlanGpeTunnelDetails.isEmpty()) { + LOG.debug( + "VxlanGpe tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" + + "after delete", key.getName(), index); + return; + } + + checkState(reply.vxlanGpeTunnelDetails.size() == 1, + "Unexpected number of returned VxlanGpe tunnels: {} for tunnel: {}", reply.vxlanGpeTunnelDetails, + key.getName()); + LOG.trace("VxlanGpe tunnel: {} attributes returned from VPP: {}", key.getName(), reply); + + final VxlanGpeTunnelDetails swInterfaceVxlanGpeDetails = reply.vxlanGpeTunnelDetails.get(0); + if (swInterfaceVxlanGpeDetails.isIpv6 == 1) { + final Ipv6Address remote6 = + new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.remote).getHostAddress()); + builder.setRemote(new IpAddress(remote6)); + final Ipv6Address local6 = + new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.local).getHostAddress()); + builder.setLocal(new IpAddress(local6)); + } else { + final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanGpeDetails.remote, 0, 4); + final Ipv4Address remote4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress()); + builder.setRemote(new IpAddress(remote4)); + final byte[] srcBytes = Arrays.copyOfRange(swInterfaceVxlanGpeDetails.local, 0, 4); + final Ipv4Address local4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress()); + builder.setLocal(new IpAddress(local4)); } + builder.setVni(new VxlanGpeVni((long) swInterfaceVxlanGpeDetails.vni)); + builder.setNextProtocol(VxlanGpeNextProtocol.forValue(swInterfaceVxlanGpeDetails.protocol)); + builder.setEncapVrfId((long) swInterfaceVxlanGpeDetails.encapVrfId); + builder.setDecapVrfId((long) swInterfaceVxlanGpeDetails.decapVrfId); + LOG.debug("VxlanGpe tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder); } @Nonnull diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/acl/ingress/AclCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/acl/ingress/AclCustomizer.java index c248575ca..091244eea 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/acl/ingress/AclCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/acl/ingress/AclCustomizer.java @@ -26,7 +26,6 @@ import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager; 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.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.core.dto.ClassifyTableByInterface; import io.fd.vpp.jvpp.core.dto.ClassifyTableByInterfaceReply; import io.fd.vpp.jvpp.core.future.FutureJVppCore; @@ -71,7 +70,8 @@ public class AclCustomizer extends FutureJVppCustomizer } @Override - public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, @Nonnull final IngressBuilder builder, + public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, + @Nonnull final IngressBuilder builder, @Nonnull final ReadContext ctx) throws ReadFailedException { LOG.debug("Reading attributes for interface ACL: {}", id); final InterfaceKey interfaceKey = id.firstKeyOf(Interface.class); @@ -79,19 +79,16 @@ public class AclCustomizer extends FutureJVppCustomizer final ClassifyTableByInterface request = new ClassifyTableByInterface(); request.swIfIndex = interfaceContext.getIndex(interfaceKey.getName(), ctx.getMappingContext()); - try { - final ClassifyTableByInterfaceReply reply = - getReplyForRead(getFutureJVpp().classifyTableByInterface(request).toCompletableFuture(), id); - builder.setL2Acl(readL2Acl(reply.l2TableId, classifyTableContext, ctx.getMappingContext())); - builder.setIp4Acl(readIp4Acl(reply.ip4TableId, classifyTableContext, ctx.getMappingContext())); - builder.setIp6Acl(readIp6Acl(reply.ip6TableId, classifyTableContext, ctx.getMappingContext())); + final ClassifyTableByInterfaceReply reply = + getReplyForRead(getFutureJVpp().classifyTableByInterface(request).toCompletableFuture(), id); - if (LOG.isTraceEnabled()) { - LOG.trace("Attributes for ACL {} successfully read: {}", id, builder.build()); - } - } catch (VppBaseCallException e) { - throw new ReadFailedException(id, e); + builder.setL2Acl(readL2Acl(reply.l2TableId, classifyTableContext, ctx.getMappingContext())); + builder.setIp4Acl(readIp4Acl(reply.ip4TableId, classifyTableContext, ctx.getMappingContext())); + builder.setIp6Acl(readIp6Acl(reply.ip6TableId, classifyTableContext, ctx.getMappingContext())); + + if (LOG.isTraceEnabled()) { + LOG.trace("Attributes for ACL {} successfully read: {}", id, builder.build()); } } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/acl/ingress/SubInterfaceAclCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/acl/ingress/SubInterfaceAclCustomizer.java index ad80f6ee2..de287cf67 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/acl/ingress/SubInterfaceAclCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/acl/ingress/SubInterfaceAclCustomizer.java @@ -27,7 +27,6 @@ import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager; 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.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.core.dto.ClassifyTableByInterface; import io.fd.vpp.jvpp.core.dto.ClassifyTableByInterfaceReply; import io.fd.vpp.jvpp.core.future.FutureJVppCore; @@ -74,7 +73,8 @@ public class SubInterfaceAclCustomizer extends FutureJVppCustomizer } @Override - public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, @Nonnull final IngressBuilder builder, + public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Ingress> id, + @Nonnull final IngressBuilder builder, @Nonnull final ReadContext ctx) throws ReadFailedException { LOG.debug("Reading attributes for sub-interface ACL: {}", id); final InterfaceKey parentInterfacekey = id.firstKeyOf(Interface.class); @@ -86,19 +86,16 @@ public class SubInterfaceAclCustomizer extends FutureJVppCustomizer final ClassifyTableByInterface request = new ClassifyTableByInterface(); request.swIfIndex = interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()); - try { - final ClassifyTableByInterfaceReply reply = - getReplyForRead(getFutureJVpp().classifyTableByInterface(request).toCompletableFuture(), id); - builder.setL2Acl(readL2Acl(reply.l2TableId, classifyTableContext, ctx.getMappingContext())); - builder.setIp4Acl(readIp4Acl(reply.ip4TableId, classifyTableContext, ctx.getMappingContext())); - builder.setIp6Acl(readIp6Acl(reply.ip6TableId, classifyTableContext, ctx.getMappingContext())); + final ClassifyTableByInterfaceReply reply = + getReplyForRead(getFutureJVpp().classifyTableByInterface(request).toCompletableFuture(), id); - if (LOG.isTraceEnabled()) { - LOG.trace("Attributes for ACL {} successfully read: {}", id, builder.build()); - } - } catch (VppBaseCallException e) { - throw new ReadFailedException(id, e); + builder.setL2Acl(readL2Acl(reply.l2TableId, classifyTableContext, ctx.getMappingContext())); + builder.setIp4Acl(readIp4Acl(reply.ip4TableId, classifyTableContext, ctx.getMappingContext())); + builder.setIp6Acl(readIp6Acl(reply.ip6TableId, classifyTableContext, ctx.getMappingContext())); + + if (LOG.isTraceEnabled()) { + LOG.trace("Attributes for ACL {} successfully read: {}", id, builder.build()); } } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java index bba2cf590..f07ef3d57 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java @@ -23,11 +23,13 @@ import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException; import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.AddressDumpExecutor; import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.params.AddressDumpParams; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.NamingContext; +import io.fd.vpp.jvpp.core.dto.IpAddressDetails; +import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.List; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface; @@ -39,9 +41,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev14061 import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.core.dto.IpAddressDetails; -import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -80,14 +79,8 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer final String interfaceName = id.firstKeyOf(Interface.class).getName(); final int interfaceIndex = interfaceContext.getIndex(interfaceName, ctx.getMappingContext()); - final Optional<IpAddressDetailsReplyDump> dumpOptional; - try { - dumpOptional = - dumpManager.getDump(CACHE_KEY, ctx.getModificationCache(), - new AddressDumpParams(interfaceIndex, false)); - } catch (DumpExecutionFailedException e) { - throw new ReadFailedException(id, e); - } + final Optional<IpAddressDetailsReplyDump> dumpOptional = dumpManager + .getDump(id, CACHE_KEY, ctx.getModificationCache(), new AddressDumpParams(interfaceIndex, false)); if (!dumpOptional.isPresent() || dumpOptional.get().ipAddressDetails.isEmpty()) { return; @@ -115,14 +108,8 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer final String interfaceName = id.firstKeyOf(Interface.class).getName(); final int interfaceIndex = interfaceContext.getIndex(interfaceName, ctx.getMappingContext()); - final Optional<IpAddressDetailsReplyDump> dumpOptional; - try { - dumpOptional = - dumpManager.getDump(CACHE_KEY, ctx.getModificationCache(), - new AddressDumpParams(interfaceIndex, false)); - } catch (DumpExecutionFailedException e) { - throw new ReadFailedException(id, e); - } + final Optional<IpAddressDetailsReplyDump> dumpOptional = dumpManager + .getDump(id, CACHE_KEY, ctx.getModificationCache(), new AddressDumpParams(interfaceIndex, false)); return getAllIpv4AddressIds(dumpOptional, AddressKey::new); } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java index 06682b641..234270883 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java @@ -23,12 +23,14 @@ import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException; import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.AddressDumpExecutor; import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.params.AddressDumpParams; 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.vpp.jvpp.core.dto.IpAddressDetails; +import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.List; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface; @@ -41,9 +43,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.core.dto.IpAddressDetails; -import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -82,14 +81,8 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer final String subInterfaceName = getSubInterfaceName(id); final int subInterfaceIndex = interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()); - final Optional<IpAddressDetailsReplyDump> dumpOptional; - try { - dumpOptional = dumpManager - .getDump(CACHE_KEY, ctx.getModificationCache(), new AddressDumpParams(subInterfaceIndex, false)); - } catch (DumpExecutionFailedException e) { - throw new ReadFailedException(id, e); - } - + final Optional<IpAddressDetailsReplyDump> dumpOptional = dumpManager + .getDump(id, CACHE_KEY, ctx.getModificationCache(), new AddressDumpParams(subInterfaceIndex, false)); final Optional<IpAddressDetails> ipAddressDetails = findIpAddressDetailsByIp(dumpOptional, id.firstKeyOf(Address.class).getIp()); @@ -113,13 +106,8 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer final String subInterfaceName = getSubInterfaceName(id); final int subInterfaceIndex = interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()); - final Optional<IpAddressDetailsReplyDump> dumpOptional; - try { - dumpOptional = dumpManager - .getDump(CACHE_KEY, ctx.getModificationCache(), new AddressDumpParams(subInterfaceIndex, false)); - } catch (DumpExecutionFailedException e) { - throw new ReadFailedException(id, e); - } + final Optional<IpAddressDetailsReplyDump> dumpOptional = dumpManager + .getDump(id, CACHE_KEY, ctx.getModificationCache(), new AddressDumpParams(subInterfaceIndex, false)); return getAllIpv4AddressIds(dumpOptional, AddressKey::new); } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/AddressDumpExecutor.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/AddressDumpExecutor.java index 20fda0405..764717db4 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/AddressDumpExecutor.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/AddressDumpExecutor.java @@ -3,19 +3,16 @@ package io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump; import static com.google.common.base.Preconditions.checkNotNull; +import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException; import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.params.AddressDumpParams; import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; -import java.util.concurrent.TimeoutException; -import javax.annotation.Nonnull; -import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; import io.fd.vpp.jvpp.core.dto.IpAddressDump; import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import javax.annotation.Nonnull; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class AddressDumpExecutor implements EntityDumpExecutor<IpAddressDetailsReplyDump, AddressDumpParams>, ByteDataTranslator, @@ -28,20 +25,15 @@ public class AddressDumpExecutor } @Override - public IpAddressDetailsReplyDump executeDump(final AddressDumpParams params) throws DumpExecutionFailedException { + @Nonnull + public IpAddressDetailsReplyDump executeDump(final InstanceIdentifier<?> identifier, final AddressDumpParams params) + throws ReadFailedException { checkNotNull(params, "Address dump params cannot be null"); IpAddressDump dumpRequest = new IpAddressDump(); dumpRequest.isIpv6 = booleanToByte(params.isIpv6()); dumpRequest.swIfIndex = params.getInterfaceIndex(); - try { - return getReply(vppApi.ipAddressDump(dumpRequest).toCompletableFuture()); - } catch (TimeoutException e) { - throw DumpTimeoutException - .wrapTimeoutException("Dumping or addresses ended in timeout[params : ]" + params, e); - } catch (VppBaseCallException e) { - throw DumpCallFailedException.wrapFailedCallException("Dumping of addresses failed[params : ]" + params, e); - } + return getReplyForRead(vppApi.ipAddressDump(dumpRequest).toCompletableFuture(), identifier); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java index c6c92aa35..58c3549fc 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizer.java @@ -23,9 +23,11 @@ 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.BdIpMacAddDel; +import io.fd.vpp.jvpp.core.dto.BdIpMacAddDelReply; +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.inet.types.rev130715.IpAddress; @@ -34,10 +36,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.bridge.domain.attributes.arp.termination.table.ArpTerminationTableEntryKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.BdIpMacAddDel; -import io.fd.vpp.jvpp.core.dto.BdIpMacAddDelReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,14 +62,9 @@ public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer @Nonnull final ArpTerminationTableEntry dataAfter, @Nonnull final WriteContext writeContext) throws WriteFailedException { - try { - LOG.debug("Creating ARP termination table entry: {} {}", id, dataAfter); - bdIpMacAddDel(id, dataAfter, writeContext, true); - LOG.debug("L2 ARP termination table entry created successfully: {} {}", id, dataAfter); - } catch (VppBaseCallException e) { - LOG.warn("Failed to create ARP termination table entry: {} {}", id, dataAfter); - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } + LOG.debug("Creating ARP termination table entry: {} {}", id, dataAfter); + bdIpMacAddDel(id, dataAfter, writeContext, true); + LOG.debug("L2 ARP termination table entry created successfully: {} {}", id, dataAfter); } @Override @@ -88,20 +81,14 @@ public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer @Nonnull final ArpTerminationTableEntry dataBefore, @Nonnull final WriteContext writeContext) throws WriteFailedException { - try { - LOG.debug("Deleting ARP termination table entry entry: {} {}", id, dataBefore); - bdIpMacAddDel(id, dataBefore, writeContext, false); - LOG.debug("ARP termination table entry deleted successfully: {} {}", id, dataBefore); - } catch (VppBaseCallException e) { - LOG.warn("Failed to delete ARP termination table entry: {} {}", id, dataBefore); - throw new WriteFailedException.DeleteFailedException(id, e); - } + LOG.debug("Deleting ARP termination table entry entry: {} {}", id, dataBefore); + bdIpMacAddDel(id, dataBefore, writeContext, false); + LOG.debug("ARP termination table entry deleted successfully: {} {}", id, dataBefore); } private void bdIpMacAddDel(@Nonnull final InstanceIdentifier<ArpTerminationTableEntry> id, @Nonnull final ArpTerminationTableEntry entry, - final WriteContext writeContext, boolean isAdd) - throws VppBaseCallException, WriteTimeoutException { + final WriteContext writeContext, boolean isAdd) throws WriteFailedException { final String bdName = id.firstKeyOf(BridgeDomain.class).getName(); final int bdId = bdContext.getIndex(bdName, writeContext.getMappingContext()); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java index 1f704e727..327247b41 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizer.java @@ -25,18 +25,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.BridgeDomainAddDel; +import io.fd.vpp.jvpp.core.dto.BridgeDomainAddDelReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import javax.annotation.Nonnull; import javax.annotation.concurrent.GuardedBy; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.BridgeDomainAddDel; -import io.fd.vpp.jvpp.core.dto.BridgeDomainAddDelReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,7 +57,7 @@ public class BridgeDomainCustomizer private BridgeDomainAddDelReply addOrUpdateBridgeDomain(@Nonnull final InstanceIdentifier<BridgeDomain> id, final int bdId, @Nonnull final BridgeDomain bd) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { final BridgeDomainAddDelReply reply; final BridgeDomainAddDel request = new BridgeDomainAddDel(); request.bdId = bdId; @@ -86,27 +84,22 @@ public class BridgeDomainCustomizer // Invoke 1. check index, 2. increase index 3. create ND 4. store mapping in a synchronized block to prevent // race conditions in case of concurrent invocation synchronized (this) { - try { - int index; - if (bdContext.containsIndex(bdName, ctx.getMappingContext())) { - index = bdContext.getIndex(bdName, ctx.getMappingContext()); - } else { - // Critical section due to bridgeDomainIndexCounter read and write access - // TODO HONEYCOMB-199 move this "get next available index" into naming context or an adapter - // or a dedicated object - - // Use counter to assign bridge domain index, but still check naming context if it's not taken there - while (bdContext.containsName(bridgeDomainIndexCounter, ctx.getMappingContext())) { - bridgeDomainIndexCounter++; - } - index = bridgeDomainIndexCounter; + int index; + if (bdContext.containsIndex(bdName, ctx.getMappingContext())) { + index = bdContext.getIndex(bdName, ctx.getMappingContext()); + } else { + // Critical section due to bridgeDomainIndexCounter read and write access + // TODO HONEYCOMB-199 move this "get next available index" into naming context or an adapter + // or a dedicated object + + // Use counter to assign bridge domain index, but still check naming context if it's not taken there + while (bdContext.containsName(bridgeDomainIndexCounter, ctx.getMappingContext())) { + bridgeDomainIndexCounter++; } - addOrUpdateBridgeDomain(id, index, dataBefore); - bdContext.addName(index, bdName, ctx.getMappingContext()); - } catch (VppBaseCallException e) { - LOG.warn("Failed to create bridge domain", e); - throw new WriteFailedException.CreateFailedException(id, dataBefore, e); + index = bridgeDomainIndexCounter; } + addOrUpdateBridgeDomain(id, index, dataBefore); + bdContext.addName(index, bdName, ctx.getMappingContext()); } } @@ -118,17 +111,12 @@ public class BridgeDomainCustomizer LOG.debug("deleteCurrentAttributes: id={}, dataBefore={}, ctx={}", id, dataBefore, ctx); final String bdName = id.firstKeyOf(BridgeDomain.class).getName(); int bdId = bdContext.getIndex(bdName, ctx.getMappingContext()); - try { - final BridgeDomainAddDel request = new BridgeDomainAddDel(); - request.bdId = bdId; + final BridgeDomainAddDel request = new BridgeDomainAddDel(); + request.bdId = bdId; - getReplyForWrite(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture(), id); - LOG.debug("Bridge domain {} (id={}) deleted successfully", bdName, bdId); - } catch (VppBaseCallException e) { - LOG.warn("Bridge domain {} (id={}) delete failed", bdName, bdId); - throw new WriteFailedException.DeleteFailedException(id, e); - } + getReplyForWrite(getFutureJVpp().bridgeDomainAddDel(request).toCompletableFuture(), id); + LOG.debug("Bridge domain {} (id={}) deleted successfully", bdName, bdId); } @Override @@ -143,12 +131,7 @@ public class BridgeDomainCustomizer checkArgument(bdName.equals(dataBefore.getName()), "BridgeDomain name changed. It should be deleted and then created."); - try { - addOrUpdateBridgeDomain(id, bdContext.getIndex(bdName, ctx.getMappingContext()), dataAfter); - } catch (VppBaseCallException e) { - LOG.warn("Failed to create bridge domain", e); - throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e); - } + addOrUpdateBridgeDomain(id, bdContext.getIndex(bdName, ctx.getMappingContext()), dataAfter); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java index eb7247b1c..59198b58a 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizer.java @@ -24,9 +24,11 @@ import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; 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 io.fd.vpp.jvpp.core.dto.L2FibAddDel; +import io.fd.vpp.jvpp.core.dto.L2FibAddDelReply; +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.L2FibFilter; @@ -34,10 +36,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.fib.attributes.l2.fib.table.L2FibEntryKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.L2FibAddDel; -import io.fd.vpp.jvpp.core.dto.L2FibAddDelReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,14 +63,10 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<L2FibEntry> id, @Nonnull final L2FibEntry dataAfter, @Nonnull final WriteContext writeContext) throws WriteFailedException { - try { - LOG.debug("Creating L2 FIB entry: {} {}", id, dataAfter); - l2FibAddDel(id, dataAfter, writeContext, true); - LOG.debug("L2 FIB entry created successfully: {} {}", id, dataAfter); - } catch (VppBaseCallException e) { - LOG.warn("Failed to create L2 FIB entry: {} {}", id, dataAfter); - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } + + LOG.debug("Creating L2 FIB entry: {} {}", id, dataAfter); + l2FibAddDel(id, dataAfter, writeContext, true); + LOG.debug("L2 FIB entry created successfully: {} {}", id, dataAfter); } @Override @@ -87,19 +81,14 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<L2FibEntry> id, @Nonnull final L2FibEntry dataBefore, @Nonnull final WriteContext writeContext) throws WriteFailedException { - try { - LOG.debug("Deleting L2 FIB entry: {} {}", id, dataBefore); - l2FibAddDel(id, dataBefore, writeContext, false); - LOG.debug("L2 FIB entry deleted successfully: {} {}", id, dataBefore); - } catch (VppBaseCallException e) { - LOG.warn("Failed to delete L2 FIB entry: {} {}", id, dataBefore); - throw new WriteFailedException.DeleteFailedException(id, e); - } + + LOG.debug("Deleting L2 FIB entry: {} {}", id, dataBefore); + l2FibAddDel(id, dataBefore, writeContext, false); + LOG.debug("L2 FIB entry deleted successfully: {} {}", id, dataBefore); } private void l2FibAddDel(@Nonnull final InstanceIdentifier<L2FibEntry> id, @Nonnull final L2FibEntry entry, - final WriteContext writeContext, boolean isAdd) - throws VppBaseCallException, WriteTimeoutException { + final WriteContext writeContext, boolean isAdd) throws WriteFailedException { final String bdName = id.firstKeyOf(BridgeDomain.class).getName(); final int bdId = bdContext.getIndex(bdName, writeContext.getMappingContext()); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java index 2b7c62f6b..be9d0d953 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReader.java @@ -29,6 +29,10 @@ import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; import io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceDataTranslator; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; +import io.fd.vpp.jvpp.core.dto.ClassifySessionDetails; +import io.fd.vpp.jvpp.core.dto.ClassifySessionDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.ClassifySessionDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -48,11 +52,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.clas import org.opendaylight.yangtools.concepts.Builder; 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.ClassifySessionDetails; -import io.fd.vpp.jvpp.core.dto.ClassifySessionDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.ClassifySessionDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -155,21 +154,18 @@ public class ClassifySessionReader extends FutureJVppCustomizer final int tableId = classifyTableContext.getTableIndex(tableName, ctx.getMappingContext()); LOG.debug("Dumping classify sessions for classify table id={}", tableId); - try { - final ClassifySessionDump dumpRequest = new ClassifySessionDump(); - dumpRequest.tableId = tableId; - classifySessionDump = - getReplyForRead(getFutureJVpp().classifySessionDump(dumpRequest).toCompletableFuture(), id); - if (classifySessionDump != null) { - // update the cache: - ctx.getModificationCache().put(cacheKey, classifySessionDump); - } + final ClassifySessionDump dumpRequest = new ClassifySessionDump(); + dumpRequest.tableId = tableId; + classifySessionDump = + getReplyForRead(getFutureJVpp().classifySessionDump(dumpRequest).toCompletableFuture(), id); - return classifySessionDump; - } catch (VppBaseCallException e) { - throw new ReadFailedException(id, e); + if (classifySessionDump != null) { + // update the cache: + ctx.getModificationCache().put(cacheKey, classifySessionDump); } + + return classifySessionDump; } private static Optional<ClassifySessionDetails> findClassifySessionDetailsByMatch( diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReader.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReader.java index c544d9c2d..96a174d8e 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReader.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReader.java @@ -28,6 +28,11 @@ import io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceDataTranslator; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.MacTranslator; +import io.fd.vpp.jvpp.core.dto.ClassifyTableIds; +import io.fd.vpp.jvpp.core.dto.ClassifyTableIdsReply; +import io.fd.vpp.jvpp.core.dto.ClassifyTableInfo; +import io.fd.vpp.jvpp.core.dto.ClassifyTableInfoReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -42,12 +47,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.clas import org.opendaylight.yangtools.concepts.Builder; 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.ClassifyTableIds; -import io.fd.vpp.jvpp.core.dto.ClassifyTableIdsReply; -import io.fd.vpp.jvpp.core.dto.ClassifyTableInfo; -import io.fd.vpp.jvpp.core.dto.ClassifyTableInfoReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -99,39 +98,36 @@ public class ClassifyTableReader extends FutureJVppCustomizer } request.tableId = classifyTableContext.getTableIndex(tableName, ctx.getMappingContext()); - try { - final ClassifyTableInfoReply reply = - getReplyForRead(getFutureJVpp().classifyTableInfo(request).toCompletableFuture(), id); - - // mandatory values: - builder.setName(tableName); - builder.setKey(key); - builder.setNbuckets(UnsignedInts.toLong(reply.nbuckets)); - builder.setSkipNVectors(UnsignedInts.toLong(reply.skipNVectors)); - - // optional value read from context - final Optional<String> tableBaseNode = - classifyTableContext.getTableBaseNode(tableName, ctx.getMappingContext()); - if (tableBaseNode.isPresent()) { - builder.setClassifierNode(new VppNodeName(tableBaseNode.get())); - } - - builder.setMissNext( - readVppNode(reply.tableId, reply.missNextIndex, classifyTableContext, ctx.getMappingContext(), LOG) - .get()); - builder.setMask(new HexString(printHexBinary(reply.mask))); - builder.setActiveSessions(UnsignedInts.toLong(reply.activeSessions)); - - if (reply.nextTableIndex != ~0) { - // next table index is present: - builder.setNextTable(classifyTableContext.getTableName(reply.nextTableIndex, ctx.getMappingContext())); - } - - if (LOG.isTraceEnabled()) { - LOG.trace("Attributes for classify table {} successfully read: {}", id, builder.build()); - } - } catch (VppBaseCallException e) { - throw new ReadFailedException(id, e); + + final ClassifyTableInfoReply reply = + getReplyForRead(getFutureJVpp().classifyTableInfo(request).toCompletableFuture(), id); + + // mandatory values: + builder.setName(tableName); + builder.setKey(key); + builder.setNbuckets(UnsignedInts.toLong(reply.nbuckets)); + builder.setSkipNVectors(UnsignedInts.toLong(reply.skipNVectors)); + + // optional value read from context + final Optional<String> tableBaseNode = + classifyTableContext.getTableBaseNode(tableName, ctx.getMappingContext()); + if (tableBaseNode.isPresent()) { + builder.setClassifierNode(new VppNodeName(tableBaseNode.get())); + } + + builder.setMissNext( + readVppNode(reply.tableId, reply.missNextIndex, classifyTableContext, ctx.getMappingContext(), LOG) + .get()); + builder.setMask(new HexString(printHexBinary(reply.mask))); + builder.setActiveSessions(UnsignedInts.toLong(reply.activeSessions)); + + if (reply.nextTableIndex != ~0) { + // next table index is present: + builder.setNextTable(classifyTableContext.getTableName(reply.nextTableIndex, ctx.getMappingContext())); + } + + if (LOG.isTraceEnabled()) { + LOG.trace("Attributes for classify table {} successfully read: {}", id, builder.build()); } } @@ -140,21 +136,18 @@ public class ClassifyTableReader extends FutureJVppCustomizer public List<ClassifyTableKey> getAllIds(@Nonnull final InstanceIdentifier<ClassifyTable> id, @Nonnull final ReadContext context) throws ReadFailedException { LOG.debug("Reading list of keys for classify tables: {}", id); - try { - final ClassifyTableIdsReply classifyTableIdsReply = - getReplyForRead(getFutureJVpp().classifyTableIds(new ClassifyTableIds()).toCompletableFuture(), - id); - if (classifyTableIdsReply.ids != null) { - return Arrays.stream(classifyTableIdsReply.ids).mapToObj(i -> { - final String tableName = classifyTableContext.getTableName(i, context.getMappingContext()); - LOG.trace("Classify table with name: {} and index: {} found in VPP", tableName, i); - return new ClassifyTableKey(tableName); - }).collect(Collectors.toList()); - } else { - return Collections.emptyList(); - } - } catch (VppBaseCallException e) { - throw new ReadFailedException(id, e); + + final ClassifyTableIdsReply classifyTableIdsReply = + getReplyForRead(getFutureJVpp().classifyTableIds(new ClassifyTableIds()).toCompletableFuture(), + id); + if (classifyTableIdsReply.ids != null) { + return Arrays.stream(classifyTableIdsReply.ids).mapToObj(i -> { + final String tableName = classifyTableContext.getTableName(i, context.getMappingContext()); + LOG.trace("Classify table with name: {} and index: {} found in VPP", tableName, i); + return new ClassifyTableKey(tableName); + }).collect(Collectors.toList()); + } else { + return Collections.emptyList(); } } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/VppNodeWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/VppNodeWriter.java index 2640d3e9e..a9cc7b1c9 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/VppNodeWriter.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppclassifier/VppNodeWriter.java @@ -19,19 +19,19 @@ package io.fd.honeycomb.translate.v3po.vppclassifier; import static com.google.common.base.Preconditions.checkArgument; import io.fd.honeycomb.translate.MappingContext; +import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; -import io.fd.honeycomb.translate.vpp.util.ReadTimeoutException; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.core.dto.GetNextIndex; +import io.fd.vpp.jvpp.core.dto.GetNextIndexReply; +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.vpp.classifier.rev150603.VppNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.vpp.classifier.ClassifyTable; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.GetNextIndex; -import io.fd.vpp.jvpp.core.dto.GetNextIndexReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; abstract class VppNodeWriter extends FutureJVppCustomizer implements JvppReplyConsumer { @@ -54,7 +54,7 @@ abstract class VppNodeWriter extends FutureJVppCustomizer implements JvppReplyCo private int nodeNameToIndex(@Nonnull final ClassifyTable classifyTable, @Nonnull final String nextNodeName, @Nonnull final VppClassifierContextManager vppClassifierContextManager, @Nonnull final MappingContext ctx, @Nonnull final InstanceIdentifier<?> id) - throws VppBaseCallException, WriteFailedException { + throws WriteFailedException { checkArgument(classifyTable != null && classifyTable.getClassifierNode() != null, "to use relative node names, table classifier node needs to be provided"); final GetNextIndex request = new GetNextIndex(); @@ -70,7 +70,7 @@ abstract class VppNodeWriter extends FutureJVppCustomizer implements JvppReplyCo // vpp does not provide relative node index to node name conversion (https://jira.fd.io/browse/VPP-219) // as a workaround we need to add mapping to vpp-classfier-context vppClassifierContextManager.addNodeName(classifyTable.getName(), reply.nextIndex, nextNodeName, ctx); - } catch (ReadTimeoutException e) { + } catch (ReadFailedException e) { throw new WriteFailedException(id, String.format("Failed to get node index for %s relative to %s", nextNodeName, classifyTable.getClassifierNode()), e); } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizer.java index f83bc9b89..f6db9bc84 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizer.java @@ -26,7 +26,10 @@ import io.fd.honeycomb.translate.v3po.interfacesstate.InterfaceDataTranslator; import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.translate.vpp.util.ReadTimeoutException; +import io.fd.vpp.jvpp.core.dto.L2FibTableDump; +import io.fd.vpp.jvpp.core.dto.L2FibTableEntry; +import io.fd.vpp.jvpp.core.dto.L2FibTableEntryReplyDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -45,11 +48,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.L2FibTableDump; -import io.fd.vpp.jvpp.core.dto.L2FibTableEntry; -import io.fd.vpp.jvpp.core.dto.L2FibTableEntryReplyDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -106,7 +104,7 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer @Nonnull private List<L2FibTableEntry> dumpL2Fibs(final InstanceIdentifier<L2FibEntry> id, final int bdId) - throws VppBaseCallException, ReadTimeoutException { + throws ReadFailedException { final L2FibTableDump l2FibRequest = new L2FibTableDump(); l2FibRequest.bdId = bdId; @@ -130,14 +128,10 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer final int bdId = bdContext.getIndex(bridgeDomainKey.getName(), ctx.getMappingContext()); LOG.debug("Reading L2 FIB for bridge domain {} (bdId={})", bridgeDomainKey, bdId); - try { - return dumpL2Fibs(id, bdId).stream() - .map(entry -> new L2FibEntryKey( - new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(entry.mac), 2)))) - .collect(Collectors.toList()); - } catch (VppBaseCallException e) { - throw new ReadFailedException(id, e); - } + return dumpL2Fibs(id, bdId).stream() + .map(entry -> new L2FibEntryKey( + new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(entry.mac), 2)))) + .collect(Collectors.toList()); } @Override diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizer.java index 86ab994b3..e4dec37fa 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizer.java @@ -22,6 +22,9 @@ import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; 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.vpp.jvpp.core.dto.ShowVersion; +import io.fd.vpp.jvpp.core.dto.ShowVersionReply; +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.VppStateBuilder; @@ -30,10 +33,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.ShowVersion; -import io.fd.vpp.jvpp.core.dto.ShowVersionReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; public final class VersionCustomizer extends FutureJVppCustomizer @@ -57,18 +56,15 @@ public final class VersionCustomizer @Override public void readCurrentAttributes(@Nonnull InstanceIdentifier<Version> id, @Nonnull final VersionBuilder builder, @Nonnull final ReadContext context) throws ReadFailedException { - try { - // Execute with timeout - final CompletionStage<ShowVersionReply> showVersionFuture = getFutureJVpp().showVersion(new ShowVersion()); - final ShowVersionReply reply = getReplyForRead(showVersionFuture.toCompletableFuture(), id); - builder.setBranch(toString(reply.version)); - builder.setName(toString(reply.program)); - builder.setBuildDate(toString(reply.buildDate)); - builder.setBuildDirectory(toString(reply.buildDirectory)); - } catch (VppBaseCallException e) { - throw new ReadFailedException(id, e); - } + // Execute with timeout + final CompletionStage<ShowVersionReply> showVersionFuture = getFutureJVpp().showVersion(new ShowVersion()); + final ShowVersionReply reply = getReplyForRead(showVersionFuture.toCompletableFuture(), id); + + builder.setBranch(toString(reply.version)); + builder.setName(toString(reply.program)); + builder.setBuildDate(toString(reply.buildDate)); + builder.setBuildDirectory(toString(reply.buildDirectory)); } } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java index 4b7489f8e..ac0a003d8 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java @@ -117,7 +117,7 @@ public class AclCustomizerTest extends WriterCustomizerTest { try { customizer.writeCurrentAttributes(id, acl, writeContext); - } catch (WriteFailedException.CreateFailedException e) { + } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof VppBaseCallException); verify(api).inputAclSetInterface(generateInputAclSetInterface((byte) 1, IF_INDEX, ACL_TABLE_INDEX)); return; @@ -146,7 +146,7 @@ public class AclCustomizerTest extends WriterCustomizerTest { try { customizer.deleteCurrentAttributes(id, acl, writeContext); - } catch (WriteFailedException.DeleteFailedException e) { + } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof VppBaseCallException); verify(api).inputAclSetInterface(generateInputAclSetInterface((byte) 0, IF_INDEX, ACL_TABLE_INDEX)); return; diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java index 7effc876e..3cedc4f71 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java @@ -26,6 +26,10 @@ import io.fd.honeycomb.translate.vpp.util.NamingContext; import io.fd.honeycomb.translate.vpp.util.TagRewriteOperation; import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.VppInvocationException; +import io.fd.vpp.jvpp.core.dto.L2InterfaceVlanTagRewrite; +import io.fd.vpp.jvpp.core.dto.L2InterfaceVlanTagRewriteReply; import org.junit.Assert; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; @@ -40,10 +44,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.yangtools.yang.binding.ChildOf; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.VppInvocationException; -import io.fd.vpp.jvpp.core.dto.L2InterfaceVlanTagRewrite; -import io.fd.vpp.jvpp.core.dto.L2InterfaceVlanTagRewriteReply; public class RewriteCustomizerTest extends WriterCustomizerTest { @@ -68,10 +68,10 @@ public class RewriteCustomizerTest extends WriterCustomizerTest { private static InstanceIdentifier<Rewrite> getVlanTagRewriteId(final String name, final long index) { final Class<ChildOf<? super SubInterface>> child = (Class) Rewrite.class; final InstanceIdentifier id = - InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(name)).augmentation( - SubinterfaceAugmentation.class).child(SubInterfaces.class) - .child(SubInterface.class, new SubInterfaceKey(index)) - .child(child); + InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(name)).augmentation( + SubinterfaceAugmentation.class).child(SubInterfaces.class) + .child(SubInterface.class, new SubInterfaceKey(index)) + .child(child); return id; } @@ -96,7 +96,7 @@ public class RewriteCustomizerTest extends WriterCustomizerTest { */ private void whenL2InterfaceVlanTagRewriteThenSuccess() { doReturn(future(new L2InterfaceVlanTagRewriteReply())).when(api) - .l2InterfaceVlanTagRewrite(any(L2InterfaceVlanTagRewrite.class)); + .l2InterfaceVlanTagRewrite(any(L2InterfaceVlanTagRewrite.class)); } /** @@ -133,7 +133,7 @@ public class RewriteCustomizerTest extends WriterCustomizerTest { try { customizer.writeCurrentAttributes(VLAN_IID, vlanTagRewrite, writeContext); - } catch (WriteFailedException.CreateFailedException e) { + } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof VppBaseCallException); verify(api).l2InterfaceVlanTagRewrite(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, op)); return; @@ -151,7 +151,7 @@ public class RewriteCustomizerTest extends WriterCustomizerTest { customizer.updateCurrentAttributes(VLAN_IID, before, after, writeContext); verify(api) - .l2InterfaceVlanTagRewrite(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, TagRewriteOperation.pop_1)); + .l2InterfaceVlanTagRewrite(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, TagRewriteOperation.pop_1)); } @Test @@ -163,10 +163,11 @@ public class RewriteCustomizerTest extends WriterCustomizerTest { try { customizer.updateCurrentAttributes(VLAN_IID, before, after, writeContext); - } catch (WriteFailedException.UpdateFailedException e) { + } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof VppBaseCallException); verify(api) - .l2InterfaceVlanTagRewrite(generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, TagRewriteOperation.pop_1)); + .l2InterfaceVlanTagRewrite( + generateL2InterfaceVlanTagRewrite(VLAN_IF_INDEX, TagRewriteOperation.pop_1)); return; } fail("WriteFailedException.UpdateFailedException was expected"); @@ -187,7 +188,7 @@ public class RewriteCustomizerTest extends WriterCustomizerTest { try { customizer.deleteCurrentAttributes(VLAN_IID, null, writeContext); - } catch (WriteFailedException.DeleteFailedException e) { + } catch (WriteFailedException e) { Assert.assertTrue(e.getCause() instanceof VppBaseCallException); verifyL2InterfaceVlanTagRewriteDeleteWasInvoked(); return; diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizerTest.java index 930e3d14f..6c7d05823 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RoutingCustomizerTest.java @@ -59,7 +59,7 @@ public class RoutingCustomizerTest extends WriterCustomizerTest { verify(api).swInterfaceSetTable(expectedRequest(vrfId)); } - @Test(expected = WriteFailedException.CreateFailedException.class) + @Test(expected = WriteFailedException.class) public void testWriteFailed() throws WriteFailedException { when(api.swInterfaceSetTable(any())).thenReturn(failedFuture()); customizer.writeCurrentAttributes(IID, routing(213), writeContext); @@ -72,7 +72,7 @@ public class RoutingCustomizerTest extends WriterCustomizerTest { verifyZeroInteractions(api); } - @Test(expected = WriteFailedException.UpdateFailedException.class) + @Test(expected = WriteFailedException.class) public void testUpdateFailed() throws WriteFailedException { when(api.swInterfaceSetTable(any())).thenReturn(failedFuture()); customizer.updateCurrentAttributes(IID, routing(123L), routing(321L), writeContext); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/SubInterfaceAclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/SubInterfaceAclCustomizerTest.java index f5ec496ef..e754ec9c1 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/SubInterfaceAclCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/SubInterfaceAclCustomizerTest.java @@ -55,9 +55,9 @@ public class SubInterfaceAclCustomizerTest extends WriterCustomizerTest { private static final int TABLE_INDEX = 123; private static final InstanceIdentifier<Ingress> IID = - InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IF_NAME)).augmentation( - SubinterfaceAugmentation.class).child(SubInterfaces.class) - .child(SubInterface.class, new SubInterfaceKey(SUBIF_ID)).child(Acl.class).child(Ingress.class); + InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IF_NAME)).augmentation( + SubinterfaceAugmentation.class).child(SubInterfaces.class) + .child(SubInterface.class, new SubInterfaceKey(SUBIF_ID)).child(Acl.class).child(Ingress.class); @Mock private VppClassifierContextManager classifyTableContext; @@ -67,7 +67,7 @@ public class SubInterfaceAclCustomizerTest extends WriterCustomizerTest { @Override protected void setUp() throws Exception { customizer = new SubInterfaceAclCustomizer(api, new NamingContext("prefix", IFC_TEST_INSTANCE), - classifyTableContext); + classifyTableContext); defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE); defineMapping(mappingContext, SUBIF_NAME, SUBIF_INDEX, IFC_TEST_INSTANCE); when(classifyTableContext.getTableIndex(TABLE_NAME, mappingContext)).thenReturn(TABLE_INDEX); @@ -80,7 +80,7 @@ public class SubInterfaceAclCustomizerTest extends WriterCustomizerTest { verify(api).inputAclSetInterface(expectedIp4AclRequest()); } - @Test(expected = WriteFailedException.CreateFailedException.class) + @Test(expected = WriteFailedException.class) public void testCreateFailed() throws WriteFailedException { when(api.inputAclSetInterface(any())).thenReturn(failedFuture()); customizer.writeCurrentAttributes(IID, ip4Acl(), writeContext); @@ -98,7 +98,7 @@ public class SubInterfaceAclCustomizerTest extends WriterCustomizerTest { verify(api).inputAclSetInterface(expectedIp6AclRequest()); } - @Test(expected = WriteFailedException.DeleteFailedException.class) + @Test(expected = WriteFailedException.class) public void testDeleteFailed() throws WriteFailedException { when(api.inputAclSetInterface(any())).thenReturn(failedFuture()); customizer.deleteCurrentAttributes(IID, ip4Acl(), writeContext); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java index dece4bfe8..4ece9228b 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java @@ -28,6 +28,10 @@ import static org.mockito.Mockito.verify; import io.fd.honeycomb.translate.vpp.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.VppInvocationException; +import io.fd.vpp.jvpp.core.dto.BdIpMacAddDel; +import io.fd.vpp.jvpp.core.dto.BdIpMacAddDelReply; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; @@ -41,10 +45,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.vpp.bridge.domains.BridgeDomain; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.VppInvocationException; -import io.fd.vpp.jvpp.core.dto.BdIpMacAddDel; -import io.fd.vpp.jvpp.core.dto.BdIpMacAddDelReply; public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest { private static final String BD_CTX_NAME = "bd-test-instance"; @@ -66,8 +66,8 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest public void setUp() throws Exception { customizer = new ArpTerminationTableEntryCustomizer(api, new NamingContext("generatedBdName", BD_CTX_NAME)); - ipAddressRaw = new byte[] {1, 2, 3, 4}; - physAddressRaw = new byte[] {1, 2, 3, 4, 5, 6}; + ipAddressRaw = new byte[]{1, 2, 3, 4}; + physAddressRaw = new byte[]{1, 2, 3, 4, 5, 6}; physAddress = new PhysAddress("01:02:03:04:05:06"); ipAddress = new IpAddress(Ipv4AddressNoZone.getDefaultInstance("1.2.3.4")); @@ -81,8 +81,8 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest private static InstanceIdentifier<ArpTerminationTableEntry> getArpEntryId(final IpAddress ipAddress, final PhysAddress physAddress) { return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(BD_NAME)) - .child(ArpTerminationTable.class) - .child(ArpTerminationTableEntry.class, new ArpTerminationTableEntryKey(ipAddress, physAddress)); + .child(ArpTerminationTable.class) + .child(ArpTerminationTableEntry.class, new ArpTerminationTableEntryKey(ipAddress, physAddress)); } private void whenBdIpMacAddDelThenSuccess() { @@ -112,7 +112,7 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest } private void verifyBdIpMacAddDelWasInvoked(final BdIpMacAddDel expected) throws - VppInvocationException { + VppInvocationException { ArgumentCaptor<BdIpMacAddDel> argumentCaptor = ArgumentCaptor.forClass(BdIpMacAddDel.class); verify(api).bdIpMacAddDel(argumentCaptor.capture()); final BdIpMacAddDel actual = argumentCaptor.getValue(); @@ -134,7 +134,7 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest whenBdIpMacAddDelThenFailure(); try { customizer.writeCurrentAttributes(id, entry, writeContext); - } catch (WriteFailedException.CreateFailedException e) { + } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof VppBaseCallException); verifyBdIpMacAddDelWasInvoked(generateBdIpMacAddDelRequest(ipAddressRaw, physAddressRaw, (byte) 1)); return; @@ -145,8 +145,8 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest @Test(expected = UnsupportedOperationException.class) public void testUpdate() throws Exception { customizer.updateCurrentAttributes(InstanceIdentifier.create(ArpTerminationTableEntry.class), - mock(ArpTerminationTableEntry.class), - mock(ArpTerminationTableEntry.class), writeContext); + mock(ArpTerminationTableEntry.class), + mock(ArpTerminationTableEntry.class), writeContext); } @Test @@ -161,7 +161,7 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest whenBdIpMacAddDelThenFailure(); try { customizer.deleteCurrentAttributes(id, entry, writeContext); - } catch (WriteFailedException.DeleteFailedException e) { + } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof VppBaseCallException); verifyBdIpMacAddDelWasInvoked(generateBdIpMacAddDelRequest(ipAddressRaw, physAddressRaw, (byte) 0)); return; diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java index 2ab921c90..b18273350 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java @@ -27,6 +27,9 @@ import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; import io.fd.honeycomb.translate.vpp.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppInvocationException; +import io.fd.vpp.jvpp.core.dto.BridgeDomainAddDel; +import io.fd.vpp.jvpp.core.dto.BridgeDomainAddDelReply; import javax.annotation.Nullable; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.BridgeDomains; @@ -35,9 +38,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.vpp.bridge.domains.BridgeDomainKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; -import io.fd.vpp.jvpp.VppInvocationException; -import io.fd.vpp.jvpp.core.dto.BridgeDomainAddDel; -import io.fd.vpp.jvpp.core.dto.BridgeDomainAddDelReply; public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator { @@ -155,7 +155,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements try { customizer.writeCurrentAttributes(bdIdentifierForName(bdName), bd, writeContext); - } catch (WriteFailedException.CreateFailedException e) { + } catch (WriteFailedException e) { verifyBridgeDomainAddOrUpdateWasInvoked(bd, bdId); return; } @@ -202,7 +202,7 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements try { customizer.deleteCurrentAttributes(bdIdentifierForName(bdName), bd, writeContext); - } catch (WriteFailedException.DeleteFailedException e) { + } catch (WriteFailedException e) { verifyBridgeDomainDeleteWasInvoked(bdId); return; } @@ -265,10 +265,8 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements whenBridgeDomainAddDelThenFailure(); try { - customizer - .updateCurrentAttributes(bdIdentifierForName(bdName), bdBefore, bdAfter, - writeContext); - } catch (WriteFailedException.UpdateFailedException e) { + customizer.updateCurrentAttributes(bdIdentifierForName(bdName), bdBefore, bdAfter, writeContext); + } catch (WriteFailedException e) { verifyBridgeDomainAddOrUpdateWasInvoked(bdAfter, bdId); return; } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java index 4704ef084..d2ea4c32d 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java @@ -27,6 +27,10 @@ import static org.mockito.Mockito.verify; import io.fd.honeycomb.translate.vpp.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.VppInvocationException; +import io.fd.vpp.jvpp.core.dto.L2FibAddDel; +import io.fd.vpp.jvpp.core.dto.L2FibAddDelReply; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress; @@ -39,10 +43,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.vpp.bridge.domains.BridgeDomain; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.VppInvocationException; -import io.fd.vpp.jvpp.core.dto.L2FibAddDel; -import io.fd.vpp.jvpp.core.dto.L2FibAddDelReply; public class L2FibEntryCustomizerTest extends WriterCustomizerTest { private static final String BD_CTX_NAME = "bd-test-instance"; @@ -141,7 +141,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest { try { customizer.writeCurrentAttributes(id, entry, writeContext); - } catch (WriteFailedException.CreateFailedException e) { + } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof VppBaseCallException); verifyL2FibAddDelWasInvoked(generateL2FibAddDelRequest(address_vpp, (byte) 1)); return; @@ -180,7 +180,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest { try { customizer.deleteCurrentAttributes(id, entry, writeContext); - } catch (WriteFailedException.DeleteFailedException e) { + } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof VppBaseCallException); verifyL2FibAddDelWasInvoked(generateL2FibAddDelRequest(address_vpp, (byte) 0)); return; diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java index b70ccf0f3..cb507b104 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java @@ -27,6 +27,9 @@ import static org.mockito.Mockito.when; import com.google.common.base.Optional; import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSession; +import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSessionReply; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.HexString; @@ -41,9 +44,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.clas import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.vpp.classifier.ClassifyTable; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.vpp.classifier.ClassifyTableKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSession; -import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSessionReply; public class ClassifySessionWriterTest extends WriterCustomizerTest { @@ -81,13 +81,13 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest { private static InstanceIdentifier<ClassifySession> getClassifySessionId(final String tableName, final String match) { return InstanceIdentifier.create(VppClassifier.class) - .child(ClassifyTable.class, new ClassifyTableKey(tableName)) - .child(ClassifySession.class, new ClassifySessionKey(new HexString(match))); + .child(ClassifyTable.class, new ClassifyTableKey(tableName)) + .child(ClassifySession.class, new ClassifySessionKey(new HexString(match))); } private void whenClassifyAddDelSessionThenSuccess() { doReturn(future(new ClassifyAddDelSessionReply())).when(api) - .classifyAddDelSession(any(ClassifyAddDelSession.class)); + .classifyAddDelSession(any(ClassifyAddDelSession.class)); } private void whenClassifyAddDelSessionThenFailure() { @@ -103,8 +103,8 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest { request.hitNextIndex = 0; request.advance = 123; request.match = - new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, - (byte) 0x05, (byte) 0x06, 0x00, 0x00, 0x00, 0x00}; + new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, + (byte) 0x05, (byte) 0x06, 0x00, 0x00, 0x00, 0x00}; return request; } @@ -131,7 +131,7 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest { try { customizer.writeCurrentAttributes(id, classifySession, writeContext); - } catch (WriteFailedException.CreateFailedException e) { + } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof VppBaseCallException); verify(api).classifyAddDelSession(generateClassifyAddDelSession((byte) 1, TABLE_INDEX, SESSION_INDEX)); return; @@ -154,8 +154,7 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest { customizer.deleteCurrentAttributes(id, classifySession, writeContext); - verify(api).classifyAddDelSession( - generateClassifyAddDelSession((byte) 0, TABLE_INDEX, SESSION_INDEX)); + verify(api).classifyAddDelSession(generateClassifyAddDelSession((byte) 0, TABLE_INDEX, SESSION_INDEX)); } @Test @@ -168,10 +167,9 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest { try { customizer.deleteCurrentAttributes(id, classifySession, writeContext); - } catch (WriteFailedException.DeleteFailedException e) { + } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof VppBaseCallException); - verify(api).classifyAddDelSession( - generateClassifyAddDelSession((byte) 0, TABLE_INDEX, SESSION_INDEX)); + verify(api).classifyAddDelSession(generateClassifyAddDelSession((byte) 0, TABLE_INDEX, SESSION_INDEX)); return; } fail("WriteFailedException.DeleteFailedException was expected"); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java index c8844e5cc..3c62c2d40 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java @@ -26,6 +26,9 @@ import static org.mockito.Mockito.when; import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTable; +import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTableReply; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.HexString; @@ -37,9 +40,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.clas import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.vpp.classifier.ClassifyTableBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.vpp.classifier.ClassifyTableKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTable; -import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTableReply; public class ClassifyTableWriterTest extends WriterCustomizerTest { @@ -71,7 +71,7 @@ public class ClassifyTableWriterTest extends WriterCustomizerTest { private static InstanceIdentifier<ClassifyTable> getClassifyTableId(final String name) { return InstanceIdentifier.create(VppClassifier.class) - .child(ClassifyTable.class, new ClassifyTableKey(name)); + .child(ClassifyTable.class, new ClassifyTableKey(name)); } private void whenClassifyAddDelTableThenSuccess() { @@ -99,8 +99,8 @@ public class ClassifyTableWriterTest extends WriterCustomizerTest { request.nextTableIndex = ~0; request.missNextIndex = ~0; request.mask = - new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, - (byte) 0x05, (byte) 0x06, 0x00, 0x00, 0x00, 0x00}; + new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, + (byte) 0x05, (byte) 0x06, 0x00, 0x00, 0x00, 0x00}; return request; } @@ -115,7 +115,7 @@ public class ClassifyTableWriterTest extends WriterCustomizerTest { verify(api).classifyAddDelTable(generateClassifyAddDelTable((byte) 1)); verify(classifierContext) - .addTable(TABLE_INDEX, classifyTable.getName(), classifyTable.getClassifierNode(), mappingContext); + .addTable(TABLE_INDEX, classifyTable.getName(), classifyTable.getClassifierNode(), mappingContext); } @Test @@ -127,11 +127,11 @@ public class ClassifyTableWriterTest extends WriterCustomizerTest { try { customizer.writeCurrentAttributes(id, classifyTable, writeContext); - } catch (WriteFailedException.CreateFailedException e) { + } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof VppBaseCallException); verify(api).classifyAddDelTable(generateClassifyAddDelTable((byte) 1)); verify(classifierContext, times(0)) - .addTable(TABLE_INDEX, classifyTable.getName(), classifyTable.getClassifierNode(), mappingContext); + .addTable(TABLE_INDEX, classifyTable.getName(), classifyTable.getClassifierNode(), mappingContext); return; } fail("WriteFailedException.CreateFailedException was expected"); @@ -162,7 +162,7 @@ public class ClassifyTableWriterTest extends WriterCustomizerTest { try { customizer.deleteCurrentAttributes(id, classifyTable, writeContext); - } catch (WriteFailedException.DeleteFailedException e) { + } catch (WriteFailedException e) { assertTrue(e.getCause() instanceof VppBaseCallException); verify(api).classifyAddDelTable(generateClassifyAddDelTable((byte) 0, TABLE_INDEX)); return; |