Add Interface Table Columns and Version Info 96/8196/2
authorDave Tucker <djt@redhat.com>
Fri, 20 Jun 2014 21:18:10 +0000 (22:18 +0100)
committerDave Tucker <djt@redhat.com>
Sat, 21 Jun 2014 00:04:17 +0000 (01:04 +0100)
Also adds IT for Port and Interface tables
Additionally fixes camel case errors in OVS Table

Change-Id: I795821a75c162fc72d491176a8ec7cf8651ce718
Signed-off-by: Dave Tucker <djt@redhat.com>
schemas/Open_vSwitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/Interface.java
schemas/Open_vSwitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/OpenVSwitch.java
schemas/Open_vSwitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/Port.java
schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/TypedVSwitchdSchemaIT.java

index 8abea0cb9e3e57a5c0810c710c810fbac480932a..e44c81934617ba17a6953f51c948c047d2d16faa 100644 (file)
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  *
- * Authors : Madhu Venugopal
+ * Authors : Madhu Venugopal, Dave Tucker
  */
 package org.opendaylight.ovsdb.schema.openvswitch;
 
@@ -20,56 +20,177 @@ import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
 import org.opendaylight.ovsdb.lib.schema.typed.TypedColumn;
 import org.opendaylight.ovsdb.lib.schema.typed.TypedTable;
 
-
-/*
- * Reusing the existing Table definitions and many of columns are not defined here
- * TODO : Fill up the missing Columns and include Supported DB Version
+/**
+ * This class is a typed interface to the Bridge Table
  */
 @TypedTable(name="Interface", database="Open_vSwitch")
 public interface Interface extends TypedBaseTable {
 
-    @TypedColumn(name="name", method=MethodType.GETCOLUMN)
+    @TypedColumn(name="name", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
     public Column<GenericTableSchema, String> getNameColumn();
-    @TypedColumn(name="name", method=MethodType.SETDATA)
+    @TypedColumn(name="name", method=MethodType.SETDATA, fromVersion="1.0.0")
     public void setName(String name);
+    @TypedColumn(name="name", method=MethodType.GETDATA, fromVersion="1.0.0")
+    public String getName();
+
+    @TypedColumn(name="type", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+    public Column<GenericTableSchema, String> getTypeColumn();
+    @TypedColumn(name="type", method=MethodType.SETDATA, fromVersion="1.0.0")
+    public void setType(String type);
 
-    @TypedColumn(name="options", method=MethodType.GETCOLUMN)
+    @TypedColumn(name="options", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
     public Column<GenericTableSchema, Map<String, String>> getOptionsColumn();
-    @TypedColumn(name="options", method=MethodType.SETDATA)
+    @TypedColumn(name="options", method=MethodType.SETDATA, fromVersion="1.0.0")
     public void setOptions(Map<String, String> options);
 
-    @TypedColumn(name="type", method=MethodType.GETCOLUMN)
-    public Column<GenericTableSchema, String> getTypeColumn();
-    @TypedColumn(name="type", method=MethodType.SETDATA)
-    public void setType(String type);
+    @TypedColumn(name="ingress_policing_rate", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+    public Column<GenericTableSchema, Set<Integer>> getIngressPolicingRateColumn();
+    @TypedColumn(name="ingress_policing_rate", method=MethodType.SETDATA, fromVersion="1.0.0")
+    public void setIngressPolicingRate(Set<Integer> ingressPolicingRate);
+
+    @TypedColumn(name="ingress_policing_burst", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+    public Column<GenericTableSchema, Set<Integer>> getIngressPolicingBurstColumn();
+    @TypedColumn(name="ingress_policing_burst", method=MethodType.SETDATA, fromVersion="1.0.0")
+    public void setIngressPolicingBurst(Set<Integer> ingressPolicingBurst);
 
-    @TypedColumn(name="ofport", method=MethodType.GETCOLUMN)
-    public Column<GenericTableSchema, Set<BigInteger>> getOfPortColumn();
-    @TypedColumn(name="ofport", method=MethodType.SETDATA)
-    public void setOfPort(Set<BigInteger> ofport);
+    @TypedColumn(name="mac_in_use", method=MethodType.GETCOLUMN, fromVersion="7.1.0")
+    public Column<GenericTableSchema,Set<String>> getMacInUseColumn();
+    @TypedColumn(name="mac_in_use", method=MethodType.SETDATA, fromVersion="7.1.0")
+    public void setMacInUse(Set<String> macInUse);
 
-    @TypedColumn(name="mac", method=MethodType.GETCOLUMN)
+    @TypedColumn(name="mac", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
     public Column<GenericTableSchema, Set<String>> getMacColumn();
-    @TypedColumn(name="mac", method=MethodType.SETDATA)
+    @TypedColumn(name="mac", method=MethodType.SETDATA, fromVersion="1.0.0")
     public void setMac(Set<String> mac);
 
-    @TypedColumn(name="statistics", method=MethodType.GETCOLUMN)
+    @TypedColumn(name="ifindex", method=MethodType.GETCOLUMN, fromVersion="7.2.1")
+    public Column<GenericTableSchema, BigInteger> getIfIndexColumn();
+    @TypedColumn(name="ifindex", method=MethodType.SETDATA, fromVersion="7.2.1")
+    public void setIfIndex(BigInteger ifIndex);
+
+    @TypedColumn(name="external_ids", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+    public Column<GenericTableSchema, Map<String, String>> getExternalIdsColumn();
+    @TypedColumn(name="external_ids", method=MethodType.SETDATA, fromVersion="1.0.0")
+    public void setExternalIds(Map<String, String> externalIds);
+
+    @TypedColumn(name="ofport", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+    public Column<GenericTableSchema, Set<Integer>> getOpenFlowPortColumn();
+    @TypedColumn(name="ofport", method=MethodType.SETDATA, fromVersion="1.0.0")
+    public void setOpenFlowPort(Set<Integer> openFlowPort);
+
+    @TypedColumn(name="ofport_request", method=MethodType.GETCOLUMN, fromVersion="6.2.0")
+    public Column<GenericTableSchema, Set<Integer>> getOpenFlowPortRequestColumn();
+    @TypedColumn(name="ofport_request", method=MethodType.SETDATA, fromVersion="6.2.0")
+    public void setOpenFlowPortRequest(String openFlowPortRequest);
+
+    @TypedColumn(name="bfd", method=MethodType.GETCOLUMN, fromVersion="7.2.0")
+    public Column<GenericTableSchema, Map<String, String>> getBfdColumn();
+    @TypedColumn(name="bfd", method=MethodType.SETDATA, fromVersion="7.2.0")
+    public void setBfd(Map<String, String> bfd);
+
+    @TypedColumn(name="bfd_status", method=MethodType.GETCOLUMN, fromVersion="7.2.0")
+    public Column<GenericTableSchema, Map<String, String>> getBfdStatusColumn();
+    @TypedColumn(name="bfd_status", method=MethodType.SETDATA, fromVersion="7.2.0")
+    public void setBfdStatus(Map<String, String> bfdStatus);
+
+    @TypedColumn(name="monitor", method=MethodType.GETCOLUMN, fromVersion="1.0.0", untilVersion="3.5.0")
+    public Column<GenericTableSchema, String> getMonitorColumn();
+    @TypedColumn(name="monitor", method=MethodType.SETDATA, fromVersion="1.0.0", untilVersion="3.5.0")
+    public void setMonitor(String monitor);
+
+    @TypedColumn(name="cfm_mpid", method=MethodType.GETCOLUMN, fromVersion="4.0.0")
+    public Column<GenericTableSchema, Set<Integer>> getCfmMpidColumn();
+    @TypedColumn(name="cfm_mpid", method=MethodType.SETDATA)
+    public void setCfmMpid(Set<Integer> cfmMpid);
+
+    @TypedColumn(name="cfm_remote_mpid", method=MethodType.GETCOLUMN, fromVersion="4.0.0", untilVersion="5.2.0")
+    public Column<GenericTableSchema, Set<Integer>> getCfmRemoteMpidColumn();
+    @TypedColumn(name="cfm_remote_mpid", method=MethodType.SETDATA, fromVersion="4.0.0", untilVersion="5.2.0")
+    public void setCfmRemoteMpid(Set<Integer> cfmRemoteMpid);
+
+    @TypedColumn(name="cfm_remote_mpids", method=MethodType.GETCOLUMN, fromVersion="6.0.0")
+    public Column<GenericTableSchema, Set<Integer>> getCfmRemoteMpidsColumn();
+    @TypedColumn(name="cfm_remote_mpids", method=MethodType.SETDATA, fromVersion="6.0.0")
+    public void setCfmRemoteMpids(Set<Integer> cfmRemoteMpids);
+
+    @TypedColumn(name="cfm_flap_count", method=MethodType.GETCOLUMN, fromVersion="7.3.0")
+    public Column<GenericTableSchema, Set<Integer>> getCfmFlapCountColumn();
+    @TypedColumn(name="cfm_flap_count", method=MethodType.SETDATA, fromVersion="7.3.0")
+    public void setCfmFlapCount(Set<Integer> cfmFlapCount);
+
+    @TypedColumn(name="cfm_fault", method=MethodType.GETCOLUMN, fromVersion="4.0.0")
+    public Column<GenericTableSchema, Set<Boolean>> getCfmFaultColumn();
+    @TypedColumn(name="cfm_fault", method=MethodType.SETDATA, fromVersion="4.0.0")
+    public void setCfmFault(Set<Boolean> cfmFault);
+
+    @TypedColumn(name="cfm_fault_status", method=MethodType.GETCOLUMN, fromVersion="6.6.0")
+    public Column<GenericTableSchema, Set<String>> getCfmFaultStatusColumn();
+    @TypedColumn(name="cfm_fault_status", method=MethodType.SETDATA, fromVersion="6.6.0")
+    public void setCfmFaultStatus(Set<String> cfmFaultStatus);
+
+    @TypedColumn(name="cfm_remote_opstate", method=MethodType.GETCOLUMN, fromVersion="6.10.0")
+    public Column<GenericTableSchema, Set<String>> getCfmRemoteOpStateColumn();
+    @TypedColumn(name="cfm_remote_opstate", method=MethodType.SETDATA, fromVersion="6.10.0")
+    public void setCfmRemoteOpState(Set<String> cfmRemoteOpState);
+
+    @TypedColumn(name="cfm_health", method=MethodType.GETCOLUMN, fromVersion="6.9.0")
+    public Column<GenericTableSchema, Set<Integer>> getCfmHealthColumn();
+    @TypedColumn(name="cfmHealth", method=MethodType.SETDATA, fromVersion="6.9.0")
+    public void setCfmHealth(Set<Integer> cfmHealth);
+
+    @TypedColumn(name="lacp_current", method=MethodType.GETCOLUMN, fromVersion="3.3.0")
+    public Column<GenericTableSchema, Set<Boolean>> getLacpCurrentColumn();
+    @TypedColumn(name="lacp_current", method=MethodType.SETDATA, fromVersion="3.3.0")
+    public void setLacpCurrent(Set<Boolean> lacpCurrent);
+
+    @TypedColumn(name="other_config", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+    public Column<GenericTableSchema, Map<String, String>> getOtherConfigColumn();
+    @TypedColumn(name="other_config", method=MethodType.SETDATA, fromVersion="1.0.0")
+    public void setOtherConfig(Map<String, String> otherConfig);
+
+    @TypedColumn(name="statistics", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
     public Column<GenericTableSchema, Map<String, Integer>> getStatisticsColumn();
-    @TypedColumn(name="statistics", method=MethodType.SETDATA)
+    @TypedColumn(name="statistics", method=MethodType.SETDATA, fromVersion="1.0.0")
     public void setStatistics(Map<String, Integer> statistics);
 
-    @TypedColumn(name="status", method=MethodType.GETCOLUMN)
+    @TypedColumn(name="status", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
     public Column<GenericTableSchema, Map<String, String>> getStatusColumn();
-    @TypedColumn(name="status", method=MethodType.SETDATA)
+    @TypedColumn(name="status", method=MethodType.SETDATA, fromVersion="1.0.0")
     public void setStatus(Map<String, String> status);
 
-    @TypedColumn(name="other_config", method=MethodType.GETCOLUMN)
-    public Column<GenericTableSchema, Map<String, String>> getOtherConfigColumn();
-    @TypedColumn(name="other_config", method=MethodType.SETDATA)
-    public void setOtherConfig(Map<String, String> otherConfig);
+    @TypedColumn(name="admin_state", method=MethodType.GETCOLUMN, fromVersion="1.0.6")
+    public Column<GenericTableSchema, Set<String>> getAdminStateColumn();
+    @TypedColumn(name="admin_state", method=MethodType.SETDATA, fromVersion="1.0.6")
+    public void setAdminState(Set<String> adminState);
+
+    @TypedColumn(name="link_state", method=MethodType.GETCOLUMN, fromVersion="1.0.6")
+    public Column<GenericTableSchema, Map<String, String>> getLinkStateColumn();
+    @TypedColumn(name="link_state", method=MethodType.SETDATA, fromVersion="1.0.6")
+    public void setLinkState(Map<String, String> linkState);
+
+    @TypedColumn(name="link_resets", method=MethodType.GETCOLUMN, fromVersion="6.2.0")
+    public Column<GenericTableSchema, Set<String>> getLinkResetsColumn();
+    @TypedColumn(name="link_resets", method=MethodType.SETDATA, fromVersion="6.2.0")
+    public void setLinkResets(Set<String> linkResets);
+
+    @TypedColumn(name="link_speed", method=MethodType.GETCOLUMN, fromVersion="1.0.6")
+    public Column<GenericTableSchema, Set<Integer>> getLinkSpeedColumn();
+    @TypedColumn(name="link_speed", method=MethodType.SETDATA, fromVersion="1.0.6")
+    public void setLinkSpeed(Set<Integer>linkSpeed);
+
+    @TypedColumn(name="duplex", method=MethodType.GETCOLUMN, fromVersion="1.0.6")
+    public Column<GenericTableSchema, Set<String>> getDuplexColumn();
+    @TypedColumn(name="duplex", method=MethodType.SETDATA, fromVersion="1.0.6")
+    public void setDuplex(Set<Integer> duplex);
+
+    @TypedColumn(name="mtu", method=MethodType.GETCOLUMN, fromVersion="1.0.6")
+    public Column<GenericTableSchema, Set<Integer>> getMtuColumn();
+    @TypedColumn(name="mtu", method=MethodType.SETDATA, fromVersion="1.0.6")
+    public void setMtu(Set<Integer> mtu);
+
+    @TypedColumn(name="error", method=MethodType.GETCOLUMN, fromVersion="7.7.0")
+    public Column<GenericTableSchema, Set<String>> getErrorColumn();
+    @TypedColumn(name="error", method=MethodType.SETDATA, fromVersion="7.7.0")
+    public void setError(Set<String> error);
 
-    @TypedColumn(name="external_ids", method=MethodType.GETCOLUMN)
-    public Column<GenericTableSchema, Map<String, String>> getExternalIdsColumn();
-    @TypedColumn(name="external_ids", method=MethodType.SETDATA)
-    public void setExternalIds(Map<String, String> externalIds);
 }
index d2e5fe348c2a8b76ea2d55f2e318dc850f2c797a..35132e95cf07064178ebedb6be8edfa66d22c4a2 100644 (file)
@@ -58,14 +58,14 @@ public interface OpenVSwitch extends TypedBaseTable {
     public void setExternalIds(Map<String, String> externalIds);
 
     @TypedColumn(name="next_cfg", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
-    public Column<GenericTableSchema, Integer> getNextCfgColumn();
+    public Column<GenericTableSchema, Integer> getNextConfigColumn();
     @TypedColumn(name="next_cfg", method=MethodType.SETDATA, fromVersion="1.0.0")
-    public void setNextCfg(Integer nextCfg);
+    public void setNextConfig(Integer nextConfig);
 
     @TypedColumn(name="cur_cfg", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
-    public Column<GenericTableSchema, Integer> getCur_cfgColumn();
+    public Column<GenericTableSchema, Integer> getCurrentConfigColumn();
     @TypedColumn(name="cur_cfg", method=MethodType.SETDATA, fromVersion="1.0.0")
-    public void setCur_cfg(Integer cur_cfg);
+    public void setCurrentConfig(Integer currentConfig);
 
     @TypedColumn(name="capabilities", method=MethodType.GETCOLUMN, fromVersion="1.0.0", untilVersion="6.7.0")
     public Column<GenericTableSchema, Map<String, UUID>> getCapabilitiesColumn();
index 6dde418e4e5841e97226cb4f720076f6920c13ab..dd57e3cded338d9eb5f7474bc9f086939309f217 100644 (file)
@@ -31,6 +31,8 @@ public interface Port extends TypedBaseTable {
     public Column<GenericTableSchema, String> getNameColumn();
     @TypedColumn(name="name", method=MethodType.SETDATA, fromVersion="1.0.0")
     public void setName(String name);
+    @TypedColumn(name="name", method=MethodType.GETDATA, fromVersion="1.0.0")
+    public String getName();
 
     @TypedColumn(name="interfaces", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
     public Column<GenericTableSchema, Set<UUID>> getInterfacesColumn();
index 01a8f0e8ef05dac64e53dfcbdd9902fb5ca79a7a..cd36d912d58b83879fca3f9466380fadf69abdb6 100644 (file)
@@ -14,12 +14,14 @@ import static org.opendaylight.ovsdb.lib.operations.Operations.op;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.util.HashMap;
+import java.math.BigInteger;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
+import com.google.common.collect.ImmutableSet;
 import junit.framework.Assert;
 
 import org.junit.After;
@@ -63,6 +65,7 @@ public class TypedVSwitchdSchemaIT extends OvsdbTestBase {
         this.monitorTables();
         this.createTypedBridge();
         this.createTypedController();
+        this.testCreateTypedPortandInterface();
     }
 
     private void createTypedBridge() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
@@ -147,7 +150,7 @@ public class TypedVSwitchdSchemaIT extends OvsdbTestBase {
                         .value(controller2.getTargetColumn()))
                 .add(op.mutate(bridge.getSchema())
                         .addMutation(bridge.getControllerColumn().getSchema(), Mutator.INSERT,
-                                     Sets.newHashSet(new UUID(transactionUuidStr)))
+                                Sets.newHashSet(new UUID(transactionUuidStr)))
                         .where(bridge.getNameColumn().getSchema().opEqual(testBridgeName))
                         .build());
 
@@ -167,6 +170,50 @@ public class TypedVSwitchdSchemaIT extends OvsdbTestBase {
         Assert.assertEquals(2, monitoredBridge.getControllerColumn().getData().size());
     }
 
+    private void testCreateTypedPortandInterface() throws InterruptedException, ExecutionException{
+        String portUuidStr = "testPort";
+        String intfUuidStr = "testIntf";
+        Port port = ovs.createTypedRowWrapper(Port.class);
+        port.setName("testPort");
+        port.setTag(ImmutableSet.of(BigInteger.ONE));
+        port.setMac(ImmutableSet.of("00:00:00:00:00:01"));
+        port.setInterfaces(ImmutableSet.of(new UUID(intfUuidStr)));
+
+        Interface intf = ovs.createTypedRowWrapper(Interface.class);
+        intf.setName(port.getNameColumn().getData());
+        intf.setExternalIds(ImmutableMap.of("vm-id", "12345abcedf78910"));
+
+        Bridge bridge = ovs.getTypedRowWrapper(Bridge.class, null);
+        TransactionBuilder transactionBuilder = ovs.transactBuilder()
+                .add(op.insert(port.getSchema())
+                        .withId(portUuidStr)
+                        .value(port.getNameColumn())
+                        .value(port.getMacColumn()))
+                .add(op.insert(intf.getSchema())
+                        .withId(intfUuidStr)
+                        .value(intf.getNameColumn()))
+                .add(op.update(port.getSchema())
+                        .set(port.getTagColumn())
+                        .set(port.getMacColumn())
+                        .set(port.getInterfacesColumn())
+                        .where(port.getNameColumn().getSchema().opEqual(port.getName()))
+                        .build())
+                .add(op.update(intf.getSchema())
+                        .set(intf.getExternalIdsColumn())
+                        .where(intf.getNameColumn().getSchema().opEqual(intf.getName()))
+                        .build())
+                .add(op.mutate(bridge.getSchema())
+                        .addMutation(bridge.getPortsColumn().getSchema(), Mutator.INSERT, Sets.newHashSet(new UUID(portUuidStr)))
+                        .where(bridge.getNameColumn().getSchema().opEqual(testBridgeName))
+                        .build());
+        ListenableFuture<List<OperationResult>> results = transactionBuilder.execute();
+        List<OperationResult> operationResults = results.get();
+        Assert.assertFalse(operationResults.isEmpty());
+        // Check if Results matches the number of operations in transaction
+        Assert.assertEquals(transactionBuilder.getOperations().size(), operationResults.size());
+        System.out.println("Insert & Mutate operation results for Port and Interface = " + operationResults);
+    }
+
     public void testGetDBs() throws ExecutionException, InterruptedException {
         ListenableFuture<List<String>> databases = ovs.getDatabases();
         List<String> dbNames = databases.get();