diff options
Diffstat (limited to 'v3po/v3po2vpp/src')
5 files changed, 80 insertions, 82 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; } } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/L2CustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/L2CustomizerTest.java index 96645551b..1d58efc5e 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/L2CustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/L2CustomizerTest.java @@ -21,9 +21,14 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; +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.SwInterfaceDetails; +import io.fd.vpp.jvpp.core.types.BridgeDomainSwIf; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -39,11 +44,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.rev170315.l2.base.attributes.Interconnection; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.l2.base.attributes.interconnection.BridgeBasedBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -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; public class L2CustomizerTest extends ReaderCustomizerTest<L2, L2Builder> { @@ -73,24 +73,21 @@ public class L2CustomizerTest extends ReaderCustomizerTest<L2, L2Builder> { VppInterfaceStateAugmentation.class).child(L2.class); } - private void whenBridgeDomainSwIfDumpThenReturn(final List<BridgeDomainSwIfDetails> bdSwIfList, - final List<BridgeDomainDetails> bridgeDomainDetailses) { + private void whenBridgeDomainDumpThenReturn(final List<BridgeDomainDetails> bridgeDomainDetails) { final BridgeDomainDetailsReplyDump reply = new BridgeDomainDetailsReplyDump(); - reply.bridgeDomainSwIfDetails = bdSwIfList; - reply.bridgeDomainDetails = bridgeDomainDetailses; - when(api.bridgeDomainSwIfDump(any(BridgeDomainDump.class))).thenReturn(future(reply)); + reply.bridgeDomainDetails = bridgeDomainDetails; + when(api.bridgeDomainDump(any(BridgeDomainDump.class))).thenReturn(future(reply)); } - private BridgeDomainSwIfDetails generateBdSwIfDetails(final int ifId, final int bdId) { - final BridgeDomainSwIfDetails bdSwIfDetails = new BridgeDomainSwIfDetails(); + private BridgeDomainSwIf generateBdSwIfDetails(final int ifId) { + final BridgeDomainSwIf bdSwIfDetails = new BridgeDomainSwIf(); bdSwIfDetails.swIfIndex = ifId; bdSwIfDetails.shg = 1; - bdSwIfDetails.bdId = bdId; return bdSwIfDetails; } - private Interconnection generateInterconnection(final int ifId, final String bdName, final Boolean bvi) { + private Interconnection generateInterconnection(final String bdName, final Boolean bvi) { final BridgeBasedBuilder bbBuilder = new BridgeBasedBuilder(); bbBuilder.setBridgeDomain(bdName); bbBuilder.setSplitHorizonGroup((short) 1); @@ -118,28 +115,28 @@ public class L2CustomizerTest extends ReaderCustomizerTest<L2, L2Builder> { cache.put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, cachedInterfaceDump); // BVIinterfaceContext - whenBridgeDomainSwIfDumpThenReturn(Collections.singletonList(generateBdSwIfDetails(ifId, bdId)), - Collections.singletonList(generateBdDetails(ifId, bdId))); + whenBridgeDomainDumpThenReturn(Collections.singletonList(generateBdDetails(ifId, ifId, bdId))); L2Builder builder = mock(L2Builder.class); getCustomizer().readCurrentAttributes(getL2Id(ifName), builder, ctx); - verify(builder).setInterconnection(generateInterconnection(ifId, bdName, true)); + verify(builder).setInterconnection(generateInterconnection(bdName, true)); // Not BVI - whenBridgeDomainSwIfDumpThenReturn(Collections.singletonList(generateBdSwIfDetails(ifId, bdId)), - Collections.singletonList(generateBdDetails(99 /* Different ifc is marked as BVI in bd details */, bdId))); + whenBridgeDomainDumpThenReturn(Collections + .singletonList(generateBdDetails(ifId, 99 /* Different ifc is marked as BVI in bd details */, bdId))); builder = mock(L2Builder.class); getCustomizer().readCurrentAttributes(getL2Id(ifName), builder, ctx); - verify(builder).setInterconnection(generateInterconnection(ifId, bdName, null)); + verify(builder).setInterconnection(generateInterconnection(bdName, null)); } - private BridgeDomainDetails generateBdDetails(final int ifId, final int bdId) { + private BridgeDomainDetails generateBdDetails(final int ifId, final int bviSwIfIndex, int bdId) { final BridgeDomainDetails bridgeDomainDetails = new BridgeDomainDetails(); - bridgeDomainDetails.bviSwIfIndex = ifId; + bridgeDomainDetails.bviSwIfIndex = bviSwIfIndex; bridgeDomainDetails.bdId = bdId; + bridgeDomainDetails.swIfDetails = new BridgeDomainSwIf[] {generateBdSwIfDetails(ifId)}; return bridgeDomainDetails; } }
\ No newline at end of file diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizerTest.java index 1633cab5b..e9031c93f 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizerTest.java @@ -22,15 +22,18 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; +import io.fd.vpp.jvpp.VppInvocationException; +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 java.util.Collections; import java.util.List; import java.util.concurrent.ExecutionException; import org.junit.Test; 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.rev170315.BridgeDomains; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.BridgeDomainsState; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.L2FibForward; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.bridge.domains.state.BridgeDomain; @@ -41,10 +44,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.rev170315.l2.fib.attributes.l2.fib.table.L2FibEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.l2.fib.attributes.l2.fib.table.L2FibEntryKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppInvocationException; -import io.fd.vpp.jvpp.core.dto.L2FibTableDump; -import io.fd.vpp.jvpp.core.dto.L2FibTableEntry; -import io.fd.vpp.jvpp.core.dto.L2FibTableEntryReplyDump; public class L2FibEntryCustomizerTest extends ListReaderCustomizerTest<L2FibEntry, L2FibEntryKey, L2FibEntryBuilder> { @@ -78,10 +77,10 @@ public class L2FibEntryCustomizerTest extends ListReaderCustomizerTest<L2FibEntr .child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(address)); } - private void whenL2FibTableDumpThenReturn(final List<L2FibTableEntry> l2FibTableEntryList) + private void whenL2FibTableDumpThenReturn(final List<L2FibTableDetails> l2FibTableEntryList) throws ExecutionException, InterruptedException, VppInvocationException { - final L2FibTableEntryReplyDump reply = new L2FibTableEntryReplyDump(); - reply.l2FibTableEntry = l2FibTableEntryList; + final L2FibTableDetailsReplyDump reply = new L2FibTableDetailsReplyDump(); + reply.l2FibTableDetails = l2FibTableEntryList; when(api.l2FibTableDump(any(L2FibTableDump.class))).thenReturn(future(reply)); } @@ -104,8 +103,8 @@ public class L2FibEntryCustomizerTest extends ListReaderCustomizerTest<L2FibEntr verify(builder).setKey(new L2FibEntryKey(address)); } - private L2FibTableEntry generateL2FibEntry(final long mac) { - final L2FibTableEntry entry = new L2FibTableEntry(); + private L2FibTableDetails generateL2FibEntry(final long mac) { + final L2FibTableDetails entry = new L2FibTableDetails(); entry.mac = mac; entry.swIfIndex = IFACE_ID; return entry; diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2state/L2StateTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2state/L2StateTest.java index 800bb8311..24b85587c 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2state/L2StateTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2state/L2StateTest.java @@ -40,9 +40,9 @@ import io.fd.honeycomb.translate.read.registry.ReaderRegistry; 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.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.Arrays; import java.util.Collections; @@ -107,9 +107,9 @@ public class L2StateTest implements FutureProducer, NamingContextHelper { readerRegistry = getVppStateReader(api, bdContext); } - private void whenL2FibTableDumpThenReturn(final List<L2FibTableEntry> entryList) { - final L2FibTableEntryReplyDump reply = new L2FibTableEntryReplyDump(); - reply.l2FibTableEntry = entryList; + private void whenL2FibTableDumpThenReturn(final List<L2FibTableDetails> entryList) { + final L2FibTableDetailsReplyDump reply = new L2FibTableDetailsReplyDump(); + reply.l2FibTableDetails = entryList; when(api.l2FibTableDump(any(L2FibTableDump.class))).thenReturn(future(reply)); } |