From 8366e77f1751abdae92284a9cbc0d26c126eb4dd Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 2 Jul 2018 07:09:14 +0200 Subject: Add initializer for FIB tables Default FIB tables (ID=0) are created in VPP during startup for both ipv4 and ipv6. In order to prevent oper and cfg mismatch, HC needs to update its cfg during startup. This patch adds initializer for FIB tables which handles that task. Change-Id: Iadae8d545985a07fdb32000d3ca498cf3f9b40ed Signed-off-by: Marek Gradzki --- .../fib/management/read/FibManagementReaderFactory.java | 4 ++-- .../fd/hc2vpp/fib/management/read/FibTableCustomizer.java | 13 +++++++++++-- .../hc2vpp/fib/management/read/FibTableCustomizerTest.java | 12 +++++++++--- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/read/FibManagementReaderFactory.java b/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/read/FibManagementReaderFactory.java index d3adc91f7..4c1de905f 100644 --- a/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/read/FibManagementReaderFactory.java +++ b/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/read/FibManagementReaderFactory.java @@ -19,7 +19,7 @@ package io.fd.hc2vpp.fib.management.read; import com.google.inject.Inject; import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; import io.fd.hc2vpp.fib.management.FibManagementIIds; -import io.fd.honeycomb.translate.impl.read.GenericListReader; +import io.fd.honeycomb.translate.impl.read.GenericInitListReader; import io.fd.honeycomb.translate.read.ReaderFactory; import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; @@ -47,7 +47,7 @@ public final class FibManagementReaderFactory implements ReaderFactory, JvppRepl registry.addStructuralReader(FibManagementIIds.FIB_MNGMNT, FibTableManagementBuilder.class); registry.addStructuralReader(FibManagementIIds.FM_FIB_TABLES, FibTablesBuilder.class); - registry.add(new GenericListReader<>(FibManagementIIds.FM_FTBLS_TABLE, + registry.add(new GenericInitListReader<>(FibManagementIIds.FM_FTBLS_TABLE, new FibTableCustomizer(ipv4DumpManager, ipv6DumpManager))); } diff --git a/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/read/FibTableCustomizer.java b/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/read/FibTableCustomizer.java index 0151a1548..08c8328e4 100644 --- a/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/read/FibTableCustomizer.java +++ b/fib-management/fib-management-impl/src/main/java/io/fd/hc2vpp/fib/management/read/FibTableCustomizer.java @@ -20,7 +20,8 @@ package io.fd.hc2vpp.fib.management.read; import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; 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.spi.read.Initialized; +import io.fd.honeycomb.translate.spi.read.InitializingListReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump; import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump; @@ -40,7 +41,7 @@ import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -class FibTableCustomizer implements ListReaderCustomizer, ByteDataTranslator { +class FibTableCustomizer implements InitializingListReaderCustomizer, ByteDataTranslator { private final DumpCacheManager ipv4DumpManager; private final DumpCacheManager ipv6DumpManager; @@ -116,4 +117,12 @@ class FibTableCustomizer implements ListReaderCustomizer init(@Nonnull final InstanceIdentifier id, + @Nonnull final Table readValue, + @Nonnull final ReadContext ctx) { + return Initialized.create(id, readValue); + } } diff --git a/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/read/FibTableCustomizerTest.java b/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/read/FibTableCustomizerTest.java index 6b2d8c4d7..081553e47 100644 --- a/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/read/FibTableCustomizerTest.java +++ b/fib-management/fib-management-impl/src/test/java/io/fd/hc2vpp/fib/management/read/FibTableCustomizerTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; -import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest; +import io.fd.hc2vpp.common.test.read.InitializingListReaderCustomizerTest; import io.fd.hc2vpp.common.translate.util.AddressTranslator; import io.fd.hc2vpp.fib.management.FibManagementIIds; import io.fd.honeycomb.translate.ModificationCache; @@ -52,8 +52,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib. import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.vpp.fib.table.management.fib.tables.TableKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public class FibTableCustomizerTest extends ListReaderCustomizerTest implements - AddressTranslator { +public class FibTableCustomizerTest extends InitializingListReaderCustomizerTest + implements AddressTranslator { private static final String IPV4_VRF_1 = "IPV4_VRF_1"; private static final IpAddress NEXT_HOP_1 = new IpAddress(new Ipv6Address("a::1")); @@ -165,6 +165,12 @@ public class FibTableCustomizerTest extends ListReaderCustomizerTest initCustomizer() { return new FibTableCustomizer(manager_v4, manager_v6); -- cgit 1.2.3-korg