Fix v3po interface type 31/15031/2
authorMichal Cmarada <[email protected]>
Fri, 28 Sep 2018 08:54:43 +0000 (10:54 +0200)
committerMichal Cmarada <[email protected]>
Fri, 28 Sep 2018 09:12:43 +0000 (09:12 +0000)
VPP introduced new flag for interfaces: portType
(see https://gerrit.fd.io/r/#/c/14689/)

This caused API changes and introduced new port types:
 - Normal
 - BVI
 - Unknown unicast (not supported by HC2VPP yet - HC2VPP-389)
This patch fixes the current implementation for normal and BVI interface.

Change-Id: I271aaab9887e3759fa90d9056bafe550c867761d
Signed-off-by: Michal Cmarada <[email protected]>
v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/InterconnectionWriteUtils.java
v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/L2CustomizerTest.java
v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceL2CustomizerTest.java

index a0e2d18..28e4e10 100644 (file)
@@ -28,11 +28,13 @@ import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2BridgeReply;
 import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Xconnect;
 import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2XconnectReply;
 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.L2PortType;
 import java.util.concurrent.CompletionStage;
 import javax.annotation.Nonnull;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev180703.l2.config.attributes.Interconnection;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev180703.l2.config.attributes.interconnection.BridgeBased;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev180703.l2.config.attributes.interconnection.XconnectBased;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev180319.sub._interface.l2.state.attributes.L2;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
@@ -103,28 +105,27 @@ final class InterconnectionWriteUtils implements JvppReplyConsumer {
         checkArgument(bdId > 0, "Unable to set Interconnection for Interface: %s, bridge domain: %s does not exist",
                 ifcName, bdName);
 
-        byte bvi = bb.isBridgedVirtualInterface()
-                ? (byte) 1
-                : (byte) 0;
         byte shg = 0;
         if (bb.getSplitHorizonGroup() != null) {
             shg = bb.getSplitHorizonGroup().byteValue();
         }
 
         final CompletionStage<SwInterfaceSetL2BridgeReply> swInterfaceSetL2BridgeReplyCompletionStage = futureJVppCore
-                .swInterfaceSetL2Bridge(getL2BridgeRequest(swIfIndex, bdId, shg, bvi, enabled));
+                .swInterfaceSetL2Bridge(getL2BridgeRequest(swIfIndex, bdId, shg, bb.isBridgedVirtualInterface(), enabled));
         getReplyForWrite(swInterfaceSetL2BridgeReplyCompletionStage.toCompletableFuture(), id);
 
         LOG.debug("Bridge based interconnection updated successfully for: {}, interconnection: {}", ifcName, bb);
     }
 
     private SwInterfaceSetL2Bridge getL2BridgeRequest(final int swIfIndex, final int bdId, final byte shg,
-                                                      final byte bvi, final byte enabled) {
+                                                      final Boolean bvi, final byte enabled) {
         final SwInterfaceSetL2Bridge swInterfaceSetL2Bridge = new SwInterfaceSetL2Bridge();
         swInterfaceSetL2Bridge.rxSwIfIndex = swIfIndex;
         swInterfaceSetL2Bridge.bdId = bdId;
         swInterfaceSetL2Bridge.shg = shg;
-        swInterfaceSetL2Bridge.bvi = bvi;
+
+        // TODO HC2VPP-389: add support for unknown unicast type
+        swInterfaceSetL2Bridge.portType = bvi ? L2PortType.L2_API_PORT_TYPE_BVI : L2PortType.L2_API_PORT_TYPE_NORMAL;
         swInterfaceSetL2Bridge.enable = enabled;
         return swInterfaceSetL2Bridge;
     }
index c37341c..bd7ced7 100644 (file)
@@ -31,6 +31,7 @@ import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Bridge;
 import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2BridgeReply;
 import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Xconnect;
 import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2XconnectReply;
+import io.fd.vpp.jvpp.core.types.L2PortType;
 import org.junit.Test;
 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;
@@ -137,7 +138,7 @@ public class L2CustomizerTest extends WriterCustomizerTest implements ByteDataTr
         final SwInterfaceSetL2Bridge request = new SwInterfaceSetL2Bridge();
         request.bdId = BD_INDEX;
         request.rxSwIfIndex = IF1_INDEX;
-        request.bvi = booleanToByte(bvi);
+        request.portType = bvi ? L2PortType.L2_API_PORT_TYPE_BVI : L2PortType.L2_API_PORT_TYPE_NORMAL;
         request.enable = booleanToByte(enable);
         request.shg = 123;
         return request;
index 7c5caef..31567e0 100644 (file)
@@ -26,6 +26,7 @@ import io.fd.hc2vpp.common.translate.util.NamingContext;
 import io.fd.honeycomb.translate.write.WriteFailedException;
 import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Bridge;
 import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2BridgeReply;
+import io.fd.vpp.jvpp.core.types.L2PortType;
 import org.junit.Test;
 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;
@@ -101,7 +102,7 @@ public class SubInterfaceL2CustomizerTest extends WriterCustomizerTest implement
         final SwInterfaceSetL2Bridge request = new SwInterfaceSetL2Bridge();
         request.bdId = BD_INDEX;
         request.rxSwIfIndex = SUBIF_INDEX;
-        request.bvi = booleanToByte(bvi);
+        request.portType = bvi ? L2PortType.L2_API_PORT_TYPE_BVI : L2PortType.L2_API_PORT_TYPE_NORMAL;
         request.enable = booleanToByte(enable);
         request.shg = 123;
         return request;