* 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;
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);
}
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;
this.monitorTables();
this.createTypedBridge();
this.createTypedController();
+ this.testCreateTypedPortandInterface();
}
private void createTypedBridge() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
.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());
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();