Bug 4790 - 'ifindex' column from Interface table on OVS 01/39801/10
authorRashmi Pujar <rpujar@inocybe.com>
Thu, 2 Jun 2016 21:36:56 +0000 (17:36 -0400)
committerRashmi Pujar <rpujar@inocybe.com>
Tue, 28 Jun 2016 19:03:09 +0000 (15:03 -0400)
Change-Id: I66f7a15a36a7c877cdeb3ca6accf761b16a7a962
Signed-off-by: Rashmi Pujar <rpujar@inocybe.com>
schemas/openvswitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/Interface.java
southbound/southbound-api/src/main/yang/ovsdb.yang
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommand.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommandTest.java
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundIT.java

index 2f2d0d32e7b507c7332d0c2a2b1c8218d27e8292..114cc06b6dac2c85f60bf42a14a3876d5cf24b8c 100644 (file)
@@ -62,9 +62,9 @@ public interface Interface extends TypedBaseTable<GenericTableSchema> {
     void setMac(Set<String> mac);
 
     @TypedColumn(name="ifindex", method=MethodType.GETCOLUMN, fromVersion="7.2.1")
-    Column<GenericTableSchema, Long> getIfIndexColumn();
+    Column<GenericTableSchema, Set<Long>> getIfIndexColumn();
     @TypedColumn(name="ifindex", method=MethodType.SETDATA, fromVersion="7.2.1")
-    void setIfIndex(Long ifIndex);
+    void setIfIndex(Set<Long> ifIndex);
 
     @TypedColumn(name="external_ids", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
     Column<GenericTableSchema, Map<String, String>> getExternalIdsColumn();
index b5ca74a6c687255b71cd2ba5fc658091849684a6..b8f39b730c7dfa69212d25c81b6aa3ca8f85fd21 100755 (executable)
@@ -838,6 +838,14 @@ module ovsdb {
             type string;
         }
 
+        leaf ifindex {
+            description "The ifindex is useful for seamless integration with protocols such as SNMP and sFlow.
+                It is a positive interface index as defined for SNMP MIB-II in RFCs 1213 and 2863 if the interface
+                has one, otherwise 0. It is a read-only column and an integer in the range 0 to 4,294,967,295";
+            type uint32;
+            config false;
+        }
+
         leaf interface-type {
             description "The type of the OVSDB interface";
             type identityref {
index 148f3cdde536884954eda008453fe0787665f76b..06868abb420a5be7b22958cf83dce20da0322042 100644 (file)
@@ -272,6 +272,7 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
                 new Uuid(interf.getUuid().toString()));
         ovsdbTerminationPointBuilder.setInterfaceType(
                 SouthboundMapper.createInterfaceType(type));
+        updateIfIndex(interf, ovsdbTerminationPointBuilder);
         updateOfPort(interf, ovsdbTerminationPointBuilder);
         updateOfPortRequest(interf, ovsdbTerminationPointBuilder);
         updateInterfaceExternalIds(interf, ovsdbTerminationPointBuilder);
@@ -415,6 +416,23 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
                         new Uri(SouthboundConstants.QOS_URI_PREFIX + "://" + qosUuid.toString())));
     }
 
+    private void updateIfIndex(final Interface interf,
+            final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder) {
+        Set<Long> ifIndexSet = null;
+        try {
+            if (interf.getIfIndexColumn() != null) {
+                ifIndexSet = interf.getIfIndexColumn().getData();
+            }
+            if (ifIndexSet != null && !ifIndexSet.isEmpty()) {
+                for (Long ifIndex : ifIndexSet) {
+                    ovsdbTerminationPointBuilder.setIfindex(ifIndex);
+                }
+            }
+        } catch (SchemaVersionMismatchException e) {
+            schemaMismatchLog("ifindex", "Interface", e);
+        }
+    }
+
     private void updateOfPort(final Interface interf,
             final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder) {
 
index 77a35c70bf33a2d97e806070a6fe502ecfa3688b..b38d6b73991e1c43753221733c567e8938406cc6 100644 (file)
@@ -403,6 +403,7 @@ import com.google.common.util.concurrent.CheckedFuture;
         MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceLldp", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
         MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceBfd", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
         MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceBfdStatus", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
+        MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateIfIndex", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
 
         Whitebox.invokeMethod(ovsdbPortUpdateCommand, "updateInterface", interf, OVSDB_INTERFACE_TYPE, ovsdbTerminationPointBuilder);
         verify(ovsdbTerminationPointBuilder).setInterfaceUuid(any(Uuid.class));
index 0db7e2967d3093970381cfb56b8ff0ce9b75065c..b18ec295af2fd9b112f49375d827e660c65e6e57 100644 (file)
@@ -168,6 +168,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
     private static final int OVSDB_ROUNDTRIP_TIMEOUT = 10000;
     private static final String FORMAT_STR = "%s_%s_%d";
     private static final Version AUTOATTACH_FROM_VERSION = Version.fromString("7.11.2");
+    private static final Version IF_INDEX_FROM_VERSION = Version.fromString("7.2.1");
     private static String addressStr;
     private static int portNumber;
     private static String connectionType;
@@ -1266,6 +1267,45 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         return tpList.get(index).getAugmentation(OvsdbTerminationPointAugmentation.class);
     }
 
+    @Test
+    public void testCRUDTerminationPointIfIndex() throws InterruptedException {
+        final boolean isOldSchema = schemaVersion.compareTo(IF_INDEX_FROM_VERSION) < 0;
+        Assume.assumeFalse(isOldSchema);
+        ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
+
+        // Test create ifIndex
+        try (TestBridge testBridge = new TestBridge(connectionInfo, null, SouthboundITConstants.BRIDGE_NAME, null, true,
+                SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
+                true, SouthboundMapper.createDatapathType("netdev"), null, null, null)) {
+            OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
+            Assert.assertNotNull(bridge);
+            LOG.info("bridge: {}", bridge);
+            NodeId nodeId = SouthboundMapper.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
+                    connectionInfo, bridge.getBridgeName()));
+            OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
+                    createGenericOvsdbTerminationPointAugmentationBuilder();
+            String portName = "testIfIndex";
+            ovsdbTerminationBuilder.setName(portName);
+
+            Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+            InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
+            Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
+            Assert.assertNotNull(terminationPointNode);
+
+            // Test read ifIndex
+            List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
+            for (TerminationPoint terminationPoint : terminationPoints) {
+                OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
+                        terminationPoint.getAugmentation(OvsdbTerminationPointAugmentation.class);
+                if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
+                    Long ifIndex = ovsdbTerminationPointAugmentation.getIfindex();
+                    Assert.assertNotNull(ifIndex);
+                    LOG.info("ifIndex: {} for the port:{}", ifIndex, portName);
+                }
+            }
+        }
+    }
+
     @Test
     public void testCRDTerminationPointOfPort() throws InterruptedException {
         final Long OFPORT_EXPECTED = 45002L;