HC2VPP-346: use fib-table-list-ref for FIB to ifc assignment 27/13327/1
authorMarek Gradzki <[email protected]>
Tue, 3 Jul 2018 07:56:58 +0000 (09:56 +0200)
committerMarek Gradzki <[email protected]>
Tue, 3 Jul 2018 08:38:42 +0000 (10:38 +0200)
Change-Id: Ie57776ab9784b7c57630b7ea9ce9b96b71feb5a5
Signed-off-by: Marek Gradzki <[email protected]>
v3po/api/src/main/yang/[email protected]
v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/RoutingCustomizer.java
v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/RoutingCustomizer.java
v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceRoutingCustomizerTest.java
v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceRoutingCustomizerTest.java
v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceRoutingCustomizerTest.java
v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/SubInterfaceRoutingCustomizerTest.java

index 09ac984..e25fc2e 100644 (file)
@@ -353,10 +353,10 @@ module v3po {
 
   grouping routing-base-attributes {
     leaf ipv4-vrf-id {
-      type uint32;
+      type fib-management:fib-table-list-ref;
     }
     leaf ipv6-vrf-id {
-      type uint32;
+      type fib-management:fib-table-list-ref;
     }
     description
       "Defines VRF tables used for ipv4 and ipv6 traffic";
index fb5ec33..1f8e236 100644 (file)
@@ -30,6 +30,7 @@ import io.fd.vpp.jvpp.core.future.FutureJVppCore;
 import java.util.concurrent.CompletionStage;
 import javax.annotation.Nonnull;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.RoutingBaseAttributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.VniReference;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -59,13 +60,13 @@ abstract class RoutingCustomizer extends FutureJVppCustomizer implements JvppRep
     }
 
     private void setVrfId(final InstanceIdentifier<? extends RoutingBaseAttributes> id, final int swIfc,
-                          final Long vrfId, boolean isIp6)
+                          final VniReference vniRef, boolean isIp6)
             throws WriteFailedException {
-        if (vrfId == null) {
+        if (vniRef == null || vniRef.getValue() == null) {
             return;
         }
-        final CompletionStage<SwInterfaceSetTableReply> cs = getFutureJVpp()
-                .swInterfaceSetTable(getInterfaceSetTableRequest(swIfc, booleanToByte(isIp6), vrfId.intValue()));
+        final CompletionStage<SwInterfaceSetTableReply> cs = getFutureJVpp().swInterfaceSetTable(
+            getInterfaceSetTableRequest(swIfc, booleanToByte(isIp6), vniRef.getValue().intValue()));
         getReplyForWrite(cs.toCompletableFuture(), id);
     }
 
index 58603c7..9727c4d 100644 (file)
@@ -28,6 +28,7 @@ import io.fd.vpp.jvpp.core.future.FutureJVppCore;
 import java.util.function.Consumer;
 import javax.annotation.Nonnull;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.RoutingBaseAttributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.VniReference;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 abstract class RoutingCustomizer extends FutureJVppCustomizer implements JvppReplyConsumer {
@@ -40,8 +41,8 @@ abstract class RoutingCustomizer extends FutureJVppCustomizer implements JvppRep
     }
 
     protected void readInterfaceRouting(@Nonnull final InstanceIdentifier<? extends RoutingBaseAttributes> id,
-                                        @Nonnull final Consumer<Long> v4VrfConsumer,
-                                        @Nonnull final Consumer<Long> v6VrfConsumer,
+                                        @Nonnull final Consumer<VniReference> v4VrfConsumer,
+                                        @Nonnull final Consumer<VniReference> v6VrfConsumer,
                                         @Nonnull final ReadContext ctx, final String interfaceName)
             throws ReadFailedException {
         final SwInterfaceGetTable request = new SwInterfaceGetTable();
@@ -55,10 +56,10 @@ abstract class RoutingCustomizer extends FutureJVppCustomizer implements JvppRep
                 getReplyForRead(getFutureJVpp().swInterfaceGetTable(request).toCompletableFuture(), id);
 
         if (ip4Reply.vrfId != 0) {
-            v4VrfConsumer.accept(UnsignedInts.toLong(ip4Reply.vrfId));
+            v4VrfConsumer.accept(new VniReference(UnsignedInts.toLong(ip4Reply.vrfId)));
         }
         if (ip6Reply.vrfId != 0) {
-            v6VrfConsumer.accept(UnsignedInts.toLong(ip6Reply.vrfId));
+            v6VrfConsumer.accept(new VniReference(UnsignedInts.toLong(ip6Reply.vrfId)));
         }
     }
 }
index 2ef3272..21d3880 100644 (file)
@@ -41,6 +41,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev14061
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.VppInterfaceAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.interfaces._interface.Routing;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.interfaces._interface.RoutingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.VniReference;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class InterfaceRoutingCustomizerTest extends WriterCustomizerTest {
@@ -144,7 +145,7 @@ public class InterfaceRoutingCustomizerTest extends WriterCustomizerTest {
     }
 
     private Routing routing(final long vrfId) {
-        return new RoutingBuilder().setIpv4VrfId(vrfId).build();
+        return new RoutingBuilder().setIpv4VrfId(new VniReference(vrfId)).build();
     }
 
     private SwInterfaceSetTable expectedRequest(final int vrfId) {
index e7e1087..3b3de2a 100644 (file)
@@ -37,6 +37,7 @@ import org.mockito.Captor;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.VniReference;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev180319.SubinterfaceAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev180319.interfaces._interface.SubInterfaces;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev180319.interfaces._interface.sub.interfaces.SubInterface;
@@ -82,21 +83,21 @@ public class SubInterfaceRoutingCustomizerTest extends WriterCustomizerTest impl
     @Test(expected = IllegalStateException.class)
     public void testWriteFailedV4AddressPresent() throws WriteFailedException {
         when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.of(v4AddressPresent()));
-        final Routing v4Routing = new RoutingBuilder().setIpv4VrfId(4L).build();
+        final Routing v4Routing = new RoutingBuilder().setIpv4VrfId(new VniReference(4L)).build();
         customizer.writeCurrentAttributes(VALID_ID, v4Routing, writeContext);
     }
 
     @Test(expected = IllegalStateException.class)
     public void testWriteFailedV6AddressPresent() throws WriteFailedException {
         when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.of(v6AddressPresent()));
-        final Routing v4Routing = new RoutingBuilder().setIpv4VrfId(4L).build();
+        final Routing v4Routing = new RoutingBuilder().setIpv4VrfId(new VniReference(4L)).build();
         customizer.writeCurrentAttributes(VALID_ID, v4Routing, writeContext);
     }
 
     @Test
     public void testWriteIpv4Vrf() throws WriteFailedException {
         when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.absent());
-        final Routing v4Routing = new RoutingBuilder().setIpv4VrfId(4L).build();
+        final Routing v4Routing = new RoutingBuilder().setIpv4VrfId(new VniReference(4L)).build();
         customizer.writeCurrentAttributes(VALID_ID, v4Routing, writeContext);
         verifySetTableRequest(1, Collections.singleton(request(false, SUBIF_INDEX, 4)));
     }
@@ -105,7 +106,7 @@ public class SubInterfaceRoutingCustomizerTest extends WriterCustomizerTest impl
     @Test
     public void testWriteIpv6Vrf() throws WriteFailedException {
         when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.absent());
-        final Routing v6Routing = new RoutingBuilder().setIpv6VrfId(3L).build();
+        final Routing v6Routing = new RoutingBuilder().setIpv6VrfId(new VniReference(3L)).build();
         customizer.writeCurrentAttributes(VALID_ID, v6Routing, writeContext);
         verifySetTableRequest(1, Collections.singleton(request(true, SUBIF_INDEX, 3)));
     }
@@ -113,8 +114,10 @@ public class SubInterfaceRoutingCustomizerTest extends WriterCustomizerTest impl
     @Test
     public void testUpdateIpv4Vrf() throws WriteFailedException {
         when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.absent());
-        final Routing routingBefore = new RoutingBuilder().setIpv6VrfId(3L).setIpv4VrfId(4L).build();
-        final Routing routingAfter = new RoutingBuilder().setIpv6VrfId(3L).setIpv4VrfId(5L).build();
+        final Routing routingBefore = new RoutingBuilder().setIpv6VrfId(new VniReference(3L))
+            .setIpv4VrfId(new VniReference(4L)).build();
+        final Routing routingAfter = new RoutingBuilder().setIpv6VrfId(new VniReference(3L))
+            .setIpv4VrfId(new VniReference(5L)).build();
         customizer.updateCurrentAttributes(VALID_ID, routingBefore, routingAfter, writeContext);
         verifySetTableRequest(2, ImmutableSet.of(request(false, SUBIF_INDEX, 5),
                 request(true, SUBIF_INDEX, 3)));
@@ -123,8 +126,10 @@ public class SubInterfaceRoutingCustomizerTest extends WriterCustomizerTest impl
     @Test
     public void testUpdateIpv6Vrf() throws WriteFailedException {
         when(writeContext.readBefore(any(InstanceIdentifier.class))).thenReturn(Optional.absent());
-        final Routing routingBefore = new RoutingBuilder().setIpv6VrfId(3L).setIpv4VrfId(4L).build();
-        final Routing routingAfter = new RoutingBuilder().setIpv6VrfId(8L).setIpv4VrfId(4L).build();
+        final Routing routingBefore = new RoutingBuilder().setIpv6VrfId(new VniReference(3L))
+            .setIpv4VrfId(new VniReference(4L)).build();
+        final Routing routingAfter = new RoutingBuilder().setIpv6VrfId(new VniReference(8L))
+            .setIpv4VrfId(new VniReference(4L)).build();
         customizer.updateCurrentAttributes(VALID_ID, routingBefore, routingAfter, writeContext);
         verifySetTableRequest(2, ImmutableSet.of(request(false, SUBIF_INDEX, 4),
                 request(true, SUBIF_INDEX, 8)));
@@ -133,7 +138,7 @@ public class SubInterfaceRoutingCustomizerTest extends WriterCustomizerTest impl
     @Test
     public void testDeleteIpv4Vrf() throws WriteFailedException {
         when(writeContext.readAfter(any(InstanceIdentifier.class))).thenReturn(Optional.absent());
-        final Routing v4Routing = new RoutingBuilder().setIpv4VrfId(4L).build();
+        final Routing v4Routing = new RoutingBuilder().setIpv4VrfId(new VniReference(4L)).build();
         customizer.deleteCurrentAttributes(VALID_ID, v4Routing, writeContext);
         verifySetTableRequest(1, Collections.singleton(request(false, SUBIF_INDEX, DISABLE_VRF)));
     }
@@ -142,7 +147,7 @@ public class SubInterfaceRoutingCustomizerTest extends WriterCustomizerTest impl
     @Test
     public void testDeleteIpv6Vrf() throws WriteFailedException {
         when(writeContext.readAfter(any(InstanceIdentifier.class))).thenReturn(Optional.absent());
-        final Routing v6Routing = new RoutingBuilder().setIpv6VrfId(3L).build();
+        final Routing v6Routing = new RoutingBuilder().setIpv6VrfId(new VniReference(3L)).build();
         customizer.deleteCurrentAttributes(VALID_ID, v6Routing, writeContext);
         verifySetTableRequest(1, Collections.singleton(request(true, SUBIF_INDEX, DISABLE_VRF)));
     }
index 6e8e8be..1af58de 100644 (file)
@@ -34,6 +34,7 @@ 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.rev170607.VppInterfaceStateAugmentationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.interfaces.state._interface.Routing;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170607.interfaces.state._interface.RoutingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.fib.table.management.rev180521.VniReference;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class InterfaceRoutingCustomizerTest extends ReaderCustomizerTest<Routing, RoutingBuilder> {
@@ -72,8 +73,8 @@ public class InterfaceRoutingCustomizerTest extends ReaderCustomizerTest<Routing
         when(api.swInterfaceGetTable(any())).thenReturn(future(tableReply(IP4_VRF_ID))).thenReturn(future(tableReply(IP6_VRF_ID)));
         getCustomizer().readCurrentAttributes(getRoutingId(IF_NAME), builder, ctx);
 
-        verify(builder).setIpv4VrfId(IP4_VRF_ID);
-        verify(builder).setIpv6VrfId(IP6_VRF_ID);
+        verify(builder).setIpv4VrfId(new VniReference(IP4_VRF_ID));
+        verify(builder).setIpv6VrfId(new VniReference(IP6_VRF_ID));
     }
 
     @Test
index 2b5e3fc..fb773a4 100644 (file)
@@ -83,8 +83,8 @@ public class SubInterfaceRoutingCustomizerTest extends ReaderCustomizerTest<Rout
         when(api.swInterfaceGetTable(request(true, SUBIF_ID))).thenReturn(future(reply(IPV6_VRF)));
         final RoutingBuilder routingBuilder = new RoutingBuilder();
         getCustomizer().readCurrentAttributes(VALID_ID, routingBuilder, ctx);
-        assertEquals(IPV4_VRF, routingBuilder.getIpv4VrfId().intValue());
-        assertEquals(IPV6_VRF, routingBuilder.getIpv6VrfId().intValue());
+        assertEquals(IPV4_VRF, routingBuilder.getIpv4VrfId().getValue().intValue());
+        assertEquals(IPV6_VRF, routingBuilder.getIpv6VrfId().getValue().intValue());
     }
 
     @Test
@@ -93,7 +93,7 @@ public class SubInterfaceRoutingCustomizerTest extends ReaderCustomizerTest<Rout
         when(api.swInterfaceGetTable(request(true, SUBIF_ID))).thenReturn(future(reply(NO_VRF)));
         final RoutingBuilder routingBuilder = new RoutingBuilder();
         getCustomizer().readCurrentAttributes(VALID_ID, routingBuilder, ctx);
-        assertEquals(IPV4_VRF, routingBuilder.getIpv4VrfId().intValue());
+        assertEquals(IPV4_VRF, routingBuilder.getIpv4VrfId().getValue().intValue());
         assertNull(routingBuilder.getIpv6VrfId());
     }