summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java32
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java92
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java73
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java11
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/RewriteCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java78
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java93
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java109
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java117
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java102
12 files changed, 390 insertions, 323 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java
index e1c3e2df6..5bbf33935 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/EthernetCustomizer.java
@@ -66,7 +66,7 @@ public class EthernetCustomizer extends FutureJVppCustomizer
@Nonnull final ReadContext ctx) throws ReadFailedException {
final InterfaceKey key = id.firstKeyOf(Interface.class);
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), key.getName(),
+ final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), id, key.getName(),
interfaceContext.getIndex(key.getName(), ctx.getMappingContext()), ctx.getModificationCache());
if(iface.linkMtu != 0) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java
index 886549ac3..f5c0e5972 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterconnectionReadUtils.java
@@ -29,6 +29,8 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.Interconnection;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.base.attributes.interconnection.BridgeBasedBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.BridgeDomainDetails;
import org.openvpp.jvpp.dto.BridgeDomainDetailsReplyDump;
import org.openvpp.jvpp.dto.BridgeDomainDump;
@@ -59,15 +61,15 @@ final class InterconnectionReadUtils {
}
@Nullable
- Interconnection readInterconnection(@Nonnull final String ifaceName, @Nonnull final ReadContext ctx)
+ Interconnection readInterconnection(@Nonnull final InstanceIdentifier<?> id, @Nonnull final String ifaceName, @Nonnull final ReadContext ctx)
throws ReadFailedException {
final int ifaceId = interfaceContext.getIndex(ifaceName, ctx.getMappingContext());
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(futureJvpp, ifaceName,
+ final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(futureJvpp, id, ifaceName,
ifaceId, ctx.getModificationCache());
LOG.debug("Interface details for interface: {}, details: {}", ifaceName, iface);
- final BridgeDomainDetailsReplyDump dumpReply = getDumpReply();
+ final BridgeDomainDetailsReplyDump dumpReply = getDumpReply(id);
final Optional<BridgeDomainSwIfDetails> bdForInterface = getBridgeDomainForInterface(ifaceId, dumpReply);
if (bdForInterface.isPresent()) {
final BridgeDomainSwIfDetails bdSwIfDetails = bdForInterface.get();
@@ -107,15 +109,19 @@ final class InterconnectionReadUtils {
return reply.bridgeDomainDetails.stream().filter(a -> a.bdId == bdId).findFirst();
}
- private BridgeDomainDetailsReplyDump getDumpReply() {
- // We need to perform full bd dump, because there is no way
- // to ask VPP for BD details given interface id/name (TODO add it to vpp.api?)
- // TODO cache dump result
- final BridgeDomainDump request = new BridgeDomainDump();
- request.bdId = -1;
-
- final CompletableFuture<BridgeDomainDetailsReplyDump> bdCompletableFuture =
- futureJvpp.bridgeDomainSwIfDump(request).toCompletableFuture();
- return TranslateUtils.getReply(bdCompletableFuture);
+ private BridgeDomainDetailsReplyDump getDumpReply(@Nonnull final InstanceIdentifier<?> id) throws ReadFailedException {
+ try {
+ // We need to perform full bd dump, because there is no way
+ // to ask VPP for BD details given interface id/name (TODO add it to vpp.api?)
+ // TODO cache dump result
+ final BridgeDomainDump request = new BridgeDomainDump();
+ request.bdId = -1;
+
+ final CompletableFuture<BridgeDomainDetailsReplyDump> bdCompletableFuture =
+ futureJvpp.bridgeDomainSwIfDump(request).toCompletableFuture();
+ return TranslateUtils.getReply(bdCompletableFuture);
+ } catch (VppBaseCallException e) {
+ throw new ReadFailedException(id,e);
+ }
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java
index d54929ea1..d83030d6e 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceCustomizer.java
@@ -23,13 +23,6 @@ import io.fd.honeycomb.v3po.translate.spi.read.ListReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesStateBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus;
@@ -39,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceDetails;
import org.openvpp.jvpp.dto.SwInterfaceDetailsReplyDump;
import org.openvpp.jvpp.dto.SwInterfaceDump;
@@ -46,6 +40,14 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+
/**
* Customizer for reading ietf-interfaces:interfaces-state/interface
*/
@@ -75,7 +77,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
final InterfaceKey key = id.firstKeyOf(id.getTargetType());
// Pass cached details from getAllIds to getDetails to avoid additional dumps
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), key.getName(),
+ final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), id, key.getName(),
interfaceContext.getIndex(key.getName(), ctx.getMappingContext()), ctx.getModificationCache());
LOG.debug("Interface details for interface: {}, details: {}", key.getName(), iface);
@@ -105,41 +107,47 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
@Override
public List<InterfaceKey> getAllIds(@Nonnull final InstanceIdentifier<Interface> id,
@Nonnull final ReadContext context) throws ReadFailedException {
- LOG.trace("Dumping all interfaces to get all IDs");
-
- final SwInterfaceDump request = new SwInterfaceDump();
- request.nameFilter = "".getBytes();
- request.nameFilterValid = 0;
-
- final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture =
- getFutureJVpp().swInterfaceDump(request).toCompletableFuture();
- final SwInterfaceDetailsReplyDump ifaces = TranslateUtils.getReply(swInterfaceDetailsReplyDumpCompletableFuture);
-
- if (null == ifaces || null == ifaces.swInterfaceDetails) {
- LOG.debug("No interfaces found in VPP");
- return Collections.emptyList();
+ try {
+ final List<InterfaceKey> interfacesKeys;
+ LOG.trace("Dumping all interfaces to get all IDs");
+
+ final SwInterfaceDump request = new SwInterfaceDump();
+ request.nameFilter = "".getBytes();
+ request.nameFilterValid = 0;
+
+ final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture =
+ getFutureJVpp().swInterfaceDump(request).toCompletableFuture();
+ final SwInterfaceDetailsReplyDump ifaces = TranslateUtils.getReply(swInterfaceDetailsReplyDumpCompletableFuture);
+
+ if (null == ifaces || null == ifaces.swInterfaceDetails) {
+ LOG.debug("No interfaces found in VPP");
+ return Collections.emptyList();
+ }
+
+ // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
+ context.getModificationCache().put(DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream()
+ .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)));
+
+ interfacesKeys = ifaces.swInterfaceDetails.stream()
+ .filter(elt -> elt != null)
+ .map((elt) -> {
+ // Store interface name from VPP in context if not yet present
+ if (!interfaceContext.containsName(elt.swIfIndex, context.getMappingContext())) {
+ interfaceContext.addName(elt.swIfIndex, TranslateUtils.toString(elt.interfaceName), context.getMappingContext());
+ }
+ LOG.trace("Interface with name: {}, VPP name: {} and index: {} found in VPP",
+ interfaceContext.getName(elt.swIfIndex, context.getMappingContext()), elt.interfaceName, elt.swIfIndex);
+
+ return new InterfaceKey(interfaceContext.getName(elt.swIfIndex, context.getMappingContext()));
+ })
+ .collect(Collectors.toList());
+
+ LOG.debug("Interfaces found in VPP: {}", interfacesKeys);
+ return interfacesKeys;
+ } catch (VppBaseCallException e) {
+ LOG.warn("getAllIds exception :" + e.toString());
+ throw new ReadFailedException( id, e);
}
-
- // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
- context.getModificationCache().put(DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream()
- .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)));
-
- final List<InterfaceKey> interfacesKeys = ifaces.swInterfaceDetails.stream()
- .filter(elt -> elt != null)
- .map((elt) -> {
- // Store interface name from VPP in context if not yet present
- if (!interfaceContext.containsName(elt.swIfIndex, context.getMappingContext())) {
- interfaceContext.addName(elt.swIfIndex, TranslateUtils.toString(elt.interfaceName), context.getMappingContext());
- }
- LOG.trace("Interface with name: {}, VPP name: {} and index: {} found in VPP",
- interfaceContext.getName(elt.swIfIndex, context.getMappingContext()), elt.interfaceName, elt.swIfIndex);
-
- return new InterfaceKey(interfaceContext.getName(elt.swIfIndex, context.getMappingContext()));
- })
- .collect(Collectors.toList());
-
- LOG.debug("Interfaces found in VPP: {}", interfacesKeys);
- return interfacesKeys;
}
@Override
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java
index a61c3890e..ba0a99147 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java
@@ -16,27 +16,20 @@
package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceCustomizer.getCachedInterfaceDump;
-import static java.util.Objects.requireNonNull;
-
import com.google.common.base.Preconditions;
import io.fd.honeycomb.v3po.translate.ModificationCache;
+import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.util.RWUtils;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import java.math.BigInteger;
-import java.util.Map;
-import java.util.concurrent.CompletionStage;
-import java.util.stream.Collector;
-import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Gauge64;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanGpeTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceDetails;
import org.openvpp.jvpp.dto.SwInterfaceDetailsReplyDump;
import org.openvpp.jvpp.dto.SwInterfaceDump;
@@ -44,6 +37,18 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.math.BigInteger;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.CompletionStage;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceCustomizer.getCachedInterfaceDump;
+import static java.util.Objects.requireNonNull;
+
public final class InterfaceUtils {
private static final Logger LOG = LoggerFactory.getLogger(InterfaceUtils.class);
@@ -110,7 +115,7 @@ public final class InterfaceUtils {
* @throws IllegalArgumentException if vppPhysAddress.length < 6
*/
public static String vppPhysAddrToYang(@Nonnull final byte[] vppPhysAddress) {
- requireNonNull(vppPhysAddress, "Empty physical address bytes");
+ Objects.requireNonNull(vppPhysAddress, "Empty physical address bytes");
Preconditions.checkArgument(PHYSICAL_ADDRESS_LENGTH <= vppPhysAddress.length,
"Invalid physical address size %s, expected >= 6", vppPhysAddress.length);
StringBuilder physAddr = new StringBuilder();
@@ -151,17 +156,21 @@ public final class InterfaceUtils {
* Queries VPP for interface description given interface key.
*
* @param futureJvpp VPP Java Future API
+ * @param id InstanceIdentifier, which is passed in ReadFailedException
* @param name interface name
* @param index VPP index of the interface
* @param ctx per-tx scope context containing cached dump with all the interfaces. If the cache is not
* available or outdated, another dump will be performed.
* @return SwInterfaceDetails DTO or null if interface was not found
* @throws IllegalArgumentException If interface cannot be found
+ * @throws ReadFailedException If read operation had failed
*/
@Nonnull
public static SwInterfaceDetails getVppInterfaceDetails(@Nonnull final FutureJVpp futureJvpp,
+ @Nonnull final InstanceIdentifier<?> id,
@Nonnull final String name, final int index,
- @Nonnull final ModificationCache ctx) {
+ @Nonnull final ModificationCache ctx)
+ throws ReadFailedException {
requireNonNull(futureJvpp, "futureJvpp should not be null");
requireNonNull(name, "name should not be null");
requireNonNull(ctx, "ctx should not be null");
@@ -177,27 +186,33 @@ public final class InterfaceUtils {
return allInterfaces.get(index);
}
- CompletionStage<SwInterfaceDetailsReplyDump> requestFuture = futureJvpp.swInterfaceDump(request);
- SwInterfaceDetailsReplyDump ifaces = TranslateUtils.getReply(requestFuture.toCompletableFuture());
- if (null == ifaces || null == ifaces.swInterfaceDetails || ifaces.swInterfaceDetails.isEmpty()) {
- request.nameFilterValid = 0;
+ SwInterfaceDetailsReplyDump ifaces = null;
+ try {
+ CompletionStage<SwInterfaceDetailsReplyDump> requestFuture = futureJvpp.swInterfaceDump(request);
+ ifaces = TranslateUtils.getReply(requestFuture.toCompletableFuture());
+ if (null == ifaces || null == ifaces.swInterfaceDetails || ifaces.swInterfaceDetails.isEmpty()) {
+ request.nameFilterValid = 0;
- LOG.warn("VPP returned null instead of interface by key {} and its not cached", name);
- LOG.warn("Iterating through all the interfaces to find interface: {}", name);
+ LOG.warn("VPP returned null instead of interface by key {} and its not cached", name);
+ LOG.warn("Iterating through all the interfaces to find interface: {}", name);
- // Or else just perform full dump and do inefficient filtering
- requestFuture = futureJvpp.swInterfaceDump(request);
- ifaces = TranslateUtils.getReply(requestFuture.toCompletableFuture());
+ // Or else just perform full dump and do inefficient filtering
+ requestFuture = futureJvpp.swInterfaceDump(request);
+ ifaces = TranslateUtils.getReply(requestFuture.toCompletableFuture());
- // Update the cache
- allInterfaces.clear();
- allInterfaces
- .putAll(ifaces.swInterfaceDetails.stream().collect(Collectors.toMap(d -> d.swIfIndex, d -> d)));
+ // Update the cache
+ allInterfaces.clear();
+ allInterfaces
+ .putAll(ifaces.swInterfaceDetails.stream().collect(Collectors.toMap(d -> d.swIfIndex, d -> d)));
- if (allInterfaces.containsKey(index)) {
- return allInterfaces.get(index);
+ if (allInterfaces.containsKey(index)) {
+ return allInterfaces.get(index);
+ }
+ throw new IllegalArgumentException("Unable to find interface " + name);
}
- throw new IllegalArgumentException("Unable to find interface " + name);
+ } catch (VppBaseCallException e) {
+ LOG.warn("getVppInterfaceDetails exception :", e);
+ throw new ReadFailedException(id);
}
// SwInterfaceDump's name filter does prefix match, so we need additional filtering:
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java
index 63e51389c..e1496e36b 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/L2Customizer.java
@@ -21,7 +21,6 @@ import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentationBuilder;
@@ -34,6 +33,12 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+
+import static com.google.common.base.Preconditions.checkState;
+
/**
* Customizer for reading ietf-interfaces:interfaces-state/interface/iface_name/v3po:l2
*/
@@ -63,10 +68,10 @@ public class L2Customizer extends FutureJVppCustomizer implements ChildReaderCus
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<L2> id, @Nonnull final L2Builder builder,
@Nonnull final ReadContext ctx) throws ReadFailedException {
+
LOG.debug("Reading attributes for L2: {}", id);
final InterfaceKey key = id.firstKeyOf(Interface.class);
final String ifaceName = key.getName();
-
- builder.setInterconnection(icReadUtils.readInterconnection(ifaceName, ctx));
+ builder.setInterconnection(icReadUtils.readInterconnection(id, ifaceName, ctx));
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/RewriteCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/RewriteCustomizer.java
index 143fb4d68..4600395be 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/RewriteCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/RewriteCustomizer.java
@@ -87,7 +87,7 @@ public class RewriteCustomizer extends FutureJVppCustomizer
final String subInterfaceName = getSubInterfaceName(id);
LOG.debug("Reading attributes for sub interface: {}", subInterfaceName);
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), subInterfaceName,
+ final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), id, subInterfaceName,
interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()), ctx.getModificationCache());
LOG.debug("VPP sub-interface details: {}", ReflectionToStringBuilder.toString(iface));
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
index 5adb43874..998b188d0 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceCustomizer.java
@@ -62,6 +62,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceDetails;
import org.openvpp.jvpp.dto.SwInterfaceDetailsReplyDump;
import org.openvpp.jvpp.dto.SwInterfaceDump;
@@ -89,43 +90,46 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
@Override
public List<SubInterfaceKey> getAllIds(@Nonnull final InstanceIdentifier<SubInterface> id,
@Nonnull final ReadContext context) throws ReadFailedException {
- // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
- // to fill in the context with initial ifc mapping
- final InterfaceKey key = id.firstKeyOf(Interface.class);
- final String ifaceName = key.getName();
- final int ifaceId = interfaceContext.getIndex(ifaceName, context.getMappingContext());
-
- // TODO if we know that full dump was already performed we could use cache
- // (checking if getCachedInterfaceDump() returns non empty map is not enough, because
- // we could be part of particular iface state read
- final SwInterfaceDump request = new SwInterfaceDump();
- request.nameFilter = "".getBytes();
- request.nameFilterValid = 0;
-
- final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture =
- getFutureJVpp().swInterfaceDump(request).toCompletableFuture();
- final SwInterfaceDetailsReplyDump ifaces =
- TranslateUtils.getReply(swInterfaceDetailsReplyDumpCompletableFuture);
-
- if (null == ifaces || null == ifaces.swInterfaceDetails) {
- LOG.warn("Looking for sub-interfaces, but no interfaces found in VPP");
- return Collections.emptyList();
- }
-
- // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
- context.getModificationCache().put(DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream()
- .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)));
-
- final List<SubInterfaceKey> interfacesKeys = ifaces.swInterfaceDetails.stream()
- .filter(elt -> elt != null)
- // accept only sub-interfaces for current iface:
- .filter(elt -> elt.subId != 0 && elt.supSwIfIndex == ifaceId)
- .map(details -> new SubInterfaceKey(new Long(details.subId)))
- .collect(Collectors.toList());
-
- LOG.debug("Sub-interfaces of {} found in VPP: {}", ifaceName, interfacesKeys);
+ try {
+ // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
+ // to fill in the context with initial ifc mapping
+ final InterfaceKey key = id.firstKeyOf(Interface.class);
+ final String ifaceName = key.getName();
+ final int ifaceId = interfaceContext.getIndex(ifaceName, context.getMappingContext());
+
+ // TODO if we know that full dump was already performed we could use cache
+ // (checking if getCachedInterfaceDump() returns non empty map is not enough, because
+ // we could be part of particular iface state read
+ final SwInterfaceDump request = new SwInterfaceDump();
+ request.nameFilter = "".getBytes();
+ request.nameFilterValid = 0;
+
+ final CompletableFuture<SwInterfaceDetailsReplyDump> swInterfaceDetailsReplyDumpCompletableFuture =
+ getFutureJVpp().swInterfaceDump(request).toCompletableFuture();
+ final SwInterfaceDetailsReplyDump ifaces =
+ TranslateUtils.getReply(swInterfaceDetailsReplyDumpCompletableFuture);
+
+ if (null == ifaces || null == ifaces.swInterfaceDetails) {
+ LOG.warn("Looking for sub-interfaces, but no interfaces found in VPP");
+ return Collections.emptyList();
+ }
- return interfacesKeys;
+ // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
+ context.getModificationCache().put(DUMPED_IFCS_CONTEXT_KEY, ifaces.swInterfaceDetails.stream()
+ .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails)));
+
+ final List<SubInterfaceKey> interfacesKeys = ifaces.swInterfaceDetails.stream()
+ .filter(elt -> elt != null)
+ // accept only sub-interfaces for current iface:
+ .filter(elt -> elt.subId != 0 && elt.supSwIfIndex == ifaceId)
+ .map(details -> new SubInterfaceKey(new Long(details.subId)))
+ .collect(Collectors.toList());
+
+ LOG.debug("Sub-interfaces of {} found in VPP: {}", ifaceName, interfacesKeys);
+ return interfacesKeys;
+ } catch (VppBaseCallException e) {
+ throw new ReadFailedException(id,e);
+ }
}
@Override
@@ -147,7 +151,7 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
final String subInterfaceName = getSubInterfaceName(id);
LOG.debug("Reading attributes for sub interface: {}", subInterfaceName);
- final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), subInterfaceName,
+ final SwInterfaceDetails iface = InterfaceUtils.getVppInterfaceDetails(getFutureJVpp(), id, subInterfaceName,
interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()), ctx.getModificationCache());
LOG.debug("VPP sub-interface details: {}", ReflectionToStringBuilder.toString(iface));
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java
index baff29466..0c6d50b76 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/SubInterfaceL2Customizer.java
@@ -72,6 +72,6 @@ public class SubInterfaceL2Customizer extends FutureJVppCustomizer implements Ch
final SubInterfaceKey subInterfacekey = id.firstKeyOf(SubInterface.class);
final String subInterfaceName = getSubInterfaceName(parentInterfacekey.getName(), subInterfacekey.getIdentifier().intValue());
- builder.setInterconnection(icReadUtils.readInterconnection(subInterfaceName, ctx));
+ builder.setInterconnection(icReadUtils.readInterconnection(id, subInterfaceName, ctx));
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java
index d4fe30b57..44256956c 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/TapCustomizer.java
@@ -16,20 +16,12 @@
package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
-import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
-
import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletionStage;
-import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentationBuilder;
@@ -38,6 +30,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceTapDetails;
import org.openvpp.jvpp.dto.SwInterfaceTapDetailsReplyDump;
import org.openvpp.jvpp.dto.SwInterfaceTapDump;
@@ -45,6 +38,15 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletionStage;
+import java.util.stream.Collectors;
+
+import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
+
public class TapCustomizer extends FutureJVppCustomizer
implements ChildReaderCustomizer<Tap, TapBuilder> {
@@ -73,44 +75,49 @@ public class TapCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Tap> id,
@Nonnull final TapBuilder builder,
@Nonnull final ReadContext ctx) throws ReadFailedException {
- final InterfaceKey key = id.firstKeyOf(Interface.class);
- // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
- // to fill in the context with initial ifc mapping
- final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
- if (!isInterfaceOfType(ctx.getModificationCache(), index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap.class)) {
- return;
- }
-
- LOG.debug("Reading attributes for tap interface: {}", key.getName());
-
- @SuppressWarnings("unchecked")
- Map<Integer, SwInterfaceTapDetails> mappedTaps =
- (Map<Integer, SwInterfaceTapDetails>) ctx.getModificationCache().get(DUMPED_TAPS_CONTEXT_KEY);
-
- if(mappedTaps == null) {
- // Full Tap dump has to be performed here, no filter or anything is here to help so at least we cache it
- final SwInterfaceTapDump request = new SwInterfaceTapDump();
- final CompletionStage<SwInterfaceTapDetailsReplyDump> swInterfaceTapDetailsReplyDumpCompletionStage =
- getFutureJVpp().swInterfaceTapDump(request);
- final SwInterfaceTapDetailsReplyDump reply =
- TranslateUtils.getReply(swInterfaceTapDetailsReplyDumpCompletionStage.toCompletableFuture());
-
- if(null == reply || null == reply.swInterfaceTapDetails) {
- mappedTaps = Collections.emptyMap();
- } else {
- final List<SwInterfaceTapDetails> swInterfaceTapDetails = reply.swInterfaceTapDetails;
- // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
- mappedTaps = swInterfaceTapDetails.stream()
- .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
+ try {
+ final InterfaceKey key = id.firstKeyOf(Interface.class);
+ // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
+ // to fill in the context with initial ifc mapping
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ if (!isInterfaceOfType(ctx.getModificationCache(), index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap.class)) {
+ return;
}
- ctx.getModificationCache().put(DUMPED_TAPS_CONTEXT_KEY, mappedTaps);
- }
+ LOG.debug("Reading attributes for tap interface: {}", key.getName());
+
+ @SuppressWarnings("unchecked")
+ Map<Integer, SwInterfaceTapDetails> mappedTaps =
+ (Map<Integer, SwInterfaceTapDetails>) ctx.getModificationCache().get(DUMPED_TAPS_CONTEXT_KEY);
+
+ if(mappedTaps == null) {
+ // Full Tap dump has to be performed here, no filter or anything is here to help so at least we cache it
+ final SwInterfaceTapDump request = new SwInterfaceTapDump();
+ final CompletionStage<SwInterfaceTapDetailsReplyDump> swInterfaceTapDetailsReplyDumpCompletionStage =
+ getFutureJVpp().swInterfaceTapDump(request);
+ final SwInterfaceTapDetailsReplyDump reply =
+ TranslateUtils.getReply(swInterfaceTapDetailsReplyDumpCompletionStage.toCompletableFuture());
+
+ if(null == reply || null == reply.swInterfaceTapDetails) {
+ mappedTaps = Collections.emptyMap();
+ } else {
+ final List<SwInterfaceTapDetails> swInterfaceTapDetails = reply.swInterfaceTapDetails;
+ // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
+ mappedTaps = swInterfaceTapDetails.stream()
+ .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
+ }
+
+ ctx.getModificationCache().put(DUMPED_TAPS_CONTEXT_KEY, mappedTaps);
+ }
- final SwInterfaceTapDetails swInterfaceTapDetails = mappedTaps.get(index);
- LOG.trace("Tap interface: {} attributes returned from VPP: {}", key.getName(), swInterfaceTapDetails);
+ final SwInterfaceTapDetails swInterfaceTapDetails = mappedTaps.get(index);
+ LOG.trace("Tap interface: {} attributes returned from VPP: {}", key.getName(), swInterfaceTapDetails);
- builder.setTapName(TranslateUtils.toString(swInterfaceTapDetails.devName));
- LOG.debug("Tap interface: {}, id: {} attributes read as: {}", key.getName(), index, builder);
+ builder.setTapName(TranslateUtils.toString(swInterfaceTapDetails.devName));
+ LOG.debug("Tap interface: {}, id: {} attributes read as: {}", key.getName(), index, builder);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to readCurrentAttributes for: {}", id);
+ throw new ReadFailedException(id);
+ }
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java
index de7514524..7085392f6 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VhostUserCustomizer.java
@@ -16,21 +16,12 @@
package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
-import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
-
import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import java.math.BigInteger;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletionStage;
-import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUserRole;
@@ -40,6 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.SwInterfaceVhostUserDetails;
import org.openvpp.jvpp.dto.SwInterfaceVhostUserDetailsReplyDump;
import org.openvpp.jvpp.dto.SwInterfaceVhostUserDump;
@@ -47,6 +39,16 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletionStage;
+import java.util.stream.Collectors;
+
+import static io.fd.honeycomb.v3po.translate.v3po.interfacesstate.InterfaceUtils.isInterfaceOfType;
+
public class VhostUserCustomizer extends FutureJVppCustomizer
implements ChildReaderCustomizer<VhostUser, VhostUserBuilder> {
@@ -75,51 +77,56 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<VhostUser> id,
@Nonnull final VhostUserBuilder builder,
@Nonnull final ReadContext ctx) throws ReadFailedException {
- final InterfaceKey key = id.firstKeyOf(Interface.class);
- // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
- // to fill in the context with initial ifc mapping
- final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
- if (!isInterfaceOfType(ctx.getModificationCache(), index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class)) {
- return;
- }
+ try {
+ final InterfaceKey key = id.firstKeyOf(Interface.class);
+ // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
+ // to fill in the context with initial ifc mapping
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ if (!isInterfaceOfType(ctx.getModificationCache(), index, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class)) {
+ return;
+ }
- LOG.debug("Reading attributes for vhpost user interface: {}", key.getName());
-
- @SuppressWarnings("unchecked")
- Map<Integer, SwInterfaceVhostUserDetails> mappedVhostUsers =
- (Map<Integer, SwInterfaceVhostUserDetails>) ctx.getModificationCache().get(DUMPED_VHOST_USERS_CONTEXT_KEY);
-
- if(mappedVhostUsers == null) {
- // Full VhostUser dump has to be performed here, no filter or anything is here to help so at least we cache it
- final SwInterfaceVhostUserDump request = new SwInterfaceVhostUserDump();
- final CompletionStage<SwInterfaceVhostUserDetailsReplyDump> swInterfaceVhostUserDetailsReplyDumpCompletionStage =
- getFutureJVpp().swInterfaceVhostUserDump(request);
- final SwInterfaceVhostUserDetailsReplyDump reply =
- TranslateUtils.getReply(swInterfaceVhostUserDetailsReplyDumpCompletionStage.toCompletableFuture());
-
- if(null == reply || null == reply.swInterfaceVhostUserDetails) {
- mappedVhostUsers = Collections.emptyMap();
- } else {
- final List<SwInterfaceVhostUserDetails> swInterfaceVhostUserDetails = reply.swInterfaceVhostUserDetails;
- // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
- mappedVhostUsers = swInterfaceVhostUserDetails.stream()
- .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
+ LOG.debug("Reading attributes for vhpost user interface: {}", key.getName());
+
+ @SuppressWarnings("unchecked")
+ Map<Integer, SwInterfaceVhostUserDetails> mappedVhostUsers =
+ (Map<Integer, SwInterfaceVhostUserDetails>) ctx.getModificationCache().get(DUMPED_VHOST_USERS_CONTEXT_KEY);
+
+ if(mappedVhostUsers == null) {
+ // Full VhostUser dump has to be performed here, no filter or anything is here to help so at least we cache it
+ final SwInterfaceVhostUserDump request = new SwInterfaceVhostUserDump();
+ final CompletionStage<SwInterfaceVhostUserDetailsReplyDump> swInterfaceVhostUserDetailsReplyDumpCompletionStage =
+ getFutureJVpp().swInterfaceVhostUserDump(request);
+ final SwInterfaceVhostUserDetailsReplyDump reply =
+ TranslateUtils.getReply(swInterfaceVhostUserDetailsReplyDumpCompletionStage.toCompletableFuture());
+
+ if(null == reply || null == reply.swInterfaceVhostUserDetails) {
+ mappedVhostUsers = Collections.emptyMap();
+ } else {
+ final List<SwInterfaceVhostUserDetails> swInterfaceVhostUserDetails = reply.swInterfaceVhostUserDetails;
+ // Cache interfaces dump in per-tx context to later be used in readCurrentAttributes
+ mappedVhostUsers = swInterfaceVhostUserDetails.stream()
+ .collect(Collectors.toMap(t -> t.swIfIndex, swInterfaceDetails -> swInterfaceDetails));
+ }
+
+ ctx.getModificationCache().put(DUMPED_VHOST_USERS_CONTEXT_KEY, mappedVhostUsers);
}
- ctx.getModificationCache().put(DUMPED_VHOST_USERS_CONTEXT_KEY, mappedVhostUsers);
+ // Relying here that parent InterfaceCustomizer was invoked first to fill in the context with initial ifc mapping
+ final SwInterfaceVhostUserDetails swInterfaceVhostUserDetails = mappedVhostUsers.get(index);
+ LOG.trace("Vhost user interface: {} attributes returned from VPP: {}", key.getName(), swInterfaceVhostUserDetails);
+
+ builder.setRole(swInterfaceVhostUserDetails.isServer == 1 ? VhostUserRole.Server : VhostUserRole.Client);
+ builder.setFeatures(BigInteger.valueOf(swInterfaceVhostUserDetails.features));
+ builder.setNumMemoryRegions((long) swInterfaceVhostUserDetails.numRegions);
+ builder.setSocket(TranslateUtils.toString(swInterfaceVhostUserDetails.sockFilename));
+ builder.setVirtioNetHdrSize((long) swInterfaceVhostUserDetails.virtioNetHdrSz);
+ builder.setConnectError(Integer.toString(swInterfaceVhostUserDetails.sockErrno));
+
+ LOG.debug("Vhost user interface: {}, id: {} attributes read as: {}", key.getName(), index, builder);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to readCurrentAttributes for: {}", id);
+ throw new ReadFailedException(id);
}
-
- // Relying here that parent InterfaceCustomizer was invoked first to fill in the context with initial ifc mapping
- final SwInterfaceVhostUserDetails swInterfaceVhostUserDetails = mappedVhostUsers.get(index);
- LOG.trace("Vhost user interface: {} attributes returned from VPP: {}", key.getName(), swInterfaceVhostUserDetails);
-
- builder.setRole(swInterfaceVhostUserDetails.isServer == 1 ? VhostUserRole.Server : VhostUserRole.Client);
- builder.setFeatures(BigInteger.valueOf(swInterfaceVhostUserDetails.features));
- builder.setNumMemoryRegions((long) swInterfaceVhostUserDetails.numRegions);
- builder.setSocket(TranslateUtils.toString(swInterfaceVhostUserDetails.sockFilename));
- builder.setVirtioNetHdrSize((long) swInterfaceVhostUserDetails.virtioNetHdrSz);
- builder.setConnectError(Integer.toString(swInterfaceVhostUserDetails.sockErrno));
-
- LOG.debug("Vhost user interface: {}, id: {} attributes read as: {}", key.getName(), index, builder);
}
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java
index b870fe260..41f4b6edc 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanCustomizer.java
@@ -16,19 +16,12 @@
package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
-import static com.google.common.base.Preconditions.checkState;
-
import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.FutureJVppCustomizer;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.TranslateUtils;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.concurrent.CompletionStage;
-import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
@@ -42,6 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.dto.VxlanTunnelDetails;
import org.openvpp.jvpp.dto.VxlanTunnelDetailsReplyDump;
import org.openvpp.jvpp.dto.VxlanTunnelDump;
@@ -49,6 +43,14 @@ import org.openvpp.jvpp.future.FutureJVpp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+import java.util.concurrent.CompletionStage;
+
+import static com.google.common.base.Preconditions.checkState;
+
public class VxlanCustomizer extends FutureJVppCustomizer
implements ChildReaderCustomizer<Vxlan, VxlanBuilder> {
@@ -76,57 +78,62 @@ public class VxlanCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Vxlan> id,
@Nonnull final VxlanBuilder builder,
@Nonnull final ReadContext ctx) throws ReadFailedException {
- final InterfaceKey key = id.firstKeyOf(Interface.class);
- // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
- // to fill in the context with initial ifc mapping
- final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
- if (!InterfaceUtils.isInterfaceOfType(ctx.getModificationCache(), index, VxlanTunnel.class)) {
- return;
- }
+ try {
+ final InterfaceKey key = id.firstKeyOf(Interface.class);
+ // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
+ // to fill in the context with initial ifc mapping
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ if (!InterfaceUtils.isInterfaceOfType(ctx.getModificationCache(), index, VxlanTunnel.class)) {
+ return;
+ }
- LOG.debug("Reading attributes for vxlan tunnel: {}", key.getName());
- // Dump just a single
- final VxlanTunnelDump request = new VxlanTunnelDump();
- request.swIfIndex = index;
-
- final CompletionStage<VxlanTunnelDetailsReplyDump> swInterfaceVxlanDetailsReplyDumpCompletionStage =
- getFutureJVpp().vxlanTunnelDump(request);
- final VxlanTunnelDetailsReplyDump reply =
- TranslateUtils.getReply(swInterfaceVxlanDetailsReplyDumpCompletionStage.toCompletableFuture());
-
- // VPP keeps vxlan tunnel interfaces even after they were deleted (optimization)
- // However there ar no longer any vxlan tunnel specific fields assigned to it and this call
- // returns nothing
- if (reply == null || reply.vxlanTunnelDetails == null || reply.vxlanTunnelDetails.isEmpty()) {
- LOG.debug(
- "Vxlan tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
- "after delete", key.getName(), index);
- return;
- }
+ LOG.debug("Reading attributes for vxlan tunnel: {}", key.getName());
+ // Dump just a single
+ final VxlanTunnelDump request = new VxlanTunnelDump();
+ request.swIfIndex = index;
+
+ final CompletionStage<VxlanTunnelDetailsReplyDump> swInterfaceVxlanDetailsReplyDumpCompletionStage =
+ getFutureJVpp().vxlanTunnelDump(request);
+ final VxlanTunnelDetailsReplyDump reply =
+ TranslateUtils.getReply(swInterfaceVxlanDetailsReplyDumpCompletionStage.toCompletableFuture());
+
+ // VPP keeps vxlan tunnel interfaces even after they were deleted (optimization)
+ // However there ar no longer any vxlan tunnel specific fields assigned to it and this call
+ // returns nothing
+ if (reply == null || reply.vxlanTunnelDetails == null || reply.vxlanTunnelDetails.isEmpty()) {
+ LOG.debug(
+ "Vxlan tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
+ "after delete", key.getName(), index);
+ return;
+ }
+
+ checkState(reply.vxlanTunnelDetails.size() == 1,
+ "Unexpected number of returned vxlan tunnels: {} for tunnel: {}", reply.vxlanTunnelDetails, key.getName());
+ LOG.trace("Vxlan tunnel: {} attributes returned from VPP: {}", key.getName(), reply);
- checkState(reply.vxlanTunnelDetails.size() == 1,
- "Unexpected number of returned vxlan tunnels: {} for tunnel: {}", reply.vxlanTunnelDetails, key.getName());
- LOG.trace("Vxlan tunnel: {} attributes returned from VPP: {}", key.getName(), reply);
-
- final VxlanTunnelDetails swInterfaceVxlanDetails = reply.vxlanTunnelDetails.get(0);
- if (swInterfaceVxlanDetails.isIpv6 == 1) {
- final Ipv6Address dstIpv6 =
- new Ipv6Address(parseAddress(swInterfaceVxlanDetails.dstAddress).getHostAddress());
- builder.setDst(new IpAddress(dstIpv6));
- final Ipv6Address srcIpv6 =
- new Ipv6Address(parseAddress(swInterfaceVxlanDetails.srcAddress).getHostAddress());
- builder.setSrc(new IpAddress(srcIpv6));
- } else {
- final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanDetails.dstAddress, 0, 4);
- final Ipv4Address dstIpv4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress());
- builder.setDst(new IpAddress(dstIpv4));
- final byte[] srcBytes = Arrays.copyOfRange(swInterfaceVxlanDetails.srcAddress, 0, 4);
- final Ipv4Address srcIpv4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress());
- builder.setSrc(new IpAddress(srcIpv4));
+ final VxlanTunnelDetails swInterfaceVxlanDetails = reply.vxlanTunnelDetails.get(0);
+ if (swInterfaceVxlanDetails.isIpv6 == 1) {
+ final Ipv6Address dstIpv6 =
+ new Ipv6Address(parseAddress(swInterfaceVxlanDetails.dstAddress).getHostAddress());
+ builder.setDst(new IpAddress(dstIpv6));
+ final Ipv6Address srcIpv6 =
+ new Ipv6Address(parseAddress(swInterfaceVxlanDetails.srcAddress).getHostAddress());
+ builder.setSrc(new IpAddress(srcIpv6));
+ } else {
+ final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanDetails.dstAddress, 0, 4);
+ final Ipv4Address dstIpv4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress());
+ builder.setDst(new IpAddress(dstIpv4));
+ final byte[] srcBytes = Arrays.copyOfRange(swInterfaceVxlanDetails.srcAddress, 0, 4);
+ final Ipv4Address srcIpv4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress());
+ builder.setSrc(new IpAddress(srcIpv4));
+ }
+ builder.setEncapVrfId((long) swInterfaceVxlanDetails.encapVrfId);
+ builder.setVni( new VxlanVni((long) swInterfaceVxlanDetails.vni));
+ LOG.debug("Vxlan tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to readCurrentAttributes for: {}", id);
+ throw new ReadFailedException( id, e );
}
- builder.setEncapVrfId((long) swInterfaceVxlanDetails.encapVrfId);
- builder.setVni(new VxlanVni((long) swInterfaceVxlanDetails.vni));
- LOG.debug("Vxlan tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder);
}
@Nonnull
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java
index 254b83961..d364eca1a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/VxlanGpeCustomizer.java
@@ -43,6 +43,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.VppCallbackException;
+import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.dto.VxlanGpeTunnelDetails;
import org.openvpp.jvpp.dto.VxlanGpeTunnelDetailsReplyDump;
import org.openvpp.jvpp.dto.VxlanGpeTunnelDump;
@@ -77,59 +80,64 @@ public class VxlanGpeCustomizer extends FutureJVppCustomizer
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<VxlanGpe> id,
@Nonnull final VxlanGpeBuilder builder,
@Nonnull final ReadContext ctx) throws ReadFailedException {
- final InterfaceKey key = id.firstKeyOf(Interface.class);
- // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
- // to fill in the context with initial ifc mapping
- final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
- if (!InterfaceUtils.isInterfaceOfType(ctx.getModificationCache(), index, VxlanGpeTunnel.class)) {
- return;
- }
+ try {
+ final InterfaceKey key = id.firstKeyOf(Interface.class);
+ // Relying here that parent InterfaceCustomizer was invoked first (PREORDER)
+ // to fill in the context with initial ifc mapping
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ if (!InterfaceUtils.isInterfaceOfType(ctx.getModificationCache(), index, VxlanGpeTunnel.class)) {
+ return;
+ }
- LOG.debug("Reading attributes for VxlanGpe tunnel: {}", key.getName());
- // Dump just a single
- final VxlanGpeTunnelDump request = new VxlanGpeTunnelDump();
- request.swIfIndex = index;
+ LOG.debug("Reading attributes for VxlanGpe tunnel: {}", key.getName());
+ // Dump just a single
+ final VxlanGpeTunnelDump request = new VxlanGpeTunnelDump();
+ request.swIfIndex = index;
- final CompletionStage<VxlanGpeTunnelDetailsReplyDump> swInterfaceVxlanGpeDetailsReplyDumpCompletionStage =
- getFutureJVpp().vxlanGpeTunnelDump(request);
- final VxlanGpeTunnelDetailsReplyDump reply =
- TranslateUtils.getReply(swInterfaceVxlanGpeDetailsReplyDumpCompletionStage.toCompletableFuture());
+ final CompletionStage<VxlanGpeTunnelDetailsReplyDump> swInterfaceVxlanGpeDetailsReplyDumpCompletionStage =
+ getFutureJVpp().vxlanGpeTunnelDump(request);
+ final VxlanGpeTunnelDetailsReplyDump reply =
+ TranslateUtils.getReply(swInterfaceVxlanGpeDetailsReplyDumpCompletionStage.toCompletableFuture());
- // VPP keeps VxlanGpe tunnel interfaces even after they were deleted (optimization)
- // However there are no longer any VxlanGpe tunnel specific fields assigned to it and this call
- // returns nothing
- if (reply == null || reply.vxlanGpeTunnelDetails == null || reply.vxlanGpeTunnelDetails.isEmpty()) {
- LOG.debug(
- "VxlanGpe tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
- "after delete", key.getName(), index);
- return;
- }
+ // VPP keeps VxlanGpe tunnel interfaces even after they were deleted (optimization)
+ // However there are no longer any VxlanGpe tunnel specific fields assigned to it and this call
+ // returns nothing
+ if (reply == null || reply.vxlanGpeTunnelDetails == null || reply.vxlanGpeTunnelDetails.isEmpty()) {
+ LOG.debug(
+ "VxlanGpe tunnel {}, id {} has no attributes assigned in VPP. Probably is a leftover interface placeholder" +
+ "after delete", key.getName(), index);
+ return;
+ }
- checkState(reply.vxlanGpeTunnelDetails.size() == 1,
- "Unexpected number of returned VxlanGpe tunnels: {} for tunnel: {}", reply.vxlanGpeTunnelDetails, key.getName());
- LOG.trace("VxlanGpe tunnel: {} attributes returned from VPP: {}", key.getName(), reply);
+ checkState(reply.vxlanGpeTunnelDetails.size() == 1,
+ "Unexpected number of returned VxlanGpe tunnels: {} for tunnel: {}", reply.vxlanGpeTunnelDetails, key.getName());
+ LOG.trace("VxlanGpe tunnel: {} attributes returned from VPP: {}", key.getName(), reply);
- final VxlanGpeTunnelDetails swInterfaceVxlanGpeDetails = reply.vxlanGpeTunnelDetails.get(0);
- if (swInterfaceVxlanGpeDetails.isIpv6 == 1) {
- final Ipv6Address remote6 =
- new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.remote).getHostAddress());
- builder.setRemote(new IpAddress(remote6));
- final Ipv6Address local6 =
- new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.local).getHostAddress());
- builder.setLocal(new IpAddress(local6));
- } else {
- final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanGpeDetails.remote, 0, 4);
- final Ipv4Address remote4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress());
- builder.setRemote(new IpAddress(remote4));
- final byte[] srcBytes = Arrays.copyOfRange(swInterfaceVxlanGpeDetails.local, 0, 4);
- final Ipv4Address local4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress());
- builder.setLocal(new IpAddress(local4));
- }
- builder.setVni(new VxlanGpeVni((long) swInterfaceVxlanGpeDetails.vni));
+ final VxlanGpeTunnelDetails swInterfaceVxlanGpeDetails = reply.vxlanGpeTunnelDetails.get(0);
+ if (swInterfaceVxlanGpeDetails.isIpv6 == 1) {
+ final Ipv6Address remote6 =
+ new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.remote).getHostAddress());
+ builder.setRemote(new IpAddress(remote6));
+ final Ipv6Address local6 =
+ new Ipv6Address(parseAddress(swInterfaceVxlanGpeDetails.local).getHostAddress());
+ builder.setLocal(new IpAddress(local6));
+ } else {
+ final byte[] dstBytes = Arrays.copyOfRange(swInterfaceVxlanGpeDetails.remote, 0, 4);
+ final Ipv4Address remote4 = new Ipv4Address(parseAddress(dstBytes).getHostAddress());
+ builder.setRemote(new IpAddress(remote4));
+ final byte[] srcBytes = Arrays.copyOfRange(swInterfaceVxlanGpeDetails.local, 0, 4);
+ final Ipv4Address local4 = new Ipv4Address(parseAddress(srcBytes).getHostAddress());
+ builder.setLocal(new IpAddress(local4));
+ }
+ builder.setVni(new VxlanGpeVni((long) swInterfaceVxlanGpeDetails.vni));
builder.setNextProtocol(VxlanGpeNextProtocol.forValue(swInterfaceVxlanGpeDetails.protocol));
- builder.setEncapVrfId((long) swInterfaceVxlanGpeDetails.encapVrfId);
- builder.setDecapVrfId((long) swInterfaceVxlanGpeDetails.decapVrfId);
- LOG.debug("VxlanGpe tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder);
+ builder.setEncapVrfId((long) swInterfaceVxlanGpeDetails.encapVrfId);
+ builder.setDecapVrfId((long) swInterfaceVxlanGpeDetails.decapVrfId);
+ LOG.debug("VxlanGpe tunnel: {}, id: {} attributes read as: {}", key.getName(), index, builder);
+ } catch (VppBaseCallException e) {
+ LOG.warn("Failed to readCurrentAttributes for: {}", id);
+ throw new ReadFailedException( id, e );
+ }
}
@Nonnull