Introducing Open_vSwitch Typed Schema wrapper on top of the Schema indepedent Library. 55/8155/1
authorMadhu Venugopal <mavenugo@gmail.com>
Thu, 19 Jun 2014 04:13:42 +0000 (21:13 -0700)
committerMadhu Venugopal <mavenugo@gmail.com>
Thu, 19 Jun 2014 04:13:42 +0000 (21:13 -0700)
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 <mavenugo@gmail.com>
schemas/Open_vSwitch/pom.xml [new file with mode: 0755]
schemas/Open_vSwitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/Bridge.java [new file with mode: 0644]
schemas/Open_vSwitch/src/main/java/org/opendaylight/ovsdb/schema/openvswitch/OpenVSwitch.java [new file with mode: 0644]
schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/OvsdbTestBase.java [new file with mode: 0644]
schemas/Open_vSwitch/src/test/java/org/opendaylight/ovsdb/schema/openvswitch/TypedVSwitchdSchemaIT.java [new file with mode: 0644]
schemas/Open_vSwitch/src/test/resources/logback.xml [new file with mode: 0644]

diff --git a/schemas/Open_vSwitch/pom.xml b/schemas/Open_vSwitch/pom.xml
new file mode 100755 (executable)
index 0000000..fe27b07
--- /dev/null
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.opendaylight.ovsdb</groupId>
+    <artifactId>ovsdb_commons</artifactId>
+    <version>1.1.0-SNAPSHOT</version>
+    <relativePath>../../commons/parent</relativePath>
+  </parent>
+  <artifactId>ovsdb_schema.Open_vSwitch</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <properties>
+    <skip.integrationtest>true</skip.integrationtest>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-classic</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-annotations</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-core</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+      <version>2.1</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+      <version>${guava.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+      <version>1.4</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+      <version>1.0</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.3</version>
+    </dependency>
+    <dependency>
+      <groupId>equinoxSDK381</groupId>
+      <artifactId>org.eclipse.osgi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.netty</groupId>
+      <artifactId>netty-all</artifactId>
+      <version>4.0.10.Final</version>
+    </dependency>
+    <dependency>
+      <groupId>javax.portlet</groupId>
+      <artifactId>portlet-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpcore-nio</artifactId>
+      <version>4.2.1</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.ovsdb</groupId>
+      <artifactId>ovsdb_library</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <testResources>
+      <testResource>
+        <filtering>true</filtering>
+        <directory>src/test/resources</directory>
+      </testResource>
+    </testResources>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <version>2.3.6</version>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Import-Package>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,
+                *</Import-Package>
+            <Embed-Transitive>true</Embed-Transitive>
+            <Export-Package>org.opendaylight.ovsdb.lib.schema.vswitchd</Export-Package>
+          </instructions>
+          <manifestLocation>${project.basedir}/META-INF</manifestLocation>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-failsafe-plugin</artifactId>
+        <configuration>
+          <skipITs>${skip.integrationtest}</skipITs>
+          <includes>
+            <include>**/*IT*</include>
+          </includes>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.16</version>
+        <configuration>
+          <excludes>
+            <!--  Exclude integration tests -->
+            <exclude>**/*IT*</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <scm>
+    <connection>scm:git:ssh://git.opendaylight.org:29418/ovsdb.git</connection>
+    <developerConnection>scm:git:ssh://git.opendaylight.org:29418/ovsdb.git</developerConnection>
+    <tag>HEAD</tag>
+    <url>https://wiki.opendaylight.org/view/OVSDB_Integration:Main</url>
+  </scm>
+
+  <profiles>
+    <profile>
+      <id>integrationtest</id>
+      <activation></activation>
+      <properties>
+        <skip.integrationtest>false</skip.integrationtest>
+      </properties>
+    </profile>
+  </profiles>
+</project>
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 (file)
index 0000000..e92eac0
--- /dev/null
@@ -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<GenericTableSchema, String> 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<GenericTableSchema, Set<UUID>> getPortsColumn();
+
+    @TypedColumn(name="ports", method=MethodType.SETDATA)
+    public void setPorts(Set<UUID> ports);
+
+
+    @TypedColumn(name="mirrors", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<UUID>> getMirrorsColumn();
+
+    @TypedColumn(name="mirrors", method=MethodType.SETDATA)
+    public void setMirrors(Set<UUID> mirrors);
+
+
+    @TypedColumn(name="controller", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<UUID>> getControllerColumn();
+
+    @TypedColumn(name="controller", method=MethodType.SETDATA)
+    public void setController(Set<UUID> controller);
+
+
+    @TypedColumn(name="datapath_id", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<String>> getDatapathIdColumn();
+
+    @TypedColumn(name="datapath_id", method=MethodType.SETDATA)
+    public void setDatapathId(Set<String> datapathId);
+
+    @TypedColumn(name="datapath_type", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, String> getDatapathTypeColumn();
+
+    @TypedColumn(name="datapath_type", method=MethodType.SETDATA)
+    public void setDatapathType(String datapathType);
+
+
+    @TypedColumn(name="fail_mode", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<String>> getFailModeColumn();
+
+    @TypedColumn(name="fail_mode", method=MethodType.SETDATA)
+    public void setFailMode(Set<String> failMode);
+
+
+    @TypedColumn(name="flood_vlans", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<Integer>> getFloodVlansColumn();
+
+    @TypedColumn(name="flood_vlans", method=MethodType.SETDATA)
+    public void setFloodVlans(Set<Integer> vlans);
+
+
+    @TypedColumn(name="sflow", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<UUID>> getSflowColumn();
+
+    @TypedColumn(name="sflow", method=MethodType.SETDATA)
+    public void setSflow(Set<UUID> sflow);
+
+
+    @TypedColumn(name="netflow", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<UUID>> getNetflowColumn();
+
+    @TypedColumn(name="netflow", method=MethodType.SETDATA)
+    public void setNetflow(Set<UUID> netflow);
+
+
+    @TypedColumn(name="flow_tables", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Map<Integer, UUID>> getFlowTablesColumn();
+
+    @TypedColumn(name="flow_tables", method=MethodType.SETDATA)
+    public void setFlowTables(Map<Integer, UUID> flowTables);
+
+
+    @TypedColumn(name="status", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Map<String, String>> getStatusColumn();
+
+    @TypedColumn(name="status", method=MethodType.SETDATA)
+    public void setStatus(Map<String, String> status);
+
+
+    @TypedColumn(name="stp_enable", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Boolean> getStpEnableColumn();
+
+    @TypedColumn(name="stp_enable", method=MethodType.SETDATA)
+    public void setStpEnable(Boolean stp_enable);
+
+
+    @TypedColumn(name="protocols", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<String>> getProtocolsColumn();
+
+    @TypedColumn(name="protocols", method=MethodType.SETDATA)
+    public void setProtocols(Set<String> protocols);
+
+
+    @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="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);
+
+
+    @TypedColumn(name="ipfix", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<UUID>> getIpfixColumn();
+
+    @TypedColumn(name="ipfix", method=MethodType.SETDATA)
+    public void setIpfix(Set<UUID> 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 (file)
index 0000000..010b119
--- /dev/null
@@ -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<GenericTableSchema, Set<UUID>> getBridgesColumn() ;
+    @TypedColumn(name="bridges", method=MethodType.SETDATA)
+    public void setBridges(Set<UUID> bridges) ;
+
+    @TypedColumn(name="curr_cfg", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Integer> 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<GenericTableSchema, Set<String>> getDbVersionColumn() ;
+    @TypedColumn(name="db_version", method=MethodType.SETDATA)
+    public void setDbVersion(Set<String> dbVersion) ;
+
+    @TypedColumn(name="manager_options", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<UUID>> getManagerOptionsColumn() ;
+    @TypedColumn(name="manager_options", method=MethodType.SETDATA)
+    public void setManagerOptions(Set<UUID> managerOptions) ;
+
+    @TypedColumn(name="status", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Map<String, String>> getStatusColumn() ;
+    @TypedColumn(name="status", method=MethodType.SETDATA)
+    public void setStatus(Map<String, String> status) ;
+
+    @TypedColumn(name="next_cfg", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Integer> getNextCfgColumn() ;
+    @TypedColumn(name="next_cfg", method=MethodType.SETDATA)
+    public void setNextCfg(Integer nextCfg) ;
+
+    @TypedColumn(name="ovs_version", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<String>> getOvsVersionColumn() ;
+    @TypedColumn(name="ovs_version", method=MethodType.SETDATA)
+    public void setOvsVersion(Set<String> ovsVersion) ;
+
+    @TypedColumn(name="ssl", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<UUID>> getSslColumn() ;
+    @TypedColumn(name="ssl", method=MethodType.SETDATA)
+    public void setSsl(Set<UUID> ssl) ;
+
+    @TypedColumn(name="system_type", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<String>> getSystemTypeColumn() ;
+    @TypedColumn(name="system_type", method=MethodType.SETDATA)
+    public void setSystemType(Set<String> systemType) ;
+
+    @TypedColumn(name="system_version", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Set<String>> getSystemVersionColumn() ;
+    @TypedColumn(name="system_version", method=MethodType.SETDATA)
+    public void setSystemVersion(Set<String> systemVersion) ;
+
+    @TypedColumn(name="capabilities", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Map<String, UUID>> getCapabilitiesColumn() ;
+    @TypedColumn(name="capabilities", method=MethodType.SETDATA)
+    public void setCapabilities(Map<String, UUID> capabilities) ;
+
+    @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="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) ;
+
+    @TypedColumn(name="statistics", method=MethodType.GETCOLUMN)
+    public Column<GenericTableSchema, Map<String, Integer>> getStatisticsColumn() ;
+    @TypedColumn(name="statistics", method=MethodType.SETDATA)
+    public void setStatistics(Map<String, Integer> 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 (file)
index 0000000..61434e9
--- /dev/null
@@ -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<SocketChannel>() {
+                @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 (file)
index 0000000..eca7410
--- /dev/null
@@ -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<GenericTableSchema>());
+        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<GenericTableSchema>());
+        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<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 & Update operation results = " + operationResults);
+        testBridgeUuid = operationResults.get(insertOperationIndex).getUuid();
+    }
+    public void testGetDBs() throws ExecutionException, InterruptedException {
+        ListenableFuture<List<String>> databases = ovs.getDatabases();
+        List<String> 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<List<OperationResult>> 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<OperationResult> 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<String> ids) {
+        // TODO Auto-generated method stub
+
+    }
+    @Override
+    public void stolen(Object node, List<String> 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 (file)
index 0000000..70118ce
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<configuration>
+
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <!-- encoders are assigned the type
+             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+        <encoder>
+            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <logger name="org.opendaylight.ovsdb.lib.jsonrpc.JsonRpcEndpoint" level="TRACE" additivity="false">
+        <appender-ref ref="STDOUT" />
+    </logger>
+
+    <!--<logger name="com.lordofthejars.foo" level="INFO" additivity="false">-->
+        <!--<appender-ref ref="STDOUT" />-->
+    <!--</logger>-->
+
+    <root level="INFO">
+        <appender-ref ref="STDOUT" />
+    </root>
+
+</configuration>
\ No newline at end of file