From: Madhu Venugopal Date: Thu, 19 Jun 2014 04:13:42 +0000 (-0700) Subject: Introducing Open_vSwitch Typed Schema wrapper on top of the Schema indepedent Library. X-Git-Tag: release/helium~170^2~71^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=1ccf1d960fe163b7a6eab2adeb6f11bf682866bf;p=ovsdb.git Introducing Open_vSwitch Typed Schema wrapper on top of the Schema indepedent Library. Adding Bridge & OpenVSwitch Tables along with IT for these 2 tables. These tables are refactored from the old plugin and hence not all Columns are statically Typed yet. Those will be added gradually based on usage pattern. More OpenVSwitch tables will be added soon. Change-Id: I1d253df432937281f2303d015cc85c3e91da8b22 Signed-off-by: Madhu Venugopal --- diff --git a/schemas/Open_vSwitch/pom.xml b/schemas/Open_vSwitch/pom.xml new file mode 100755 index 000000000..fe27b0701 --- /dev/null +++ b/schemas/Open_vSwitch/pom.xml @@ -0,0 +1,180 @@ + + + 4.0.0 + + org.opendaylight.ovsdb + ovsdb_commons + 1.1.0-SNAPSHOT + ../../commons/parent + + ovsdb_schema.Open_vSwitch + 1.0.0-SNAPSHOT + bundle + + + true + + + + ch.qos.logback + logback-classic + + + ch.qos.logback + logback-core + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.google.code.gson + gson + 2.1 + compile + + + com.google.guava + guava + ${guava.version} + + + commons-codec + commons-codec + 1.4 + true + + + commons-collections + commons-collections + 1.0 + + + commons-lang + commons-lang + 2.3 + + + equinoxSDK381 + org.eclipse.osgi + + + io.netty + netty-all + 4.0.10.Final + + + javax.portlet + portlet-api + 2.0 + + + junit + junit + + + org.apache.httpcomponents + httpcore-nio + 4.2.1 + true + + + org.opendaylight.ovsdb + ovsdb_library + 1.0.0-SNAPSHOT + + + org.slf4j + slf4j-api + + + + + + + true + src/test/resources + + + + + org.apache.felix + maven-bundle-plugin + 2.3.6 + true + + + org.opendaylight.ovsdb.lib, + org.opendaylight.ovsdb.lib.table, + org.opendaylight.ovsdb.lib.jsonrpc, + org.opendaylight.ovsdb.lib.notation, + org.opendaylight.ovsdb.lib.database, + org.opendaylight.ovsdb.lib.operations, + org.opendaylight.ovsdb.lib.message, + org.opendaylight.ovsdb.lib.schema, + org.opendaylight.ovsdb.lib.schema.typed, + org.apache.commons.lang3.builder, + org.apache.commons.lang3.tuple, + org.apache.felix.dm, + org.slf4j, + org.eclipse.osgi.framework.console, + org.osgi.framework, + javax.net.ssl, + * + true + org.opendaylight.ovsdb.lib.schema.vswitchd + + ${project.basedir}/META-INF + + + + org.apache.maven.plugins + maven-failsafe-plugin + + ${skip.integrationtest} + + **/*IT* + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.16 + + + + **/*IT* + + + + + + + scm:git:ssh://git.opendaylight.org:29418/ovsdb.git + scm:git:ssh://git.opendaylight.org:29418/ovsdb.git + HEAD + https://wiki.opendaylight.org/view/OVSDB_Integration:Main + + + + + integrationtest + + + false + + + + diff --git a/schemas/Open_vSwitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/Bridge.java b/schemas/Open_vSwitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/Bridge.java new file mode 100644 index 000000000..e92eac026 --- /dev/null +++ b/schemas/Open_vSwitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/Bridge.java @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * This program and the accompanying materials are made available under the + * 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 + */ + +package org.opendaylight.ovsdb.schema.openvswitch; +import java.util.Map; +import java.util.Set; + +import org.opendaylight.ovsdb.lib.notation.Column; +import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.schema.GenericTableSchema; +import org.opendaylight.ovsdb.lib.schema.typed.MethodType; +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 some of columns are not defined here + * TODO : Fill up the missing Columns and include Supported DB Version + */ + +@TypedTable(name="Bridge", database="Open_vSwitch") +public interface Bridge extends TypedBaseTable { + + @TypedColumn(name="name", method=MethodType.GETCOLUMN) + public Column getNameColumn(); + + @TypedColumn(name="name", method=MethodType.GETDATA) + public String getName(); + + @TypedColumn(name="name", method=MethodType.SETDATA) + public void setName(String name); + + + @TypedColumn(name="ports", method=MethodType.GETCOLUMN) + public Column> getPortsColumn(); + + @TypedColumn(name="ports", method=MethodType.SETDATA) + public void setPorts(Set ports); + + + @TypedColumn(name="mirrors", method=MethodType.GETCOLUMN) + public Column> getMirrorsColumn(); + + @TypedColumn(name="mirrors", method=MethodType.SETDATA) + public void setMirrors(Set mirrors); + + + @TypedColumn(name="controller", method=MethodType.GETCOLUMN) + public Column> getControllerColumn(); + + @TypedColumn(name="controller", method=MethodType.SETDATA) + public void setController(Set controller); + + + @TypedColumn(name="datapath_id", method=MethodType.GETCOLUMN) + public Column> getDatapathIdColumn(); + + @TypedColumn(name="datapath_id", method=MethodType.SETDATA) + public void setDatapathId(Set datapathId); + + @TypedColumn(name="datapath_type", method=MethodType.GETCOLUMN) + public Column getDatapathTypeColumn(); + + @TypedColumn(name="datapath_type", method=MethodType.SETDATA) + public void setDatapathType(String datapathType); + + + @TypedColumn(name="fail_mode", method=MethodType.GETCOLUMN) + public Column> getFailModeColumn(); + + @TypedColumn(name="fail_mode", method=MethodType.SETDATA) + public void setFailMode(Set failMode); + + + @TypedColumn(name="flood_vlans", method=MethodType.GETCOLUMN) + public Column> getFloodVlansColumn(); + + @TypedColumn(name="flood_vlans", method=MethodType.SETDATA) + public void setFloodVlans(Set vlans); + + + @TypedColumn(name="sflow", method=MethodType.GETCOLUMN) + public Column> getSflowColumn(); + + @TypedColumn(name="sflow", method=MethodType.SETDATA) + public void setSflow(Set sflow); + + + @TypedColumn(name="netflow", method=MethodType.GETCOLUMN) + public Column> getNetflowColumn(); + + @TypedColumn(name="netflow", method=MethodType.SETDATA) + public void setNetflow(Set netflow); + + + @TypedColumn(name="flow_tables", method=MethodType.GETCOLUMN) + public Column> getFlowTablesColumn(); + + @TypedColumn(name="flow_tables", method=MethodType.SETDATA) + public void setFlowTables(Map flowTables); + + + @TypedColumn(name="status", method=MethodType.GETCOLUMN) + public Column> getStatusColumn(); + + @TypedColumn(name="status", method=MethodType.SETDATA) + public void setStatus(Map status); + + + @TypedColumn(name="stp_enable", method=MethodType.GETCOLUMN) + public Column getStpEnableColumn(); + + @TypedColumn(name="stp_enable", method=MethodType.SETDATA) + public void setStpEnable(Boolean stp_enable); + + + @TypedColumn(name="protocols", method=MethodType.GETCOLUMN) + public Column> getProtocolsColumn(); + + @TypedColumn(name="protocols", method=MethodType.SETDATA) + public void setProtocols(Set protocols); + + + @TypedColumn(name="other_config", method=MethodType.GETCOLUMN) + public Column> getOtherConfigColumn(); + + @TypedColumn(name="other_config", method=MethodType.SETDATA) + public void setOtherConfig(Map otherConfig); + + + @TypedColumn(name="external_ids", method=MethodType.GETCOLUMN) + public Column> getExternalIdsColumn(); + + @TypedColumn(name="external_ids", method=MethodType.SETDATA) + public void setExternalIds(Map externalIds); + + + @TypedColumn(name="ipfix", method=MethodType.GETCOLUMN) + public Column> getIpfixColumn(); + + @TypedColumn(name="ipfix", method=MethodType.SETDATA) + public void setIpfix(Set ipfix); +} diff --git a/schemas/Open_vSwitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/OpenVSwitch.java b/schemas/Open_vSwitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/OpenVSwitch.java new file mode 100644 index 000000000..010b11972 --- /dev/null +++ b/schemas/Open_vSwitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/OpenVSwitch.java @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2013 Red Hat, Inc. + * + * This program and the accompanying materials are made available under the + * 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 + */ +package org.opendaylight.ovsdb.schema.openvswitch; + +import java.util.Map; +import java.util.Set; + +import org.opendaylight.ovsdb.lib.notation.Column; +import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.schema.GenericTableSchema; +import org.opendaylight.ovsdb.lib.schema.typed.MethodType; +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 a few columns are not defined here + * TODO : Fill up the missing Columns and include Supported DB Version + */ + +@TypedTable(name="Open_vSwitch", database="Open_vSwitch") +public interface OpenVSwitch extends TypedBaseTable { + @TypedColumn(name="bridges", method=MethodType.GETCOLUMN) + public Column> getBridgesColumn() ; + @TypedColumn(name="bridges", method=MethodType.SETDATA) + public void setBridges(Set bridges) ; + + @TypedColumn(name="curr_cfg", method=MethodType.GETCOLUMN) + public Column getCurr_cfgColumn() ; + @TypedColumn(name="curr_cfg", method=MethodType.SETDATA) + public void setCurr_cfg(Integer curr_cfg) ; + + @TypedColumn(name="db_version", method=MethodType.GETCOLUMN) + public Column> getDbVersionColumn() ; + @TypedColumn(name="db_version", method=MethodType.SETDATA) + public void setDbVersion(Set dbVersion) ; + + @TypedColumn(name="manager_options", method=MethodType.GETCOLUMN) + public Column> getManagerOptionsColumn() ; + @TypedColumn(name="manager_options", method=MethodType.SETDATA) + public void setManagerOptions(Set managerOptions) ; + + @TypedColumn(name="status", method=MethodType.GETCOLUMN) + public Column> getStatusColumn() ; + @TypedColumn(name="status", method=MethodType.SETDATA) + public void setStatus(Map status) ; + + @TypedColumn(name="next_cfg", method=MethodType.GETCOLUMN) + public Column getNextCfgColumn() ; + @TypedColumn(name="next_cfg", method=MethodType.SETDATA) + public void setNextCfg(Integer nextCfg) ; + + @TypedColumn(name="ovs_version", method=MethodType.GETCOLUMN) + public Column> getOvsVersionColumn() ; + @TypedColumn(name="ovs_version", method=MethodType.SETDATA) + public void setOvsVersion(Set ovsVersion) ; + + @TypedColumn(name="ssl", method=MethodType.GETCOLUMN) + public Column> getSslColumn() ; + @TypedColumn(name="ssl", method=MethodType.SETDATA) + public void setSsl(Set ssl) ; + + @TypedColumn(name="system_type", method=MethodType.GETCOLUMN) + public Column> getSystemTypeColumn() ; + @TypedColumn(name="system_type", method=MethodType.SETDATA) + public void setSystemType(Set systemType) ; + + @TypedColumn(name="system_version", method=MethodType.GETCOLUMN) + public Column> getSystemVersionColumn() ; + @TypedColumn(name="system_version", method=MethodType.SETDATA) + public void setSystemVersion(Set systemVersion) ; + + @TypedColumn(name="capabilities", method=MethodType.GETCOLUMN) + public Column> getCapabilitiesColumn() ; + @TypedColumn(name="capabilities", method=MethodType.SETDATA) + public void setCapabilities(Map capabilities) ; + + @TypedColumn(name="other_config", method=MethodType.GETCOLUMN) + public Column> getOtherConfigColumn() ; + @TypedColumn(name="other_config", method=MethodType.SETDATA) + public void setOtherConfig(Map otherConfig) ; + + @TypedColumn(name="external_ids", method=MethodType.GETCOLUMN) + public Column> getExternalIdsColumn() ; + @TypedColumn(name="external_ids", method=MethodType.SETDATA) + public void setExternalIds(Map externalIds) ; + + @TypedColumn(name="statistics", method=MethodType.GETCOLUMN) + public Column> getStatisticsColumn() ; + @TypedColumn(name="statistics", method=MethodType.SETDATA) + public void setStatistics(Map statistics) ; +} \ No newline at end of file diff --git a/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/OvsdbTestBase.java b/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/OvsdbTestBase.java new file mode 100644 index 000000000..61434e90e --- /dev/null +++ b/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/OvsdbTestBase.java @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * This program and the accompanying materials are made available under the + * 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 + */ + +package org.opendaylight.ovsdb.schema.openvswitch; + +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.AdaptiveRecvByteBufAllocator; +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelOption; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.handler.codec.string.StringEncoder; +import io.netty.util.CharsetUtil; + +import java.io.IOException; +import java.net.InetAddress; +import java.util.Properties; +import java.util.concurrent.ExecutionException; + +import junit.framework.Assert; + +import org.opendaylight.ovsdb.lib.jsonrpc.JsonRpcDecoder; +import org.opendaylight.ovsdb.lib.jsonrpc.JsonRpcEndpoint; +import org.opendaylight.ovsdb.lib.jsonrpc.JsonRpcServiceBinderHandler; +import org.opendaylight.ovsdb.lib.message.OvsdbRPC; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + +public abstract class OvsdbTestBase implements OvsdbRPC.Callback{ + private final static String SERVER_IPADDRESS = "ovsdbserver.ipaddress"; + private final static String SERVER_PORT = "ovsdbserver.port"; + private final static String DEFAULT_SERVER_PORT = "6640"; + + /** + * Represents the Open Vswitch Schema + */ + public final static String OPEN_VSWITCH_SCHEMA = "Open_vSwitch"; + + public Properties loadProperties() { + Properties props = new Properties(System.getProperties()); + return props; + } + + private Channel connect(String addressStr, String portStr) { + InetAddress address; + try { + address = InetAddress.getByName(addressStr); + } catch (Exception e) { + System.out.println("Unable to resolve " + addressStr); + e.printStackTrace(); + return null; + } + + Integer port; + try { + port = Integer.parseInt(portStr); + } catch (NumberFormatException e) { + System.out.println("Invalid port number : " + portStr); + e.printStackTrace(); + return null; + } + + try { + Bootstrap bootstrap = new Bootstrap(); + bootstrap.group(new NioEventLoopGroup()); + bootstrap.channel(NioSocketChannel.class); + bootstrap.option(ChannelOption.TCP_NODELAY, true); + bootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, new AdaptiveRecvByteBufAllocator(65535, 65535, 65535)); + + bootstrap.handler(new ChannelInitializer() { + @Override + public void initChannel(SocketChannel channel) throws Exception { + channel.pipeline().addLast( + //new LoggingHandler(LogLevel.INFO), + new JsonRpcDecoder(100000), + new StringEncoder(CharsetUtil.UTF_8)); + } + }); + + ChannelFuture future = bootstrap.connect(address, port).sync(); + Channel channel = future.channel(); + return channel; + } catch (InterruptedException e) { + System.out.println("Thread was interrupted during connect"); + } + return null; + } + + public OvsdbRPC getTestConnection() throws IOException { + Properties props = loadProperties(); + String address = props.getProperty(SERVER_IPADDRESS); + String port = props.getProperty(SERVER_PORT, DEFAULT_SERVER_PORT); + + if (address == null) { + Assert.fail("Integration Test requires a valid ovsdbserver.ipaddress value.\n" + + "Usage : mvn -Pintegrationtest -Dovsdbserver.ipaddress=x.x.x.x -Dovsdbserver.port=yyyy verify"); + } + Channel channel = this.connect(address, port); + if (channel == null) { + throw new IOException("Failed to connect to ovsdb server"); + } + try { + return this.handleNewConnection(channel); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + return null; + } + + private OvsdbRPC handleNewConnection(Channel channel) throws InterruptedException, ExecutionException { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + objectMapper.setSerializationInclusion(Include.NON_NULL); + + JsonRpcEndpoint factory = new JsonRpcEndpoint(objectMapper, channel); + JsonRpcServiceBinderHandler binderHandler = new JsonRpcServiceBinderHandler(factory); + binderHandler.setContext(channel); + channel.pipeline().addLast(binderHandler); + + OvsdbRPC ovsdb = factory.getClient(channel, OvsdbRPC.class); + ovsdb.registerCallback(this); + return ovsdb; + } +} diff --git a/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/TypedVSwitchdSchemaIT.java b/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/TypedVSwitchdSchemaIT.java new file mode 100644 index 000000000..eca74105a --- /dev/null +++ b/schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/TypedVSwitchdSchemaIT.java @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * This program and the accompanying materials are made available under the + * 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 + */ +package org.opendaylight.ovsdb.schema.openvswitch; + +import static org.opendaylight.ovsdb.lib.operations.Operations.op; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import junit.framework.Assert; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.ovsdb.lib.OvsDBClientImpl; +import org.opendaylight.ovsdb.lib.message.OvsdbRPC; +import org.opendaylight.ovsdb.lib.message.UpdateNotification; +import org.opendaylight.ovsdb.lib.notation.Mutator; +import org.opendaylight.ovsdb.lib.notation.Row; +import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.OperationResult; +import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; +import org.opendaylight.ovsdb.lib.schema.DatabaseSchema; +import org.opendaylight.ovsdb.lib.schema.GenericTableSchema; +import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import com.google.common.util.concurrent.ListenableFuture; + +public class TypedVSwitchdSchemaIT extends OvsdbTestBase { + + Logger logger = LoggerFactory.getLogger(TypedVSwitchdSchemaIT.class); + OvsDBClientImpl ovs; + DatabaseSchema dbSchema = null; + static String testBridgeName = "br_test"; + static UUID testBridgeUuid = null; + + @Test + public void testTypedBridgeOperations() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + this.createTypedBridge(); + } + + private void createTypedBridge() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + GenericTableSchema bridgeSchema = TyperUtils.getTableSchema(dbSchema, Bridge.class); + Bridge bridge = TyperUtils.getTypedRowWrapper(dbSchema, Bridge.class, new Row()); + bridge.setName(testBridgeName); + bridge.setStatus(Maps.newHashMap(ImmutableMap.of("key","value"))); + bridge.setFloodVlans(Sets.newHashSet(34)); + + GenericTableSchema ovsTable = TyperUtils.getTableSchema(dbSchema, OpenVSwitch.class); + OpenVSwitch openVSwitch = TyperUtils.getTypedRowWrapper(dbSchema, OpenVSwitch.class, new Row()); + openVSwitch.setBridges(Sets.newHashSet(new UUID(testBridgeName))); + + int insertOperationIndex = 0; + + TransactionBuilder transactionBuilder = ovs.transactBuilder() + .add(op.insert(bridgeSchema) + .withId(testBridgeName) + .value(bridge.getNameColumn())) + .add(op.update(bridgeSchema) + .set(bridge.getStatusColumn()) + .set(bridge.getFloodVlansColumn()) + .where(bridge.getNameColumn().getSchema().opEqual(bridge.getName())) + .and(bridge.getNameColumn().getSchema().opEqual(bridge.getName())).build()) + .add(op.mutate(ovsTable) + .addMutation(openVSwitch.getBridgesColumn().getSchema(), Mutator.INSERT, + openVSwitch.getBridgesColumn().getData())); + + ListenableFuture> results = transactionBuilder.execute(); + List 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 & Update operation results = " + operationResults); + testBridgeUuid = operationResults.get(insertOperationIndex).getUuid(); + } + public void testGetDBs() throws ExecutionException, InterruptedException { + ListenableFuture> databases = ovs.getDatabases(); + List dbNames = databases.get(); + Assert.assertNotNull(dbNames); + boolean hasOpenVswitchSchema = false; + for(String dbName : dbNames) { + if (dbName.equals(OPEN_VSWITCH_SCHEMA)) { + hasOpenVswitchSchema = true; + break; + } + } + Assert.assertTrue(OPEN_VSWITCH_SCHEMA+" schema is not supported by the switch", hasOpenVswitchSchema); + } + + @Before + public void setUp() throws IOException, ExecutionException, InterruptedException { + if (ovs != null) { + return; + } + OvsdbRPC rpc = getTestConnection(); + if (rpc == null) { + System.out.println("Unable to Establish Test Connection"); + } + ExecutorService executorService = Executors.newFixedThreadPool(3); + ovs = new OvsDBClientImpl(rpc, executorService); + testGetDBs(); + dbSchema = ovs.getSchema(OPEN_VSWITCH_SCHEMA, true).get(); + } + + @After + public void tearDown() throws InterruptedException, ExecutionException { + GenericTableSchema bridgeSchema = TyperUtils.getTableSchema(dbSchema, Bridge.class); + Bridge bridge = TyperUtils.getTypedRowWrapper(dbSchema, Bridge.class, null); + + GenericTableSchema ovsTable = TyperUtils.getTableSchema(dbSchema, OpenVSwitch.class); + OpenVSwitch openVSwitch = TyperUtils.getTypedRowWrapper(dbSchema, OpenVSwitch.class, null); + + ListenableFuture> results = ovs.transactBuilder() + .add(op.delete(bridgeSchema) + .where(bridge.getNameColumn().getSchema().opEqual(testBridgeName)) + .build()) + .add(op.mutate(ovsTable) + .addMutation(openVSwitch.getBridgesColumn().getSchema(), Mutator.DELETE, Sets.newHashSet(testBridgeUuid))) + .add(op.commit(true)) + .execute(); + + List operationResults = results.get(); + System.out.println("Delete operation results = " + operationResults); + } + + @Override + public void update(Object node, UpdateNotification upadateNotification) { + // TODO Auto-generated method stub + + } + @Override + public void locked(Object node, List ids) { + // TODO Auto-generated method stub + + } + @Override + public void stolen(Object node, List ids) { + // TODO Auto-generated method stub + + } +} diff --git a/schemas/Open_vSwitch/src/test/resources/logback.xml b/schemas/Open_vSwitch/src/test/resources/logback.xml new file mode 100644 index 000000000..70118ce54 --- /dev/null +++ b/schemas/Open_vSwitch/src/test/resources/logback.xml @@ -0,0 +1,25 @@ + + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n + + + + + + + + + + + + + + + + \ No newline at end of file