summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-05-19 14:01:09 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-05-19 14:01:11 +0200
commitb5d9c75265a5779ed7404b426f3f91a6b1e07e49 (patch)
tree12c935f9a56b345eb4d1e86d04eecba6f865fbed /v3po/v3po2vpp/src/main/java/io
parent1b5053846c1ee87fb6c23678717a7e7f74487699 (diff)
Adapt to vpp API changes
Changes were introduced by https://gerrit.fd.io/r/#/c/6662/ Change-Id: If5d4866339623c6789ac1674c5c190a4a28f51c6 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterconnectionReadUtils.java60
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizer.java24
2 files changed, 43 insertions, 41 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterconnectionReadUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterconnectionReadUtils.java
index 2111deee0..731619641 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterconnectionReadUtils.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterconnectionReadUtils.java
@@ -19,15 +19,16 @@ package io.fd.hc2vpp.v3po.interfacesstate;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
-import io.fd.hc2vpp.common.translate.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 io.fd.vpp.jvpp.core.types.BridgeDomainSwIf;
+import java.util.Arrays;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
@@ -68,40 +69,41 @@ final class InterconnectionReadUtils implements InterfaceDataTranslator {
LOG.debug("Interface details for interface: {}, details: {}", ifaceName, iface);
final BridgeDomainDetailsReplyDump dumpReply = getDumpReply(id);
- final Optional<BridgeDomainSwIfDetails> bdForInterface = getBridgeDomainForInterface(ifaceId, dumpReply);
- if (bdForInterface.isPresent()) {
- final BridgeDomainSwIfDetails bdSwIfDetails = bdForInterface.get();
- final BridgeBasedBuilder bbBuilder = new BridgeBasedBuilder();
- bbBuilder.setBridgeDomain(bridgeDomainContext.getName(bdSwIfDetails.bdId, ctx.getMappingContext()));
-
- // Set BVI if the bridgeDomainDetails.bviSwIfIndex == current sw if index
- final Optional<BridgeDomainDetails> bridgeDomainForInterface =
- getBridgeDomainForInterface(dumpReply, bdForInterface.get().bdId);
- // Since we already found an interface assigned to a bridge domain, the details for BD must be present
- checkState(bridgeDomainForInterface.isPresent());
- if (bridgeDomainForInterface.get().bviSwIfIndex == ifaceId) {
- bbBuilder.setBridgedVirtualInterface(true);
- } else {
- bbBuilder.setBridgedVirtualInterface(false);
- }
-
- if (bdSwIfDetails.shg != 0) {
- bbBuilder.setSplitHorizonGroup((short) bdSwIfDetails.shg);
+ for (final BridgeDomainDetails bd : dumpReply.bridgeDomainDetails) {
+ final Optional<BridgeDomainSwIf> bdIfAssignment = getBridgeDomainSwIf(ifaceId, bd);
+ if (bdIfAssignment.isPresent()) {
+ final BridgeDomainSwIf bridgeDomainSwIf = bdIfAssignment.get();
+ final BridgeBasedBuilder bbBuilder = new BridgeBasedBuilder();
+ bbBuilder.setBridgeDomain(bridgeDomainContext.getName(bd.bdId, ctx.getMappingContext()));
+
+ // Set BVI if the bridgeDomainDetails.bviSwIfIndex == current sw if index
+ final Optional<BridgeDomainDetails> bridgeDomainForInterface =
+ getBridgeDomainForInterface(dumpReply, bd.bdId);
+ // Since we already found an interface assigned to a bridge domain, the details for BD must be present
+ checkState(bridgeDomainForInterface.isPresent());
+ if (bridgeDomainForInterface.get().bviSwIfIndex == ifaceId) {
+ bbBuilder.setBridgedVirtualInterface(true);
+ } else {
+ bbBuilder.setBridgedVirtualInterface(false);
+ }
+
+ if (bridgeDomainSwIf.shg != 0) {
+ bbBuilder.setSplitHorizonGroup((short) bridgeDomainSwIf.shg);
+ }
+ return bbBuilder.build();
}
- return bbBuilder.build();
}
// TODO HONEYCOMB-190 is there a way to check if interconnection is XconnectBased?
return null;
}
- private Optional<BridgeDomainSwIfDetails> getBridgeDomainForInterface(final int ifaceId,
- final BridgeDomainDetailsReplyDump reply) {
- if (null == reply || null == reply.bridgeDomainSwIfDetails || reply.bridgeDomainSwIfDetails.isEmpty()) {
+ private Optional<BridgeDomainSwIf> getBridgeDomainSwIf(final int ifaceId, @Nonnull final BridgeDomainDetails bd) {
+ if (null == bd.swIfDetails) {
return Optional.empty();
}
// interface can be added to only one BD only
- return reply.bridgeDomainSwIfDetails.stream().filter(a -> a.swIfIndex == ifaceId).findFirst();
+ return Arrays.stream(bd.swIfDetails).filter(el -> el.swIfIndex == ifaceId).findFirst();
}
private Optional<BridgeDomainDetails> getBridgeDomainForInterface(final BridgeDomainDetailsReplyDump reply,
@@ -112,13 +114,13 @@ final class InterconnectionReadUtils implements InterfaceDataTranslator {
private BridgeDomainDetailsReplyDump getDumpReply(@Nonnull final InstanceIdentifier<?> id)
throws ReadFailedException {
// 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
+ // to ask VPP for BD details given interface id/name (TODO HC2VPP-22 add it to vpp.api?)
+ // TODO HC2VPP-22 cache dump result
final BridgeDomainDump request = new BridgeDomainDump();
request.bdId = -1;
final CompletableFuture<BridgeDomainDetailsReplyDump> bdCompletableFuture =
- futureJVppCore.bridgeDomainSwIfDump(request).toCompletableFuture();
+ futureJVppCore.bridgeDomainDump(request).toCompletableFuture();
return getReplyForRead(bdCompletableFuture, id);
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizer.java
index 587c1132d..21f250e86 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizer.java
@@ -18,18 +18,18 @@ package io.fd.hc2vpp.v3po.l2state;
import com.google.common.base.Preconditions;
import com.google.common.primitives.Longs;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.v3po.interfacesstate.InterfaceDataTranslator;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
import io.fd.honeycomb.translate.spi.read.InitializingListReaderCustomizer;
import io.fd.honeycomb.translate.util.RWUtils;
-import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.vpp.jvpp.core.dto.L2FibTableDetails;
+import io.fd.vpp.jvpp.core.dto.L2FibTableDetailsReplyDump;
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;
@@ -59,7 +59,7 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer
private static final Logger LOG = LoggerFactory.getLogger(L2FibEntryCustomizer.class);
- private static final Collector<L2FibTableEntry, ?, L2FibTableEntry> SINGLE_ITEM_COLLECTOR =
+ private static final Collector<L2FibTableDetails, ?, L2FibTableDetails> SINGLE_ITEM_COLLECTOR =
RWUtils.singleItemCollector();
private final NamingContext bdContext;
@@ -84,7 +84,7 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer
try {
// TODO HONEYCOMB-186 use cached l2FibTable
- final L2FibTableEntry entry = dumpL2Fibs(id, bdId).stream().filter(e -> key.getPhysAddress()
+ final L2FibTableDetails entry = dumpL2Fibs(id, bdId).stream().filter(e -> key.getPhysAddress()
.equals(new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(e.mac), 2))))
.collect(SINGLE_ITEM_COLLECTOR);
@@ -105,20 +105,20 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer
}
@Nonnull
- private List<L2FibTableEntry> dumpL2Fibs(final InstanceIdentifier<L2FibEntry> id, final int bdId)
+ private List<L2FibTableDetails> dumpL2Fibs(final InstanceIdentifier<L2FibEntry> id, final int bdId)
throws ReadFailedException {
final L2FibTableDump l2FibRequest = new L2FibTableDump();
l2FibRequest.bdId = bdId;
- final CompletableFuture<L2FibTableEntryReplyDump> l2FibTableDumpCompletableFuture =
+ final CompletableFuture<L2FibTableDetailsReplyDump> l2FibTableDumpCompletableFuture =
getFutureJVpp().l2FibTableDump(l2FibRequest).toCompletableFuture();
- final L2FibTableEntryReplyDump dump = getReplyForRead(l2FibTableDumpCompletableFuture, id);
+ final L2FibTableDetailsReplyDump dump = getReplyForRead(l2FibTableDumpCompletableFuture, id);
- if (null == dump || null == dump.l2FibTableEntry) {
+ if (null == dump || null == dump.l2FibTableDetails) {
return Collections.emptyList();
} else {
- return dump.l2FibTableEntry;
+ return dump.l2FibTableDetails;
}
}