-.idea/\r
-target/\r
-*.class\r
-*.iml\r
-**/target\r
-**/bin\r
-dist\r
-**/logs\r
-products\r
-repository\r
-workspace\r
-*~\r
-target\r
-.classpath\r
-.project\r
-.settings\r
-MANIFEST.MF\r
-.vagrant\r
-.DS_Store\r
+*.class
+**/target
+bin/
+dist
+**/logs
+products
+repository
+workspace
+*~
+target
+.classpath
+.project
+.settings
+MANIFEST.MF
+opendaylight/northbound/integrationtest/logs/*
+*.ipr
+*.iml
+*.iws
+.idea
+*.pyc
+log.html
+output.xml
+report.html
+*.swp
+.gitignore
+target-ide/
host=git.opendaylight.org
port=29418
project=ovsdb.git
+defaultbranch=topic/schema
<version>1.4.2-SNAPSHOT</version>
</parent>
<groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>commons.ovsdb</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <artifactId>ovsdb_commons</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<prerequisites>
<maven>3.0</maven>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>commons.ovsdb</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <artifactId>ovsdb_commons</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>../../commons/parent/</relativePath>
</parent>
</dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>ovsdb</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <artifactId>ovsdb_library</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>ovsdb.neutron</artifactId>
+ <artifactId>ovsdb_neutron</artifactId>
<version>0.7.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>ovsdb.northbound</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <artifactId>ovsdb_northbound</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>ovsdb_plugin</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
--- /dev/null
+<?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_library</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.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.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,
+ 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</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>
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib;
+
+/**
+ * @author Ashwin Raveendran (ashwin at gmail)
+ */
+public interface EchoServiceCallbackFilters {
+}
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib;
+
+/**
+ * Callback that can be registered with {@link OvsdbClient} to
+ * get notified of a lock stolen.
+ * @see <a href="http://tools.ietf.org/html/draft-pfaff-ovsdb-proto-04#section-4.1.10">ovsdb spec</a>
+ * <p/>
+ *
+ * @see OvsdbClient
+ */
+public interface LockAquisitionCallback {
+
+ public void lockAcquired();
+
+}
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib;
+
+/**
+ * Callback that can be registered with {@link org.opendaylight.ovsdb.lib.OvsdbClient} to
+ * get notified of a lock stolen.
+ * @see <a href="http://tools.ietf.org/html/draft-pfaff-ovsdb-proto-04#section-4.1.10">ovsdb spec</a>
+ * <p/>
+ *
+ * @see org.opendaylight.ovsdb.lib.OvsdbClient#lock(String, LockAquisitionCallback, LockStolenCallback)
+ */
+public interface LockStolenCallback {
+
+ public void lockStolen();
+
+}
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib;
+
+import org.opendaylight.ovsdb.lib.message.TableUpdates;
+
+public interface MonitorCallBack {
+
+ void update(TableUpdates result);
+
+ void exception(Throwable t);
+}
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib;
+
+import java.io.Serializable;
+
+public class MonitorHandle implements Serializable{
+ String id;
+
+ public MonitorHandle(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+}
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.lib.message.MonitorRequest;
+import org.opendaylight.ovsdb.lib.notation.Row;
+import org.opendaylight.ovsdb.lib.operations.Operation;
+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.TableSchema;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * The main interface to interact with a device speaking ovsdb protocol in an asynchronous fashion and hence most
+ * operations return a Future object representing the eventual response data from the remote.
+ */
+public interface OvsdbClient {
+
+ /**
+ * Gets the list of database names exposed by this ovsdb capable device
+ * @return list of database names
+ */
+ ListenableFuture<List<String>> getDatabases();
+
+ /**
+ * Asynchronously returns the schema object for a specific database
+ * @param database name of the database schema
+ * @param cacheResult if the results be cached by this instance
+ * @return DatabaseSchema future
+ */
+ ListenableFuture<DatabaseSchema> getSchema(String database, boolean cacheResult);
+
+ /**
+ * Allows for a mini DSL way of collecting the transactions to be executed against the ovsdb instance.
+ * @return TransactionBuilder
+ */
+ TransactionBuilder transactBuilder();
+
+ /**
+ * Execute the list of operations in a single Transactions. Similar to the transactBuilder() method
+ * @param operations List of operations that needs to be part of a transact call
+ * @return Future object representing the result of the transaction. Calling
+ * cancel on the Future would cause OVSDB cancel operation to be fired against
+ * the device.
+ */
+ ListenableFuture<List<OperationResult>> transact(List<Operation> operations);
+
+
+ /**
+ * ovsdb <a href="http://tools.ietf.org/html/draft-pfaff-ovsdb-proto-04#section-4.1.5">monitor</a> operation.
+ * @param monitorRequests represents what needs to be monitored including a client specified monitor handle. This
+ * handle is used to later cancel ({@link #cancelMonitor(MonitorHandle)}) the monitor.
+ * @param callback receives the monitor response
+ */
+ public <E extends TableSchema<E>> MonitorHandle monitor(DatabaseSchema schema, List<MonitorRequest<E>> monitorRequests,
+ MonitorCallBack callback);
+
+ /**
+ * Cancels an existing monitor method.
+ * @param handler Handle identifying a specific monitor request that is being cancelled.
+ * @throws java.lang.IllegalStateException if there is no outstanding monitor request for this handle
+ */
+ public void cancelMonitor(MonitorHandle handler);
+
+ /**
+ * ovsdb <a href="http://tools.ietf.org/html/draft-pfaff-ovsdb-proto-04#section-4.1.8">lock</a> operation.
+ * @param lockId a client specified id for the lock; this can be used for unlocking ({@link #unLock(String)})
+ * @param lockedCallBack Callback to nofify when the lock is acquired
+ * @param stolenCallback Callback to notify when an acquired lock is stolen by another client
+ */
+ public void lock(String lockId, LockAquisitionCallback lockedCallBack, LockStolenCallback stolenCallback);
+
+ /**
+ * ovsdb steal operation, see {@link #lock(String, LockAquisitionCallback, LockStolenCallback)}
+ * @param lockId
+ * @return
+ */
+ public ListenableFuture<Boolean> steal(String lockId);
+
+ /**
+ * ovsdb unlock operaiton, see {@link #unLock(String)}
+ * @param lockId
+ * @return
+ */
+ public ListenableFuture<Boolean> unLock(String lockId);
+
+ /**
+ * Starts the echo service. The {@code callbackFilters} can be used to get notified on the absence of echo
+ * notifications from the remote device and control the frequency of such notifications.
+ * @param callbackFilters callbacks for notifying the client of missing echo calls from remote.
+ */
+ public void startEchoService(EchoServiceCallbackFilters callbackFilters);
+
+ /**
+ * Stops the echo service, i.e echo requests from the remote would not be acknowledged after this call.
+ */
+ public void stopEchoService();
+
+ public OvsdbConnectionInfo getConnectionInfo();
+
+ public DatabaseSchema getDatabaseSchema (String dbName);
+
+ /**
+ * User friendly convenient methods that make use of TyperUtils.getTypedRowWrapper to create a Typed Row Proxy
+ * given the Typed Table Class
+ *
+ * @param klazz Typed Interface
+ * @return Proxy wrapper for the actual raw Row class.
+ */
+ public <T> T createTypedRowWrapper(Class<T> klazz);
+ /**
+ * User friendly convenient methods that make use of getTypedRowWrapper to create a Typed Row Proxy given
+ * DatabaseSchema and Typed Table Class.
+ *
+ * @param dbSchema Database Schema of interest
+ * @param klazz Typed Interface
+ * @return Proxy wrapper for the actual raw Row class.
+ */
+ public <T> T createTypedRowWrapper(DatabaseSchema dbSchema, Class<T> klazz);
+
+ /**
+ * User friendly convenient method to get a Typed Row Proxy given a Typed Table Class and the Row to be wrapped.
+ *
+ * @param klazz Typed Interface
+ * @param row The actual Row that the wrapper is operating on. It can be null if the caller is just interested in getting ColumnSchema.
+ * @return Proxy wrapper for the actual raw Row class.
+ */
+ public <T> T getTypedRowWrapper(final Class<T> klazz, final Row<GenericTableSchema> row);
+
+}
--- /dev/null
+/*
+ * 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.lib;
+
+import java.net.InetAddress;
+
+/**
+ * OvsDBConnection Interface provides OVSDB connection management APIs which includes
+ * both Active and Passive connections.
+ * From the Library perspective, Active OVSDB connections are those that are initiated from
+ * the Controller towards the ovsdb-manager.
+ * While Passive OVSDB connections are those that are initiated from the ovs towards
+ * the controller.
+ *
+ * Applications that use OvsDBConnectionService can use the connect APIs to initiate Active
+ * connections and can listen to the asynchronous Passive connections via registerForPassiveConnection
+ * listener API.
+ */
+
+public interface OvsdbConnection {
+ /**
+ * connect API can be used by the applications to initiate Active connection from
+ * the controller towards ovsdb-server
+ * @param address IP Address of the remote server that hosts the ovsdb server.
+ * @param port Layer 4 port on which the remote ovsdb server is listening on.
+ * @return OvsDBClient The primary Client interface for the ovsdb connection.
+ */
+ public OvsdbClient connect(InetAddress address, int port);
+
+ /**
+ * Method to disconnect an existing connection.
+ * @param client that represents the ovsdb connection.
+ */
+ public void disconnect(OvsdbClient client);
+
+ /**
+ * Method to register a Passive Connection Listener with the ConnectionService.
+ * @param listener Passive Connection listener interested in Passive OVSDB connection requests.
+ */
+ public void registerForPassiveConnection(OvsdbConnectionListener listener);
+}
--- /dev/null
+/*
+ * 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.lib;
+
+import java.net.InetAddress;
+public class OvsdbConnectionInfo {
+ public enum ConnectionType {
+ ACTIVE, PASSIVE
+ }
+
+ InetAddress address;
+ int port;
+ ConnectionType type;
+
+ public OvsdbConnectionInfo(InetAddress address, int port, ConnectionType type) {
+ this.address = address;
+ this.port = port;
+ this.type = type;
+ }
+
+ public InetAddress getAddress() {
+ return address;
+ }
+ public int getPort() {
+ return port;
+ }
+ public ConnectionType getType() {
+ return type;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((address == null) ? 0 : address.hashCode());
+ result = prime * result + port;
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ OvsdbConnectionInfo other = (OvsdbConnectionInfo) obj;
+ if (address == null) {
+ if (other.address != null)
+ return false;
+ } else if (!address.equals(other.address))
+ return false;
+ if (port != other.port)
+ return false;
+ if (type != other.type)
+ return false;
+ return true;
+ }
+ @Override
+ public String toString() {
+ return "ConnectionInfo [address=" + address + ", port=" + port
+ + ", type=" + type + "]";
+ }
+}
--- /dev/null
+/*
+ * 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.lib;
+
+/**
+ * Applications interested in Passive ovsdb connection events should implement this interface.
+ */
+public interface OvsdbConnectionListener {
+ /**
+ * Event thrown to the connection listener when a new Passive connection is established.
+ * @param OvsdbClient that represents the connection.
+ */
+ public void connected(OvsdbClient client);
+
+ /**
+ * Event thrown to the connection listener when an existing connection is terminated.
+ * @param OvsdbClient that represents the connection.
+ */
+ public void disconnected(OvsdbClient client);
+}
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib;
+
+public class ParsingException extends RuntimeException {
+
+ public ParsingException() {
+ }
+
+ public ParsingException(String message) {
+ super(message);
+ }
+
+ public ParsingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ParsingException(Throwable cause) {
+ super(cause);
+ }
+
+ public ParsingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.lib.database;
+
+
+public class Column<E extends Table> {
+ ColumnSchema schema;
+}
*
* Authors : Brent Salisbury, Evan Zeller
*/
-package org.opendaylight.ovsdb.lib.database;\r
-\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-public class ColumnSchema {\r
- @JsonProperty("type")\r
- private OvsdbType type;\r
- @JsonProperty("ephemeral")\r
- private Boolean ephemeral;\r
- @JsonProperty("mutable")\r
- private Boolean mutable;\r
- public OvsdbType getType() {\r
- return type;\r
- }\r
- public Boolean getEphemeral() {\r
- return ephemeral;\r
- }\r
- public Boolean getMutable() {\r
- return mutable;\r
- }\r
- @Override\r
- public String toString() {\r
- return "ColumnSchema [type=" + type + ", ephemeral=" + ephemeral\r
- + ", mutable=" + mutable + "]";\r
- }\r
-}\r
+package org.opendaylight.ovsdb.lib.database;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class ColumnSchema {
+
+ String name;
+
+ @JsonProperty("type")
+ private OvsdbType type;
+
+ @JsonProperty("ephemeral")
+ private Boolean ephemeral;
+
+ @JsonProperty("mutable")
+ private Boolean mutable;
+
+ public OvsdbType getType() {
+ return type;
+ }
+
+ public Boolean getEphemeral() {
+ return ephemeral;
+ }
+
+ public Boolean getMutable() {
+ return mutable;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ @Override
+ public String toString() {
+ return "ColumnType [type=" + type + ", ephemeral=" + ephemeral
+ + ", mutable=" + mutable + "]";
+ }
+
+}
*
* Authors : Brent Salisbury, Evan Zeller
*/
-package org.opendaylight.ovsdb.lib.database;\r
-\r
-import java.util.Map;\r
-\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-public class DatabaseSchema {\r
- @JsonProperty("name")\r
- private String name;\r
- @JsonProperty("version")\r
- private String version;\r
- @JsonProperty("cksum")\r
- private String cksum;\r
- @JsonProperty("tables")\r
- private Map<String, TableSchema> tables;\r
- public String getName() {\r
- return name;\r
- }\r
- public String getVersion() {\r
- return version;\r
- }\r
- public String getCksum() {\r
- return cksum;\r
- }\r
- public Map<String, TableSchema> getTables() {\r
- return tables;\r
- }\r
- @Override\r
- public String toString() {\r
- return "DatabaseSchema [name=" + name + ", version=" + version\r
- + ", cksum=" + cksum + ", tables=" + tables + "]";\r
- }\r
-}\r
+package org.opendaylight.ovsdb.lib.database;
+
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class DatabaseSchema {
+ @JsonProperty("name")
+ private String name;
+
+ @JsonProperty("version")
+ private String version;
+
+ @JsonProperty("cksum")
+ private String cksum;
+
+ @JsonProperty("tables")
+ private Map<String, TableSchema> tables;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getCksum() {
+ return cksum;
+ }
+
+ public Map<String, TableSchema> getTables() {
+ return tables;
+ }
+
+ public TableSchema getTable(String tableName) {
+ return tables.get(tableName);
+ }
+
+ @Override
+ public String toString() {
+ return "DatabaseSchema [name=" + name + ", version=" + version
+ + ", cksum=" + cksum + ", tables=" + tables + "]";
+ }
+}
*
* Authors : Brent Salisbury, Evan Zeller
*/
-package org.opendaylight.ovsdb.lib.database;\r
-\r
-\r
+package org.opendaylight.ovsdb.lib.database;
+
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.opendaylight.ovsdb.plugin.Connection;
-import org.opendaylight.ovsdb.plugin.OvsdbMessage;
-\r
-public class OVSBridge {\r
-\r
- private String uuid;\r
- private String name;\r
-\r
- public OVSBridge(String uuid, String name){\r
- this.uuid = uuid;\r
- this.name = name;\r
- }\r
-\r
- public String getUuid(){\r
- return this.uuid;\r
- }\r
-\r
- public String getName(){\r
- return this.name;\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- public static Map<String, OVSBridge> monitorBridge(Connection connection){\r
- List<String> columns = new ArrayList<String>();\r
- columns.add("_uuid");\r
- columns.add("name");\r
-\r
- Map<String, List<String>> row = new HashMap<String, List<String>>();\r
- row.put("columns", columns);\r
-\r
- Map<String, Map> tables = new HashMap<String, Map>();\r
- tables.put("Bridge", row);\r
-\r
- Object[] params = {"Open_vSwitch", null, tables};\r
-\r
- OvsdbMessage msg = new OvsdbMessage("monitor", params);\r
- Map<String, Object> monitorResponse = new HashMap<String, Object>();\r
-\r
- Map<String, Object> bridgeTable = (Map) monitorResponse.get("Bridge");\r
-\r
- Object[] uuidObjects = bridgeTable.keySet().toArray();\r
- String[] uuids = Arrays.copyOf(uuidObjects, uuidObjects.length, String[].class);\r
-\r
- Map<String, OVSBridge> result = new HashMap<String, OVSBridge>();\r
-\r
- for(String uuid : uuids){\r
- Map<String, Object> newRow = (Map) bridgeTable.get(uuid);\r
- Map<String, Object> newColumns = (Map) newRow.get("new");\r
- String name = (String) newColumns.get("name");\r
- result.put(name, new OVSBridge(uuid, name));\r
- }\r
-\r
- return result;\r
- }\r
-}\r
+public class OVSBridge {
+
+ private String uuid;
+ private String name;
+
+ public OVSBridge(String uuid, String name){
+ this.uuid = uuid;
+ this.name = name;
+ }
+
+ public String getUuid(){
+ return this.uuid;
+ }
+
+ public String getName(){
+ return this.name;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Map<String, OVSBridge> monitorBridge(){
+ List<String> columns = new ArrayList<String>();
+ columns.add("_uuid");
+ columns.add("name");
+
+ Map<String, List<String>> row = new HashMap<String, List<String>>();
+ row.put("columns", columns);
+
+ Map<String, Map> tables = new HashMap<String, Map>();
+ tables.put("Bridge", row);
+
+ Object[] params = {"Open_vSwitch", null, tables};
+
+ Map<String, Object> monitorResponse = new HashMap<String, Object>();
+ Map<String, Object> bridgeTable = (Map) monitorResponse.get("Bridge");
+
+ Object[] uuidObjects = bridgeTable.keySet().toArray();
+ String[] uuids = Arrays.copyOf(uuidObjects, uuidObjects.length, String[].class);
+
+ Map<String, OVSBridge> result = new HashMap<String, OVSBridge>();
+
+ for(String uuid : uuids){
+ Map<String, Object> newRow = (Map) bridgeTable.get(uuid);
+ Map<String, Object> newColumns = (Map) newRow.get("new");
+ String name = (String) newColumns.get("name");
+ result.put(name, new OVSBridge(uuid, name));
+ }
+
+ return result;
+ }
+}
*
* Authors : Brent Salisbury, Evan Zeller
*/
-package org.opendaylight.ovsdb.lib.database;\r
-\r
-\r
-import org.opendaylight.ovsdb.plugin.Connection;\r
-import org.opendaylight.ovsdb.plugin.OvsdbMessage;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-public class OVSInstance {\r
- private String uuid;\r
-\r
- public OVSInstance(){\r
- this.uuid = null;\r
- }\r
-\r
- public OVSInstance(String uuid){\r
- this.uuid = uuid;\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- public static OVSInstance monitorOVS(Connection connection){\r
- List<String> columns = new ArrayList<String>();\r
- columns.add("_uuid");\r
- columns.add("bridges");\r
-\r
- Map<String, List<String>> row = new HashMap<String, List<String>>();\r
- row.put("columns", columns);\r
-\r
- Map<String, Map> tables = new HashMap<String, Map>();\r
- tables.put("Open_vSwitch", row);\r
-\r
- Object[] params = {"Open_vSwitch", null, tables};\r
-\r
- OvsdbMessage msg = new OvsdbMessage("monitor", params);\r
- Map<String, Object> monitorResponse = new HashMap<String, Object>();\r
-\r
- Map<String, Object> vSwitchTable = (Map) monitorResponse.get("Open_vSwitch");\r
- if(vSwitchTable != null){\r
- String uuid = (String) vSwitchTable.keySet().toArray()[0];\r
- return new OVSInstance(uuid);\r
- }\r
- return null;\r
- }\r
-\r
- public String getUuid(){\r
- return this.uuid;\r
- }\r
-\r
-}\r
+package org.opendaylight.ovsdb.lib.database;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class OVSInstance {
+ private String uuid;
+
+ public OVSInstance(){
+ this.uuid = null;
+ }
+
+ public OVSInstance(String uuid){
+ this.uuid = uuid;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static OVSInstance monitorOVS(){
+ List<String> columns = new ArrayList<String>();
+ columns.add("_uuid");
+ columns.add("bridges");
+
+ Map<String, List<String>> row = new HashMap<String, List<String>>();
+ row.put("columns", columns);
+
+ Map<String, Map> tables = new HashMap<String, Map>();
+ tables.put("Open_vSwitch", row);
+
+ Object[] params = {"Open_vSwitch", null, tables};
+
+ Map<String, Object> monitorResponse = new HashMap<String, Object>();
+
+ Map<String, Object> vSwitchTable = (Map) monitorResponse.get("Open_vSwitch");
+ if(vSwitchTable != null){
+ String uuid = (String) vSwitchTable.keySet().toArray()[0];
+ return new OVSInstance(uuid);
+ }
+ return null;
+ }
+
+ public String getUuid(){
+ return this.uuid;
+ }
+
+}
*
* Authors : Brent Salisbury, Evan Zeller
*/
-package org.opendaylight.ovsdb.lib.database;\r
-\r
+package org.opendaylight.ovsdb.lib.database;
+
import com.fasterxml.jackson.annotation.JsonProperty;
-\r
-\r
-public class OvsdbType {\r
- public enum PortType {\r
- VLAN("vlan"),\r
- TUNNEL("Tunnel"),\r
- BONDING("Bonding"),\r
- PATCH("patch"),\r
- INTERNAL("internal");\r
-\r
- private PortType(String name) {\r
- this.name = name;\r
- }\r
-\r
- private String name;\r
-\r
+
+
+public class OvsdbType {
+ public enum PortType {
+ VLAN("vlan"),
+ TUNNEL("Tunnel"),
+ BONDING("Bonding"),
+ PATCH("patch"),
+ INTERNAL("internal");
+
+ private PortType(String name) {
+ this.name = name;
+ }
+
+ private String name;
+
@Override
- public String toString() {\r
- return name;\r
- }\r
- }\r
- public OvsdbType(String type){\r
- this.key = new BaseType(type);\r
- }\r
-\r
- public OvsdbType(@JsonProperty("key") BaseType key, @JsonProperty("value") BaseType value,\r
- @JsonProperty("min") Integer min, @JsonProperty("max") Object max){\r
- this.key = key;\r
- this.value = value;\r
- this.min = min;\r
- this.max = max;\r
- }\r
-\r
- public BaseType key;\r
- public BaseType value;\r
- public Integer min;\r
- public Object max;\r
-\r
- public static class BaseType{\r
-\r
- public BaseType(String type){\r
- this.type = type;\r
- }\r
-\r
- public BaseType(@JsonProperty("type") String type, @JsonProperty("enum") Object ovsdbEnum,\r
- @JsonProperty("minInteger") Integer minInteger, @JsonProperty("maxInteger") Integer maxInteger,\r
- @JsonProperty("minReal") Double minReal, @JsonProperty("maxReal") Double maxReal,\r
- @JsonProperty("minLength") Integer minLength, @JsonProperty("maxLength") Integer maxLength,\r
- @JsonProperty("refTable") String refTable, @JsonProperty("refType") String refType){\r
- this.type = type;\r
- this.ovsdbEnum = ovsdbEnum;\r
- this.minInteger = minInteger;\r
- this.maxInteger = maxInteger;\r
- this.minReal = minReal;\r
- this.maxReal = maxReal;\r
- this.minLength = minLength;\r
- this.maxLength = maxLength;\r
- this.refTable = refTable;\r
- this.refType = refType;\r
- }\r
-\r
- public String type;\r
- public Object ovsdbEnum;\r
- public Integer minInteger;\r
- public Integer maxInteger;\r
- public Double minReal;\r
- public Double maxReal;\r
- public Integer minLength;\r
- public Integer maxLength;\r
- public String refTable;\r
- public String refType;\r
- @Override\r
- public String toString() {\r
- return "BaseType [type=" + type + ", ovsdbEnum="\r
- + ovsdbEnum + ", minInteger=" + minInteger\r
- + ", maxInteger=" + maxInteger + ", minReal=" + minReal\r
- + ", maxReal=" + maxReal + ", minLength=" + minLength\r
- + ", maxLength=" + maxLength + ", refTable=" + refTable\r
- + ", refType=" + refType + "]";\r
- }\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return "OvsdbType [key=" + key + ", value=" + value + ", min=" + min\r
- + ", max=" + max + "]";\r
- }\r
-}\r
+ public String toString() {
+ return name;
+ }
+ }
+ public OvsdbType(String type){
+ this.key = new BaseType(type);
+ }
+
+ public OvsdbType(@JsonProperty("key") BaseType key, @JsonProperty("value") BaseType value,
+ @JsonProperty("min") Integer min, @JsonProperty("max") Object max){
+ this.key = key;
+ this.value = value;
+ this.min = min;
+ this.max = max;
+ }
+
+ public BaseType key;
+ public BaseType value;
+ public Integer min;
+ public Object max;
+
+ public static class BaseType{
+
+ public BaseType(String type){
+ this.type = type;
+ }
+
+ public BaseType(@JsonProperty("type") String type, @JsonProperty("enum") Object ovsdbEnum,
+ @JsonProperty("minInteger") Integer minInteger, @JsonProperty("maxInteger") Integer maxInteger,
+ @JsonProperty("minReal") Double minReal, @JsonProperty("maxReal") Double maxReal,
+ @JsonProperty("minLength") Integer minLength, @JsonProperty("maxLength") Integer maxLength,
+ @JsonProperty("refTable") String refTable, @JsonProperty("refType") String refType){
+ this.type = type;
+ this.ovsdbEnum = ovsdbEnum;
+ this.minInteger = minInteger;
+ this.maxInteger = maxInteger;
+ this.minReal = minReal;
+ this.maxReal = maxReal;
+ this.minLength = minLength;
+ this.maxLength = maxLength;
+ this.refTable = refTable;
+ this.refType = refType;
+ }
+
+ public String type;
+ public Object ovsdbEnum;
+ public Integer minInteger;
+ public Integer maxInteger;
+ public Double minReal;
+ public Double maxReal;
+ public Integer minLength;
+ public Integer maxLength;
+ public String refTable;
+ public String refType;
+ @Override
+ public String toString() {
+ return "BaseType [type=" + type + ", ovsdbEnum="
+ + ovsdbEnum + ", minInteger=" + minInteger
+ + ", maxInteger=" + maxInteger + ", minReal=" + minReal
+ + ", maxReal=" + maxReal + ", minLength=" + minLength
+ + ", maxLength=" + maxLength + ", refTable=" + refTable
+ + ", refType=" + refType + "]";
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "OvsdbType [key=" + key + ", value=" + value + ", min=" + min
+ + ", max=" + max + "]";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.lib.database;
+
+
+public class Table<E extends Table> {
+ TableSchema schema;
+
+
+}
*
* Authors : Brent Salisbury, Evan Zeller
*/
-package org.opendaylight.ovsdb.lib.database;\r
-\r
-import java.util.Map;\r
-\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-public class TableSchema {\r
- @JsonProperty("columns")\r
- private Map<String, ColumnSchema> columns;\r
- @JsonProperty("maxRows")\r
- private Integer maxRows;\r
- @JsonProperty("isRoot")\r
- private Boolean isRoot;\r
- @JsonProperty("indexes")\r
- private Object indexes;\r
-\r
- public Map<String, ColumnSchema> getColumns(){\r
- return this.columns;\r
- }\r
-\r
- public Integer getMaxRows() {\r
- return maxRows;\r
- }\r
-\r
- public Boolean getIsRoot() {\r
- return isRoot;\r
- }\r
-\r
- public Object getIndexes() {\r
- return indexes;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return "TableSchema [columns=" + columns + ", maxRows=" + maxRows\r
- + ", isRoot=" + isRoot + ", indexes=" + indexes + "]";\r
- }\r
-}\r
+package org.opendaylight.ovsdb.lib.database;
+
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class TableSchema {
+
+ @JsonProperty("columns")
+ private Map<String, ColumnSchema> columns;
+
+ @JsonProperty("maxRows")
+ private Integer maxRows;
+
+ @JsonProperty("isRoot")
+ private Boolean isRoot;
+
+ @JsonProperty("indexes")
+ private Object indexes;
+
+ public Map<String, ColumnSchema> getColumns() {
+ return this.columns;
+ }
+
+ public ColumnSchema getColumn(String columnName) {
+ return this.columns.get(columnName);
+ }
+
+ public Integer getMaxRows() {
+ return maxRows;
+ }
+
+ public Boolean getIsRoot() {
+ return isRoot;
+ }
+
+ public Object getIndexes() {
+ return indexes;
+ }
+
+ @Override
+ public String toString() {
+ return "TableSchema [columns=" + columns + ", maxRows=" + maxRows
+ + ", isRoot=" + isRoot + ", indexes=" + indexes + "]";
+ }
+}
*
* Authors : Brent Salisbury, Evan Zeller
*/
-package org.opendaylight.ovsdb.lib.database;\r
-\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-\r
-public class Uuid {\r
- @JsonProperty("uuid")\r
- public String[] uuid;\r
-}\r
+package org.opendaylight.ovsdb.lib.database;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Uuid {
+ @JsonProperty("uuid")
+ public String[] uuid;
+}
--- /dev/null
+/*
+ * 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.lib.impl;
+
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
+
+import org.opendaylight.ovsdb.lib.OvsdbClient;
+
+public class ChannelConnectionHandler implements ChannelFutureListener {
+ OvsdbClient client;
+ public ChannelConnectionHandler (OvsdbClient client) {
+ this.client = client;
+ }
+ @Override
+ public void operationComplete(ChannelFuture arg0) throws Exception {
+ OvsdbConnectionService.channelClosed(client);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran, Madhu Venugopal
+ */
+package org.opendaylight.ovsdb.lib.impl;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+
+import org.opendaylight.ovsdb.lib.EchoServiceCallbackFilters;
+import org.opendaylight.ovsdb.lib.LockAquisitionCallback;
+import org.opendaylight.ovsdb.lib.LockStolenCallback;
+import org.opendaylight.ovsdb.lib.MonitorCallBack;
+import org.opendaylight.ovsdb.lib.MonitorHandle;
+import org.opendaylight.ovsdb.lib.OvsdbClient;
+import org.opendaylight.ovsdb.lib.OvsdbConnectionInfo;
+import org.opendaylight.ovsdb.lib.jsonrpc.Params;
+import org.opendaylight.ovsdb.lib.message.MonitorRequest;
+import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
+import org.opendaylight.ovsdb.lib.message.TableUpdate;
+import org.opendaylight.ovsdb.lib.message.TableUpdates;
+import org.opendaylight.ovsdb.lib.message.TransactBuilder;
+import org.opendaylight.ovsdb.lib.message.UpdateNotification;
+import org.opendaylight.ovsdb.lib.notation.Row;
+import org.opendaylight.ovsdb.lib.operations.Operation;
+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.TableSchema;
+import org.opendaylight.ovsdb.lib.schema.typed.TypedTable;
+import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+
+
+public class OvsdbClientImpl implements OvsdbClient {
+
+ protected static final Logger logger = LoggerFactory.getLogger(OvsdbClientImpl.class);
+ private ExecutorService executorService;
+ private OvsdbRPC rpc;
+ private Map<String, DatabaseSchema> schema = Maps.newHashMap();
+ private HashMap<String, CallbackContext> monitorCallbacks = Maps.newHashMap();
+ private Queue<Throwable> exceptions;
+ private OvsdbRPC.Callback rpcCallback;
+ private OvsdbConnectionInfo connectionInfo;
+
+ public OvsdbClientImpl(OvsdbRPC rpc, OvsdbConnectionInfo connectionInfo, ExecutorService executorService) {
+ this.rpc = rpc;
+ this.executorService = executorService;
+ this.connectionInfo = connectionInfo;
+ }
+
+ OvsdbClientImpl() {
+ }
+
+ void setupUpdateListener() {
+ if (rpcCallback == null) {
+ OvsdbRPC.Callback temp = new OvsdbRPC.Callback() {
+ @Override
+ public void update(Object node, UpdateNotification upadateNotification) {
+ Object key = upadateNotification.getContext();
+ CallbackContext callbackContext = monitorCallbacks.get(key);
+ MonitorCallBack monitorCallBack = callbackContext.monitorCallBack;
+ if (monitorCallBack == null) {
+ //ignore ?
+ logger.info("callback received with context {}, but no known handler. Ignoring!", key);
+ return;
+ }
+ _transformingCallback(upadateNotification.getUpdates(), monitorCallBack, callbackContext.schema);
+ }
+
+ @Override
+ public void locked(Object node, List<String> ids) {
+
+ }
+
+ @Override
+ public void stolen(Object node, List<String> ids) {
+
+ }
+ };
+ this.rpcCallback = temp;
+ rpc.registerCallback(temp);
+ }
+ }
+
+
+ protected void _transformingCallback(JsonNode tableUpdatesJson, MonitorCallBack monitorCallBack, DatabaseSchema dbSchema) {
+ //todo(ashwin): we should move all the JSON parsing logic to a utility class
+ if (tableUpdatesJson instanceof ObjectNode) {
+ Map<String, TableUpdate> tableUpdateMap = Maps.newHashMap();
+ ObjectNode updatesJson = (ObjectNode) tableUpdatesJson;
+ for (Iterator<Map.Entry<String,JsonNode>> itr = updatesJson.fields(); itr.hasNext();){
+ Map.Entry<String, JsonNode> entry = itr.next();
+
+ DatabaseSchema databaseSchema = this.schema.get(dbSchema.getName());
+ TableSchema table = databaseSchema.table(entry.getKey(), TableSchema.class);
+ tableUpdateMap.put(entry.getKey(), table.updatesFromJson(entry.getValue()));
+
+ }
+ TableUpdates updates = new TableUpdates(tableUpdateMap);
+ monitorCallBack.update(updates);
+ }
+ }
+
+ @Override
+ public ListenableFuture<List<OperationResult>> transact(List<Operation> operations) {
+
+ //todo, we may not need transactionbuilder if we can have JSON objects
+ TransactBuilder builder = new TransactBuilder();
+ for (Operation o : operations) {
+ builder.addOperation(o);
+ }
+
+ return rpc.transact(builder);
+ }
+
+ @Override
+ public <E extends TableSchema<E>> MonitorHandle monitor(final DatabaseSchema dbSchema,
+ List<MonitorRequest<E>> monitorRequest,
+ final MonitorCallBack callback) {
+
+ final ImmutableMap<String, MonitorRequest<E>> reqMap = Maps.uniqueIndex(monitorRequest,
+ new Function<MonitorRequest<E>, String>() {
+ @Override
+ public String apply(MonitorRequest<E> input) {
+ return input.getTableName();
+ }
+ });
+
+ final MonitorHandle monitorHandle = new MonitorHandle(UUID.randomUUID().toString());
+ registerCallback(monitorHandle, callback, dbSchema);
+
+ ListenableFuture<JsonNode> monitor = rpc.monitor(new Params() {
+ @Override
+ public List<Object> params() {
+ return Lists.<Object>newArrayList(dbSchema.getName(), monitorHandle.getId(), reqMap);
+ }
+ });
+ Futures.addCallback(monitor, new FutureCallback<JsonNode>() {
+ @Override
+ public void onSuccess(JsonNode result) {
+ _transformingCallback(result, callback, dbSchema);
+ }
+
+ @Override
+ public void onFailure(Throwable t) {
+ callback.exception(t);
+ }
+ });
+
+ return monitorHandle;
+ }
+
+ private void registerCallback(MonitorHandle monitorHandle, MonitorCallBack callback, DatabaseSchema schema) {
+ this.monitorCallbacks.put(monitorHandle.getId(), new CallbackContext(callback, schema));
+ setupUpdateListener();
+ }
+
+ @Override
+ public void cancelMonitor(MonitorHandle handler) {
+ throw new UnsupportedOperationException("not yet implemented");
+ }
+
+ @Override
+ public void lock(String lockId, LockAquisitionCallback lockedCallBack, LockStolenCallback stolenCallback) {
+ throw new UnsupportedOperationException("not yet implemented");
+ }
+
+ @Override
+ public ListenableFuture<Boolean> steal(String lockId) {
+ throw new UnsupportedOperationException("not yet implemented");
+ }
+
+ @Override
+ public ListenableFuture<Boolean> unLock(String lockId) {
+ throw new UnsupportedOperationException("not yet implemented");
+ }
+
+ @Override
+ public void startEchoService(EchoServiceCallbackFilters callbackFilters) {
+ throw new UnsupportedOperationException("not yet implemented");
+ }
+
+ @Override
+ public void stopEchoService() {
+ throw new UnsupportedOperationException("not yet implemented");
+ }
+
+ @Override
+ public TransactionBuilder transactBuilder() {
+ return new TransactionBuilder(this);
+ }
+
+
+ public boolean isReady(int timeout) throws InterruptedException {
+ while (timeout > 0) {
+ if (!schema.isEmpty()) {
+ return true;
+ }
+ Thread.sleep(1000);
+ timeout--;
+ }
+ return false;
+ }
+
+ @Override
+ public ListenableFuture<List<String>> getDatabases() {
+ return rpc.list_dbs();
+ }
+
+ @Override
+ public ListenableFuture<DatabaseSchema> getSchema(final String database, final boolean cacheResult) {
+
+ DatabaseSchema databaseSchema = schema.get(database);
+
+ if (databaseSchema == null || cacheResult) {
+ return Futures.transform(
+ getSchemaFromDevice(Lists.newArrayList(database)),
+ new Function<Map<String, DatabaseSchema>, DatabaseSchema>() {
+ @Override
+ public DatabaseSchema apply(Map<String, DatabaseSchema> result) {
+ if (result.containsKey(database)) {
+ DatabaseSchema s = result.get(database);
+ s.populateInternallyGeneratedColumns();
+ if (cacheResult) {
+ OvsdbClientImpl.this.schema.put(database, s);
+ }
+ return s;
+ } else {
+ return null;
+ }
+ }
+ }, executorService);
+
+
+ } else {
+ return Futures.immediateFuture(databaseSchema);
+ }
+ }
+
+ private ListenableFuture<Map<String, DatabaseSchema>> getSchemaFromDevice(final List<String> dbNames) {
+ Map<String, DatabaseSchema> schema = Maps.newHashMap();
+ SettableFuture<Map<String, DatabaseSchema>> future = SettableFuture.create();
+ _populateSchema(dbNames, schema, future);
+ return future;
+ }
+
+ private void _populateSchema(final List<String> dbNames,
+ final Map<String, DatabaseSchema> schema,
+ final SettableFuture<Map<String, DatabaseSchema>> sfuture) {
+
+ if (dbNames == null || dbNames.isEmpty()) {
+ return;
+ }
+
+ Futures.transform(rpc.get_schema(Lists.newArrayList(dbNames.get(0))),
+ new com.google.common.base.Function<JsonNode, Void>() {
+ @Override
+ public Void apply(JsonNode jsonNode) {
+ try {
+ schema.put(dbNames.get(0), DatabaseSchema.fromJson(dbNames.get(0), jsonNode));
+ if (schema.size() > 1 && !sfuture.isCancelled()) {
+ _populateSchema(dbNames.subList(1, dbNames.size()), schema, sfuture);
+ } else if (schema.size() == 1) {
+ sfuture.set(schema);
+ }
+ } catch (Throwable e) {
+ sfuture.setException(e);
+ }
+ return null;
+ }
+ });
+ }
+
+ public void setRpc(OvsdbRPC rpc) {
+ this.rpc = rpc;
+ }
+
+ public Queue<Throwable> getExceptions() {
+ return exceptions;
+ }
+
+ static class CallbackContext {
+ MonitorCallBack monitorCallBack;
+ DatabaseSchema schema;
+
+ CallbackContext(MonitorCallBack monitorCallBack, DatabaseSchema schema) {
+ this.monitorCallBack = monitorCallBack;
+ this.schema = schema;
+ }
+ }
+
+ @Override
+ public DatabaseSchema getDatabaseSchema (String dbName) {
+ return schema.get(dbName);
+ }
+
+ /**
+ * This method finds the DatabaseSchema that matches a given Typed Table Class.
+ * With the introduction of TypedTable and TypedColumn annotations, it is possible to express
+ * the Database Name, Table Name & the Database Versions within which the Table is defined and maintained.
+ *
+ * @param klazz Typed Class that represents a Table
+ * @return DatabaseSchema that matches a Typed Table Class
+ */
+ private <T> DatabaseSchema getDatabaseSchemaForTypedTable (Class <T> klazz) {
+ TypedTable typedTable = klazz.getAnnotation(TypedTable.class);
+ if (typedTable != null) {
+ return this.getDatabaseSchema(typedTable.database());
+ }
+ return null;
+ }
+
+ /**
+ * User friendly convenient method that make use of TyperUtils.getTypedRowWrapper to create a Typed Row Proxy
+ * given the Typed Table Class
+ *
+ * @param klazz Typed Interface
+ * @return Proxy wrapper for the actual raw Row class.
+ */
+ @Override
+ public <T> T createTypedRowWrapper(Class<T> klazz) {
+ DatabaseSchema dbSchema = getDatabaseSchemaForTypedTable(klazz);
+ return this.createTypedRowWrapper(dbSchema, klazz);
+ }
+
+ /**
+ * User friendly convenient method that make use of getTypedRowWrapper to create a Typed Row Proxy given
+ * DatabaseSchema and Typed Table Class.
+ *
+ * @param dbSchema Database Schema of interest
+ * @param klazz Typed Interface
+ * @return Proxy wrapper for the actual raw Row class.
+ */
+ @Override
+ public <T> T createTypedRowWrapper(DatabaseSchema dbSchema, Class<T> klazz) {
+ return TyperUtils.getTypedRowWrapper(dbSchema, klazz, new Row<GenericTableSchema>());
+ }
+
+ /**
+ * User friendly convenient method to get a Typed Row Proxy given a Typed Table Class and the Row to be wrapped.
+ *
+ * @param klazz Typed Interface
+ * @param row The actual Row that the wrapper is operating on. It can be null if the caller is just interested in getting ColumnSchema.
+ * @return Proxy wrapper for the actual raw Row class.
+ */
+ @Override
+ public <T> T getTypedRowWrapper(final Class<T> klazz, final Row<GenericTableSchema> row) {
+ DatabaseSchema dbSchema = getDatabaseSchemaForTypedTable(klazz);
+ return TyperUtils.getTypedRowWrapper(dbSchema, klazz, row);
+ }
+
+ @Override
+ public OvsdbConnectionInfo getConnectionInfo() {
+ return connectionInfo;
+ }
+}
--- /dev/null
+/*
+ * 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.lib.impl;
+
+import io.netty.bootstrap.Bootstrap;
+import io.netty.bootstrap.ServerBootstrap;
+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.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import io.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.logging.LogLevel;
+import io.netty.handler.logging.LoggingHandler;
+import io.netty.util.CharsetUtil;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.opendaylight.ovsdb.lib.OvsdbClient;
+import org.opendaylight.ovsdb.lib.OvsdbConnection;
+import org.opendaylight.ovsdb.lib.OvsdbConnectionInfo;
+import org.opendaylight.ovsdb.lib.OvsdbConnectionInfo.ConnectionType;
+import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
+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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+/**
+ * OvsDBConnectionService provides OVSDB connection management functionality which includes
+ * both Active and Passive connections.
+ * From the Library perspective, Active OVSDB connections are those that are initiated from
+ * the Controller towards the ovsdb-manager.
+ * While Passive OVSDB connections are those that are initiated from the ovs towards
+ * the controller.
+ *
+ * Applications that use OvsDBConnectionService can use the OvsDBConnection class' connect APIs
+ * to initiate Active connections and can listen to the asynchronous Passive connections via
+ * registerForPassiveConnection listener API.
+ *
+ * The library is designed as Java modular component that can work in both OSGi and non-OSGi
+ * environment. Hence a single instance of the service will be active (via Service Registry in OSGi)
+ * and a Singleton object in a non-OSGi environment.
+ */
+public class OvsdbConnectionService implements OvsdbConnection {
+ private static final Logger logger = LoggerFactory.getLogger(OvsdbConnectionService.class);
+ private final static int DEFAULT_SERVER_PORT = 6640;
+ private static final String OVSDB_LISTENPORT = "ovsdb.listenPort";
+ private final static int NUM_THREADS = 3;
+
+ // Singleton Service object that can be used in Non-OSGi environment
+ private static Set<OvsdbConnectionListener> connectionListeners = Sets.newHashSet();
+ private static Map<OvsdbClient, Channel> connections = Maps.newHashMap();
+ private static OvsdbConnection connectionService;
+ private static int ovsdbListenPort = DEFAULT_SERVER_PORT;
+
+ public static OvsdbConnection getService() {
+ if (connectionService == null) {
+ connectionService = new OvsdbConnectionService();
+ }
+ return connectionService;
+ }
+ @Override
+ public OvsdbClient connect(InetAddress address, int port) {
+ 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();
+ OvsdbClient client = getChannelClient(channel, ConnectionType.ACTIVE, Executors.newFixedThreadPool(NUM_THREADS));
+ return client;
+ } catch (InterruptedException e) {
+ System.out.println("Thread was interrupted during connect");
+ }
+ return null;
+ }
+
+ @Override
+ public void disconnect(OvsdbClient client) {
+ if (client == null) return;
+ Channel channel = connections.get(client);
+ if (channel != null) {
+ channel.disconnect();
+ }
+ connections.remove(client);
+ }
+
+ @Override
+ public void registerForPassiveConnection(OvsdbConnectionListener listener) {
+ connectionListeners.add(listener);
+ }
+
+ private static OvsdbClient getChannelClient(Channel channel, ConnectionType type,
+ ExecutorService executorService) {
+ 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 rpc = factory.getClient(channel, OvsdbRPC.class);
+ InetSocketAddress channelAddress = (InetSocketAddress)channel.remoteAddress();
+ InetAddress address = channelAddress.getAddress();
+ int port = channelAddress.getPort();
+
+ OvsdbConnectionInfo info = new OvsdbConnectionInfo(address, port, type);
+ OvsdbClientImpl client = new OvsdbClientImpl(rpc, info, executorService);
+ connections.put(client, channel);
+ ChannelFuture closeFuture = channel.closeFuture();
+ closeFuture.addListener(new ChannelConnectionHandler(client));
+ return client;
+ }
+
+ /**
+ * Method that initiates the Passive OVSDB channel listening functionality.
+ * By default the ovsdb passive connection will listen in port 6640 which can
+ * be overridden using the ovsdb.listenPort system property.
+ */
+ private static void startOvsdbManager() {
+ String portString = System.getProperty(OVSDB_LISTENPORT);
+ if (portString != null) {
+ ovsdbListenPort = Integer.decode(portString).intValue();
+ }
+
+ new Thread() {
+ @Override
+ public void run() {
+ ovsdbManager();
+ }
+ }.start();
+ }
+
+
+ /**
+ * OVSDB Passive listening thread that uses Netty ServerBootstrap to open passive connection
+ * and handle channel callbacks.
+ */
+ private static void ovsdbManager() {
+ EventLoopGroup bossGroup = new NioEventLoopGroup();
+ EventLoopGroup workerGroup = new NioEventLoopGroup();
+ try {
+ ServerBootstrap b = new ServerBootstrap();
+ b.group(bossGroup, workerGroup)
+ .channel(NioServerSocketChannel.class)
+ .option(ChannelOption.SO_BACKLOG, 100)
+ .handler(new LoggingHandler(LogLevel.INFO))
+ .childHandler(new ChannelInitializer<SocketChannel>() {
+ @Override
+ public void initChannel(SocketChannel channel) throws Exception {
+ logger.debug("New Passive channel created : "+ channel.toString());
+ channel.pipeline().addLast(
+ new JsonRpcDecoder(100000),
+ new StringEncoder(CharsetUtil.UTF_8));
+
+ handleNewPassiveConnection(channel);
+ }
+ });
+ b.option(ChannelOption.TCP_NODELAY, true);
+ b.option(ChannelOption.RCVBUF_ALLOCATOR, new AdaptiveRecvByteBufAllocator(65535, 65535, 65535));
+ // Start the server.
+ ChannelFuture f = b.bind(ovsdbListenPort).sync();
+ Channel serverListenChannel = f.channel();
+ // Wait until the server socket is closed.
+ serverListenChannel.closeFuture().sync();
+ } catch (InterruptedException e) {
+ logger.error("Thread interrupted", e);
+ } finally {
+ // Shut down all event loops to terminate all threads.
+ bossGroup.shutdownGracefully();
+ workerGroup.shutdownGracefully();
+ }
+ }
+
+ static {
+ startOvsdbManager();
+ }
+
+ private static void handleNewPassiveConnection(Channel channel) {
+ OvsdbClient client = getChannelClient(channel, ConnectionType.PASSIVE, Executors.newFixedThreadPool(NUM_THREADS));
+ for (OvsdbConnectionListener listener : connectionListeners) {
+ listener.connected(client);
+ }
+ }
+
+ public static void channelClosed(OvsdbClient client) {
+ logger.info("Connection closed {}", client.getConnectionInfo().toString());
+ connections.remove(client);
+ for (OvsdbConnectionListener listener : connectionListeners) {
+ listener.disconnected(client);
+ }
+ }
+}
import java.util.Map;
import java.util.UUID;
-import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.google.common.collect.Maps;
+import com.google.common.reflect.Invokable;
import com.google.common.reflect.Reflection;
import com.google.common.reflect.TypeToken;
import com.google.common.util.concurrent.ListenableFuture;
ObjectMapper objectMapper;
Channel nettyChannel;
Map<String, CallContext> methodContext = Maps.newHashMap();
- Map<Node, OvsdbRPC.Callback> requestCallbacks = Maps.newHashMap();
+ Map<Object, OvsdbRPC.Callback> requestCallbacks = Maps.newHashMap();
public JsonRpcEndpoint(ObjectMapper objectMapper, Channel channel) {
this.objectMapper = objectMapper;
this.nettyChannel = channel;
}
- public <T> T getClient(final Node node, Class<T> klazz) {
+ public <T> T getClient(final Object context, Class<T> klazz) {
return Reflection.newProxy(klazz, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals(OvsdbRPC.REGISTER_CALLBACK_METHOD)) {
if ((args == null) || args.length != 1 || !(args[0] instanceof OvsdbRPC.Callback)) return false;
- requestCallbacks.put(node, (OvsdbRPC.Callback)args[0]);
+ requestCallbacks.put(context, (OvsdbRPC.Callback)args[0]);
return true;
}
JavaType javaType = TypeFactory.defaultInstance().constructType (retType.getType());
JsonNode result = response.get("result");
- logger.trace("Result : {}", result.toString());
-
Object result1 = objectMapper.convertValue(result, javaType);
JsonNode error = response.get("error");
if (error != null && !error.isNull()) {
}
}
- public void processRequest(Node node, JsonNode requestJson) {
+ public void processRequest(Object context, JsonNode requestJson) {
JsonRpc10Request request = new JsonRpc10Request(requestJson.get("id").asText());
request.setMethod(requestJson.get("method").asText());
logger.trace("Request : {} {}", requestJson.get("method"), requestJson.get("params"));
- OvsdbRPC.Callback callback = requestCallbacks.get(node);
+ OvsdbRPC.Callback callback = requestCallbacks.get(context);
if (callback != null) {
Method[] methods = callback.getClass().getDeclaredMethods();
for (Method m : methods) {
JsonNode params = requestJson.get("params");
Object param = objectMapper.convertValue(params, parameters[1]);
try {
- m.invoke(callback, node, param);
+ Invokable from = Invokable.from(m);
+ from.setAccessible(true);
+ from.invoke(callback, context, param);
} catch (IllegalAccessException | InvocationTargetException e) {
logger.error("Unable to invoke callback " + m.getName(), e);
}
return;
}
- logger.error("No handler for Request : {} on {}",requestJson.toString(), node);
+ logger.error("No handler for Request : {} on {}",requestJson.toString(), context);
}
public Map<String, CallContext> getMethodContext() {
*
* Authors : Ashwin Raveendran, Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.jsonrpc;\r
-\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.google.common.base.Strings;\r
-import com.google.common.collect.Maps;\r
-import com.google.common.util.concurrent.SettableFuture;\r
-\r
-import io.netty.channel.ChannelHandlerContext;\r
-import io.netty.channel.ChannelInboundHandlerAdapter;\r
-\r
-import org.opendaylight.controller.sal.core.Node;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import java.util.Map;\r
-\r
-public class JsonRpcServiceBinderHandler extends ChannelInboundHandlerAdapter {\r
- protected static final Logger logger = LoggerFactory.getLogger(JsonRpcServiceBinderHandler.class);\r
- Map<Object, SettableFuture<Object>> waitingForReply = Maps.newHashMap();\r
- JsonRpcEndpoint factory = null;\r
- Node node = null;\r
-\r
- public Node getNode() {\r
- return node;\r
- }\r
-\r
- public void setNode(Node node) {\r
- this.node = node;\r
- }\r
-\r
- public JsonRpcServiceBinderHandler(JsonRpcEndpoint factory) {\r
- this.factory = factory;\r
- }\r
-\r
- @Override\r
- public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {\r
-\r
- if (msg instanceof JsonNode) {\r
- JsonNode jsonNode = (JsonNode) msg;\r
-\r
- if (jsonNode.has("result")) {\r
- factory.processResult(jsonNode);\r
- } else if (jsonNode.hasNonNull("method")) {\r
- if (jsonNode.has("id") && !Strings.isNullOrEmpty(jsonNode.get("id").asText())) {\r
- factory.processRequest(node, jsonNode);\r
- }\r
- }\r
-\r
- return;\r
- }\r
-\r
- ctx.channel().close();\r
- }\r
-\r
- @Override\r
- public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {\r
- ctx.flush();\r
- }\r
+package org.opendaylight.ovsdb.lib.jsonrpc;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.base.Strings;
+import com.google.common.collect.Maps;
+import com.google.common.util.concurrent.SettableFuture;
+
+public class JsonRpcServiceBinderHandler extends ChannelInboundHandlerAdapter {
+ protected static final Logger logger = LoggerFactory.getLogger(JsonRpcServiceBinderHandler.class);
+ Map<Object, SettableFuture<Object>> waitingForReply = Maps.newHashMap();
+ JsonRpcEndpoint factory = null;
+ Object context = null;
+
+ public Object getContext() {
+ return context;
+ }
+
+ public void setContext(Object context) {
+ this.context = context;
+ }
+
+ public JsonRpcServiceBinderHandler(JsonRpcEndpoint factory) {
+ this.factory = factory;
+ }
+
+ @Override
+ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+
+ if (msg instanceof JsonNode) {
+ JsonNode jsonNode = (JsonNode) msg;
+
+ if (jsonNode.has("result")) {
+ factory.processResult(jsonNode);
+ } else if (jsonNode.hasNonNull("method")) {
+ if (jsonNode.has("id") && !Strings.isNullOrEmpty(jsonNode.get("id").asText())) {
+ factory.processRequest(context, jsonNode);
+ }
+ }
+
+ return;
+ }
+
+ ctx.channel().close();
+ }
+
+ @Override
+ public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+ ctx.flush();
+ }
}
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.lib.jsonrpc;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
+
+
+public class JsonUtils {
+
+ static ObjectMapper mapper = new ObjectMapper();
+
+ static ObjectWriter prettyWriter = mapper.writerWithDefaultPrettyPrinter();
+
+ public static String prettyString(Object jsonNode){
+ try {
+ return prettyWriter.writeValueAsString(jsonNode);
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
import java.io.IOException;
-import org.opendaylight.ovsdb.lib.message.operations.InsertOperation;
+import org.opendaylight.ovsdb.lib.operations.InsertOperation;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
--- /dev/null
+/*
+ * Copyright (C) 2013 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran, Madhu Venugopal
+ */
+package org.opendaylight.ovsdb.lib.message;
+
+import java.util.Set;
+
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.google.common.collect.Sets;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class MonitorRequest<E extends TableSchema<E>> {
+ @JsonIgnore String tableName;
+ Set<String> columns;
+ MonitorSelect select;
+
+ public MonitorRequest() {
+ }
+
+ public MonitorRequest(String tableName, Set<String> columns) {
+ this.tableName = tableName;
+ this.columns = columns;
+ }
+
+ public MonitorRequest(String tableName) {
+ this.tableName = tableName;
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ public MonitorSelect getSelect() {
+ return select;
+ }
+
+ public void setSelect(MonitorSelect select) {
+ this.select = select;
+ }
+
+ public Set<String> getColumns() {
+ return columns;
+ }
+
+ public void setColumns(Set<String> columns) {
+ this.columns = columns;
+ }
+
+ public void addColumn(String column) {
+ if (columns == null) {
+ columns = Sets.<String>newHashSet();
+ }
+ columns.add(column);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2013 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran, Madhu Venugopal
+ */
+package org.opendaylight.ovsdb.lib.message;
+
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+public class MonitorRequestBuilder<E extends TableSchema<E>> {
+
+ E tableSchema;
+ MonitorRequest<E> monitorRequest;
+
+ MonitorRequestBuilder(E tableSchema) {
+ this.tableSchema = tableSchema;
+ }
+
+ public static <T extends TableSchema<T>> MonitorRequestBuilder<T> builder(T tableSchema) {
+ return new MonitorRequestBuilder<>(tableSchema);
+ }
+
+ MonitorRequest<E> getMonitorRequest() {
+ if (monitorRequest == null) {
+ monitorRequest = new MonitorRequest<>();
+ }
+ return monitorRequest;
+ }
+
+ public MonitorRequestBuilder<E> addColumn(String column) {
+ getMonitorRequest().addColumn(column);
+ return this;
+ }
+
+ public MonitorRequestBuilder<E> addColumn(ColumnSchema<?, ?> column) {
+ this.addColumn(column.getName());
+ return this;
+ }
+
+ public MonitorRequestBuilder<E> addColumns(List<ColumnSchema<E, ?>> columns) {
+ for(ColumnSchema<E, ?> schema : columns) {
+ this.addColumn(schema);
+ }
+ return this;
+ }
+
+ public Set<String> getColumns() {
+ return getMonitorRequest().getColumns();
+ }
+
+ public MonitorRequestBuilder<E> with(MonitorSelect select) {
+ getMonitorRequest().setSelect(select);
+ return this;
+ }
+
+ public MonitorRequest<E> build() {
+ MonitorRequest<E> monitorRequest = getMonitorRequest();
+ if (monitorRequest.getSelect() == null) {
+ monitorRequest.setSelect(new MonitorSelect());
+ }
+ monitorRequest.setTableName(tableSchema.getName());
+ return monitorRequest;
+ }
+}
public class MonitorSelect {
- boolean inital;
+ boolean initial;
boolean insert;
boolean delete;
boolean modify;
- public boolean isInital() {
- return inital;
+ public MonitorSelect(boolean initial, boolean insert, boolean delete, boolean modify) {
+ this.initial = initial;
+ this.insert = insert;
+ this.delete = delete;
+ this.modify = modify;
+ }
+
+ public MonitorSelect() {
+ }
+
+ public boolean isInitial() {
+ return initial;
}
- public void setInital(boolean inital) {
- this.inital = inital;
+ public void setInitial(boolean initial) {
+ this.initial = initial;
}
public boolean isInsert() {
import java.util.List;
+import org.opendaylight.ovsdb.lib.operations.OperationResult;
+
+import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.ovsdb.lib.database.DatabaseSchema;
-import org.opendaylight.ovsdb.lib.message.operations.OperationResult;
+import org.opendaylight.ovsdb.lib.jsonrpc.Params;
public interface OvsdbRPC {
public static final String REGISTER_CALLBACK_METHOD = "registerCallback";
- public ListenableFuture<DatabaseSchema> get_schema(List<String> db_names);
+ //public ListenableFuture<DatabaseSchema> get_schema(List<String> db_names);
+ public ListenableFuture<JsonNode> get_schema(List<String> db_names);
public ListenableFuture<List<String>> echo();
- public ListenableFuture<TableUpdates> monitor(MonitorRequestBuilder request);
+ public ListenableFuture<JsonNode> monitor(Params equest);
public ListenableFuture<List<String>> list_dbs();
public boolean registerCallback(Callback callback);
+
public static interface Callback {
- public void update(Node node, UpdateNotification upadateNotification);
- public void locked(Node node, List<String> ids);
- public void stolen(Node node, List<String> ids);
+ public void update(Object context, UpdateNotification upadateNotification);
+ public void locked(Object context, List<String> ids);
+ public void stolen(Object context, List<String> ids);
// ECHO is handled by JsonRPCEndpoint directly.
// We can add Echo request here if there is a need for clients to handle it.
}
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib.message;
+
+import org.opendaylight.ovsdb.lib.notation.Row;
+import org.opendaylight.ovsdb.lib.notation.UUID;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+public class TableUpdate<E extends TableSchema<E>> {
+ private UUID uuid;
+ private Row<E> old;
+ private Row<E> new_;
+
+ public TableUpdate(UUID uuid) {
+ super();
+ this.uuid = uuid;
+ }
+
+ public UUID getUuid() {
+ return this.uuid;
+ }
+
+ public Row<E> getOld() {
+ return old;
+ }
+
+ public void setOld(Row<E> old) {
+ this.old = old;
+ }
+
+ public Row<E> getNew() {
+ return new_;
+ }
+
+ public void setNew(Row<E> new_) {
+ this.new_ = new_;
+ }
+
+ @Override
+ public String toString() {
+ return "TableUpdate [uuid=" + uuid + ", old=" + old + ", new_=" + new_
+ + "]";
+ }
+}
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+package org.opendaylight.ovsdb.lib.message;
+
+import java.util.Map;
+
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+import com.google.common.collect.Maps;
+
+
+public class TableUpdates extends Response {
+
+ Map<String, TableUpdate> map = Maps.newHashMap();
+
+ public TableUpdates() {
+ this(Maps.<String, TableUpdate>newHashMap());
+ }
+
+ public TableUpdates(Map<String, TableUpdate> map) {
+ this.map = map;
+ }
+
+ public <E extends TableSchema<E>> TableUpdate<E> getUpdate(TableSchema<E> table) {
+ return this.map.get(table.getName());
+ }
+
+ public Map<String, TableUpdate> getUpdates() {
+ return map;
+ }
+
+ @Override
+ public String toString() {
+ return "TableUpdates [map=" + map + ", error=" + error + ", details="
+ + details + ", getError()=" + getError() + ", getDetails()="
+ + getDetails() + ", getClass()=" + getClass() + ", hashCode()="
+ + hashCode() + ", toString()=" + super.toString() + "]";
+ }
+}
import com.google.common.collect.Lists;
import org.opendaylight.ovsdb.lib.jsonrpc.Params;
-import org.opendaylight.ovsdb.lib.message.operations.Operation;
+import org.opendaylight.ovsdb.lib.operations.Operation;
import java.util.List;
public class TransactBuilder implements Params {
import java.util.ArrayList;
-import org.opendaylight.ovsdb.lib.message.operations.OperationResult;
+import org.opendaylight.ovsdb.lib.operations.OperationResult;
public class TransactResponse extends Response {
ArrayList<OperationResult> result;
*/
package org.opendaylight.ovsdb.lib.message;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.opendaylight.ovsdb.lib.message.temp.TableUpdates;
import org.opendaylight.ovsdb.lib.notation.json.Converter.UpdateNotificationConverter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
public class UpdateNotification {
Object context;
TableUpdates update;
+ private JsonNode updatesJson;
+
public Object getContext() {
return context;
}
public void setUpdate(TableUpdates update) {
this.update = update;
}
+
+ @JsonAnySetter
+ public void setValue(String key, JsonNode val) {
+ System.out.println("key = " + key);
+ System.out.println("val = " + val);
+ System.out.println();
+ }
+
+ public void setUpdates(JsonNode jsonNode) {
+ this.updatesJson = jsonNode;
+ }
+
+ public JsonNode getUpdates() {
+ return updatesJson;
+ }
}
*
* Authors : Ashwin Raveendran, Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message;
+package org.opendaylight.ovsdb.lib.message.temp;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import java.util.Collection;
import java.util.Map;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
public class TableUpdate<T extends Table> {
*
* Authors : Ashwin Raveendran, Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message;
+package org.opendaylight.ovsdb.lib.message.temp;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Maps;
+
+import org.opendaylight.ovsdb.lib.message.Response;
+import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
import org.opendaylight.ovsdb.lib.table.Bridge;
import org.opendaylight.ovsdb.lib.table.Capability;
import org.opendaylight.ovsdb.lib.table.Interface;
import org.opendaylight.ovsdb.lib.table.Flow_Sample_Collector_Set;
import org.opendaylight.ovsdb.lib.table.Flow_Table;
import org.opendaylight.ovsdb.lib.table.IPFIX;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import java.util.Map;
import java.util.Set;
public class TableUpdates extends Response {
- Map<Table.Name, TableUpdate> map = Maps.newHashMap();
+ public Map<Table.Name, TableUpdate> map = Maps.newHashMap();
public Set<Table.Name> availableUpdates() {
return map.keySet();
public void setIPFIXUpdate(TableUpdate<IPFIX> IPFIXUpdate) {
put(IPFIX.NAME, IPFIXUpdate);
}
+
+ public TableUpdate getUpdate(GenericTableSchema table) {
+ //todo Horrible just for time being, before this whole thing is refactored.
+ for (Map.Entry<Table.Name, TableUpdate> s : this.map.entrySet()) {
+ if (table.getName().equals(s.getKey().getName())) {
+ return s.getValue();
+ }
+ }
+ return null;
+ }
}
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib.notation;
+
+
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+
+public class Column<E extends TableSchema<E>, D> {
+
+ private ColumnSchema<E, D> schema;
+ private D data;
+
+ public Column(ColumnSchema<E, D> schema, D d) {
+ this.schema = schema;
+ this.data = d;
+ }
+
+ public <E extends TableSchema<E>, T> T getData(ColumnSchema<E, T> schema) {
+ return schema.validate(data);
+ }
+
+ public D getData() {
+ return data;
+ }
+
+ public void setData(D data) {
+ this.data = data;
+ }
+
+ public ColumnSchema<E, D> getSchema() {
+ return schema;
+ }
+
+ public void setSchema(ColumnSchema<E, D> schema) {
+ this.schema = schema;
+ }
+
+ @Override
+ public String toString() {
+ return "Column [schema=" + schema + ", data=" + data + "]";
+ }
+}
String column;
Function function;
Object value;
+
public Condition(String column, Function function, Object value) {
super();
this.column = column;
this.function = function;
this.value = value;
}
+
public String getColumn() {
return column;
}
+
public void setColumn(String column) {
this.column = column;
}
+
public Function getFunction() {
return function;
}
+
public void setFunction(Function function) {
this.function = function;
}
+
public Object getValue() {
return value;
}
+
public void setValue(Object value) {
this.value = value;
}
import org.opendaylight.ovsdb.lib.notation.json.MutationSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-@JsonSerialize(using = MutationSerializer.class)
+@JsonSerialize(using = MutationSerializer.class)
public class Mutation {
String column;
Mutator mutator;
this.mutator = mutator;
this.value = value;
}
+
public String getColumn() {
return column;
}
+
public void setColumn(String column) {
this.column = column;
}
+
public Mutator getMutator() {
return mutator;
}
+
public void setMutator(Mutator mutator) {
this.mutator = mutator;
}
+
public Object getValue() {
return value;
}
+
public void setValue(Object value) {
this.value = value;
}
*/
package org.opendaylight.ovsdb.lib.notation;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.google.common.collect.ForwardingMap;
-import com.google.common.collect.Maps;
+import java.util.Map;
import org.opendaylight.ovsdb.lib.notation.json.Converter;
import org.opendaylight.ovsdb.lib.notation.json.OvsDBMapSerializer;
-import java.util.HashMap;
-import java.util.Map;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.google.common.collect.ForwardingMap;
+import com.google.common.collect.Maps;
@JsonDeserialize(converter = Converter.MapConverter.class)
@JsonSerialize(using = OvsDBMapSerializer.class)
public class OvsDBMap<K, V> extends ForwardingMap<K, V> {
- HashMap<K, V> target = Maps.newHashMap();
+ Map<K, V> target = Maps.newHashMap();
+
+ public OvsDBMap() {
+ this(Maps.<K,V>newHashMap());
+ }
+
+ public OvsDBMap(Map<K, V> value) {
+ this.target = value;
+ }
@Override
public Map<K, V> delegate() {
return target;
}
+
+ public static<K,V> OvsDBMap<K,V> fromMap(Map<K, V> value) {
+ return new OvsDBMap<K,V>(value);
+ }
}
@JsonSerialize(using = OvsDBSetSerializer.class)
public class OvsDBSet<T> extends ForwardingSet<T> {
- Set<T> target = Sets.newHashSet();
+ Set<T> target = null;
+
+ public OvsDBSet() {
+ this(Sets.<T>newHashSet());
+ }
+
+ public OvsDBSet(Set<T> backing) {
+ this.target = backing;
+ }
@Override
public Set<T> delegate() {
return target;
}
+
+ public static<D> OvsDBSet<D> fromSet(Set<D> value) {
+ return new OvsDBSet<>(value);
+ }
}
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib.notation;
+
+import java.util.List;
+
+/**
+ * A collection of Rows as returned by select and other operations on OVSDB
+ */
+public class ResultSet {
+
+ private List<Row> rows;
+
+ public List<Row> getRows() {
+ return rows;
+ }
+
+ public void setRows(List<Row> rows) {
+ this.rows = rows;
+ }
+}
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib.notation;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+import com.google.common.collect.Maps;
+
+public class Row<E extends TableSchema<E>> {
+ protected Map<String, Column<E, ?>> columns;
+
+ public Row() {
+ this.columns = Maps.newHashMap();
+ }
+
+ public Row(List<Column<E, ?>> columns) {
+ this.columns = Maps.newHashMap();
+ for (Column<E, ?> column : columns) {
+ this.columns.put(column.getSchema().getName(), column);
+ }
+ }
+
+ public <D> Column<E, D> getColumn(ColumnSchema<E, D> schema) {
+ return (Column<E, D>) columns.get(schema.getName());
+ }
+
+ public Collection<Column<E, ?>> getColumns() {
+ return columns.values();
+ }
+
+ public void addColumn(String columnName, Column<E, ?> data) {
+ this.columns.put(columnName, data);
+ }
+
+ @Override
+ public String toString() {
+ return "Row [columns=" + columns + "]";
+ }
+}
--- /dev/null
+/*
+ * 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 : Dave Tucker
+ */
+
+package org.opendaylight.ovsdb.lib.notation;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * This class represents a version according to RFC 7047
+ * The default implementation assumes the left-most digit is most significant when performing comparisons
+ * @see <a href-="http://tools.ietf.org/html/rfc7047#section-3.1">RFC7047 Section 3.1</a>
+ */
+public class Version implements Comparable<Version> {
+
+ int major;
+ int minor;
+ int patch;
+
+ private static final String FORMAT = "(\\d+)\\.(\\d+)\\.(\\d+)";
+ private static final Pattern PATTERN = Pattern.compile(Version.FORMAT);
+
+ public Version(int major, int minor, int patch) {
+ this.major = major;
+ this.minor = minor;
+ this.patch = patch;
+ }
+
+ public static final Version NULL = new Version(0,0,0);
+ public static final String NULL_VERSION_STRING = "0.0.0";
+
+ public static Version fromString(String version){
+ final Matcher matcher = Version.PATTERN.matcher(version);
+ if (!matcher.matches()) {
+ throw new IllegalArgumentException("<"+version+"> does not match format "+Version.FORMAT);
+ }
+ int major = Integer.valueOf(matcher.group(1));
+ int minor = Integer.valueOf(matcher.group(2));
+ int patch = Integer.valueOf(matcher.group(3));
+ return new Version(major, minor, patch);
+ }
+
+ public String toString(){
+ return "" + major + "." + minor + "." + patch;
+ }
+
+ public int getMajor() {
+ return major;
+ }
+
+ public void setMajor(int major) {
+ this.major = major;
+ }
+
+ public int getMinor() {
+ return minor;
+ }
+
+ public void setMinor(int minor) {
+ this.minor = minor;
+ }
+
+ public int getPatch() {
+ return patch;
+ }
+
+ public void setPatch(int patch) {
+ this.patch = patch;
+ }
+
+
+ // ToDo: While format is X.X.X semantics are schema dependent.
+ // Therefore we should allow equals to be overridden by the schema
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Version version = (Version) o;
+
+ if (major != version.major) return false;
+ if (minor != version.minor) return false;
+ if (patch != version.patch) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = major;
+ result = 31 * result + minor;
+ result = 31 * result + patch;
+ return result;
+ }
+
+ // ToDo: While format is X.X.X semantics are schema dependent
+ // Therefore we should allow compareTo to be overridden by the schema
+ @Override
+ public int compareTo(Version o) {
+ if (this.equals(o)) return 0;
+ if (this.major > o.major) return 1;
+ if (this.major < o.major) return -1;
+ // major is equal
+ if (this.minor > o.minor) return 1;
+ if (this.minor < o.minor) return -1;
+ // minor is equal
+ if (this.patch > o.patch) return 1;
+ // must be less than
+ return -1;
+ }
+}
*/
package org.opendaylight.ovsdb.lib.notation.json;
-import org.opendaylight.ovsdb.lib.message.TableUpdates;
+import org.opendaylight.ovsdb.lib.message.temp.TableUpdates;
import org.opendaylight.ovsdb.lib.message.UpdateNotification;
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
if (node.isArray()) {
if (node.size() == 2) {
un.setContext(node.get(0).asText());
+ un.setUpdates(node.get(1));
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
TableUpdates updates = objectMapper.convertValue(node.get(1), TableUpdates.class);
--- /dev/null
+/*
+ * 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.lib.operations;
+
+public class Abort extends Operation {
+ public static final String ABORT = "abort";
+
+ public Abort() {
+ super(null, ABORT);
+ }
+}
--- /dev/null
+/*
+ * 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.lib.operations;
+
+
+public class Assert extends Operation {
+
+ public static final String ASSERT = "assert";
+ String lock;
+
+ public Assert(String lock) {
+ super(null, ASSERT);
+ this.lock = lock;
+ }
+
+ public String getLock() {
+ return lock;
+ }
+}
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
public class AssertOperation extends Operation {
--- /dev/null
+/*
+ * 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.lib.operations;
+
+
+public class Comment extends Operation {
+
+ public static final String COMMENT = "comment";
+ String comment;
+
+ public Comment(String comment) {
+ super(null, COMMENT);
+ this.comment = comment;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+}
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
public class CommentOperation extends Operation {
--- /dev/null
+/*
+ * 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.lib.operations;
+
+
+public class Commit extends Operation {
+
+ public static final String COMMIT = "commit";
+ Boolean durable;
+
+ public Commit(Boolean durable) {
+ super(null, COMMIT);
+ this.durable = durable;
+ }
+
+ public Boolean isDurable() {
+ return durable;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.lib.operations;
+
+import org.opendaylight.ovsdb.lib.notation.Condition;
+
+/**
+ * Represents an Operation type that accepts a condition, for e.g Update, Select etc
+ */
+public interface ConditionalOperation {
+
+ public void addCondition(Condition condition);
+}
--- /dev/null
+/*
+ * 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 : Dave Tucker
+ *
+ */
+
+package org.opendaylight.ovsdb.lib.operations;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.lib.notation.Condition;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+import com.google.common.collect.Lists;
+
+public class Delete<E extends TableSchema<E>> extends Operation<E> implements ConditionalOperation {
+
+ public static final String DELETE = "delete";
+ List<Condition> where = Lists.newArrayList();
+ Integer count;
+
+ public Delete(TableSchema<E> schema) {
+ super(schema, DELETE);
+ }
+
+ public Delete<E> on(TableSchema schema){
+ return this;
+ }
+
+ public Where where(Condition condition) {
+ where.add(condition);
+ return new Where(this);
+ }
+
+ @Override
+ public void addCondition(Condition condition) {
+ this.where.add(condition);
+ }
+
+ public List<Condition> getWhere() {
+ return where;
+ }
+
+ public void setWhere(List<Condition> where) {
+ this.where = where;
+ }
+
+ public Integer getCount() {
+ return count;
+ }
+
+ public void setCount(Integer count) {
+ this.count = count;
+ }
+}
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
import java.util.List;
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.lib.operations;
+
+import java.util.Map;
+
+import org.opendaylight.ovsdb.lib.notation.Column;
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.Maps;
+
+
+public class Insert<E extends TableSchema<E>> extends Operation<E> {
+
+ public static final String INSERT = "insert";
+
+ String uuid;
+
+ @JsonProperty("uuid-name")
+ private String uuidName;
+
+ private Map<String, Object> row = Maps.newHashMap();
+
+ public Insert<E> on(TableSchema schema){
+ this.setTableSchema(schema);
+ return this;
+ }
+
+ public Insert<E> withId(String name) {
+ this.uuidName = name;
+ this.setOp(INSERT);
+ return this;
+ }
+
+
+ public Insert(TableSchema<E> schema) {
+ super(schema, INSERT);
+ }
+
+ public <D, C extends TableSchema<C>> Insert<E> value(ColumnSchema<C, D> columnSchema, D value) {
+ Object untypedValue = columnSchema.getNormalizeData(value);
+ row.put(columnSchema.getName(), untypedValue);
+ return this;
+ }
+
+ public <D, C extends TableSchema<C>> Insert<E> value(Column<C, D> column) {
+ ColumnSchema<C, D> columnSchema = column.getSchema();
+ D value = column.getData();
+ return this.value(columnSchema, value);
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getUuidName() {
+ return uuidName;
+ }
+
+ public void setUuidName(String uuidName) {
+ this.uuidName = uuidName;
+ }
+
+ public Map<String, Object> getRow() {
+ return row;
+ }
+
+ public void setRow(Map<String, Object> row) {
+ this.row = row;
+ }
+
+}
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import com.fasterxml.jackson.annotation.JsonProperty;
// TODO Madhu : This is not complete. Getting it in to enable other committers to make progress
--- /dev/null
+/*
+ * Copyright (C) 2014 Matt Oswalt
+ *
+ * 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 : Matt Oswalt
+ *
+ */
+package org.opendaylight.ovsdb.lib.operations;
+
+import java.util.List;
+
+import org.opendaylight.ovsdb.lib.notation.Condition;
+import org.opendaylight.ovsdb.lib.notation.Mutation;
+import org.opendaylight.ovsdb.lib.notation.Mutator;
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+import com.google.common.collect.Lists;
+
+public class Mutate<E extends TableSchema<E>> extends Operation<E> implements ConditionalOperation {
+
+ public static final String MUTATE = "mutate";
+ List<Condition> where = Lists.newArrayList();
+ private List<Mutation> mutations = Lists.newArrayList();
+
+ public Mutate on(TableSchema schema){
+ this.setTableSchema(schema);
+ return this;
+ }
+
+ public Mutate(TableSchema<E> schema) {
+ super(schema, MUTATE);
+ }
+
+ public <T extends TableSchema<T>, D> Mutate<E> addMutation(ColumnSchema<T, D> columnSchema, Mutator mutator, D value) {
+ columnSchema.validate(value);
+ Object untypedValue = columnSchema.getNormalizeData(value);
+ mutations.add(new Mutation(columnSchema.getName(), mutator, untypedValue));
+ return this;
+ }
+
+ public List<Mutation> getMutations() {
+ return mutations;
+ }
+
+ public void setMutations(List<Mutation> mutations) {
+ this.mutations = mutations;
+ }
+
+ @Override
+ public void addCondition(Condition condition) {
+ this.where.add(condition);
+ }
+
+ public Where where(Condition condition) {
+ this.where.add(condition);
+ return new Where(this);
+ }
+
+ public List<Condition> getWhere() {
+ return where;
+ }
+
+ public void setWhere(List<Condition> where) {
+ this.where = where;
+ }
+}
\ No newline at end of file
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
import java.util.List;
List<Mutation> mutations;
public MutateOperation(String table, List<Condition> where,
- List<Mutation> mutations) {
+ List<Mutation> mutations) {
super();
super.setOp("mutate");
this.table = table;
this.where = where;
this.mutations = mutations;
}
+
public String getTable() {
return table;
}
+
public void setTable(String table) {
this.table = table;
}
+
public List<Condition> getWhere() {
return where;
}
+
public void setWhere(List<Condition> where) {
this.where = where;
}
+
public List<Mutation> getMutations() {
return mutations;
}
+
public void setMutations(List<Mutation> mutations) {
this.mutations = mutations;
}
+
@Override
public String toString() {
return "MutateOperation [table=" + table + ", where=" + where
--- /dev/null
+/*
+ * 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, Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.lib.operations;
+
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public abstract class Operation<E extends TableSchema<E>> {
+
+ @JsonIgnore
+ private TableSchema<E> tableSchema;
+
+ private String op;
+
+ @JsonIgnore
+ //todo(Ashwin): remove this
+ // Just a simple way to retain the result of a transact operation which the client can refer to.
+ private OperationResult result;
+
+
+ protected Operation() {
+ }
+
+ protected Operation(TableSchema<E> tableSchema) {
+ this.tableSchema = tableSchema;
+ }
+
+ public Operation(TableSchema<E> schema, String operation) {
+ this.tableSchema = schema;
+ this.op = operation;
+ }
+
+ public String getOp() {
+ return op;
+ }
+
+ public void setOp(String op) {
+ this.op = op;
+ }
+
+ public OperationResult getResult() {
+ return result;
+ }
+
+ public void setResult(OperationResult result) {
+ this.result = result;
+ }
+
+ public TableSchema<E> getTableSchema() {
+ return tableSchema;
+ }
+
+ public void setTableSchema(TableSchema<E> tableSchema) {
+ this.tableSchema = tableSchema;
+ }
+
+ @JsonProperty
+ public String getTable() {
+ return (tableSchema == null) ? null : tableSchema.getName();
+ }
+
+ @Override
+ public String toString() {
+ return "Operation [op=" + op + ", result=" + result + "]";
+ }
+
+}
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
import java.util.ArrayList;
import java.util.List;
+import org.opendaylight.ovsdb.lib.notation.Row;
import org.opendaylight.ovsdb.lib.notation.UUID;
+import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
private int count;
@JsonIgnore
private UUID uuid;
- private ArrayList<Object> rows;
+ private ArrayList<Row<GenericTableSchema>> rows;
private String error;
private String details;
public void setUuid(List<String> uuidList) {
this.uuid = new UUID(uuidList.get(1));
}
- public ArrayList<Object> getRows() {
+ public ArrayList<Row<GenericTableSchema>> getRows() {
return rows;
}
- public void setRows(ArrayList<Object> rows) {
+ public void setRows(ArrayList<Row<GenericTableSchema>> rows) {
this.rows = rows;
}
public String getError() {
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib.operations;
+
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+public class Operations {
+ public static Operations op = new Operations();
+
+ public <E extends TableSchema<E>> Insert<E> insert(TableSchema<E> schema) {
+ return new Insert<>(schema);
+ }
+
+ public <E extends TableSchema<E>> Update<E> update(TableSchema<E> schema) {
+ return new Update<>(schema);
+ }
+
+ public <E extends TableSchema<E>> Delete<E> delete(TableSchema<E> schema) {
+ return new Delete<>(schema);
+ }
+
+ public <E extends TableSchema<E>> Mutate<E> mutate(TableSchema<E> schema) {
+ return new Mutate<>(schema);
+ }
+
+ public Commit commit(Boolean durable) {
+ return new Commit(durable);
+ }
+
+ public Abort abort() {
+ return new Abort();
+ }
+
+ public <E extends TableSchema<E>> Select<E> select(TableSchema<E> schema) {
+ return new Select<>(schema);
+ }
+
+ public Comment comment(String comment) {
+ return new Comment(comment);
+ }
+
+ /*
+ * Could not use Java keyword "assert" which clashes with the ovsdb json-rpc method.
+ * using assertion instead.
+ */
+ public Assert assertion(String lock) {
+ return new Assert(lock);
+ }
+}
--- /dev/null
+/*
+ * 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 : Dave Tucker
+ *
+ */
+package org.opendaylight.ovsdb.lib.operations;
+
+import com.google.common.collect.Lists;
+import org.opendaylight.ovsdb.lib.notation.Condition;
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+import java.util.List;
+
+public class Select<E extends TableSchema<E>> extends Operation<E> implements ConditionalOperation {
+
+ public static final String SELECT = "select";
+ List<Condition> where = Lists.newArrayList();
+ private List<String> columns = Lists.newArrayList();
+
+ public Select on(TableSchema schema){
+ this.setTableSchema(schema);
+ return this;
+ }
+
+ public Select(TableSchema<E> schema) {
+ super(schema, SELECT);
+ }
+
+ public <D, C extends TableSchema<C>> Select<E> column(ColumnSchema<C, D> columnSchema) {
+ columns.add(columnSchema.getName());
+ return this;
+ }
+
+ public Where where(Condition condition) {
+ where.add(condition);
+ return new Where(this);
+ }
+
+ public List<String> getColumns() {
+ return columns;
+ }
+
+ public void setColumns(List<String> columns) {
+ this.columns = columns;
+ }
+
+ @Override
+ public void addCondition(Condition condition) {
+ this.where.add(condition);
+ }
+
+ public List<Condition> getWhere() {
+ return where;
+ }
+
+ public void setWhere(List<Condition> where) {
+ this.where = where;
+ }
+}
\ No newline at end of file
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
import java.util.List;
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib.operations;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.ovsdb.lib.impl.OvsdbClientImpl;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+
+import com.google.common.collect.Lists;
+import com.google.common.util.concurrent.ListenableFuture;
+
+public class TransactionBuilder {
+
+ private DatabaseSchema eDatabaseSchema;
+ OvsdbClientImpl ovs;
+ ArrayList<Operation> operations = Lists.newArrayList();
+
+ public TransactionBuilder(OvsdbClientImpl ovs) {
+ this.ovs = ovs;
+ }
+
+ public TransactionBuilder(DatabaseSchema eDatabaseSchema) {
+ this.eDatabaseSchema = eDatabaseSchema;
+ }
+
+ public ArrayList<Operation> getOperations() {
+ return operations;
+ }
+
+ public TransactionBuilder add(Operation operation) {
+ operations.add(operation);
+ return this;
+ }
+
+ public List<Operation> build() {
+ return operations;
+ }
+
+ public ListenableFuture<List<OperationResult>> execute() {
+ return ovs.transact(operations);
+ }
+}
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib.operations;
+
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.ovsdb.lib.notation.Column;
+import org.opendaylight.ovsdb.lib.notation.Condition;
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+public class Update<E extends TableSchema<E>> extends Operation<E> implements ConditionalOperation {
+
+ public static final String UPDATE = "update";
+
+ Map<String, Object> row = Maps.newHashMap();
+ String uuid;
+ //Where where;
+ List<Condition> where = Lists.newArrayList();
+
+ private String uuidName;
+
+ public Update(TableSchema<E> schema) {
+ super(schema, UPDATE);
+ }
+
+ public Update<E> on(TableSchema schema){
+ return this;
+ }
+
+ public <T extends TableSchema<T>, D> Update<E> set(ColumnSchema<T, D> columnSchema, D value) {
+ columnSchema.validate(value);
+ Object untypedValue = columnSchema.getNormalizeData(value);
+ this.row.put(columnSchema.getName(), untypedValue);
+ return this;
+ }
+
+ public <T extends TableSchema<T>, D> Update<E> set(Column<T, D> column) {
+ ColumnSchema<T, D> columnSchema = column.getSchema();
+ D value = column.getData();
+ return this.set(columnSchema, value);
+ }
+
+ public Where where(Condition condition) {
+ where.add(condition);
+ return new Where(this);
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getUuidName() {
+ return uuidName;
+ }
+
+ public void setUuidName(String uuidName) {
+ this.uuidName = uuidName;
+ }
+
+ public Map<String, Object> getRow() {
+ return row;
+ }
+
+ public void setRow(Map<String, Object> row) {
+ this.row = row;
+ }
+
+ @Override
+ public void addCondition(Condition condition) {
+ this.where.add(condition);
+ }
+
+ public List<Condition> getWhere() {
+ return where;
+ }
+
+ public void setWhere(List<Condition> where) {
+ this.where = where;
+ }
+}
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
import java.util.List;
import org.opendaylight.ovsdb.lib.notation.Condition;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
//TODO Madhu : This is not complete. Getting it in to enable other committers to make progress
public class UpdateOperation extends Operation {
String table;
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
public class WaitOperation extends Operation {
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib.operations;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.opendaylight.ovsdb.lib.notation.Condition;
+import org.opendaylight.ovsdb.lib.notation.Function;
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+
+public class Where {
+
+ @JsonIgnore
+ ConditionalOperation operation;
+
+ public Where() {
+ }
+
+ public Where(ConditionalOperation operation) {
+ this.operation = operation;
+ }
+
+ public Where condition(Condition condition) {
+ operation.addCondition(condition);
+ return this;
+ }
+
+ public Where condition(ColumnSchema column, Function function, Object value) {
+ this.condition(new Condition(column.getName(), function, value));
+ return this;
+ }
+
+ public Where and(ColumnSchema column, Function function, Object value) {
+ condition(column, function, value);
+ return this;
+ }
+
+ public Where and(Condition condition) {
+ condition(condition);
+ return this;
+ }
+
+ public Operation build() {
+ return (Operation) this.operation;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.lib.schema;
+
+import java.util.Set;
+
+import org.opendaylight.ovsdb.lib.notation.UUID;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.Sets;
+
+public abstract class BaseType<E extends BaseType<E>> {
+
+ private static BaseType[] types = new BaseType[]{
+ new StringBaseType(),
+ new IntegerBaseType(),
+ new RealBaseType(),
+ new BooleanBaseType(),
+ new UuidBaseType(),
+ };
+
+ public static BaseType fromJson(JsonNode json, String keyorval) {
+ BaseType baseType = null;
+ if (json.isValueNode()) {
+ for (BaseType baseTypeFactory : types) {
+ String type = json.asText().trim();
+ baseType = baseTypeFactory.fromString(type);
+ if (baseType != null) {
+ break;
+ }
+ }
+ } else {
+ if (!json.has(keyorval)) {
+ throw new RuntimeException("Not a type");
+ }
+
+ for (BaseType baseTypeFactory : types) {
+ baseType = baseTypeFactory.fromJsonNode(json.get(keyorval), keyorval);
+ if (baseType != null) {
+ break;
+ }
+ }
+ }
+ return baseType;
+ }
+
+ protected abstract E fromString(String type);
+
+ protected abstract void getConstraints(E baseType, JsonNode type);
+
+ protected E fromJsonNode(JsonNode type, String keyorval) {
+
+ E baseType = null;
+
+ //json like "string"
+ if (type.isTextual()) {
+ baseType = fromString(type.asText());
+ if (baseType != null) {
+ return baseType;
+ }
+ }
+
+ //json like {"type" : "string", "enum": ["set", ["access", "native-tagged"]]}" for key or value
+ if (type.isObject() && type.has("type")) {
+ baseType = fromString(type.get("type").asText());
+ if (baseType != null) {
+ getConstraints(baseType, type);
+ }
+ }
+
+ return baseType;
+ }
+
+ public abstract Object toValue(JsonNode value);
+
+ public abstract void validate(Object value);
+
+ public static class IntegerBaseType extends BaseType<IntegerBaseType> {
+ long min = Long.MIN_VALUE;
+ long max = Long.MAX_VALUE;
+ Set<Integer> enums;
+
+ @Override
+ public IntegerBaseType fromString(String typeString) {
+ return "integer".equals(typeString) ? new IntegerBaseType() : null;
+ }
+
+ @Override
+ protected void getConstraints(IntegerBaseType baseType, JsonNode type) {
+
+ JsonNode node = null;
+
+ if ((node = type.get("maxInteger")) != null) {
+ baseType.setMax(node.asLong());
+ }
+
+ if ((node = type.get("minInteger")) != null) {
+ baseType.setMin(node.asLong());
+ }
+
+ populateEnum(type);
+ }
+
+ @Override
+ public Object toValue(JsonNode value) {
+ return value.asLong();
+ }
+
+ @Override
+ public void validate(Object value) {
+
+ }
+
+ private void populateEnum(JsonNode node) {
+ if (node.has("enum")) {
+ Set<Long> s = Sets.newHashSet();
+ JsonNode anEnum = node.get("enum").get(1);
+ for (JsonNode n : anEnum) {
+ s.add(n.asLong());
+ }
+ }
+ }
+
+
+ public long getMin() {
+ return min;
+ }
+
+ public void setMin(long min) {
+ this.min = min;
+ }
+
+ public long getMax() {
+ return max;
+ }
+
+ public void setMax(long max) {
+ this.max = max;
+ }
+
+ public Set<Integer> getEnums() {
+ return enums;
+ }
+
+ public void setEnums(Set<Integer> enums) {
+ this.enums = enums;
+ }
+
+ @Override
+ public String toString() {
+ return "IntegerBaseType";
+ }
+ }
+
+ public static class RealBaseType extends BaseType<RealBaseType> {
+ double min = Double.MIN_VALUE;
+ double max = Double.MAX_VALUE;
+ Set<Double> enums;
+
+ @Override
+ public RealBaseType fromString(String typeString) {
+ return "real".equals(typeString) ? new RealBaseType() : null;
+ }
+
+ @Override
+ protected void getConstraints(RealBaseType baseType, JsonNode type) {
+
+ JsonNode node = null;
+
+ if ((node = type.get("maxReal")) != null) {
+ baseType.setMax(node.asLong());
+ }
+
+ if ((node = type.get("minReal")) != null) {
+ baseType.setMin(node.asLong());
+ }
+
+ populateEnum(type);
+ }
+
+ @Override
+ public Object toValue(JsonNode value) {
+ return value.asDouble();
+ }
+
+ @Override
+ public void validate(Object value) {
+
+ }
+
+ private void populateEnum(JsonNode node) {
+ if (node.has("enum")) {
+ Set<Double> s = Sets.newHashSet();
+ JsonNode anEnum = node.get("enum").get(1);
+ for (JsonNode n : anEnum) {
+ s.add(n.asDouble());
+ }
+ }
+ }
+
+ public double getMin() {
+ return min;
+ }
+
+ public void setMin(double min) {
+ this.min = min;
+ }
+
+ public double getMax() {
+ return max;
+ }
+
+ public void setMax(double max) {
+ this.max = max;
+ }
+
+ public Set<Double> getEnums() {
+ return enums;
+ }
+
+ public void setEnums(Set<Double> enums) {
+ this.enums = enums;
+ }
+
+ @Override
+ public String toString() {
+ return "RealBaseType";
+ }
+ }
+
+
+ public static class BooleanBaseType extends BaseType {
+
+ @Override
+ public BooleanBaseType fromString(String typeString) {
+ return "boolean".equals(typeString) ? new BooleanBaseType() : null;
+ }
+
+ @Override
+ protected void getConstraints(BaseType baseType, JsonNode node) {
+ //no op
+ }
+
+ @Override
+ public Object toValue(JsonNode value) {
+ return value.asBoolean();
+ }
+
+ @Override
+ public void validate(Object value) {
+
+ }
+
+ @Override
+ public String toString() {
+ return "BooleanBaseType";
+ }
+ }
+
+ public static class StringBaseType extends BaseType<StringBaseType> {
+ int minLength = Integer.MIN_VALUE;
+ int maxLength = Integer.MAX_VALUE;
+ Set<String> enums;
+
+ @Override
+ public StringBaseType fromString(String typeString) {
+ return "string".equals(typeString) ? new StringBaseType() : null;
+ }
+
+ @Override
+ protected void getConstraints(StringBaseType baseType, JsonNode type) {
+
+ JsonNode node = null;
+
+ if ((node = type.get("maxLength")) != null) {
+ baseType.setMaxLength(node.asInt());
+ }
+
+ if ((node = type.get("minLength")) != null) {
+ baseType.setMinLength(node.asInt());
+ }
+
+ populateEnum(baseType, type);
+ }
+
+ @Override
+ public Object toValue(JsonNode value) {
+ return value.asText();
+ }
+
+ @Override
+ public void validate(Object value) {
+
+ }
+
+ private void populateEnum(StringBaseType baseType, JsonNode node) {
+ if (node.has("enum")) {
+ Set<String> s = Sets.newHashSet();
+ JsonNode enumVal = node.get("enum");
+ if (enumVal.isArray()) {
+ JsonNode anEnum = enumVal.get(1);
+ for (JsonNode n : anEnum) {
+ s.add(n.asText());
+ }
+ } else if (enumVal.isTextual()) {
+ s.add(enumVal.asText());
+ }
+ baseType.setEnums(s);
+ }
+ }
+
+ public int getMinLength() {
+ return minLength;
+ }
+
+ public void setMinLength(int minLength) {
+ this.minLength = minLength;
+ }
+
+ public int getMaxLength() {
+ return maxLength;
+ }
+
+ public void setMaxLength(int maxLength) {
+ this.maxLength = maxLength;
+ }
+
+ public Set<String> getEnums() {
+ return enums;
+ }
+
+ public void setEnums(Set<String> enums) {
+ this.enums = enums;
+ }
+
+ @Override
+ public String toString() {
+ return "StringBaseType";
+ }
+
+ }
+
+
+ public static class UuidBaseType extends BaseType<UuidBaseType> {
+ public static enum RefType {strong, weak}
+
+ String refTable;
+ RefType refType;
+
+
+ @Override
+ public UuidBaseType fromString(String typeString) {
+ return "uuid".equals(typeString) ? new UuidBaseType() : null;
+ }
+
+ @Override
+ protected void getConstraints(UuidBaseType baseType, JsonNode node) {
+
+ JsonNode refTable = node.get("refTable");
+ baseType.setRefTable(refTable != null ? refTable.asText() : null);
+
+ JsonNode refTypeJson = node.get("refType");
+ baseType.setRefType(refTypeJson != null ? RefType.valueOf(refTypeJson.asText()) : RefType.strong);
+
+ }
+
+ @Override
+ public Object toValue(JsonNode value) {
+ if(value.isArray()) {
+ if (value.size() == 2) {
+ if (value.get(0).isTextual() && "uuid".equals(value.get(0).asText())) {
+ return new UUID(value.get(1).asText());
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void validate(Object value) {
+
+ }
+
+ public String getRefTable() {
+ return refTable;
+ }
+
+ public void setRefTable(String refTable) {
+ this.refTable = refTable;
+ }
+
+ public RefType getRefType() {
+ return refType;
+ }
+
+ public void setRefType(RefType refType) {
+ this.refType = refType;
+ }
+
+ @Override
+ public String toString() {
+ return "UuidBaseType";
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.lib.schema;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.ovsdb.lib.notation.Condition;
+import org.opendaylight.ovsdb.lib.notation.Function;
+import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
+import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+
+public class ColumnSchema<E extends TableSchema<E>, D> {
+ String name;
+ ColumnType type;
+ boolean ephemeral;
+ boolean mutable;
+
+ public ColumnSchema(String name, ColumnType columnType) {
+ this.name = name;
+ this.type = columnType;
+ }
+
+ public static ColumnSchema fromJson(String name, JsonNode json) {
+ if (!json.isObject() || !json.has("type")) {
+ //todo specific types of exception
+ throw new RuntimeException("bad column schema root, expected \"type\" as child");
+ }
+
+ return new ColumnSchema(name, ColumnType.fromJson(json.get("type")));
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public ColumnType getType() { return type; }
+
+ // --- Operations on the column ----------//
+
+ public Condition opEqual(D data) {
+ return new Condition(this.getName(), Function.EQUALS, data);
+ }
+
+ public Condition opGreaterThan(D data) {
+ return new Condition(this.getName(), Function.GREATER_THAN, data);
+ }
+
+ public Condition opLesserThan(D data) {
+ return new Condition(this.getName(), Function.GREATER_THAN, data);
+ }
+
+ public Condition opLesserThanOrEquals(D data) {
+ return new Condition(this.getName(), Function.LESS_THAN_OR_EQUALS, data);
+ }
+
+ // --- Operations on the column ----------//:w
+
+
+ @Override
+ public String toString() {
+ return "ColumnSchema{" +
+ "name='" + name + '\'' +
+ ", type=" + type +
+ '}';
+ }
+
+ /**
+ * Validates the passed in value against the constraints set for this ColumnSchema
+ * @param value
+ * @throws java.lang.RuntimeException (validation exception)
+ */
+ public D validate(Object value)throws RuntimeException {
+ //todo(type check and validate based on constraints set)
+ this.type.validate(value);
+ return (D) value;
+ }
+
+ /**
+ * Verifies if this Column if of the specified type
+ * @param type the type to check for
+ */
+ public void validateType(Class<?> type) {
+
+ }
+
+ public D valueFromJson(JsonNode value) {
+ return (D) this.getType().valueFromJson(value);
+ }
+
+ public Object getNormalizeData(D value) {
+ Object untypedValue = null;
+ if (value instanceof Set) {
+ untypedValue = OvsDBSet.fromSet((Set) value);
+ } else if (value instanceof Map) {
+ untypedValue = OvsDBMap.fromMap((Map)value);
+ } else {
+ untypedValue = value;
+ }
+ return untypedValue;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.lib.schema;
+
+import java.util.Set;
+
+import org.opendaylight.ovsdb.lib.jsonrpc.JsonUtils;
+import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.Sets;
+
+
+public abstract class ColumnType {
+ BaseType baseType;
+ long min = 1;
+ long max = 1;
+
+ public long getMin() {
+ return min;
+ }
+
+ void setMin(long min) {
+ this.min = min;
+ }
+
+ public long getMax() {
+ return max;
+ }
+
+ void setMax(long max) {
+ this.max = max;
+ }
+
+ private static ColumnType columns[] = new ColumnType[]{
+ new AtomicColumnType(),
+ new KeyValuedColumnType()
+ };
+
+
+ public ColumnType() {
+
+ }
+
+ public ColumnType(BaseType baseType) {
+ this.baseType = baseType;
+ }
+
+ public BaseType getBaseType() {
+ return baseType;
+ }
+
+ /**
+ "type": {
+ "key": {
+ "maxInteger": 4294967295,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0,
+ "value": {
+ "type": "uuid",
+ "refTable": "Queue"
+ },
+ "max": "unlimited"
+ }
+ * @param json
+ * @return
+ */
+ public static ColumnType fromJson(JsonNode json) {
+ for (ColumnType colType : columns) {
+ ColumnType columnType = colType.fromJsonNode(json);
+ if (null != columnType) {
+ return columnType;
+ }
+ }
+ //todo move to speicfic typed exception
+ throw new RuntimeException(String.format("could not find the right column type %s",
+ JsonUtils.prettyString(json)));
+ }
+
+
+ /**
+ * Creates a ColumnType from the JsonNode if the implementation knows how to, returns null otherwise
+ *
+ * @param json the JSONNode object that needs to converted
+ * @return a valid SubType or Null (if the JsonNode does not represent
+ * the subtype)
+ */
+ protected abstract ColumnType fromJsonNode(JsonNode json);
+
+ public boolean isMultiValued() {
+ //todo check if this is the right logic
+ return this.min != this.max && this.min != 1;
+ }
+
+ public abstract Object valueFromJson(JsonNode value);
+
+ public abstract void validate(Object value);
+
+ @Override
+ public String toString() {
+ return "ColumnType{" +
+ "baseType=" + baseType +
+ ", min=" + min +
+ ", max=" + max +
+ '}';
+ }
+
+ public static class AtomicColumnType extends ColumnType {
+
+ public AtomicColumnType() {
+ }
+
+ public AtomicColumnType(BaseType baseType1) {
+ super(baseType1);
+ }
+
+ @Override
+ public AtomicColumnType fromJsonNode(JsonNode json) {
+ if (json.isObject() && json.has("value")) {
+ return null;
+ }
+ BaseType baseType = BaseType.fromJson(json, "key");
+
+ if (baseType != null) {
+
+ AtomicColumnType atomicColumnType = new AtomicColumnType(baseType);
+
+ JsonNode node = null;
+ if ((node = json.get("min")) != null) {
+ atomicColumnType.setMin(node.asLong());
+ }
+
+ if ((node = json.get("max")) != null) {
+ if (node.isLong()){
+ atomicColumnType.setMax(node.asLong());
+ } else if (node.isTextual() && "unlimited".equals(node.asText())) {
+ max = Long.MAX_VALUE;
+ }
+ }
+ return atomicColumnType;
+ }
+
+ return null;
+ }
+
+ @Override
+ public Object valueFromJson(JsonNode value) {
+ if (isMultiValued()) {
+ Set<Object> result = Sets.newHashSet();
+ if(value.isArray()) {
+ if (value.size() == 2) {
+ if (value.get(0).isTextual() && "set".equals(value.get(0).asText())) {
+ for(JsonNode node: value.get(1)) {
+ result.add(getBaseType().toValue(node));
+ }
+ } else {
+ result.add(getBaseType().toValue(value));
+ }
+ }
+ } else {
+ result.add(getBaseType().toValue(value));
+ }
+ return result;
+ } else {
+ return getBaseType().toValue(value);
+ }
+ }
+
+ @Override
+ public void validate(Object value) {
+ this.baseType.validate(value);
+ }
+
+ }
+
+ public static class KeyValuedColumnType extends ColumnType {
+ BaseType keyType;
+
+ public BaseType getKeyType() {
+ return keyType;
+ }
+
+ public KeyValuedColumnType() {
+ }
+
+ public KeyValuedColumnType(BaseType keyType, BaseType valueType) {
+ super(valueType);
+ this.keyType = keyType;
+ }
+
+ @Override
+ public KeyValuedColumnType fromJsonNode(JsonNode json) {
+ if (json.isValueNode() || !json.has("value")) {
+ return null;
+ }
+ BaseType keyType = BaseType.fromJson(json, "key");
+ BaseType valueType = BaseType.fromJson(json, "value");
+
+ KeyValuedColumnType keyValueColumnType = new KeyValuedColumnType(keyType, valueType);
+ JsonNode node = null;
+ if ((node = json.get("min")) != null) {
+ keyValueColumnType.setMin(node.asLong());
+ }
+
+ if ((node = json.get("max")) != null) {
+ if (node.isLong()){
+ keyValueColumnType.setMax(node.asLong());
+ } else if (node.isTextual() && "unlimited".equals(node.asText())) {
+ max = Long.MAX_VALUE;
+ }
+ }
+
+ return keyValueColumnType;
+ }
+
+ @Override
+ public Object valueFromJson(JsonNode node) {
+ if (node.isArray()) {
+ if (node.size() == 2) {
+ if (node.get(0).isTextual() && "map".equals(node.get(0).asText())) {
+ OvsDBMap<Object, Object> map = new OvsDBMap<Object, Object>();
+ for (JsonNode pairNode : node.get(1)) {
+ if (pairNode.isArray() && node.size() == 2) {
+ Object key = getKeyType().toValue(pairNode.get(0));
+ Object value = getBaseType().toValue(pairNode.get(1));
+ map.put(key, value);
+ }
+ }
+ return map;
+ } else if (node.size() == 0) {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void validate(Object value) {
+ this.baseType.validate(value);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.lib.schema;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.ovsdb.lib.ParsingException;
+import org.opendaylight.ovsdb.lib.notation.Version;
+import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.reflect.Invokable;
+
+/**
+ * Represents an ovsdb database schema, which is comprised of a set of tables.
+ */
+public class DatabaseSchema {
+
+ public static Logger logger = LoggerFactory.getLogger(DatabaseSchema.class);
+
+ private String name;
+
+ private Version version;
+ private Map<String, TableSchema> tables;
+
+ public DatabaseSchema(Map<String, TableSchema> tables) {
+ this.tables = tables;
+ }
+
+ public DatabaseSchema(String name, Version version, Map<String, TableSchema> tables) {
+ this.name = name;
+ this.version = version;
+ this.tables = tables;
+ }
+
+ public Set<String> getTables() {
+ return this.tables.keySet();
+ }
+
+ public boolean hasTable(String table) {
+ return this.getTables().contains(table);
+ }
+
+ public TransactionBuilder beginTransaction() {
+ return new TransactionBuilder(this);
+ }
+
+ public <E extends TableSchema<E>> E table(String tableName, Class<E> clazz) {
+ TableSchema<E> table = tables.get(tableName);
+
+ if (clazz.isInstance(table)) {
+ return clazz.cast(table);
+ }
+
+ return createTableSchema(clazz, table);
+ }
+
+ protected <E extends TableSchema<E>> E createTableSchema(Class<E> clazz, TableSchema<E> table) {
+ Constructor<E> declaredConstructor = null;
+ try {
+ declaredConstructor = clazz.getDeclaredConstructor(TableSchema.class);
+ } catch (NoSuchMethodException e) {
+ String message = String.format("Class %s does not have public constructor that accepts TableSchema object",
+ clazz);
+ throw new IllegalArgumentException(message, e);
+ }
+ Invokable<E, E> invokable = Invokable.from(declaredConstructor);
+ try {
+ return invokable.invoke(null, table);
+ } catch (Exception e) {
+ String message = String.format("Not able to create instance of class %s using public constructor " +
+ "that accepts TableSchema object", clazz);
+ throw new IllegalArgumentException(message, e);
+ }
+ }
+
+ //todo : this needs to move to a custom factory
+ public static DatabaseSchema fromJson(String dbName, JsonNode json) {
+ if (!json.isObject() || !json.has("tables")) {
+ throw new ParsingException("bad DatabaseSchema root, expected \"tables\" as child but was not found");
+ }
+ if (!json.isObject() || !json.has("version")) {
+ throw new ParsingException("bad DatabaseSchema root, expected \"version\" as child but was not found");
+ }
+
+ Version dbVersion = Version.fromString(json.get("version").asText());
+
+ Map<String, TableSchema> tables = new HashMap<>();
+ for (Iterator<Map.Entry<String, JsonNode>> iter = json.get("tables").fields(); iter.hasNext(); ) {
+ Map.Entry<String, JsonNode> table = iter.next();
+ logger.debug("Read schema for table[{}]:{}", table.getKey(), table.getValue());
+
+ //todo : this needs to done by a factory
+ tables.put(table.getKey(), new GenericTableSchema().fromJson(table.getKey(), table.getValue()));
+ }
+
+ return new DatabaseSchema(dbName, dbVersion, tables);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Version getVersion() { return version; }
+
+ public void setVersion(Version version) { this.version = version; }
+
+ public void populateInternallyGeneratedColumns() {
+ for (TableSchema tableSchema : tables.values()) {
+ tableSchema.populateInternallyGeneratedColumns();
+ }
+ }
+}
--- /dev/null
+/*
+ *
+ * * Copyright (C) 2014 EBay Software Foundation
+ * *
+ * * 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 : Ashwin Raveendran
+ *
+ */
+
+package org.opendaylight.ovsdb.lib.schema;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+public class GenericTableSchema extends TableSchema<GenericTableSchema> {
+
+ public GenericTableSchema() {
+ }
+
+ public GenericTableSchema(String tableName) {
+ super(tableName);
+ }
+
+ public GenericTableSchema (TableSchema tableSchema) {
+ super(tableSchema.getName(), tableSchema.getColumnSchemas());
+ }
+
+ public GenericTableSchema fromJson(String tableName, JsonNode json) {
+
+ if (!json.isObject() || !json.has("columns")) {
+ //todo specific types of exception
+ throw new RuntimeException("bad tableschema root, expected \"columns\" as child");
+ }
+
+ Map<String, ColumnSchema> columns = new HashMap<>();
+ for (Iterator<Map.Entry<String, JsonNode>> iter = json.get("columns").fields(); iter.hasNext(); ) {
+ Map.Entry<String, JsonNode> column = iter.next();
+ logger.debug("%s:%s", tableName, column.getKey());
+ columns.put(column.getKey(), ColumnSchema.fromJson(column.getKey(), column.getValue()));
+ }
+
+ this.setName(tableName);
+ this.setColumns(columns);
+ return this;
+ }
+
+// public TableUpdate<GenericTableSchema> updatesFromJson(JsonNode value) {
+// ObjectNode new_ = (ObjectNode) value.get("new");
+// ObjectNode old = (ObjectNode) value.get("new");
+//
+// Row<GenericTableSchema> newRow = createRow(new_);
+// Row<GenericTableSchema> oldRow = createRow(old);
+//
+// TableUpdate<GenericTableSchema> tableUpdate = new TableUpdate<GenericTableSchema>();
+// tableUpdate.setNew(newRow);
+// tableUpdate.setNew(oldRow);
+//
+//
+// return null;
+// }
+//
+// protected Row<GenericTableSchema> createRow(ObjectNode rowNode) {
+// List<Column<GenericTableSchema, ?>> columns = Lists.newArrayList();
+// for (Iterator<Map.Entry<String, JsonNode>> iter = rowNode.fields(); iter.hasNext();) {
+// Map.Entry<String, JsonNode> next = iter.next();
+// ColumnSchema schema = column(next.getKey());
+// Object o = schema.valueFromJson(next.getValue());
+// columns.add(new Column(schema, o));
+// }
+// return new Row<>(columns);
+// }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.lib.schema;
+
+import java.lang.reflect.Constructor;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.ovsdb.lib.message.TableUpdate;
+import org.opendaylight.ovsdb.lib.notation.Column;
+import org.opendaylight.ovsdb.lib.notation.Row;
+import org.opendaylight.ovsdb.lib.notation.UUID;
+import org.opendaylight.ovsdb.lib.operations.Insert;
+import org.opendaylight.ovsdb.lib.schema.BaseType.UuidBaseType;
+import org.opendaylight.ovsdb.lib.schema.ColumnType.AtomicColumnType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Lists;
+
+
+public abstract class TableSchema<E extends TableSchema<E>> {
+
+
+ protected static final Logger logger = LoggerFactory.getLogger(TableSchema.class);
+ private String name;
+ private Map<String, ColumnSchema> columns;
+
+ public TableSchema() {
+ }
+
+ protected TableSchema(String name) {
+ this.name = name;
+ }
+
+ public TableSchema(String name, Map<String, ColumnSchema> columns) {
+ this.name = name;
+ this.columns = columns;
+ }
+
+ public Set<String> getColumns() {
+ return this.columns.keySet();
+ }
+
+ public Map<String, ColumnSchema> getColumnSchemas() {
+ return columns;
+ }
+
+ public boolean hasColumn(String column) {
+ return this.getColumns().contains(column);
+ }
+
+
+ public ColumnType getColumnType(String column) {
+ return this.columns.get(column).getType();
+ }
+
+ public <E extends TableSchema<E>> E as(Class<E> clazz) {
+ try {
+ Constructor<E> e = clazz.getConstructor(TableSchema.class);
+ return e.newInstance(this);
+ } catch (Exception e) {
+ throw new RuntimeException("exception constructing instance of clazz " + clazz, e);
+ }
+ }
+
+ public Insert<E> insert() {
+ return new Insert<>(this);
+ }
+
+ public <D> ColumnSchema<E, Set<D>> multiValuedColumn(String column, Class<D> type) {
+ //todo exception handling
+
+ ColumnSchema columnSchema = columns.get(column);
+ columnSchema.validateType(type);
+ return columnSchema;
+ }
+
+ public <K,V> ColumnSchema<E, Map<K,V>> multiValuedColumn(String column, Class<K> keyType, Class<V> valueType) {
+ //todo exception handling
+
+ ColumnSchema columnSchema = columns.get(column);
+ columnSchema.validateType(valueType);
+ return columnSchema;
+ }
+
+ public <D> ColumnSchema<E, D> column(String column, Class<D> type) {
+ //todo exception handling
+
+ ColumnSchema columnSchema = columns.get(column);
+ if (columnSchema != null) {
+ columnSchema.validateType(type);
+ }
+ return columnSchema;
+ }
+
+ public ColumnSchema column(String column) {
+ return this.columns.get(column);
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ protected void setName(String name) {
+ this.name = name;
+ }
+
+ protected void setColumns(Map<String, ColumnSchema> columns) {
+ this.columns = columns;
+ }
+
+ public TableUpdate<E> updatesFromJson(JsonNode value) {
+
+ Map.Entry<String, JsonNode> idOldNew = value.fields().next();
+ String uuid = idOldNew.getKey();
+
+ ObjectNode new_ = (ObjectNode) idOldNew.getValue().get("new");
+ ObjectNode old = (ObjectNode) idOldNew.getValue().get("old");
+
+ Row<E> newRow = new_ != null ? createRow(new_) : null;
+ Row<E> oldRow = old != null ? createRow(old) : null;
+
+ TableUpdate<E> tableUpdate = new TableUpdate<>(new UUID(uuid));
+ tableUpdate.setNew(newRow);
+ tableUpdate.setOld(oldRow);
+
+ return tableUpdate;
+ }
+
+ protected Row<E> createRow(ObjectNode rowNode) {
+ List<Column<E, ?>> columns = Lists.newArrayList();
+ for (Iterator<Map.Entry<String, JsonNode>> iter = rowNode.fields(); iter.hasNext();) {
+ Map.Entry<String, JsonNode> next = iter.next();
+ ColumnSchema<E, Object> schema = column(next.getKey(), Object.class);
+ /*
+ * Ideally the ColumnSchema shouldn't be null at this stage. But there can be cases in which
+ * the OVSDB manager Schema implementation might decide to include some "hidden" columns that
+ * are NOT reported in getSchema, but decide to report it in unfiltered monitor.
+ * Hence adding some safety checks around that.
+ */
+ if (schema != null) {
+ Object o = schema.valueFromJson(next.getValue());
+ columns.add(new Column<>(schema, o));
+ }
+ }
+ return new Row<>(columns);
+ }
+
+ /*
+ * RFC 7047 Section 3.2 specifies 2 internally generated columns in each table
+ * namely _uuid and _version which are not exposed in get_schema call.
+ * Since these 2 columns are extremely useful for Mutate, update and select operations,
+ * the ColumnSchema for these 2 columns are manually populated.
+ *
+ * It is to be noted that these 2 columns are specified as part of the RFC7047 and not
+ * a specific Schema implementation detail & hence adding it by default in the Library
+ * for better application experience using the library.
+ */
+ public void populateInternallyGeneratedColumns() {
+ columns.put("_uuid", new ColumnSchema("_uuid", new AtomicColumnType(new UuidBaseType())));
+ columns.put("_version", new ColumnSchema("_version", new AtomicColumnType(new UuidBaseType())));
+ }
+}
/*
- * Copyright (C) 2013 Red Hat, Inc.
+ * 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,
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
-public class AbortOperation extends Operation {
+package org.opendaylight.ovsdb.lib.schema.typed;
+public enum MethodType {
+ GETCOLUMN, GETDATA, SETDATA, GETTABLESCHEMA
}
--- /dev/null
+/*
+ * 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.lib.schema.typed;
+
+import org.opendaylight.ovsdb.lib.notation.Column;
+import org.opendaylight.ovsdb.lib.notation.UUID;
+import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
+
+public interface TypedBaseTable {
+ @TypedColumn(name="", method=MethodType.GETTABLESCHEMA)
+ GenericTableSchema getSchema();
+
+ @TypedColumn(name="_uuid", method=MethodType.GETDATA)
+ public UUID getUuid();
+
+ @TypedColumn(name="_uuid", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, UUID> getUuidColumn();
+
+ @TypedColumn(name="_version", method=MethodType.GETDATA)
+ public UUID getVersion();
+
+ @TypedColumn(name="_version", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, UUID> getVersionColumn();
+}
--- /dev/null
+/*
+ * 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.lib.schema.typed;
+
+import org.opendaylight.ovsdb.lib.notation.Version;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface TypedColumn {
+ public String name();
+ public MethodType method();
+ public String fromVersion() default Version.NULL_VERSION_STRING;
+ public String untilVersion() default Version.NULL_VERSION_STRING;
+}
--- /dev/null
+/*
+ * 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.lib.schema.typed;
+
+import org.opendaylight.ovsdb.lib.notation.Version;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface TypedTable {
+ public String name();
+ public String database();
+ public String fromVersion() default Version.NULL_VERSION_STRING;
+ public String untilVersion() default Version.NULL_VERSION_STRING;
+}
--- /dev/null
+/*
+ * 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.lib.schema.typed;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+import org.opendaylight.ovsdb.lib.notation.Column;
+import org.opendaylight.ovsdb.lib.notation.Row;
+import org.opendaylight.ovsdb.lib.notation.Version;
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
+
+import com.google.common.reflect.Reflection;
+
+public class TyperUtils {
+ private static final String GET_STARTS_WITH="get";
+ private static final String SET_STARTS_WITH="set";
+ private static final String GETCOLUMN_ENDS_WITH="Column";
+
+ private static <T> String getTableName (Class<T> klazz) {
+ TypedTable typedTable = klazz.getAnnotation(TypedTable.class);
+ if (typedTable != null) {
+ return typedTable.name();
+ }
+ return klazz.getSimpleName();
+ }
+
+ public static <T> GenericTableSchema getTableSchema(DatabaseSchema dbSchema, Class<T> klazz) {
+ String tableName = getTableName(klazz);
+ return dbSchema.table(tableName, GenericTableSchema.class);
+ }
+
+ public static ColumnSchema<GenericTableSchema, Object> getColumnSchema(GenericTableSchema tableSchema, String columnName, Class<Object> metaClass) {
+ return tableSchema.column(columnName, metaClass);
+ }
+
+ private static String getColumnName (Method method) {
+ TypedColumn typedColumn = method.getAnnotation(TypedColumn.class);
+ if (typedColumn != null) {
+ return typedColumn.name();
+ }
+
+ /*
+ * Attempting to get the column name by parsing the method name with a following convention :
+ * 1. GETDATA : get<ColumnName>
+ * 2. SETDATA : set<ColumnName>
+ * 3. GETCOLUMN : get<ColumnName>Column
+ * where <ColumnName> is the name of the column that we are interested in.
+ */
+ int index = GET_STARTS_WITH.length();
+ if (isGetData(method) || isSetData(method)) {
+ return method.getName().substring(index, method.getName().length()).toLowerCase();
+ } else if (isGetColumn(method)) {
+ return method.getName().substring(index, method.getName().indexOf(GETCOLUMN_ENDS_WITH, index)).toLowerCase();
+ }
+
+ return null;
+ }
+
+ private static boolean isGetTableSchema (Method method) {
+ TypedColumn typedColumn = method.getAnnotation(TypedColumn.class);
+ if (typedColumn != null) {
+ return typedColumn.method().equals(MethodType.GETTABLESCHEMA) ? true : false;
+ }
+ return false;
+ }
+
+ private static boolean isGetColumn (Method method) {
+ TypedColumn typedColumn = method.getAnnotation(TypedColumn.class);
+ if (typedColumn != null) {
+ return typedColumn.method().equals(MethodType.GETCOLUMN) ? true : false;
+ }
+
+ if (method.getName().startsWith(GET_STARTS_WITH) && method.getName().endsWith(GETCOLUMN_ENDS_WITH)) {
+ return true;
+ }
+ return false;
+ }
+
+ private static boolean isGetData (Method method) {
+ TypedColumn typedColumn = method.getAnnotation(TypedColumn.class);
+ if (typedColumn != null) {
+ return typedColumn.method().equals(MethodType.GETDATA) ? true : false;
+ }
+
+ if (method.getName().startsWith(GET_STARTS_WITH) && !method.getName().endsWith(GETCOLUMN_ENDS_WITH)) {
+ return true;
+ }
+ return false;
+ }
+
+ private static boolean isSetData (Method method) {
+ TypedColumn typedColumn = method.getAnnotation(TypedColumn.class);
+ if (typedColumn != null) {
+ return typedColumn.method().equals(MethodType.SETDATA) ? true : false;
+ }
+
+ if (method.getName().startsWith(SET_STARTS_WITH)) {
+ return true;
+ }
+ return false;
+ }
+
+ public static Version getFromVersion (Method method) {
+ TypedColumn typedColumn = method.getAnnotation(TypedColumn.class);
+ if (typedColumn != null) {
+ return Version.fromString(typedColumn.fromVersion());
+ }
+ TypedTable typedTable = method.getAnnotation(TypedTable.class);
+ if (typedTable != null) {
+ return Version.fromString(typedTable.fromVersion());
+ }
+ return Version.NULL;
+ }
+
+ public static Version getUntilVersion(Method method) {
+ TypedColumn typedColumn = method.getAnnotation(TypedColumn.class);
+ if (typedColumn != null) {
+ return Version.fromString(typedColumn.untilVersion());
+ }
+ TypedTable typedTable = method.getAnnotation(TypedTable.class);
+ if (typedTable != null) {
+ return Version.fromString(typedTable.untilVersion());
+ }
+ return Version.NULL;
+ }
+
+ /**
+ * Method that checks validity of the parameter passed to getTypedRowWrapper.
+ * This method checks for a valid Database Schema matching the expected Database for a given table
+ * and checks for the presence of the Table in Database Schema.
+ *
+ * @param dbSchema DatabaseSchema as learnt from a OVSDB connection
+ * @param klazz Typed Class that represents a Table
+ * @return true if valid, false otherwise
+ */
+ private static <T> boolean isValid (DatabaseSchema dbSchema, final Class<T> klazz) {
+ if (dbSchema == null) {
+ return false;
+ }
+
+ TypedTable typedTable = klazz.getAnnotation(TypedTable.class);
+ if (typedTable != null) {
+ if (!dbSchema.getName().equalsIgnoreCase(typedTable.database())) {
+ return false;
+ }
+ }
+
+ if (!dbSchema.getTables().contains(getTableName(klazz))) {
+ return false;
+ }
+ return true;
+ }
+
+ private static void checkSchemaVersion(DatabaseSchema dbSchema, Method method) {
+ Version fromVersion = getFromVersion(method);
+ Version untilVersion = getUntilVersion(method);
+ if (!fromVersion.equals(Version.NULL)) {
+ if (dbSchema.getVersion().compareTo(fromVersion) < 0) {
+ throw new RuntimeException("This row is not supported until version "
+ + fromVersion + "of the Schema");
+ }
+ }
+ if (!untilVersion.equals(Version.NULL)) {
+ if (dbSchema.getVersion().compareTo(untilVersion) > 0) {
+ throw new RuntimeException("This row was deprecated in "
+ + untilVersion + "of the Schema");
+ }
+ }
+ }
+
+ /**
+ * This method returns a Typed Proxy implementation for the klazz passed as a parameter.
+ * Per design choice, the Typed Proxy implementation is just a Wrapper on top of the actual Row which is untyped.
+ * Being just a wrapper, it is state-less and more of a convenience functionality to provide a type-safe infrastructure
+ * for the applications to built on top of. And this Typed infra is completely optional.
+ *
+ * It is the applications responsibilty to pass on the raw Row parameter & this method will return the appropriate
+ * Proxy wrapper for the passed klazz Type. The raw Row parameter may be null if the caller is interested in just the
+ * ColumnSchema. But that is not a very common use-case.
+ *
+ * @param dbSchema DatabaseSchema as learnt from a OVSDB connection
+ * @param klazz Typed Class that represents a Table
+ * @param row The actual Row that the wrapper is operating on. It can be null if the caller is just interested in getting ColumnSchema.
+ * @return
+ */
+ public static <T> T getTypedRowWrapper(final DatabaseSchema dbSchema, final Class<T> klazz, final Row<GenericTableSchema> row) {
+ if (!isValid(dbSchema, klazz)) {
+ return null;
+ }
+ return Reflection.newProxy(klazz, new InvocationHandler() {
+ private Object processGetData(Method method) throws Throwable {
+ String columnName = getColumnName(method);
+ checkSchemaVersion(dbSchema, method);
+ if (columnName == null) {
+ throw new RuntimeException("Error processing Getter : "+ method.getName());
+ }
+ GenericTableSchema tableSchema = getTableSchema(dbSchema, klazz);
+ if (tableSchema == null) {
+ throw new RuntimeException("Unable to locate TableSchema for "+getTableName(klazz)+ " in "+ dbSchema.getName());
+ }
+ ColumnSchema<GenericTableSchema, Object> columnSchema = getColumnSchema(tableSchema, columnName, (Class<Object>) method.getReturnType());
+ if (columnSchema == null) {
+ throw new RuntimeException("Unable to locate ColumnSchema for "+columnName+ " in "+ tableSchema.getName());
+ }
+ if (row == null) {
+ return null;
+ }
+ return row.getColumn(columnSchema).getData();
+ }
+
+ private Object processGetColumn(Method method) throws Throwable {
+ String columnName = getColumnName(method);
+ checkSchemaVersion(dbSchema, method);
+ if (columnName == null) {
+ throw new RuntimeException("Error processing GetColumn : "+ method.getName());
+ }
+ GenericTableSchema tableSchema = getTableSchema(dbSchema, klazz);
+ if (tableSchema == null) {
+ throw new RuntimeException("Unable to locate TableSchema for "+getTableName(klazz)+ " in "+ dbSchema.getName());
+ }
+ ColumnSchema<GenericTableSchema, Object> columnSchema = getColumnSchema(tableSchema, columnName, (Class<Object>) method.getReturnType());
+ if (columnSchema == null) {
+ throw new RuntimeException("Unable to locate ColumnSchema for "+columnName+ " in "+ tableSchema.getName());
+ }
+ // When the row is null, that might indicate that the user maybe interested only in the ColumnSchema and not on the Data.
+ if (row == null) {
+ return new Column<GenericTableSchema, Object>(columnSchema, null);
+ }
+ return row.getColumn(columnSchema);
+ }
+
+ private Object processSetData(Object proxy, Method method, Object[] args) throws Throwable {
+ if (args == null || args.length != 1) {
+ throw new RuntimeException("Setter method : "+method.getName() + " requires 1 argument");
+ }
+ checkSchemaVersion(dbSchema, method);
+ String columnName = getColumnName(method);
+ if (columnName == null) {
+ throw new RuntimeException("Unable to locate Column Name for "+method.getName());
+ }
+ GenericTableSchema tableSchema = getTableSchema(dbSchema, klazz);
+ ColumnSchema<GenericTableSchema, Object> columnSchema = getColumnSchema(tableSchema, columnName,
+ (Class<Object>) args[0].getClass());
+ Column<GenericTableSchema, Object> column = new Column<GenericTableSchema, Object>(columnSchema, args[0]);
+ row.addColumn(columnName, column);
+ return proxy;
+ }
+
+ private Object processGetTableSchema() throws Throwable {
+ if (dbSchema == null) return null;
+ return getTableSchema(dbSchema, klazz);
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (isGetTableSchema(method)) {
+ return processGetTableSchema();
+ } else if (isSetData(method)) {
+ return processSetData(proxy, method, args);
+ } else if(isGetData(method)) {
+ return processGetData(method);
+ } else if(isGetColumn(method)) {
+ return processGetColumn(method);
+ } else {
+ /*
+ * TODO : Handle the methods provided by Object class (such as toString, hashCode, equals, etc.).
+ * Reintroduce throwing RuntimeException("Unsupported method : "+method.getName()); after these methods
+ * are handled
+ */
+ return null;
+ }
+ }
+ }
+ );
+ }
+}
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
public class Bridge extends Table<Bridge> {
public static final Name<Bridge> NAME = new Name<Bridge>("Bridge"){};
- public enum Column implements org.opendaylight.ovsdb.lib.table.internal.Column<Bridge>{controller, fail_mode, name, ports}
+ public enum Column implements org.opendaylight.ovsdb.lib.table.Column<Bridge>{controller, fail_mode, name, ports}
private String name;
private OvsDBSet<UUID> ports;
package org.opendaylight.ovsdb.lib.table;
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.table.internal;
+package org.opendaylight.ovsdb.lib.table;
public interface Column<E> {
*/
package org.opendaylight.ovsdb.lib.table;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
-
import com.fasterxml.jackson.annotation.JsonIgnore;
public class Controller extends Table<Controller> {
package org.opendaylight.ovsdb.lib.table;
import com.fasterxml.jackson.annotation.JsonIgnore;
+
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
/**
* Per ovs-vswitchd.conf.db 2.0.90
"]";
}
- public enum Column implements org.opendaylight.ovsdb.lib.table.internal.Column<Flow_Sample_Collector_Set> {
+ public enum Column implements org.opendaylight.ovsdb.lib.table.Column<Flow_Sample_Collector_Set> {
id,
bridge,
external_ids,
package org.opendaylight.ovsdb.lib.table;
import com.fasterxml.jackson.annotation.JsonIgnore;
+
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
/**
* Per ovs-vswitchd.conf.db 2.0.90
}
- public enum Column implements org.opendaylight.ovsdb.lib.table.internal.Column<Flow_Table> {
+ public enum Column implements org.opendaylight.ovsdb.lib.table.Column<Flow_Table> {
name,
flow_limit,
overflow_policy,
package org.opendaylight.ovsdb.lib.table;
import com.fasterxml.jackson.annotation.JsonIgnore;
+
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
/**
* Per ovs-vswitchd.conf.db 2.0.90
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
*/
package org.opendaylight.ovsdb.lib.table;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
-
import com.fasterxml.jackson.annotation.JsonIgnore;
public class Manager extends Table<Manager> {
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
package org.opendaylight.ovsdb.lib.table;
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
+ external_ids + ", statistics=" + statistics + "]";
}
- public enum Column implements org.opendaylight.ovsdb.lib.table.internal.Column<Open_vSwitch>{ controller, fail_mode, name, ports}
+ public enum Column implements org.opendaylight.ovsdb.lib.table.Column<Open_vSwitch>{ controller, fail_mode, name, ports}
}
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
+ external_ids + "]";
}
- public enum Column implements org.opendaylight.ovsdb.lib.table.internal.Column<Port> {
+ public enum Column implements org.opendaylight.ovsdb.lib.table.Column<Port> {
interfaces,
name,
tag,
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
+ other_config + ", external_ids=" + external_ids + "]";
}
- public enum Column implements org.opendaylight.ovsdb.lib.table.internal.Column<Qos> {
+ public enum Column implements org.opendaylight.ovsdb.lib.table.Column<Qos> {
queues,
type,
other_config,
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
+ ", external_ids=" + external_ids + "]";
}
- public enum Column implements org.opendaylight.ovsdb.lib.table.internal.Column<Queue> {
+ public enum Column implements org.opendaylight.ovsdb.lib.table.Column<Queue> {
dscp,
other_config,
external_ids}
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
package org.opendaylight.ovsdb.lib.table;
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
+ external_ids + "]";
}
- public enum Column implements org.opendaylight.ovsdb.lib.table.internal.Column<SSL> {
+ public enum Column implements org.opendaylight.ovsdb.lib.table.Column<SSL> {
ca_cert,
bootstrap_ca_cert,
certificate,
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.table.internal;
+package org.opendaylight.ovsdb.lib.table;
public abstract class Table<E extends Table> {
public abstract Name<E> getTableName();
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.table.internal;
-
-import org.opendaylight.ovsdb.lib.table.Bridge;
-import org.opendaylight.ovsdb.lib.table.Capability;
-import org.opendaylight.ovsdb.lib.table.Interface;
-import org.opendaylight.ovsdb.lib.table.Port;
-import org.opendaylight.ovsdb.lib.table.Controller;
-import org.opendaylight.ovsdb.lib.table.Manager;
-import org.opendaylight.ovsdb.lib.table.Mirror;
-import org.opendaylight.ovsdb.lib.table.NetFlow;
-import org.opendaylight.ovsdb.lib.table.Open_vSwitch;
-import org.opendaylight.ovsdb.lib.table.Qos;
-import org.opendaylight.ovsdb.lib.table.Queue;
-import org.opendaylight.ovsdb.lib.table.SFlow;
-import org.opendaylight.ovsdb.lib.table.SSL;
-import org.opendaylight.ovsdb.lib.table.Flow_Sample_Collector_Set;
-import org.opendaylight.ovsdb.lib.table.Flow_Table;
-import org.opendaylight.ovsdb.lib.table.IPFIX;
+package org.opendaylight.ovsdb.lib.table;
import java.util.ArrayList;
import java.util.List;
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.lib;
+
+import static org.opendaylight.ovsdb.lib.operations.Operations.op;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import junit.framework.Assert;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.ovsdb.lib.impl.OvsdbConnectionService;
+import org.opendaylight.ovsdb.lib.message.MonitorRequest;
+import org.opendaylight.ovsdb.lib.message.MonitorRequestBuilder;
+import org.opendaylight.ovsdb.lib.message.MonitorSelect;
+import org.opendaylight.ovsdb.lib.message.TableUpdate;
+import org.opendaylight.ovsdb.lib.message.TableUpdates;
+import org.opendaylight.ovsdb.lib.message.UpdateNotification;
+import org.opendaylight.ovsdb.lib.notation.Column;
+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.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.ListenableFuture;
+
+
+public class OvsdbClientTestIT extends OvsdbTestBase {
+ Logger logger = LoggerFactory.getLogger(OvsdbClientTestIT.class);
+
+ OvsdbClient ovs;
+ DatabaseSchema dbSchema = null;
+ static String testBridgeName = "br-test";
+ static UUID testBridgeUuid = null;
+ @Test
+ public void testTransact() throws IOException, InterruptedException, ExecutionException {
+ Assert.assertNotNull(dbSchema);
+ TableSchema<GenericTableSchema> bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+ ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
+
+ createBridgeTransaction();
+ abortTransaction();
+ assertTransaction();
+ }
+
+ @Test
+ public void testMonitorRequest() throws ExecutionException, InterruptedException, IOException {
+ Assert.assertNotNull(dbSchema);
+ // Create Test Bridge before testing the Monitor operation
+ createBridgeTransaction();
+ sendBridgeMonitorRequest(true); // Test monitor request with Column filters
+ sendBridgeMonitorRequest(false); // Test monitor request without filters
+ }
+
+ public void sendBridgeMonitorRequest(boolean filter) throws ExecutionException, InterruptedException, IOException {
+ Assert.assertNotNull(dbSchema);
+ GenericTableSchema bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+
+ List<MonitorRequest<GenericTableSchema>> monitorRequests = Lists.newArrayList();
+ ColumnSchema<GenericTableSchema, Set<Integer>> flood_vlans = bridge.multiValuedColumn("flood_vlans", Integer.class);
+ ColumnSchema<GenericTableSchema, Map<String, String>> externalIds = bridge.multiValuedColumn("external_ids", String.class, String.class);
+ MonitorRequestBuilder<GenericTableSchema> builder = MonitorRequestBuilder.builder(bridge);
+ if (filter) {
+ builder.addColumn(bridge.column("name"))
+ .addColumn(bridge.column("fail_mode", String.class))
+ .addColumn(flood_vlans)
+ .addColumn(externalIds);
+ }
+ monitorRequests.add(builder.with(new MonitorSelect(true, true, true, true))
+ .build());
+
+ final List<Object> results = Lists.newArrayList();
+
+ MonitorHandle monitor = ovs.monitor(dbSchema, monitorRequests, new MonitorCallBack() {
+ @Override
+ public void update(TableUpdates result) {
+ results.add(result);
+ System.out.println("result = " + result);
+ }
+
+ @Override
+ public void exception(Throwable t) {
+ results.add(t);
+ System.out.println("t = " + t);
+ }
+ });
+
+ for (int i = 0; i < 3 ; i++) { //wait 3 seconds to get a result
+ System.out.println("waiting on monitor response for Bridge Table...");
+ if (!results.isEmpty()) break;
+ Thread.sleep(1000);
+ }
+
+ Assert.assertTrue(!results.isEmpty());
+ Object result = results.get(0);
+ Assert.assertTrue(result instanceof TableUpdates);
+ TableUpdates updates = (TableUpdates) result;
+ TableUpdate<GenericTableSchema> update = updates.getUpdate(bridge);
+ Row<GenericTableSchema> aNew = update.getNew();
+ if (filter) {
+ Assert.assertEquals(builder.getColumns().size(), aNew.getColumns().size());
+ } else {
+ // As per RFC7047, Section 4.1.5 : If "columns" is omitted, all columns in the table, except for "_uuid", are monitored.
+ Assert.assertEquals(bridge.getColumns().size() - 1, aNew.getColumns().size());
+ }
+ for (Column<GenericTableSchema, ?> column: aNew.getColumns()) {
+ if (column.getSchema().equals(flood_vlans)) {
+ // Test for the 5 flood_vlans inserted in Bridge br-test in createBridgeTransaction
+ Set<Integer> data = column.getData(flood_vlans);
+ Assert.assertTrue(!data.isEmpty());
+ Assert.assertEquals(5, data.size());
+ } else if (column.getSchema().equals(externalIds)) {
+ // Test for the {"key", "value"} external_ids inserted in Bridge br-test in createBridgeTransaction
+ Map<String, String> data = column.getData(externalIds);
+ Assert.assertNotNull(data.get("key"));
+ Assert.assertEquals("value", data.get("key"));
+ // Test for {"key2", "value2"} external_ids mutation-inserted in Bridge br-test in createBridgeTransaction
+ Assert.assertNotNull(data.get("key2"));
+ Assert.assertEquals("value2", data.get("key2"));
+ }
+ }
+ }
+
+ /*
+ * Ideally we should be using selectOpenVSwitchTableUuid() instead of this method.
+ * But Row.java needs some Jackson Jitsu to obtain the appropriate Row Json mapped to Java object
+ * for Select operation.
+ * Hence using the Monitor approach to obtain the uuid of the open_vSwitch table entry.
+ * Replace this method with selectOpenVSwitchTableUuid() once it is functional,
+ */
+ private UUID getOpenVSwitchTableUuid() throws ExecutionException, InterruptedException {
+ Assert.assertNotNull(dbSchema);
+ GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
+ List<MonitorRequest<GenericTableSchema>> monitorRequests = Lists.newArrayList();
+ ColumnSchema<GenericTableSchema, UUID> _uuid = ovsTable.column("_uuid", UUID.class);
+
+ monitorRequests.add(
+ MonitorRequestBuilder.builder(ovsTable)
+ .addColumn(_uuid)
+ .with(new MonitorSelect(true, true, true, true))
+ .build());
+
+ final List<Object> results = Lists.newArrayList();
+
+ MonitorHandle monitor = ovs.monitor(dbSchema, monitorRequests, new MonitorCallBack() {
+ @Override
+ public void update(TableUpdates result) {
+ results.add(result);
+ }
+
+ @Override
+ public void exception(Throwable t) {
+ results.add(t);
+ System.out.println("t = " + t);
+ }
+ });
+
+ for (int i = 0; i < 3 ; i++) { //wait 5 seconds to get a result
+ System.out.println("waiting on monitor response for open_vSwtich Table...");
+ if (!results.isEmpty()) break;
+ Thread.sleep(1000);
+ }
+
+ Assert.assertTrue(!results.isEmpty());
+ Object result = results.get(0); // open_vSwitch table has just 1 row.
+ Assert.assertTrue(result instanceof TableUpdates);
+ TableUpdates updates = (TableUpdates) result;
+ TableUpdate<GenericTableSchema> update = updates.getUpdate(ovsTable);
+ Assert.assertNotNull(update.getUuid());
+ return update.getUuid();
+ }
+
+ /*
+ * TODO : selectOpenVSwitchTableUuid method isn't working as expected due to the Jackson
+ * parsing challenges on the Row object returned by the Select operation.
+ */
+ private UUID selectOpenVSwitchTableUuid() throws ExecutionException, InterruptedException {
+ Assert.assertNotNull(dbSchema);
+ GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
+
+ List<MonitorRequest<GenericTableSchema>> monitorRequests = Lists.newArrayList();
+ ColumnSchema<GenericTableSchema, UUID> _uuid = ovsTable.column("_uuid", UUID.class);
+
+ List<OperationResult> results = ovs.transactBuilder()
+ .add(op.select(ovsTable)
+ .column(_uuid))
+ .execute()
+ .get();
+
+ Assert.assertTrue(!results.isEmpty());
+ OperationResult result = results.get(0);
+ List<Row<GenericTableSchema>> rows = result.getRows();
+ Row<GenericTableSchema> ovsTableRow = rows.get(0);
+ return ovsTableRow.getColumn(_uuid).getData();
+ }
+
+ private void createBridgeTransaction() throws IOException, InterruptedException, ExecutionException {
+ Assert.assertNotNull(dbSchema);
+ TableSchema<GenericTableSchema> bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+ GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
+
+ ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
+ ColumnSchema<GenericTableSchema, String> fail_mode = bridge.column("fail_mode", String.class);
+ ColumnSchema<GenericTableSchema, Set<Integer>> flood_vlans = bridge.multiValuedColumn("flood_vlans", Integer.class);
+ ColumnSchema<GenericTableSchema, Map<String, String>> externalIds = bridge.multiValuedColumn("external_ids", String.class, String.class);
+ ColumnSchema<GenericTableSchema, Set<UUID>> bridges = ovsTable.multiValuedColumn("bridges", UUID.class);
+ ColumnSchema<GenericTableSchema, UUID> _uuid = ovsTable.column("_uuid", UUID.class);
+
+ String namedUuid = "br_test";
+ int insertOperationIndex = 0;
+ UUID parentTable = getOpenVSwitchTableUuid();
+ TransactionBuilder transactionBuilder = ovs.transactBuilder()
+ /*
+ * Make sure that the position of insert operation matches the insertOperationIndex.
+ * This will be used later when the Results are processed.
+ */
+ .add(op.insert(bridge)
+ .withId(namedUuid)
+ .value(name, testBridgeName)
+ .value(flood_vlans, Sets.newHashSet(100, 101, 4001))
+ .value(externalIds, ImmutableMap.of("key","value")))
+ .add(op.comment("Inserting Bridge br-int"))
+ .add(op.update(bridge)
+ .set(fail_mode, "secure")
+ .where(name.opEqual(testBridgeName))
+ .build())
+ .add(op.select(bridge)
+ .column(name)
+ .column(_uuid)
+ .where(name.opEqual(testBridgeName))
+ .build())
+ .add(op.mutate(bridge)
+ .addMutation(flood_vlans, Mutator.INSERT, Sets.newHashSet(200,400))
+ .where(name.opEqual(testBridgeName))
+ .build())
+ .add(op.mutate(bridge)
+ .addMutation(externalIds, Mutator.INSERT, ImmutableMap.of("key2","value2"))
+ .where(name.opEqual(testBridgeName))
+ .build())
+ .add(op.mutate(ovsTable)
+ .addMutation(bridges, Mutator.INSERT, Sets.newHashSet(new UUID(namedUuid)))
+ .where(_uuid.opEqual(parentTable))
+ .build())
+ .add(op.commit(true));
+
+ 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);
+ for (OperationResult result : operationResults) {
+ Assert.assertNull(result.getError());
+ }
+ testBridgeUuid = operationResults.get(insertOperationIndex).getUuid();
+ }
+
+ private void assertTransaction() throws InterruptedException, ExecutionException {
+ Assert.assertNotNull(dbSchema);
+ TableSchema<GenericTableSchema> bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+ ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
+
+ /*
+ * Adding a separate Assert operation in a transaction. Lets not mix this with other
+ * valid transactions as above.
+ */
+ ListenableFuture<List<OperationResult>> results = ovs.transactBuilder()
+ .add(op.delete(bridge)
+ .where(name.opEqual(testBridgeName))
+ .build())
+ .add(op.assertion("Assert12345")) // Failing intentionally
+ .execute();
+
+ List<OperationResult> operationResults = results.get();
+ Assert.assertFalse(operationResults.isEmpty());
+ /* Testing for an Assertion Error */
+ Assert.assertFalse(operationResults.get(1).getError() == null);
+ System.out.println("Assert operation results = " + operationResults);
+ }
+
+ private void abortTransaction() throws InterruptedException, ExecutionException {
+ Assert.assertNotNull(dbSchema);
+ TableSchema<GenericTableSchema> bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+ ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
+
+ /*
+ * Adding a separate Abort operation in a transaction. Lets not mix this with other
+ * valid transactions as above.
+ */
+ ListenableFuture<List<OperationResult>> results = ovs.transactBuilder()
+ .add(op.delete(bridge)
+ .where(name.opEqual(testBridgeName))
+ .build())
+ .add(op.abort())
+ .execute();
+
+ List<OperationResult> operationResults = results.get();
+ Assert.assertFalse(operationResults.isEmpty());
+ /* Testing for Abort Error */
+ Assert.assertFalse(operationResults.get(1).getError() == null);
+ System.out.println("Abort operation results = " + operationResults);
+ }
+
+ 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, TimeoutException {
+ if (ovs != null) {
+ return;
+ }
+
+ ovs = getTestConnection();
+ System.out.println("Connection Info :" + ovs.getConnectionInfo().toString());
+ testGetDBs();
+ dbSchema = ovs.getSchema(OPEN_VSWITCH_SCHEMA, true).get();
+ }
+
+ @After
+ public void tearDown() throws InterruptedException, ExecutionException {
+ if (dbSchema == null) return;
+ TableSchema<GenericTableSchema> bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+ ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
+ GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
+ ColumnSchema<GenericTableSchema, Set<UUID>> bridges = ovsTable.multiValuedColumn("bridges", UUID.class);
+ ColumnSchema<GenericTableSchema, UUID> _uuid = ovsTable.column("_uuid", UUID.class);
+ UUID parentTable = getOpenVSwitchTableUuid();
+
+ ListenableFuture<List<OperationResult>> results = ovs.transactBuilder()
+ .add(op.delete(bridge)
+ .where(name.opEqual(testBridgeName))
+ .build())
+ .add(op.mutate(ovsTable)
+ .addMutation(bridges, Mutator.DELETE, Sets.newHashSet(testBridgeUuid))
+ .where(_uuid.opEqual(parentTable))
+ .build())
+ .add(op.commit(true))
+ .execute();
+
+ List<OperationResult> operationResults = results.get();
+ System.out.println("Delete operation results = " + operationResults);
+ OvsdbConnectionService.getService().disconnect(ovs);
+ }
+
+
+ @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
+
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran, Madhu Venugopal
+ */
+
+package org.opendaylight.ovsdb.lib;
+
+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.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import junit.framework.Assert;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.ovsdb.lib.impl.OvsdbConnectionService;
+import org.opendaylight.ovsdb.lib.message.UpdateNotification;
+import org.opendaylight.ovsdb.lib.notation.Mutator;
+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.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.ListenableFuture;
+
+public class OvsdbClientTestITTyped extends OvsdbTestBase {
+
+ Logger logger = LoggerFactory.getLogger(OvsdbClientTestITTyped.class);
+ OvsdbClient ovs;
+ DatabaseSchema dbSchema = null;
+ static String testBridgeName = "br-test";
+ static UUID testBridgeUuid = null;
+
+ @Test
+ public void testTypedBridgeCreate() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ TestBridge rBridge = ovs.createTypedRowWrapper(TestBridge.class);
+ rBridge.setName(testBridgeName);
+ rBridge.setStatus(ImmutableMap.of("key","value"));
+ rBridge.setFloodVlans(Sets.newHashSet(34));
+
+ GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
+ ColumnSchema<GenericTableSchema, Set<UUID>> bridges = ovsTable.multiValuedColumn("bridges", UUID.class);
+
+ String namedUuid = "br_test";
+ int insertOperationIndex = 0;
+
+ TransactionBuilder transactionBuilder = ovs.transactBuilder()
+ .add(op.insert(rBridge.getSchema())
+ .withId(namedUuid)
+ .value(rBridge.getNameColumn()))
+ .add(op.update(rBridge.getSchema())
+ .set(rBridge.getStatusColumn())
+ .set(rBridge.getFloodVlansColumn())
+ .where(rBridge.getNameColumn().getSchema().opEqual(rBridge.getName()))
+ .and(rBridge.getNameColumn().getSchema().opEqual(rBridge.getName())).build())
+ .add(op.mutate(ovsTable)
+ .addMutation(bridges, Mutator.INSERT, Sets.newHashSet(new UUID(namedUuid))));
+
+ 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, TimeoutException {
+ if (ovs != null) {
+ return;
+ }
+ ovs = this.getTestConnection();
+ testGetDBs();
+ dbSchema = ovs.getSchema(OPEN_VSWITCH_SCHEMA, true).get();
+ }
+
+ @After
+ public void tearDown() throws InterruptedException, ExecutionException {
+ TableSchema<GenericTableSchema> bridge = dbSchema.table("Bridge", GenericTableSchema.class);
+ ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
+ GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
+ ColumnSchema<GenericTableSchema, Set<UUID>> bridges = ovsTable.multiValuedColumn("bridges", UUID.class);
+
+ ListenableFuture<List<OperationResult>> results = ovs.transactBuilder()
+ .add(op.delete(bridge)
+ .where(name.opEqual(testBridgeName))
+ .build())
+ .add(op.mutate(ovsTable)
+ .addMutation(bridges, Mutator.DELETE, Sets.newHashSet(testBridgeUuid)))
+ .add(op.commit(true))
+ .execute();
+
+ List<OperationResult> operationResults = results.get();
+ System.out.println("Delete operation results = " + operationResults);
+ OvsdbConnectionService.getService().disconnect(ovs);
+ }
+
+ @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
+
+ }
+}
--- /dev/null
+/*
+ * 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.lib;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import junit.framework.Assert;
+
+import org.opendaylight.ovsdb.lib.impl.OvsdbConnectionService;
+import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
+
+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 CONNECTION_TYPE = "ovsdbserver.connection";
+ private final static String CONNECTION_TYPE_ACTIVE = "active";
+ private final static String CONNECTION_TYPE_PASSIVE = "passive";
+
+ 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;
+ }
+
+ public OvsdbClient getTestConnection() throws IOException, InterruptedException, ExecutionException, TimeoutException {
+ Properties props = loadProperties();
+ String addressStr = props.getProperty(SERVER_IPADDRESS);
+ String portStr = props.getProperty(SERVER_PORT, DEFAULT_SERVER_PORT);
+ String connectionType = props.getProperty(CONNECTION_TYPE, "active");
+
+ // If the connection type is active, controller connects to the ovsdb-server
+ if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_ACTIVE)) {
+ if (addressStr == null) {
+ Assert.fail(usage());
+ }
+
+ 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;
+ }
+
+ OvsdbConnection connection = OvsdbConnectionService.getService();
+ return connection.connect(address, port);
+ } else if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_PASSIVE)) {
+ ExecutorService executor = Executors.newFixedThreadPool(1);
+ Future<OvsdbClient> passiveConnection = executor.submit(new PassiveListener());
+ return passiveConnection.get(60, TimeUnit.SECONDS);
+ }
+ Assert.fail("Connection parameter ("+CONNECTION_TYPE+") must be either active or passive");
+ return null;
+ }
+
+ private String usage() {
+ return "Integration Test needs a valid connection configuration as follows :\n" +
+ "active connection : mvn -Pintegrationtest -Dovsdbserver.ipaddress=x.x.x.x -Dovsdbserver.port=yyyy verify\n"+
+ "passive connection : mvn -Pintegrationtest -Dovsdbserver.connection=passive verify\n";
+ }
+
+ public class PassiveListener implements Callable<OvsdbClient>, OvsdbConnectionListener {
+ OvsdbClient client = null;
+ @Override
+ public OvsdbClient call() throws Exception {
+ OvsdbConnection connection = OvsdbConnectionService.getService();
+ connection.registerForPassiveConnection(this);
+ while (client == null) {
+ Thread.sleep(500);
+ }
+ return client;
+ }
+
+ @Override
+ public void connected(OvsdbClient client) {
+ this.client = client;
+ }
+
+ @Override
+ public void disconnected(OvsdbClient client) {
+ Assert.assertEquals(this.client.getConnectionInfo(), client.getConnectionInfo());
+ this.client = null;
+ }
+ }
+}
--- /dev/null
+/*
+ * 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.lib;
+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;
+
+/**
+ * Statically Typed Bridge Table as defined in ovs-vswitchd.conf.db
+ */
+
+/*
+ * Interface name was set to TestBridge on purpose to test the @TypeTable annotation
+ * functionality of TyperHelper.java
+ */
+@TypedTable(name="Bridge", database="Open_vSwitch")
+public interface TestBridge extends TypedBaseTable {
+ /*
+ * Its a good practice to set the @TypedColumn to these Statically typed Tables & Columns.
+ * Implementations can choose to use GETDATA or GETCOLUMN or both to get the data.
+ * But GETCOLUMN gives more info on ColumnSchema.
+ * The following "name" column is decorated with both GETDATA and GETCOLUMN and the corresponding test
+ * will test both the options.
+ */
+ @TypedColumn(name="name", method=MethodType.GETDATA)
+ public String getName();
+
+ @TypedColumn(name="name", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, String> getNameColumn();
+
+ @TypedColumn(name="name", method=MethodType.SETDATA)
+ public void setName(String name);
+
+ /*
+ * Annotations are NOT added to the Status column on purpose to test the backup
+ * functionality on getter, setter, column name derivation etc. TyperHelper.java.
+ */
+ public Column<GenericTableSchema, Map<String, String>> getStatusColumn();
+ public void setStatus(Map<String, String> status);
+
+ /*
+ * TypedColumn's name Annotation should override the method name based Column derivation.
+ * The method name and TypedColumn name was kept different on purpose to test the name
+ * resolution priority of TyperHelper.java
+ */
+ @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="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="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="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> other_config);
+
+
+ @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);
+}
--- /dev/null
+/*
+ * 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.lib;
+import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
+import org.opendaylight.ovsdb.lib.schema.typed.TypedTable;
+
+/**
+ * VersionIncompatibleBridge is used to test the Version Compatibility logic in the Library
+ * with an absurdly low fromVersion and untilVersion which will fail for all the OVS versions.
+ */
+@TypedTable(name="Bridge", database="Open_vSwitch", fromVersion="0.0.1", untilVersion="0.0.2")
+public interface VersionIncompatibleBridge extends TypedBaseTable {
+}
--- /dev/null
+/*
+ * 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 : Dave Tucker
+ */
+
+package org.opendaylight.ovsdb.lib.jsonrpc;
+
+import static io.netty.buffer.Unpooled.copiedBuffer;
+import static org.junit.Assert.assertEquals;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Resources;
+import io.netty.channel.embedded.EmbeddedChannel;
+import io.netty.handler.codec.DecoderException;
+import io.netty.handler.codec.TooLongFrameException;
+import io.netty.util.CharsetUtil;
+import java.net.URL;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JsonRpcDecoderTest {
+ static int testJson_BYTES = 179;
+ String testJson;
+ String prettyTestJson;
+ static final String PREAMBLE = " ";
+ static final String PARTIAL_START = "{\"foo\":";
+ static final String PARTIAL_END = "{\"bar\":\"baz\"}}";
+
+ JsonRpcDecoder decoder;
+ EmbeddedChannel ch;
+
+ @Before
+ public void setUp() throws Exception {
+ decoder = new JsonRpcDecoder(1000);
+ ch = new EmbeddedChannel(decoder);
+
+ URL testJsonUrl = Resources.getResource(JsonRpcDecoderTest.class, "test.json");
+ testJson = Resources.toString(testJsonUrl, Charsets.UTF_8);
+ URL prettyTestJsoUrl = Resources.getResource(JsonRpcDecoderTest.class, "pretty-test.json");
+ prettyTestJson = Resources.toString(prettyTestJsoUrl, Charsets.UTF_8);
+ }
+
+ @Test
+ public void testDecode() throws Exception {
+ for (int i = 0; i < 10; i++) {
+ ch.writeInbound(copiedBuffer(testJson, CharsetUtil.UTF_8));
+ }
+ ch.readInbound();
+ assertEquals(10, decoder.getRecordsRead());
+ ch.finish();
+ }
+
+ @Test
+ public void testDecodePrettyJson() throws Exception {
+ ch.writeInbound(copiedBuffer(prettyTestJson, CharsetUtil.UTF_8));
+ ch.readInbound();
+ assertEquals(1, decoder.getRecordsRead());
+ ch.finish();
+ }
+
+ @Test
+ public void testDecodeSkipSpaces() throws Exception {
+ ch.writeInbound(copiedBuffer(PREAMBLE + testJson + PREAMBLE + testJson, CharsetUtil.UTF_8));
+ ch.readInbound();
+ assertEquals(2, decoder.getRecordsRead());
+ ch.finish();
+ }
+
+ @Test
+ public void testDecodePartial() throws Exception {
+ ch.writeInbound(copiedBuffer(PARTIAL_START, CharsetUtil.UTF_8));
+ ch.readInbound();
+ Thread.sleep(10);
+ ch.writeInbound(copiedBuffer(PARTIAL_END, CharsetUtil.UTF_8));
+ ch.readInbound();
+ assertEquals(1, decoder.getRecordsRead());
+ ch.finish();
+ }
+
+ @Test(expected= DecoderException.class)
+ public void testDecodeInvalidEncoding() throws Exception {
+ ch.writeInbound(copiedBuffer(testJson, CharsetUtil.UTF_16));
+ ch.finish();
+ }
+
+ @Test(expected=TooLongFrameException.class)
+ public void testDecodeFrameLengthExceed() {
+ decoder = new JsonRpcDecoder(testJson_BYTES -1);
+ ch = new EmbeddedChannel(decoder);
+ ch.writeInbound(copiedBuffer(testJson, CharsetUtil.UTF_8));
+ ch.finish();
+ }
+}
\ No newline at end of file
import junit.framework.TestCase;
+import org.opendaylight.ovsdb.lib.message.temp.TableUpdate;
+import org.opendaylight.ovsdb.lib.message.temp.TableUpdates;
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.lib.table.Bridge;
import org.opendaylight.ovsdb.lib.table.Interface;
import org.opendaylight.ovsdb.lib.table.Port;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import java.io.IOException;
import java.io.InputStream;
assertEquals(2, rows.size());
List<TableUpdate.Row<Port>> sorted = Ordering.natural().onResultOf(new Function<TableUpdate.Row<Port>, String>() {
@Override
- public String apply(org.opendaylight.ovsdb.lib.message.TableUpdate.Row<Port> input) {
+ public String apply(TableUpdate.Row<Port> input) {
return input.getId();
}
}).sortedCopy(rows);
--- /dev/null
+/*
+ * 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 : Dave Tucker
+ */
+
+package org.opendaylight.ovsdb.lib.notation;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class VersionTest {
+
+ @Test
+ public void testToString() throws Exception {
+ Version a = Version.fromString("1.2.3");
+ assertEquals("1.2.3", a.toString());
+ }
+
+ @Test
+ public void testEquals() throws Exception {
+ Version a = Version.fromString("1.2.3");
+ Version b = Version.fromString("0.0.0");
+ assertEquals(a, Version.fromString("1.2.3"));
+ assertTrue(a.hashCode() == Version.fromString("1.2.3").hashCode());
+ assertEquals(b, Version.fromString("0.0.0"));
+ assertTrue(b.hashCode() == Version.fromString("0.0.0").hashCode());
+ }
+
+ @Test
+ public void testCompareTo() throws Exception {
+ Version a = Version.fromString("1.2.27");
+ Version b = Version.fromString("1.2.0");
+ Version c = Version.fromString("1.99.0");
+ Version d = Version.fromString("99.1.0");
+
+ assertTrue(a.compareTo(b) > 0);
+ assertTrue(b.compareTo(a) < 0);
+ assertTrue(a.compareTo(c) < 0);
+ assertTrue(c.compareTo(b) > 0);
+ assertTrue(d.compareTo(a) > 0);
+ assertTrue(b.compareTo(d) < 0);
+
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 EBay Software Foundation
+ *
+ * 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 : Ashwin Raveendran
+ */
+package org.opendaylight.ovsdb.lib.schema;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Test;
+import org.opendaylight.ovsdb.lib.notation.Version;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import java.io.IOException;
+import java.io.InputStream;
+
+
+public class OvsdbSchemaTest {
+
+ @Test
+ public void testSchema() throws IOException {
+ InputStream resourceAsStream = OvsdbSchemaTest.class.getResourceAsStream("test_schema.json");
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode jsonNode = mapper.readTree(resourceAsStream);
+ System.out.println("jsonNode = " + jsonNode.get("id"));
+
+ DatabaseSchema schema = DatabaseSchema.fromJson("some", jsonNode.get("result"));
+ assertNotNull(schema);
+ assertEquals(Version.fromString("6.12.0"), schema.getVersion());
+ }
+}
/*
- * Copyright (C) 2013 Red Hat, Inc.
+ * Copyright (C) 2014 EBay Software Foundation
*
* 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
+ * Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.schema.temp;
-public class CommitOperation extends Operation {
+
+public class Reference {
}
--- /dev/null
+{
+ "id": 0,
+ "result": {
+ "tables": {
+ "Port": {
+ "columns": {
+ "name": {
+ "mutable": false,
+ "type": "string"
+ },
+ "statistics": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "integer",
+ "max": "unlimited"
+ }
+ },
+ "vlan_mode": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "access",
+ "native-tagged",
+ "native-untagged",
+ "trunk"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "qos": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "QoS"
+ },
+ "min": 0
+ }
+ },
+ "status": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "trunks": {
+ "type": {
+ "key": {
+ "maxInteger": 4095,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0,
+ "max": 4096
+ }
+ },
+ "mac": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "interfaces": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "Interface"
+ },
+ "max": "unlimited"
+ }
+ },
+ "bond_downdelay": {
+ "type": "integer"
+ },
+ "bond_mode": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "active-backup",
+ "balance-slb",
+ "balance-tcp",
+ "stable"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "bond_updelay": {
+ "type": "integer"
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "tag": {
+ "type": {
+ "key": {
+ "maxInteger": 4095,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "bond_fake_iface": {
+ "type": "boolean"
+ },
+ "fake_bridge": {
+ "type": "boolean"
+ },
+ "lacp": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "active",
+ "off",
+ "passive"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ }
+ },
+ "indexes": [
+ [
+ "name"
+ ]
+ ]
+ },
+ "Manager": {
+ "columns": {
+ "is_connected": {
+ "ephemeral": true,
+ "type": "boolean"
+ },
+ "target": {
+ "type": "string"
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "max_backoff": {
+ "type": {
+ "key": {
+ "minInteger": 1000,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "connection_mode": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "in-band",
+ "out-of-band"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "status": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "inactivity_probe": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ }
+ },
+ "indexes": [
+ [
+ "target"
+ ]
+ ]
+ },
+ "Bridge": {
+ "columns": {
+ "name": {
+ "mutable": false,
+ "type": "string"
+ },
+ "flood_vlans": {
+ "type": {
+ "key": {
+ "maxInteger": 4095,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0,
+ "max": 4096
+ }
+ },
+ "netflow": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "NetFlow"
+ },
+ "min": 0
+ }
+ },
+ "mirrors": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "Mirror"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "status": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "datapath_id": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "controller": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "Controller"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "protocols": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "OpenFlow10",
+ "OpenFlow12",
+ "OpenFlow13"
+ ]
+ ]
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "fail_mode": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "secure",
+ "standalone"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "ports": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "Port"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "flow_tables": {
+ "type": {
+ "key": {
+ "maxInteger": 254,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0,
+ "value": {
+ "type": "uuid",
+ "refTable": "Flow_Table"
+ },
+ "max": "unlimited"
+ }
+ },
+ "sflow": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "sFlow"
+ },
+ "min": 0
+ }
+ },
+ "datapath_type": {
+ "type": "string"
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "stp_enable": {
+ "type": "boolean"
+ }
+ },
+ "indexes": [
+ [
+ "name"
+ ]
+ ]
+ },
+ "Interface": {
+ "columns": {
+ "options": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "name": {
+ "mutable": false,
+ "type": "string"
+ },
+ "statistics": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "integer",
+ "max": "unlimited"
+ }
+ },
+ "link_speed": {
+ "ephemeral": true,
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "mtu": {
+ "ephemeral": true,
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "mac_in_use": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "type": {
+ "type": "string"
+ },
+ "ingress_policing_rate": {
+ "type": {
+ "key": {
+ "minInteger": 0,
+ "type": "integer"
+ }
+ }
+ },
+ "cfm_remote_opstate": {
+ "ephemeral": true,
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "down",
+ "up"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "status": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "mac": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "ofport": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "cfm_fault_status": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "duplex": {
+ "ephemeral": true,
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "full",
+ "half"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "lacp_current": {
+ "ephemeral": true,
+ "type": {
+ "key": "boolean",
+ "min": 0
+ }
+ },
+ "cfm_fault": {
+ "ephemeral": true,
+ "type": {
+ "key": "boolean",
+ "min": 0
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "admin_state": {
+ "ephemeral": true,
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "down",
+ "up"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "link_state": {
+ "ephemeral": true,
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "down",
+ "up"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "cfm_remote_mpids": {
+ "ephemeral": true,
+ "type": {
+ "key": "integer",
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "cfm_mpid": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "ofport_request": {
+ "type": {
+ "key": {
+ "maxInteger": 65279,
+ "minInteger": 1,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "ingress_policing_burst": {
+ "type": {
+ "key": {
+ "minInteger": 0,
+ "type": "integer"
+ }
+ }
+ },
+ "cfm_health": {
+ "ephemeral": true,
+ "type": {
+ "key": {
+ "maxInteger": 100,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "link_resets": {
+ "ephemeral": true,
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ }
+ },
+ "indexes": [
+ [
+ "name"
+ ]
+ ]
+ },
+ "SSL": {
+ "columns": {
+ "ca_cert": {
+ "type": "string"
+ },
+ "private_key": {
+ "type": "string"
+ },
+ "bootstrap_ca_cert": {
+ "type": "boolean"
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "certificate": {
+ "type": "string"
+ }
+ },
+ "maxRows": 1
+ },
+ "Open_vSwitch": {
+ "columns": {
+ "ovs_version": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "system_version": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "bridges": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "Bridge"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "statistics": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "next_cfg": {
+ "type": "integer"
+ },
+ "manager_options": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "Manager"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "system_type": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "ssl": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "SSL"
+ },
+ "min": 0
+ }
+ },
+ "db_version": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "cur_cfg": {
+ "type": "integer"
+ }
+ },
+ "maxRows": 1,
+ "isRoot": true
+ },
+ "Queue": {
+ "columns": {
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "dscp": {
+ "type": {
+ "key": {
+ "maxInteger": 63,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ }
+ },
+ "isRoot": true
+ },
+ "NetFlow": {
+ "columns": {
+ "engine_type": {
+ "type": {
+ "key": {
+ "maxInteger": 255,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "targets": {
+ "type": {
+ "key": "string",
+ "max": "unlimited"
+ }
+ },
+ "add_id_to_interface": {
+ "type": "boolean"
+ },
+ "active_timeout": {
+ "type": {
+ "key": {
+ "minInteger": -1,
+ "type": "integer"
+ }
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "engine_id": {
+ "type": {
+ "key": {
+ "maxInteger": 255,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ }
+ }
+ },
+ "Mirror": {
+ "columns": {
+ "name": {
+ "type": "string"
+ },
+ "output_port": {
+ "type": {
+ "key": {
+ "refType": "weak",
+ "type": "uuid",
+ "refTable": "Port"
+ },
+ "min": 0
+ }
+ },
+ "output_vlan": {
+ "type": {
+ "key": {
+ "maxInteger": 4095,
+ "minInteger": 1,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "statistics": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "integer",
+ "max": "unlimited"
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "select_dst_port": {
+ "type": {
+ "key": {
+ "refType": "weak",
+ "type": "uuid",
+ "refTable": "Port"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "select_all": {
+ "type": "boolean"
+ },
+ "select_vlan": {
+ "type": {
+ "key": {
+ "maxInteger": 4095,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0,
+ "max": 4096
+ }
+ },
+ "select_src_port": {
+ "type": {
+ "key": {
+ "refType": "weak",
+ "type": "uuid",
+ "refTable": "Port"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ }
+ }
+ },
+ "QoS": {
+ "columns": {
+ "queues": {
+ "type": {
+ "key": {
+ "maxInteger": 4294967295,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0,
+ "value": {
+ "type": "uuid",
+ "refTable": "Queue"
+ },
+ "max": "unlimited"
+ }
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "type": {
+ "type": "string"
+ }
+ },
+ "isRoot": true
+ },
+ "Controller": {
+ "columns": {
+ "is_connected": {
+ "ephemeral": true,
+ "type": "boolean"
+ },
+ "enable_async_messages": {
+ "type": {
+ "key": "boolean",
+ "min": 0
+ }
+ },
+ "controller_rate_limit": {
+ "type": {
+ "key": {
+ "minInteger": 100,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "target": {
+ "type": "string"
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "local_netmask": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "local_gateway": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "max_backoff": {
+ "type": {
+ "key": {
+ "minInteger": 1000,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "local_ip": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "connection_mode": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "in-band",
+ "out-of-band"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "status": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "role": {
+ "ephemeral": true,
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "master",
+ "other",
+ "slave"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "inactivity_probe": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "controller_burst_limit": {
+ "type": {
+ "key": {
+ "minInteger": 25,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ }
+ }
+ },
+ "Flow_Table": {
+ "columns": {
+ "groups": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "name": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "overflow_policy": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "evict",
+ "refuse"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "flow_limit": {
+ "type": {
+ "key": {
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ }
+ }
+ },
+ "sFlow": {
+ "columns": {
+ "polling": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "targets": {
+ "type": {
+ "key": "string",
+ "max": "unlimited"
+ }
+ },
+ "header": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "agent": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "sampling": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ }
+ }
+ }
+ },
+ "cksum": "2180939265 17455",
+ "name": "Open_vSwitch",
+ "version": "6.12.0"
+ },
+ "error": null
+}
--- /dev/null
+<?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
--- /dev/null
+{
+ "Image": {
+ "Width": 800,
+ "Height": 600,
+ "Title": "View from 15th Floor",
+ "Thumbnail": {
+ "Url": "http://www.example.com/image/481989943",
+ "Height": 125,
+ "Width": "100"
+ },
+ "IDs": [
+ 116,
+ 943,
+ 234,
+ 38793
+ ]
+ }
+}
\ No newline at end of file
--- /dev/null
+{"Image":{"Width":800,"Height":600,"Title":"View from 15th Floor","Thumbnail":{"Url":"http://www.example.com/image/481989943","Height":125,"Width":"100"},"IDs":[116,943,234,38793]}}
\ No newline at end of file
--- /dev/null
+{
+ "id": 0,
+ "result": {
+ "tables": {
+ "Port": {
+ "columns": {
+ "name": {
+ "mutable": false,
+ "type": "string"
+ },
+ "statistics": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "integer",
+ "max": "unlimited"
+ }
+ },
+ "vlan_mode": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "access",
+ "native-tagged",
+ "native-untagged",
+ "trunk"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "qos": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "QoS"
+ },
+ "min": 0
+ }
+ },
+ "status": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "trunks": {
+ "type": {
+ "key": {
+ "maxInteger": 4095,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0,
+ "max": 4096
+ }
+ },
+ "mac": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "interfaces": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "Interface"
+ },
+ "max": "unlimited"
+ }
+ },
+ "bond_downdelay": {
+ "type": "integer"
+ },
+ "bond_mode": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "active-backup",
+ "balance-slb",
+ "balance-tcp",
+ "stable"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "bond_updelay": {
+ "type": "integer"
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "tag": {
+ "type": {
+ "key": {
+ "maxInteger": 4095,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "bond_fake_iface": {
+ "type": "boolean"
+ },
+ "fake_bridge": {
+ "type": "boolean"
+ },
+ "lacp": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "active",
+ "off",
+ "passive"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ }
+ },
+ "indexes": [
+ [
+ "name"
+ ]
+ ]
+ },
+ "Manager": {
+ "columns": {
+ "is_connected": {
+ "ephemeral": true,
+ "type": "boolean"
+ },
+ "target": {
+ "type": "string"
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "max_backoff": {
+ "type": {
+ "key": {
+ "minInteger": 1000,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "connection_mode": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "in-band",
+ "out-of-band"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "status": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "inactivity_probe": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ }
+ },
+ "indexes": [
+ [
+ "target"
+ ]
+ ]
+ },
+ "Bridge": {
+ "columns": {
+ "name": {
+ "mutable": false,
+ "type": "string"
+ },
+ "flood_vlans": {
+ "type": {
+ "key": {
+ "maxInteger": 4095,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0,
+ "max": 4096
+ }
+ },
+ "netflow": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "NetFlow"
+ },
+ "min": 0
+ }
+ },
+ "mirrors": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "Mirror"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "status": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "datapath_id": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "controller": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "Controller"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "protocols": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "OpenFlow10",
+ "OpenFlow12",
+ "OpenFlow13"
+ ]
+ ]
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "fail_mode": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "secure",
+ "standalone"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "ports": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "Port"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "flow_tables": {
+ "type": {
+ "key": {
+ "maxInteger": 254,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0,
+ "value": {
+ "type": "uuid",
+ "refTable": "Flow_Table"
+ },
+ "max": "unlimited"
+ }
+ },
+ "sflow": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "sFlow"
+ },
+ "min": 0
+ }
+ },
+ "datapath_type": {
+ "type": "string"
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "stp_enable": {
+ "type": "boolean"
+ }
+ },
+ "indexes": [
+ [
+ "name"
+ ]
+ ]
+ },
+ "Interface": {
+ "columns": {
+ "options": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "name": {
+ "mutable": false,
+ "type": "string"
+ },
+ "statistics": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "integer",
+ "max": "unlimited"
+ }
+ },
+ "link_speed": {
+ "ephemeral": true,
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "mtu": {
+ "ephemeral": true,
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "mac_in_use": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "type": {
+ "type": "string"
+ },
+ "ingress_policing_rate": {
+ "type": {
+ "key": {
+ "minInteger": 0,
+ "type": "integer"
+ }
+ }
+ },
+ "cfm_remote_opstate": {
+ "ephemeral": true,
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "down",
+ "up"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "status": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "mac": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "ofport": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "cfm_fault_status": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "duplex": {
+ "ephemeral": true,
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "full",
+ "half"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "lacp_current": {
+ "ephemeral": true,
+ "type": {
+ "key": "boolean",
+ "min": 0
+ }
+ },
+ "cfm_fault": {
+ "ephemeral": true,
+ "type": {
+ "key": "boolean",
+ "min": 0
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "admin_state": {
+ "ephemeral": true,
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "down",
+ "up"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "link_state": {
+ "ephemeral": true,
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "down",
+ "up"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "cfm_remote_mpids": {
+ "ephemeral": true,
+ "type": {
+ "key": "integer",
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "cfm_mpid": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "ofport_request": {
+ "type": {
+ "key": {
+ "maxInteger": 65279,
+ "minInteger": 1,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "ingress_policing_burst": {
+ "type": {
+ "key": {
+ "minInteger": 0,
+ "type": "integer"
+ }
+ }
+ },
+ "cfm_health": {
+ "ephemeral": true,
+ "type": {
+ "key": {
+ "maxInteger": 100,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "link_resets": {
+ "ephemeral": true,
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ }
+ },
+ "indexes": [
+ [
+ "name"
+ ]
+ ]
+ },
+ "SSL": {
+ "columns": {
+ "ca_cert": {
+ "type": "string"
+ },
+ "private_key": {
+ "type": "string"
+ },
+ "bootstrap_ca_cert": {
+ "type": "boolean"
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "certificate": {
+ "type": "string"
+ }
+ },
+ "maxRows": 1
+ },
+ "Open_vSwitch": {
+ "columns": {
+ "ovs_version": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "system_version": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "bridges": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "Bridge"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "statistics": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "next_cfg": {
+ "type": "integer"
+ },
+ "manager_options": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "Manager"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "system_type": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "ssl": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "SSL"
+ },
+ "min": 0
+ }
+ },
+ "db_version": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "cur_cfg": {
+ "type": "integer"
+ }
+ },
+ "maxRows": 1,
+ "isRoot": true
+ },
+ "Queue": {
+ "columns": {
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "dscp": {
+ "type": {
+ "key": {
+ "maxInteger": 63,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ }
+ },
+ "isRoot": true
+ },
+ "NetFlow": {
+ "columns": {
+ "engine_type": {
+ "type": {
+ "key": {
+ "maxInteger": 255,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "targets": {
+ "type": {
+ "key": "string",
+ "max": "unlimited"
+ }
+ },
+ "add_id_to_interface": {
+ "type": "boolean"
+ },
+ "active_timeout": {
+ "type": {
+ "key": {
+ "minInteger": -1,
+ "type": "integer"
+ }
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "engine_id": {
+ "type": {
+ "key": {
+ "maxInteger": 255,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ }
+ }
+ },
+ "Mirror": {
+ "columns": {
+ "name": {
+ "type": "string"
+ },
+ "output_port": {
+ "type": {
+ "key": {
+ "refType": "weak",
+ "type": "uuid",
+ "refTable": "Port"
+ },
+ "min": 0
+ }
+ },
+ "output_vlan": {
+ "type": {
+ "key": {
+ "maxInteger": 4095,
+ "minInteger": 1,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "statistics": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "integer",
+ "max": "unlimited"
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "select_dst_port": {
+ "type": {
+ "key": {
+ "refType": "weak",
+ "type": "uuid",
+ "refTable": "Port"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "select_all": {
+ "type": "boolean"
+ },
+ "select_vlan": {
+ "type": {
+ "key": {
+ "maxInteger": 4095,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0,
+ "max": 4096
+ }
+ },
+ "select_src_port": {
+ "type": {
+ "key": {
+ "refType": "weak",
+ "type": "uuid",
+ "refTable": "Port"
+ },
+ "min": 0,
+ "max": "unlimited"
+ }
+ }
+ }
+ },
+ "QoS": {
+ "columns": {
+ "queues": {
+ "type": {
+ "key": {
+ "maxInteger": 4294967295,
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0,
+ "value": {
+ "type": "uuid",
+ "refTable": "Queue"
+ },
+ "max": "unlimited"
+ }
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "type": {
+ "type": "string"
+ }
+ },
+ "isRoot": true
+ },
+ "Controller": {
+ "columns": {
+ "is_connected": {
+ "ephemeral": true,
+ "type": "boolean"
+ },
+ "enable_async_messages": {
+ "type": {
+ "key": "boolean",
+ "min": 0
+ }
+ },
+ "controller_rate_limit": {
+ "type": {
+ "key": {
+ "minInteger": 100,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "target": {
+ "type": "string"
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "other_config": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "local_netmask": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "local_gateway": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "max_backoff": {
+ "type": {
+ "key": {
+ "minInteger": 1000,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ },
+ "local_ip": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "connection_mode": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "in-band",
+ "out-of-band"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "status": {
+ "ephemeral": true,
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "role": {
+ "ephemeral": true,
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "master",
+ "other",
+ "slave"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "inactivity_probe": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "controller_burst_limit": {
+ "type": {
+ "key": {
+ "minInteger": 25,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ }
+ }
+ },
+ "Flow_Table": {
+ "columns": {
+ "groups": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "max": "unlimited"
+ }
+ },
+ "name": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "overflow_policy": {
+ "type": {
+ "key": {
+ "type": "string",
+ "enum": [
+ "set",
+ [
+ "evict",
+ "refuse"
+ ]
+ ]
+ },
+ "min": 0
+ }
+ },
+ "flow_limit": {
+ "type": {
+ "key": {
+ "minInteger": 0,
+ "type": "integer"
+ },
+ "min": 0
+ }
+ }
+ }
+ },
+ "sFlow": {
+ "columns": {
+ "polling": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "targets": {
+ "type": {
+ "key": "string",
+ "max": "unlimited"
+ }
+ },
+ "header": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ },
+ "agent": {
+ "type": {
+ "key": "string",
+ "min": 0
+ }
+ },
+ "external_ids": {
+ "type": {
+ "key": "string",
+ "min": 0,
+ "value": "string",
+ "max": "unlimited"
+ }
+ },
+ "sampling": {
+ "type": {
+ "key": "integer",
+ "min": 0
+ }
+ }
+ }
+ }
+ },
+ "cksum": "2180939265 17455",
+ "name": "Open_vSwitch",
+ "version": "6.12.0"
+ },
+ "error": null
+}
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>commons.ovsdb</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <artifactId>ovsdb_commons</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>../commons/parent</relativePath>
</parent>
- <artifactId>ovsdb.neutron</artifactId>
+ <artifactId>ovsdb_neutron</artifactId>
<version>0.7.0-SNAPSHOT</version>
<packaging>bundle</packaging>
</dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>ovsdb</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <artifactId>ovsdb_library</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>ovsdb_plugin</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
org.opendaylight.ovsdb.plugin,
org.opendaylight.ovsdb.lib.notation,
org.opendaylight.ovsdb.lib.table,
- org.opendaylight.ovsdb.lib.table.internal,
org.opendaylight.controller.sal.binding.api,
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819,
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes,
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.ServiceHelper;
import org.opendaylight.ovsdb.lib.table.Open_vSwitch;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import org.opendaylight.ovsdb.plugin.OVSDBConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.opendaylight.ovsdb.lib.table.Bridge;
import org.opendaylight.ovsdb.lib.table.Interface;
import org.opendaylight.ovsdb.lib.table.Port;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import org.opendaylight.ovsdb.neutron.provider.IProviderNetworkManager;
import org.opendaylight.ovsdb.plugin.IConnectionServiceInternal;
import org.opendaylight.ovsdb.plugin.OVSDBConfigService;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.ServiceHelper;
import org.opendaylight.ovsdb.lib.table.Interface;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import org.opendaylight.ovsdb.plugin.IConnectionServiceInternal;
import org.opendaylight.ovsdb.plugin.OVSDBInventoryListener;
import org.slf4j.Logger;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.lib.table.Interface;
import org.opendaylight.ovsdb.lib.table.Port;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import org.opendaylight.ovsdb.plugin.OVSDBConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.ServiceHelper;
import org.opendaylight.ovsdb.lib.table.Interface;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import org.opendaylight.ovsdb.plugin.IConnectionServiceInternal;
import org.opendaylight.ovsdb.plugin.OVSDBInventoryListener;
import org.slf4j.Logger;
package org.opendaylight.ovsdb.neutron;
import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
public class SouthboundEvent {
public enum Type { NODE, ROW };
import org.opendaylight.ovsdb.lib.table.Interface;
import org.opendaylight.ovsdb.lib.table.Open_vSwitch;
import org.opendaylight.ovsdb.lib.table.Port;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import org.opendaylight.ovsdb.neutron.provider.IProviderNetworkManager;
import org.opendaylight.ovsdb.plugin.OVSDBInventoryListener;
import org.slf4j.Logger;
import org.opendaylight.ovsdb.lib.table.Interface;
import org.opendaylight.ovsdb.lib.table.Open_vSwitch;
import org.opendaylight.ovsdb.lib.table.Port;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import org.opendaylight.ovsdb.neutron.provider.IProviderNetworkManager;
import org.opendaylight.ovsdb.plugin.IConnectionServiceInternal;
import org.opendaylight.ovsdb.plugin.OVSDBConfigService;
import org.opendaylight.ovsdb.lib.table.Bridge;
import org.opendaylight.ovsdb.lib.table.Interface;
import org.opendaylight.ovsdb.lib.table.Port;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import org.opendaylight.ovsdb.neutron.NetworkHandler;
import org.opendaylight.ovsdb.neutron.IAdminConfigManager;
import org.opendaylight.ovsdb.neutron.IInternalNetworkManager;
String bridgeUUID = null;
String tunnelBridgeName = adminConfigManager.getIntegrationBridgeName();
OVSDBConfigService ovsdbTable = (OVSDBConfigService)ServiceHelper.getGlobalInstance(OVSDBConfigService.class, this);
- Map<String, org.opendaylight.ovsdb.lib.table.internal.Table<?>> bridgeTable = ovsdbTable.getRows(node, Bridge.NAME.getName());
+ Map<String, org.opendaylight.ovsdb.lib.table.Table<?>> bridgeTable = ovsdbTable.getRows(node, Bridge.NAME.getName());
if (bridgeTable != null) {
for (String uuid : bridgeTable.keySet()) {
Bridge bridge = (Bridge)bridgeTable.get(uuid);
try {
String bridgeUUID = null;
OVSDBConfigService ovsdbTable = (OVSDBConfigService)ServiceHelper.getGlobalInstance(OVSDBConfigService.class, this);
- Map<String, org.opendaylight.ovsdb.lib.table.internal.Table<?>> bridgeTable = ovsdbTable.getRows(node, Bridge.NAME.getName());
+ Map<String, org.opendaylight.ovsdb.lib.table.Table<?>> bridgeTable = ovsdbTable.getRows(node, Bridge.NAME.getName());
if (bridgeTable != null) {
for (String uuid : bridgeTable.keySet()) {
Bridge bridge = (Bridge)bridgeTable.get(uuid);
return;
}
- Map<String, org.opendaylight.ovsdb.lib.table.internal.Table<?>> intfs = ovsdbTable.getRows(node, Interface.NAME.getName());
+ Map<String, org.opendaylight.ovsdb.lib.table.Table<?>> intfs = ovsdbTable.getRows(node, Interface.NAME.getName());
if (intfs != null) {
- for (org.opendaylight.ovsdb.lib.table.internal.Table<?> row : intfs.values()) {
+ for (org.opendaylight.ovsdb.lib.table.Table<?> row : intfs.values()) {
Interface tunIntf = (Interface)row;
if (tunIntf.getName().equals(this.getTunnelName(tunnelType, dst))) {
of_ports = tunIntf.getOfport();
return;
}
- Map<String, org.opendaylight.ovsdb.lib.table.internal.Table<?>> intfs = ovsdbTable.getRows(node, Interface.NAME.getName());
+ Map<String, org.opendaylight.ovsdb.lib.table.Table<?>> intfs = ovsdbTable.getRows(node, Interface.NAME.getName());
if (intfs != null) {
- for (org.opendaylight.ovsdb.lib.table.internal.Table<?> row : intfs.values()) {
+ for (org.opendaylight.ovsdb.lib.table.Table<?> row : intfs.values()) {
Interface tunIntf = (Interface)row;
if (tunIntf.getName().equals(this.getTunnelName(tunnelType, dst))) {
of_ports = tunIntf.getOfport();
return;
}
- Map<String, org.opendaylight.ovsdb.lib.table.internal.Table<?>> intfs = ovsdbTable.getRows(node, Interface.NAME.getName());
+ Map<String, org.opendaylight.ovsdb.lib.table.Table<?>> intfs = ovsdbTable.getRows(node, Interface.NAME.getName());
if (intfs != null) {
- for (org.opendaylight.ovsdb.lib.table.internal.Table<?> row : intfs.values()) {
+ for (org.opendaylight.ovsdb.lib.table.Table<?> row : intfs.values()) {
Interface ethIntf = (Interface)row;
if (ethIntf.getName().equalsIgnoreCase(adminConfigManager.getPhysicalInterfaceName(node, network.getProviderPhysicalNetwork()))) {
of_ports = ethIntf.getOfport();
return;
}
- Map<String, org.opendaylight.ovsdb.lib.table.internal.Table<?>> intfs = ovsdbTable.getRows(node, Interface.NAME.getName());
+ Map<String, org.opendaylight.ovsdb.lib.table.Table<?>> intfs = ovsdbTable.getRows(node, Interface.NAME.getName());
if (intfs != null) {
- for (org.opendaylight.ovsdb.lib.table.internal.Table<?> row : intfs.values()) {
+ for (org.opendaylight.ovsdb.lib.table.Table<?> row : intfs.values()) {
Interface ethIntf = (Interface)row;
if (ethIntf.getName().equalsIgnoreCase(adminConfigManager.getPhysicalInterfaceName(node,
network.getProviderPhysicalNetwork()))) {
private Status triggerInterfaceUpdates(Node node) {
try {
OVSDBConfigService ovsdbTable = (OVSDBConfigService)ServiceHelper.getGlobalInstance(OVSDBConfigService.class, this);
- Map<String, org.opendaylight.ovsdb.lib.table.internal.Table<?>> intfs = ovsdbTable.getRows(node, Interface.NAME.getName());
+ Map<String, org.opendaylight.ovsdb.lib.table.Table<?>> intfs = ovsdbTable.getRows(node, Interface.NAME.getName());
if (intfs != null) {
- for (org.opendaylight.ovsdb.lib.table.internal.Table<?> row : intfs.values()) {
+ for (org.opendaylight.ovsdb.lib.table.Table<?> row : intfs.values()) {
Interface intf = (Interface)row;
NeutronNetwork network = tenantNetworkManager.getTenantNetworkForInterface(intf);
logger.debug("Trigger Interface update for {}", intf);
private String getInternalBridgeUUID (Node node, String bridgeName) {
try {
OVSDBConfigService ovsdbTable = (OVSDBConfigService)ServiceHelper.getGlobalInstance(OVSDBConfigService.class, this);
- Map<String, org.opendaylight.ovsdb.lib.table.internal.Table<?>> bridgeTable = ovsdbTable.getRows(node, Bridge.NAME.getName());
+ Map<String, org.opendaylight.ovsdb.lib.table.Table<?>> bridgeTable = ovsdbTable.getRows(node, Bridge.NAME.getName());
if (bridgeTable == null) return null;
for (String key : bridgeTable.keySet()) {
Bridge bridge = (Bridge)bridgeTable.get(key);
import org.opendaylight.controller.sal.utils.ServiceHelper;
import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
import org.opendaylight.ovsdb.lib.table.Open_vSwitch;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import org.opendaylight.ovsdb.plugin.ConfigurationService;
import org.opendaylight.ovsdb.plugin.OVSDBConfigService;
import org.powermock.api.mockito.PowerMockito;
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>commons.ovsdb</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- <relativePath>../../commons/parent</relativePath>
+ <artifactId>ovsdb_commons</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../commons/parent</relativePath>
</parent>
- <artifactId>ovsdb.northbound</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <artifactId>ovsdb_northbound</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
</dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>ovsdb</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <artifactId>ovsdb_library</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>ovsdb_plugin</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
org.opendaylight.controller.sal.core,
org.opendaylight.controller.sal.authorization,
org.opendaylight.ovsdb.lib.table,
- org.opendaylight.ovsdb.lib.table.internal,
org.opendaylight.ovsdb.lib.notation,
org.opendaylight.ovsdb.plugin,
javax.ws.rs,
import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
-import org.opendaylight.ovsdb.lib.table.internal.Tables;
+import org.opendaylight.ovsdb.lib.table.Table;
+import org.opendaylight.ovsdb.lib.table.Tables;
import org.opendaylight.ovsdb.plugin.OVSDBConfigService;
import org.opendaylight.ovsdb.plugin.StatusWithUuid;
import org.slf4j.Logger;
import org.opendaylight.ovsdb.lib.table.Queue;
import org.opendaylight.ovsdb.lib.table.SFlow;
import org.opendaylight.ovsdb.lib.table.SSL;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import java.util.Map;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
public class OVSDBRows {
Map<String, Table<?>> rows;
+++ /dev/null
-/*
- * Copyright (C) 2013 EBay Software Foundation
- *
- * 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 : Ashwin Raveendran, Madhu Venugopal
- */
-package org.opendaylight.ovsdb.lib.message;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.google.common.collect.Lists;
-
-import java.util.List;
-
-import org.opendaylight.ovsdb.lib.table.internal.Column;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class MonitorRequest<E> {
-
- //@JsonSerialize(contentAs = ToStringSerializer.class)
- List<Column<E>> columns;
-
- MonitorSelect select;
-
- public List<? extends Column> getColumns() {
- return columns;
- }
-
- public void setColumns(List<Column<E>> columns) {
- this.columns = columns;
- }
-
-
- public MonitorSelect getSelect() {
- return select;
- }
-
- public void setSelect(MonitorSelect select) {
- this.select = select;
- }
-
- public MonitorRequest<E> column(Column<E> column) {
- if (null == columns) {
- columns = Lists.newArrayList();
- }
- columns.add(column);
- return this;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2013 EBay Software Foundation
- *
- * 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 : Ashwin Raveendran, Madhu Venugopal
- */
-package org.opendaylight.ovsdb.lib.message;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-import org.opendaylight.ovsdb.lib.jsonrpc.Params;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
-
-import java.util.List;
-import java.util.Map;
-
-public class MonitorRequestBuilder implements Params {
-
- Map<String, MonitorRequest> requests = Maps.newLinkedHashMap();
-
- @Override
- public List<Object> params() {
- return Lists.newArrayList("Open_vSwitch", null, requests);
- }
-
- public <T extends Table> MonitorRequest<T> monitor(T table) {
- MonitorRequest<T> req = new MonitorRequest<T>();
- requests.put(table.getTableName().getName(), req);
- return req;
- }
-}
+++ /dev/null
-/*
- * 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.lib.message.operations;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
-public abstract class Operation {
- private String op;
- @JsonIgnore
- // Just a simple way to retain the result of a transact operation which the client can refer to.
- private OperationResult result;
-
- public String getOp() {
- return op;
- }
-
- public void setOp(String op) {
- this.op = op;
- }
-
- public OperationResult getResult() {
- return result;
- }
-
- public void setResult(OperationResult result) {
- this.result = result;
- }
-
- @Override
- public String toString() {
- return "Operation [op=" + op + ", result=" + result + "]";
- }
-}
+++ /dev/null
-/*
- * [[ Authors will Fill in the Copyright header ]]
- *
- * 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 : Brent Salisbury, Madhu Venugopal, Aswin Raveendran
- */
-package org.opendaylight.ovsdb.lib.message;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.apache.commons.collections.MapUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.sal.connection.ConnectionConstants;
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.ovsdb.lib.database.DatabaseSchema;
-import org.opendaylight.ovsdb.lib.message.operations.InsertOperation;
-import org.opendaylight.ovsdb.lib.message.operations.MutateOperation;
-import org.opendaylight.ovsdb.lib.message.operations.Operation;
-import org.opendaylight.ovsdb.lib.message.operations.OperationResult;
-import org.opendaylight.ovsdb.lib.notation.Condition;
-import org.opendaylight.ovsdb.lib.notation.Function;
-import org.opendaylight.ovsdb.lib.notation.Mutation;
-import org.opendaylight.ovsdb.lib.notation.Mutator;
-import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
-import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.lib.table.Bridge;
-import org.opendaylight.ovsdb.lib.table.Interface;
-import org.opendaylight.ovsdb.lib.table.Open_vSwitch;
-import org.opendaylight.ovsdb.lib.table.Port;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
-import org.opendaylight.ovsdb.lib.table.internal.Tables;
-import org.opendaylight.ovsdb.plugin.Connection;
-import org.opendaylight.ovsdb.plugin.ConnectionService;
-import org.opendaylight.ovsdb.plugin.InventoryService;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-public class OVSDBNettyFactoryIT {
- InventoryService inventoryService;
- private static String bridgeIdentifier = "br1";
- private static final Integer CONNECTION_TIMEOUT_MSEC = 3000;
- private Properties props;
-
- @Before
- public void initialize() throws IOException {
- InputStream is = this.getClass().getClassLoader()
- .getResourceAsStream(
- "org/opendaylight/ovsdb/lib/message/integration-test.properties");
- if (is == null) {
- throw new IOException("Unable to load integration-test.properties");
- }
- props = new Properties();
- props.load(is);
-
- }
-
- @Test
- public void testSome() throws InterruptedException, ExecutionException, TimeoutException,
- IOException {
- ConnectionService connectionService = new ConnectionService();
- connectionService.init();
- inventoryService = new InventoryService();
- inventoryService.init();
- connectionService.setInventoryServiceInternal(inventoryService);
- Node.NodeIDType.registerIDType("OVS", String.class);
- Map<ConnectionConstants, String> params = new HashMap<ConnectionConstants, String>();
- params.put(ConnectionConstants.ADDRESS,
- props.getProperty("ovsdbserver.ipaddress"));
- params.put(ConnectionConstants.PORT,
- props.getProperty("ovsdbserver.port", "6640"));
-
- Node node = connectionService.connect("TEST", params);
- if (node == null) {
- throw new IOException("Unable to connect to the host");
- }
-
- Connection connection = connectionService.getConnection(node);
- if (connection == null) {
- throw new IOException("Unable to connect to the host");
- }
-
- OvsdbRPC ovsdb = connection.getRpc();
- if (ovsdb == null) {
- throw new IOException("Unable to obtain RPC instance");
- }
-
- //GET DB-SCHEMA
- List<String> dbNames = Arrays.asList(Open_vSwitch.NAME.getName());
- ListenableFuture<DatabaseSchema> dbSchemaF = ovsdb.get_schema(dbNames);
- DatabaseSchema databaseSchema = null;
- databaseSchema = dbSchemaF.get(CONNECTION_TIMEOUT_MSEC, TimeUnit.MILLISECONDS);
-
- MapUtils.debugPrint(System.out, null, databaseSchema.getTables());
-
- // TEST MONITOR
- // YES it is expected to fail with "duplicate monitor ID" as we have a perpetual monitor in Inventory Service
- MonitorRequestBuilder monitorReq = new MonitorRequestBuilder();
- for (Table<?> table : Tables.getTables()) {
- monitorReq.monitor(table);
- }
-
- ListenableFuture<TableUpdates> monResponse = ovsdb.monitor(monitorReq);
- System.out.println("Monitor Request sent :");
- TableUpdates updates = monResponse.get();
- inventoryService.processTableUpdates(node, updates);
- inventoryService.printCache(node);
-
- // TRANSACT INSERT TEST
-
- Map<String, Table<?>> ovsTable = inventoryService.getTableCache(node, Open_vSwitch.NAME.getName());
- String newBridge = "new_bridge";
- String newInterface = "new_interface";
- String newPort = "new_port";
- String newSwitch = "new_switch";
-
- Operation addSwitchRequest = null;
-
- if(ovsTable != null){
- String ovsTableUUID = (String) ovsTable.keySet().toArray()[0];
- UUID bridgeUuidPair = new UUID(newBridge);
- Mutation bm = new Mutation("bridges", Mutator.INSERT, bridgeUuidPair);
- List<Mutation> mutations = new ArrayList<Mutation>();
- mutations.add(bm);
-
- UUID uuid = new UUID(ovsTableUUID);
- Condition condition = new Condition("_uuid", Function.EQUALS, uuid);
- List<Condition> where = new ArrayList<Condition>();
- where.add(condition);
- addSwitchRequest = new MutateOperation(Open_vSwitch.NAME.getName(), where, mutations);
- }
- else{
- Open_vSwitch ovsTableRow = new Open_vSwitch();
- OvsDBSet<UUID> bridges = new OvsDBSet<UUID>();
- UUID bridgeUuidPair = new UUID(newBridge);
- bridges.add(bridgeUuidPair);
- ovsTableRow.setBridges(bridges);
- addSwitchRequest = new InsertOperation(Open_vSwitch.NAME.getName(), newSwitch, ovsTableRow);
- }
-
- Bridge bridgeRow = new Bridge();
- bridgeRow.setName(bridgeIdentifier);
- OvsDBSet<UUID> ports = new OvsDBSet<UUID>();
- UUID port = new UUID(newPort);
- ports.add(port);
- bridgeRow.setPorts(ports);
- InsertOperation addBridgeRequest = new InsertOperation(Bridge.NAME.getName(), newBridge, bridgeRow);
-
- Port portRow = new Port();
- portRow.setName(bridgeIdentifier);
- OvsDBSet<UUID> interfaces = new OvsDBSet<UUID>();
- UUID interfaceid = new UUID(newInterface);
- interfaces.add(interfaceid);
- portRow.setInterfaces(interfaces);
- InsertOperation addPortRequest = new InsertOperation(Port.NAME.getName(), newPort, portRow);
-
- Interface interfaceRow = new Interface();
- interfaceRow.setName(bridgeIdentifier);
- interfaceRow.setType("internal");
- InsertOperation addIntfRequest = new InsertOperation(Interface.NAME.getName(), newInterface, interfaceRow);
-
- TransactBuilder transaction = new TransactBuilder();
- transaction.addOperations(new ArrayList<Operation>(
- Arrays.asList(addSwitchRequest, addIntfRequest, addPortRequest, addBridgeRequest)));
-
- ListenableFuture<List<OperationResult>> transResponse = ovsdb.transact(transaction);
- System.out.println("Transcation sent :");
- List<OperationResult> tr = transResponse.get();
- System.out.println("Transaction response : "+transResponse.toString());
- List<Operation> requests = transaction.getRequests();
- for (int i = 0; i < tr.size() ; i++) {
- if (i < requests.size()) requests.get(i).setResult(tr.get(i));
- }
-
- System.out.println("Request + Response : "+requests.toString());
- if (tr.size() > requests.size()) {
- System.out.println("ERROR : "+tr.get(tr.size()-1).getError());
- System.out.println("Details : "+tr.get(tr.size()-1).getDetails());
- }
-
- // TEST ECHO
-
- ListenableFuture<List<String>> some = ovsdb.echo();
- Object s = some.get();
- System.out.printf("Result of echo is %s \n", s);
-
- // TEST ECHO REQUEST/REPLY
- Thread.sleep(10000);
-
- connectionService.disconnect(node);
- }
-}
+++ /dev/null
-ovsdbserver.ipaddress=${ovsdbserver.ipaddress}
-ovsdbserver.port=${ovsdbserver.port}
\ No newline at end of file
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>commons.ovsdb</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <artifactId>ovsdb_commons</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>../commons/parent</relativePath>
</parent>
- <artifactId>ovsdb</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <artifactId>ovsdb_plugin</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<properties>
<!-- used for filtering the integration test resource -->
- <ovsdbserver.ipaddress>192.168.56.10</ovsdbserver.ipaddress>
- <ovsdbserver.port>6640</ovsdbserver.port>
<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>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
- <version>4.0.17.Final</version>
+ <version>4.0.10.Final</version>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>sal.networkconfiguration</artifactId>
<version>0.0.3-SNAPSHOT</version>
</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>
org.opendaylight.controller.sal.connection,
org.opendaylight.controller.clustering.services,
org.opendaylight.controller.sal.networkconfig.bridgedomain,
+ org.opendaylight.ovsdb.lib.table,
+ org.opendaylight.ovsdb.plugin,
+ org.opendaylight.ovsdb.lib.notation,
+ org.opendaylight.ovsdb.lib.database,
+ org.opendaylight.ovsdb.lib.operations,
+ org.opendaylight.ovsdb.lib.message,
org.apache.commons.lang3.builder,
org.apache.commons.lang3.tuple,
org.apache.felix.dm,
<Embed-Dependency>httpclient,commons-codec,httpcore-nio,javax.servlet-api,portlet-api,commons-collections;type=!pom;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Bundle-Activator>org.opendaylight.ovsdb.plugin.Activator</Bundle-Activator>
- <Export-Package>org.opendaylight.ovsdb.lib.table, org.opendaylight.ovsdb.lib.table.internal, org.opendaylight.ovsdb.plugin, org.opendaylight.ovsdb.lib.notation</Export-Package>
+ <Export-Package>org.opendaylight.ovsdb.plugin</Export-Package>
</instructions>
<manifestLocation>${project.basedir}/META-INF</manifestLocation>
</configuration>
import org.opendaylight.ovsdb.lib.database.OVSInstance;
import org.opendaylight.ovsdb.lib.database.OvsdbType;
import org.opendaylight.ovsdb.lib.message.TransactBuilder;
-import org.opendaylight.ovsdb.lib.message.operations.DeleteOperation;
-import org.opendaylight.ovsdb.lib.message.operations.InsertOperation;
-import org.opendaylight.ovsdb.lib.message.operations.MutateOperation;
-import org.opendaylight.ovsdb.lib.message.operations.Operation;
-import org.opendaylight.ovsdb.lib.message.operations.OperationResult;
-import org.opendaylight.ovsdb.lib.message.operations.UpdateOperation;
+import org.opendaylight.ovsdb.lib.operations.DeleteOperation;
+import org.opendaylight.ovsdb.lib.operations.InsertOperation;
+import org.opendaylight.ovsdb.lib.operations.MutateOperation;
+import org.opendaylight.ovsdb.lib.operations.Operation;
+import org.opendaylight.ovsdb.lib.operations.OperationResult;
+import org.opendaylight.ovsdb.lib.operations.UpdateOperation;
import org.opendaylight.ovsdb.lib.notation.Condition;
import org.opendaylight.ovsdb.lib.notation.Function;
import org.opendaylight.ovsdb.lib.notation.Mutation;
import org.opendaylight.ovsdb.lib.table.Queue;
import org.opendaylight.ovsdb.lib.table.SFlow;
import org.opendaylight.ovsdb.lib.table.SSL;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
if (connection != null) {
String newmanager = "new_manager";
- OVSInstance instance = OVSInstance.monitorOVS(connection);
+ OVSInstance instance = OVSInstance.monitorOVS();
Map ovsoutter = new LinkedHashMap();
Map ovsinner = new LinkedHashMap();
import org.opendaylight.ovsdb.lib.jsonrpc.JsonRpcServiceBinderHandler;
import org.opendaylight.ovsdb.lib.message.MonitorRequestBuilder;
import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
-import org.opendaylight.ovsdb.lib.message.TableUpdates;
+import org.opendaylight.ovsdb.lib.message.temp.TableUpdates;
import org.opendaylight.ovsdb.lib.message.UpdateNotification;
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
import org.opendaylight.ovsdb.lib.table.Bridge;
import org.opendaylight.ovsdb.lib.table.Controller;
import org.opendaylight.ovsdb.lib.table.Open_vSwitch;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
-import org.opendaylight.ovsdb.lib.table.internal.Tables;
+import org.opendaylight.ovsdb.lib.table.Table;
+import org.opendaylight.ovsdb.lib.table.Tables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
JsonRpcEndpoint factory = new JsonRpcEndpoint(objectMapper, channel);
JsonRpcServiceBinderHandler binderHandler = new JsonRpcServiceBinderHandler(factory);
- binderHandler.setNode(node);
+ binderHandler.setContext(node);
channel.pipeline().addLast(binderHandler);
OvsdbRPC ovsdb = factory.getClient(node, OvsdbRPC.class);
inventoryServiceInternal.addNode(connection.getNode(), props);
List<String> dbNames = Arrays.asList(Open_vSwitch.NAME.getName());
- ListenableFuture<DatabaseSchema> dbSchemaF = connection.getRpc().get_schema(dbNames);
+ ListenableFuture<DatabaseSchema> dbSchemaF = null;//TODO : fix it up to new structue : connection.getRpc().get_schema(dbNames);
DatabaseSchema databaseSchema = dbSchemaF.get();
inventoryServiceInternal.updateDatabaseSchema(connection.getNode(), databaseSchema);
- MonitorRequestBuilder monitorReq = new MonitorRequestBuilder();
+ MonitorRequestBuilder monitorReq = null; //ashwin(not sure if we need) : new MonitorRequestBuilder();
for (Table<?> table : Tables.getTables()) {
if (databaseSchema.getTables().keySet().contains(table.getTableName().getName())) {
- monitorReq.monitor(table);
+ //ashwin(not sure if we need) monitorReq.monitor(table);
} else {
logger.debug("We know about table {} but it is not in the schema of {}", table.getTableName().getName(), connection.getNode().getNodeIDString());
}
}
- ListenableFuture<TableUpdates> monResponse = connection.getRpc().monitor(monitorReq);
+ ListenableFuture<TableUpdates> monResponse = null; //TODO : ashwin(not sure if we need)connection.getRpc().monitor(monitorReq);
TableUpdates updates = monResponse.get();
if (updates.getError() != null) {
logger.error("Error configuring monitor, error : {}, details : {}",
}
@Override
- public void update(Node node, UpdateNotification updateNotification) {
+ public void update(Object context, UpdateNotification updateNotification) {
if (updateNotification == null) return;
- inventoryServiceInternal.processTableUpdates(node, updateNotification.getUpdate());
+ inventoryServiceInternal.processTableUpdates((Node)context, updateNotification.getUpdate());
}
@Override
- public void locked(Node node, List<String> ids) {
+ public void locked(Object context, List<String> ids) {
// TODO Auto-generated method stub
}
@Override
- public void stolen(Node node, List<String> ids) {
+ public void stolen(Object context, List<String> ids) {
// TODO Auto-generated method stub
}
-
}
import org.opendaylight.controller.sal.utils.HexEncode;
import org.opendaylight.controller.sal.utils.ServiceHelper;
import org.opendaylight.ovsdb.lib.database.DatabaseSchema;
-import org.opendaylight.ovsdb.lib.message.TableUpdate;
-import org.opendaylight.ovsdb.lib.message.TableUpdate.Row;
-import org.opendaylight.ovsdb.lib.message.TableUpdates;
+import org.opendaylight.ovsdb.lib.message.temp.TableUpdate;
+import org.opendaylight.ovsdb.lib.message.temp.TableUpdate.Row;
+import org.opendaylight.ovsdb.lib.message.temp.TableUpdates;
import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
import org.opendaylight.ovsdb.lib.table.Bridge;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.opendaylight.controller.sal.core.UpdateType;
import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
import org.opendaylight.ovsdb.lib.database.DatabaseSchema;
-import org.opendaylight.ovsdb.lib.message.TableUpdates;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.message.temp.TableUpdates;
+import org.opendaylight.ovsdb.lib.table.Table;
public interface InventoryServiceInternal extends IPluginInInventoryService {
public ConcurrentMap<String, ConcurrentMap<String, Table<?>>> getCache(Node n);
import org.apache.commons.collections.MapUtils;
import org.opendaylight.ovsdb.lib.database.DatabaseSchema;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
public class NodeDB {
private DatabaseSchema schema;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
public interface OVSDBConfigService {
public StatusWithUuid insertRow (Node node, String tableName, String parentUUID, Table<?> row);
package org.opendaylight.ovsdb.plugin;
import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.Table;
public interface OVSDBInventoryListener {
public void nodeAdded(Node node);
package org.opendaylight.ovsdb.plugin;
import java.io.IOException;
-import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import junit.framework.Assert;
+
import org.opendaylight.controller.sal.connection.ConnectionConstants;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
protected final static String TAGGED_PORT_NAME = "eth1";
protected final static String TUNNEL_PORT_NAME = "vxlan0";
protected final static String FAKE_IP = "192.168.254.254";
+ private final static String SERVER_IPADDRESS = "ovsdbserver.ipaddress";
+ private final static String SERVER_PORT = "ovsdbserver.port";
+ private final static String DEFAULT_SERVER_PORT = "6640";
public Properties loadProperties() throws IOException {
- InputStream is = this
- .getClass()
- .getClassLoader()
- .getResourceAsStream(
- "org/opendaylight/ovsdb/lib/message/integration-test.properties");
- if (is == null) {
- throw new IOException("Unable to load integration-test.properties");
- }
- Properties props = new Properties();
- props.load(is);
-
+ Properties props = new Properties(System.getProperties());
return props;
}
}
public TestObjects 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("Usage : mvn -Pintegrationtest -Dovsdbserver.ipaddress=x.x.x.x -Dovsdbserver.port=yyyy verify");
+ }
+
Node.NodeIDType.registerIDType("OVS", String.class);
NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class,
"OVS");
+ InventoryService inventoryService = new InventoryService();
+ inventoryService.init();
ConnectionService connectionService = new ConnectionService();
connectionService.init();
inventory.init();
connectionService.setInventoryServiceInternal(inventory);
Map<ConnectionConstants, String> params = new HashMap<ConnectionConstants, String>();
- Properties props = loadProperties();
- params.put(ConnectionConstants.ADDRESS,
- props.getProperty("ovsdbserver.ipaddress"));
- params.put(ConnectionConstants.PORT,
- props.getProperty("ovsdbserver.port", "6640"));
+
+ params.put(ConnectionConstants.ADDRESS, address);
+ params.put(ConnectionConstants.PORT, port);
Node node = connectionService.connect(identifier, params);
if (node == null) {
*/
package org.opendaylight.ovsdb.plugin;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.sal.core.Node;
import org.slf4j.Logger;
private static final Logger logger = LoggerFactory
.getLogger(OvsdbTestAddPortIT.class);
- private Properties props;
-
- @Before
- public void loadProps() throws IOException {
- props = loadProperties();
- }
-
@Test
public void deletePort() throws Throwable{
TestObjects testObjects = getTestConnection();
ConnectionService connectionService = testObjects.connectionService;
Node node = testObjects.node;
-
+ /**
+ * Deletes an existing port from an existing bridge
+ * Ex. ovs-vsctl del-port ovsbr0 tap0
+ * @param node Node serving this configuration service
+ * @param bridgeDomainIdentifier String representation of a Bridge Domain
+ * @param portIdentifier String representation of a user defined Port Name
+ */
ConfigurationService configurationService = new ConfigurationService();
configurationService.setConnectionServiceInternal(connectionService);
configurationService.deletePort(node, BRIDGE_NAME, PORT_NAME);
<parent>
<groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>commons.ovsdb</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <artifactId>ovsdb_commons</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
<relativePath>commons/parent</relativePath>
</parent>
<groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>ovsdb.project</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <artifactId>ovsdb_project</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<prerequisites>
<maven>3.0</maven>
</prerequisites>
<modules>
- <module>ovsdb</module>
- <module>northbound/ovsdb</module>
+ <module>library</module>
+ <module>schemas/Open_vSwitch</module>
+ <module>plugin</module>
+ <module>northbound</module>
<module>neutron</module>
<module>commons/parent</module>
<module>distribution/opendaylight</module>
--- /dev/null
+<?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.schema.openvswitch</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>
--- /dev/null
+/*
+ * 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, Dave Tucker
+ */
+
+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;
+
+/**
+ * This class is a typed interface to the Bridge Table
+ */
+@TypedTable(name="Bridge", database="Open_vSwitch")
+public interface Bridge extends TypedBaseTable {
+
+ @TypedColumn(name="name", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getNameColumn();
+
+ @TypedColumn(name="name", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getName();
+
+ @TypedColumn(name="name", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setName(String name);
+
+ @TypedColumn(name="datapath_type", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getDatapathTypeColumn();
+
+ @TypedColumn(name="datapath_type", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setDatapathType(String datapathType);
+
+ @TypedColumn(name="datapath_id", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<String>> getDatapathIdColumn();
+
+ @TypedColumn(name="datapath_id", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setDatapathId(Set<String> datapathId);
+
+ @TypedColumn(name="stp_enable", method=MethodType.GETCOLUMN, fromVersion="6.2.0")
+ public Column<GenericTableSchema, Boolean> getStpEnableColumn();
+
+ @TypedColumn(name="stp_enable", method=MethodType.SETDATA, fromVersion="6.2.0")
+ public void setStpEnable(Boolean stp_enable);
+
+ @TypedColumn(name="ports", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getPortsColumn();
+
+ @TypedColumn(name="ports", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setPorts(Set<UUID> ports);
+
+ @TypedColumn(name="mirrors", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getMirrorsColumn();
+
+ @TypedColumn(name="mirrors", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setMirrors(Set<UUID> mirrors);
+
+ @TypedColumn(name="netflow", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getNetflowColumn();
+
+ @TypedColumn(name="netflow", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setNetflow(Set<UUID> netflow);
+
+ @TypedColumn(name="sflow", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getSflowColumn();
+
+ @TypedColumn(name="sflow", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setSflow(Set<UUID> sflow);
+
+ @TypedColumn(name="ipfix", method=MethodType.GETCOLUMN, fromVersion="7.1.0")
+ public Column<GenericTableSchema, Set<UUID>> getIpfixColumn();
+
+ @TypedColumn(name="ipfix", method=MethodType.SETDATA, fromVersion="7.1.0")
+ public void setIpfix(Set<UUID> ipfix);
+
+ @TypedColumn(name="controller", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getControllerColumn();
+
+ @TypedColumn(name="controller", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setController(Set<UUID> controller);
+
+ @TypedColumn(name="protocols", method=MethodType.GETCOLUMN, fromVersion="6.11.1")
+ public Column<GenericTableSchema, Set<String>> getProtocolsColumn();
+
+ @TypedColumn(name="protocols", method=MethodType.SETDATA, fromVersion="6.11.1")
+ public void setProtocols(Set<String> protocols);
+
+ @TypedColumn(name="fail_mode", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<String>> getFailModeColumn();
+
+ @TypedColumn(name="fail_mode", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setFailMode(Set<String> failMode);
+
+ @TypedColumn(name="status", method=MethodType.GETCOLUMN, fromVersion="6.2.0")
+ public Column<GenericTableSchema, Map<String, String>> getStatusColumn();
+
+ @TypedColumn(name="status", method=MethodType.SETDATA, fromVersion="6.2.0")
+ public void setStatus(Map<String, String> status);
+
+ @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="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="flood_vlans", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<Integer>> getFloodVlansColumn();
+
+ @TypedColumn(name="flood_vlans", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setFloodVlans(Set<Integer> vlans);
+
+ @TypedColumn(name="flow_tables", method=MethodType.GETCOLUMN, fromVersion="6.5.0")
+ public Column<GenericTableSchema, Map<Integer, UUID>> getFlowTablesColumn();
+
+ @TypedColumn(name="flow_tables", method=MethodType.SETDATA, fromVersion="6.5.0")
+ public void setFlowTables(Map<Integer, UUID> flowTables);
+
+}
--- /dev/null
+/*
+ * 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 org.opendaylight.ovsdb.lib.notation.Column;
+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 many of columns are not defined here
+ * TODO : Fill up the missing Columns and include Supported DB Version
+ */
+@TypedTable(name="Capability", database="Open_vSwitch")
+public interface Capability extends TypedBaseTable {
+ @TypedColumn(name="details", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Map<String, String>> getDetailsColumn();
+
+ @TypedColumn(name="details", method=MethodType.SETDATA)
+ public void setDetails(Map<String, String> details);
+}
--- /dev/null
+/*
+ * 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 org.opendaylight.ovsdb.lib.notation.Column;
+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 many of columns are not defined here
+ * TODO : Fill up the missing Columns and include Supported DB Version
+ */
+
+@TypedTable(name="Controller", database="Open_vSwitch")
+public interface Controller extends TypedBaseTable {
+
+ @TypedColumn(name="target", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, String> getTargetColumn();
+
+ @TypedColumn(name="target", method=MethodType.SETDATA)
+ public void setTarget(String target);
+
+ @TypedColumn(name="controller_burst_limit", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Integer> getBurstLimitColumn();
+
+ @TypedColumn(name="controller_burst_limit", method=MethodType.SETDATA)
+ public void setBurstLimit(Integer burstLimit);
+
+ @TypedColumn(name="controller_rate_limit", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Integer> getRateLimitColumn();
+
+ @TypedColumn(name="controller_rate_limit", method=MethodType.SETDATA)
+ public void setRateLimit(Integer burstLimit);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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 org.opendaylight.ovsdb.lib.notation.Column;
+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 many of columns are not defined here
+ * TODO : Fill up the missing Columns and include Supported DB Version
+ */
+@TypedTable(name="Flow_Sample_Collector_Set", database="Open_vSwitch")
+public interface FlowSampleCollectorSet extends TypedBaseTable {
+ @TypedColumn(name="id", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Integer> getIdColumn();
+ @TypedColumn(name="id", method=MethodType.SETDATA)
+ public void setId(Integer id);
+
+ @TypedColumn(name="bridge", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Bridge> getBridgeColumn();
+ @TypedColumn(name="bridge", method=MethodType.SETDATA)
+ public void setBridge(Bridge bridge);
+
+ @TypedColumn(name="ipfix", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, IPFIX> getIpfixColumn();
+ @TypedColumn(name="ipfix", method=MethodType.SETDATA)
+ public void setIpfix(IPFIX ipfix);
+
+ @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);
+}
--- /dev/null
+/*
+ * 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.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;
+
+/**
+ * This class is a typed interface to the Flow_Table Table
+ */
+@TypedTable(name="Flow_Table", database="Open_vSwitch", fromVersion="6.5.0")
+public interface FlowTable extends TypedBaseTable {
+
+ @TypedColumn(name="flow_limit", method=MethodType.GETCOLUMN, fromVersion="6.5.0")
+ public Column<GenericTableSchema, Integer> getFlowLimitColumn() ;
+
+ @TypedColumn(name="flow_limit", method=MethodType.SETDATA, fromVersion="6.5.0")
+ public void setFlowLimit(Integer flowLimit) ;
+
+ @TypedColumn(name="overflow_policy", method=MethodType.GETCOLUMN, fromVersion="6.5.0")
+ public Column<GenericTableSchema, Set<String>> getOverflowPolicyColumn() ;
+
+ @TypedColumn(name="overflow_policy", method=MethodType.SETDATA, fromVersion="6.5.0")
+ public void setOverflowPolicy(Set<String> overflowPolicy) ;
+
+ @TypedColumn(name="groups", method=MethodType.GETCOLUMN, fromVersion="6.5.0")
+ public Column<GenericTableSchema, Set<String>> getGroupsColumn() ;
+
+ @TypedColumn(name="groups", method=MethodType.SETDATA, fromVersion="6.5.0")
+ public void setGroups(Set<String> groups) ;
+
+ @TypedColumn(name="name", method=MethodType.GETCOLUMN, fromVersion="6.5.0")
+ public Column<GenericTableSchema, Set<String>> getNameColumn();
+
+ @TypedColumn(name="name", method=MethodType.SETDATA, fromVersion="6.5.0")
+ public void setName(Set<String> name);
+
+ @TypedColumn(name="prefixes", method=MethodType.GETCOLUMN, fromVersion="7.4.0")
+ public Column<GenericTableSchema, Set<String>> getPrefixesColumn();
+
+ @TypedColumn(name="prefixes", method=MethodType.SETDATA, fromVersion="7.4.0")
+ public void setPrefixes(Set<String> prefixes);
+
+ @TypedColumn(name="external_ids", method=MethodType.GETCOLUMN, fromVersion="7.5.0")
+ public Column<GenericTableSchema, Map<String, String>> getExternalIdsColumn();
+
+ @TypedColumn(name="external_ids", method=MethodType.SETDATA, fromVersion="7.5.0")
+ public void setExternalIds(Map<String, String> externalIds);
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.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;
+
+/**
+ * This class is a typed interface to the IPFIX Table
+ */
+@TypedTable(name="IPFIX", database="Open_vSwitch", fromVersion="7.1.0")
+public interface IPFIX extends TypedBaseTable {
+
+ @TypedColumn(name="targets", method=MethodType.GETCOLUMN, fromVersion="7.1.0")
+ public Column<GenericTableSchema, Set<String>> getTargetsColumn();
+ @TypedColumn(name="targets", method=MethodType.SETDATA, fromVersion="7.1.0")
+ public void setTargets(Set<String> targets);
+
+ @TypedColumn(name="sampling", method=MethodType.GETCOLUMN, fromVersion="7.1.0")
+ public Column<GenericTableSchema, Set<Integer>> getSamplingColumn();
+ @TypedColumn(name="sampling", method=MethodType.SETDATA, fromVersion="7.1.0")
+ public void setSampling(Set<Integer> sampling);
+
+ @TypedColumn(name="obs_domain_id", method=MethodType.GETCOLUMN, fromVersion="7.1.0")
+ public Column<GenericTableSchema, Set<Integer>> getObsDomainIdColumn();
+ @TypedColumn(name="obs_domain_id", method=MethodType.SETDATA, fromVersion="7.1.0")
+ public void setObsDomainId(Set<Integer> obs_domain_id);
+
+ @TypedColumn(name="obs_point_id", method=MethodType.GETCOLUMN, fromVersion="7.1.0")
+ public Column<GenericTableSchema, Set<Integer>> getObsPointIdColumn();
+ @TypedColumn(name="obs_point_id", method=MethodType.SETDATA, fromVersion="7.1.0")
+ public void setObsPointId(Set<Integer> obsPointId);
+
+ @TypedColumn(name="cache_active_timeout", method=MethodType.GETCOLUMN, fromVersion="7.3.0")
+ public Column<GenericTableSchema, Set<Integer>> getCacheActiveTimeoutColumn();
+ @TypedColumn(name="cache_active_timeout", method=MethodType.SETDATA, fromVersion="7.3.0")
+ public void setCacheActiveTimeout(Set<Integer> cacheActiveTimeout);
+
+ @TypedColumn(name="cache_max_flows", method=MethodType.GETCOLUMN, fromVersion="7.3.0")
+ public Column<GenericTableSchema, Set<Integer>> getCacheMaxFlowsColumn();
+ @TypedColumn(name="cache_max_flows", method=MethodType.SETDATA, fromVersion="7.3.0")
+ public void setCacheMaxFlows(Set<Integer> cacheMaxFlows);
+
+ @TypedColumn(name="external_ids", method=MethodType.GETCOLUMN, fromVersion="7.1.0")
+ public Column<GenericTableSchema, Map<String, String>> getExternalIdsColumn();
+ @TypedColumn(name="external_ids", method=MethodType.SETDATA, fromVersion="7.1.0")
+ public void setExternalIds(Map<String, String> externalIds);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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, Dave Tucker
+ */
+package org.opendaylight.ovsdb.schema.openvswitch;
+
+import java.math.BigInteger;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.ovsdb.lib.notation.Column;
+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;
+
+/**
+ * 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, fromVersion="1.0.0")
+ 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="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, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Map<String, String>> getOptionsColumn();
+ @TypedColumn(name="options", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setOptions(Map<String, String> options);
+
+ @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="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, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<String>> getMacColumn();
+ @TypedColumn(name="mac", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setMac(Set<String> mac);
+
+ @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, fromVersion="1.0.0")
+ public void setStatistics(Map<String, Integer> statistics);
+
+ @TypedColumn(name="status", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Map<String, String>> getStatusColumn();
+ @TypedColumn(name="status", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setStatus(Map<String, String> status);
+
+ @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);
+
+}
--- /dev/null
+/*
+ * 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 org.opendaylight.ovsdb.lib.notation.Column;
+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 many of columns are not defined here
+ * TODO : Fill up the missing Columns and include Supported DB Version
+ */
+@TypedTable(name="Manager", database="Open_vSwitch")
+public interface Manager extends TypedBaseTable {
+ @TypedColumn(name="target", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, String> getTargetColumn() ;
+ @TypedColumn(name="target", method=MethodType.SETDATA)
+ public void setTarget(String target) ;
+}
--- /dev/null
+/*
+ * 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 many of columns are not defined here
+ * TODO : Fill up the missing Columns and include Supported DB Version
+ */
+@TypedTable(name="Mirror", database="Open_vSwitch")
+public interface Mirror extends TypedBaseTable {
+
+ @TypedColumn(name="name", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, String> getNameColumn();
+ @TypedColumn(name="name", method=MethodType.SETDATA)
+ public void setName(String name);
+
+ @TypedColumn(name="select_src_port", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Set<UUID>> getSelectSrcPortColumn();
+ @TypedColumn(name="select_src_port", method=MethodType.SETDATA)
+ public void setSelectSrcPort(Set<UUID> selectSrcPort);
+
+ @TypedColumn(name="select_dst_port", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Set<UUID>> getSelectDstPortColumn();
+ @TypedColumn(name="select_dst_port", method=MethodType.SETDATA)
+ public void setSelectDstPort(Set<UUID> selectDstPrt);
+
+ @TypedColumn(name="select_vlan", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Set<Integer>> getSelectVlanColumn();
+ @TypedColumn(name="select_vlan", method=MethodType.SETDATA)
+ public void setSelectVlan(Set<Integer> selectVlan);
+
+ @TypedColumn(name="output_port", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Set<UUID>> getOutputPortColumn();
+ @TypedColumn(name="output_port", method=MethodType.SETDATA)
+ public void setOutputPort(Set<UUID> outputPort);
+
+ @TypedColumn(name="output_vlan", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Set<Integer>> getOutputVlanColumn();
+ @TypedColumn(name="output_vlan", method=MethodType.SETDATA)
+ public void setOutputVlan(Set<Integer> outputVlan);
+
+ @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);
+
+ @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);
+}
--- /dev/null
+/*
+ * 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.math.BigInteger;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.ovsdb.lib.notation.Column;
+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;
+
+/**
+ * This class is a typed interface to the NetFlow Table
+ */
+@TypedTable(name="NetFlow", database="Open_vSwitch", fromVersion="1.0.0")
+public interface NetFlow extends TypedBaseTable {
+
+ @TypedColumn(name="targets", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<String>> getTargetsColumn();
+
+ @TypedColumn(name="targets", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setTargets(Set<String> targets);
+
+ @TypedColumn(name="active_timeout", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<Integer>> getActiveTimeoutColumn();
+
+ @TypedColumn(name="active_timeout", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setActiveTimeout(Integer activeTimeout);
+
+ @TypedColumn(name="engine_type", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<BigInteger>> getEngineTypeColumn();
+
+ @TypedColumn(name="engine_type", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setEngineType(Set<BigInteger> engineType);
+
+ @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="active_timeout", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<Integer>> getActivityTimeoutColumn();
+
+ @TypedColumn(name="active_timeout", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setActivityTimeout(Set<Integer> activityTimeout);
+
+ @TypedColumn(name="add_id_to_interface", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<Boolean>> getAddIdToInterfaceColumn();
+
+ @TypedColumn(name="add_id_to_interface", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setAddIdToInterface(Boolean addIdToInterface);
+
+ @TypedColumn(name="engine_id", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<BigInteger>> getEngineIdColumn();
+
+ @TypedColumn(name="engine_id", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setEngineId(Set<BigInteger> engineId);
+
+}
--- /dev/null
+/*
+ * 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, Dave Tucker
+ */
+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;
+
+
+/**
+ * This class is a typed interface to the Open_vSwitch table
+ */
+@TypedTable(name="Open_vSwitch", database="Open_vSwitch")
+public interface OpenVSwitch extends TypedBaseTable {
+
+ @TypedColumn(name="bridges", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getBridgesColumn();
+ @TypedColumn(name="bridges", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setBridges(Set<UUID> bridges);
+
+ @TypedColumn(name="managers", method=MethodType.GETCOLUMN, fromVersion="1.0.0", untilVersion="2.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getManagersColumn();
+ @TypedColumn(name="managers", method=MethodType.SETDATA, fromVersion="1.0.0", untilVersion="2.0.0")
+ public void setManagers(Set<UUID> managers);
+
+ @TypedColumn(name="manager_options", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getManagerOptionsColumn();
+ @TypedColumn(name="manager_options", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setManagerOptions(Set<UUID> managerOptions);
+
+ @TypedColumn(name="ssl", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getSslColumn();
+ @TypedColumn(name="ssl", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setSsl(Set<UUID> ssl);
+
+ @TypedColumn(name="other_config", method=MethodType.GETCOLUMN, fromVersion="5.1.0")
+ public Column<GenericTableSchema, Map<String, String>> getOtherConfigColumn() ;
+ @TypedColumn(name="other_config", method=MethodType.SETDATA, fromVersion="5.1.0")
+ public void setOtherConfig(Map<String, String> otherConfig);
+
+ @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="next_cfg", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Integer> getNextConfigColumn();
+ @TypedColumn(name="next_cfg", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setNextConfig(Integer nextConfig);
+
+ @TypedColumn(name="cur_cfg", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Integer> getCurrentConfigColumn();
+ @TypedColumn(name="cur_cfg", method=MethodType.SETDATA, fromVersion="1.0.0")
+ 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();
+ @TypedColumn(name="capabilities", method=MethodType.SETDATA, fromVersion="1.0.0", untilVersion="6.7.0")
+ public void setCapabilities(Map<String, UUID> capabilities);
+
+ @TypedColumn(name="statistics", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Map<String, Integer>> getStatisticsColumn();
+ @TypedColumn(name="statistics", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setStatistics(Map<String, Integer> statistics);
+
+ @TypedColumn(name="ovs_version", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<String>> getOvsVersionColumn();
+ @TypedColumn(name="ovs_version", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setOvsVersion(Set<String> ovsVersion);
+
+ @TypedColumn(name="db_version", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<String>> getDbVersionColumn();
+ @TypedColumn(name="db_version", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setDbVersion(Set<String> dbVersion);
+
+ @TypedColumn(name="system_type", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<String>> getSystemTypeColumn();
+ @TypedColumn(name="system_type", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setSystemType(Set<String> systemType);
+
+ @TypedColumn(name="system_version", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<String>> getSystemVersionColumn();
+ @TypedColumn(name="system_version", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setSystemVersion(Set<String> systemVersion);
+
+}
--- /dev/null
+/*
+ * 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, Dave Tucker
+ */
+package org.opendaylight.ovsdb.schema.openvswitch;
+
+import java.math.BigInteger;
+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;
+
+/**
+ * This class is a typed interface to the Port Table
+ */
+@TypedTable(name="Port", database="Open_vSwitch")
+public interface Port extends TypedBaseTable {
+
+ @TypedColumn(name="name", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ 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();
+ @TypedColumn(name="interfaces", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setInterfaces(Set<UUID> interfaces);
+
+ @TypedColumn(name="trunks", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<BigInteger>> getTrunksColumn();
+ @TypedColumn(name="trunks", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setTrunks(Set<BigInteger> trunks);
+
+ @TypedColumn(name="tag", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<BigInteger>> getTagColumn();
+ @TypedColumn(name="tag", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setTag(Set<BigInteger> tag);
+
+ @TypedColumn(name="vlan_mode", method=MethodType.GETCOLUMN, fromVersion="6.1.0")
+ public Column<GenericTableSchema, Set<String>> getVlanModeColumn();
+ @TypedColumn(name="vlan_mode", method=MethodType.SETDATA, fromVersion="6.1.0")
+ public void setVlanMode(Set<String> vlanMode);
+
+ @TypedColumn(name="qos", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getQosColumn();
+ @TypedColumn(name="qos", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setQos(Set<UUID> qos);
+
+ @TypedColumn(name="mac", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<String>> getMacColumn();
+ @TypedColumn(name="mac", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setMac(Set<String> mac);
+
+ @TypedColumn(name="bond_type", method=MethodType.GETCOLUMN, fromVersion="1.0.2", untilVersion="1.0.3")
+ public Column<GenericTableSchema, Set<String>> getBondTypeColumn();
+ @TypedColumn(name="bond_type", method=MethodType.SETDATA)
+ public void setBondType(Set<String> bond_type);
+
+ @TypedColumn(name="bond_mode", method=MethodType.GETCOLUMN, fromVersion="1.0.4")
+ public Column<GenericTableSchema, Set<String>> getBondModeColumn();
+ @TypedColumn(name="bond_mode", method=MethodType.SETDATA, fromVersion="1.0.4")
+ public void setBondMode(Set<String> bond_mode);
+
+ @TypedColumn(name="lacp", method=MethodType.GETCOLUMN, fromVersion="1.3.0")
+ public Column<GenericTableSchema, Set<String>> getLacpColumn();
+ @TypedColumn(name="lacp", method=MethodType.SETDATA, fromVersion="1.3.0")
+ public void setLacp(Set<String> lacp);
+
+ @TypedColumn(name="bond_updelay", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<BigInteger>> getBondUpDelayColumn();
+ @TypedColumn(name="bond_updelay", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setBondUpDelay(Set<BigInteger> bondUpDelay);
+
+ @TypedColumn(name="bond_downdelay", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<BigInteger>> getBondDownDelayColumn();
+ @TypedColumn(name="bond_downdelay", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setBondDownDelay(Set<BigInteger> bondDownDelay);
+
+ @TypedColumn(name="bond_fake_iface", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<Boolean>> getBondFakeInterfaceColumn();
+ @TypedColumn(name="bond_fake_iface", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setBondFakeInterface(Set<Boolean> bondFakeInterface);
+
+ @TypedColumn(name="fake_bridge", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<Boolean>> getFakeBridgeColumn();
+ @TypedColumn(name="fake_bridge", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setFakeBridge(Set<Boolean> fakeBridge);
+
+ @TypedColumn(name="status", method=MethodType.GETCOLUMN, fromVersion="6.2.0")
+ public Column<GenericTableSchema, Map<String, String>> getStatusColumn();
+ @TypedColumn(name="status", method=MethodType.SETDATA, fromVersion="6.2.0")
+ public void setStatus(Map<String, String> status);
+
+ @TypedColumn(name="statistics", method=MethodType.GETCOLUMN, fromVersion="6.3.0")
+ public Column<GenericTableSchema, Map<String, BigInteger>> getStatisticsColumn();
+ @TypedColumn(name="statistics", method=MethodType.SETDATA)
+ public void setStatistics(Map<String, BigInteger> statistics);
+
+ @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="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);
+}
--- /dev/null
+/*
+ * 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 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 many of columns are not defined here
+ * TODO : Fill up the missing Columns and include Supported DB Version
+ */
+
+@TypedTable(name="Qos", database="Open_vSwitch")
+public interface Qos extends TypedBaseTable {
+ @TypedColumn(name="queues", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Map<Integer, UUID>> getQueuesColumn() ;
+ @TypedColumn(name="queues", method=MethodType.SETDATA)
+ public void setQueues(Map<Integer, UUID> queues) ;
+
+ @TypedColumn(name="type", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, String> getTypeColumn() ;
+ @TypedColumn(name="type", method=MethodType.SETDATA)
+ public void setType(String type) ;
+
+ @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="externalIds", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Map<String, String>> getExternalIdsColumn() ;
+ @TypedColumn(name="externalIds", method=MethodType.SETDATA)
+ public void setExternalIds(Map<String, String> externalIds) ;
+}
--- /dev/null
+/*
+ * 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.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 many of columns are not defined here
+ * TODO : Fill up the missing Columns and include Supported DB Version
+ */
+
+@TypedTable(name="Queue", database="Open_vSwitch")
+public interface Queue extends TypedBaseTable {
+ @TypedColumn(name="dscp", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Set<Integer>> getDscpColumn() ;
+ @TypedColumn(name="dscp", method=MethodType.SETDATA)
+ public void setDscp(Set<Integer> dscp) ;
+
+ @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) ;
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.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;
+
+/**
+ * This class is a typed interface to the SFlow Table
+ */
+@TypedTable(name="sFlow", database="Open_vSwitch", fromVersion="1.0.0")
+public interface SFlow extends TypedBaseTable {
+ @TypedColumn(name="targets", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<String>> getTargetsColumn() ;
+ @TypedColumn(name="targets", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setTargets(Set<String> targets) ;
+
+ @TypedColumn(name="agent", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<String>> getAgentColumn() ;
+ @TypedColumn(name="agent", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setAgent(Set<String> agent) ;
+
+ @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="header", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<Integer>> getHeaderColumn() ;
+ @TypedColumn(name="header", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setHeader(Set<Integer> header) ;
+
+ @TypedColumn(name="polling", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<Integer>> getPollingColumn() ;
+ @TypedColumn(name="polling", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setPolling(Set<Integer> polling) ;
+
+ @TypedColumn(name="sampling", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<Integer>> getSamplingColumn() ;
+ @TypedColumn(name="sampling", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setSampling(Set<Integer> sampling) ;
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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 org.opendaylight.ovsdb.lib.notation.Column;
+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 many of columns are not defined here
+ * TODO : Fill up the missing Columns and include Supported DB Version
+ */
+@TypedTable(name="SSL", database="Open_vSwitch")
+public interface SSL extends TypedBaseTable {
+ @TypedColumn(name="ca_cert", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, String> getCaCertColumn() ;
+ @TypedColumn(name="ca_cert", method=MethodType.SETDATA)
+ public void setCaCert(String caCert) ;
+
+ @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="bootstrap_ca_cert", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, Boolean> getBootstrapCaCertColumn() ;
+ @TypedColumn(name="bootstrap_ca_cert", method=MethodType.SETDATA)
+ public void setBootstrapCaCert(Boolean bootstrapCaCert) ;
+
+ @TypedColumn(name="certificate", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, String> getCertificateColumn() ;
+ @TypedColumn(name="certificate", method=MethodType.SETDATA)
+ public void setCertificate(String certificate) ;
+
+ @TypedColumn(name="private_key", method=MethodType.GETCOLUMN)
+ public Column<GenericTableSchema, String> getPrivateKeyColumn() ;
+ @TypedColumn(name="private_key", method=MethodType.SETDATA)
+ public void setPrivateKey(String private_key) ;
+}
--- /dev/null
+/*
+ * 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.io.IOException;
+import java.net.InetAddress;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import junit.framework.Assert;
+
+import org.opendaylight.ovsdb.lib.OvsdbClient;
+import org.opendaylight.ovsdb.lib.OvsdbConnection;
+import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
+import org.opendaylight.ovsdb.lib.impl.OvsdbConnectionService;
+import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
+
+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 CONNECTION_TYPE = "ovsdbserver.connection";
+ private final static String CONNECTION_TYPE_ACTIVE = "active";
+ private final static String CONNECTION_TYPE_PASSIVE = "passive";
+
+ 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;
+ }
+
+ public OvsdbClient getTestConnection() throws IOException, InterruptedException, ExecutionException, TimeoutException {
+ Properties props = loadProperties();
+ String addressStr = props.getProperty(SERVER_IPADDRESS);
+ String portStr = props.getProperty(SERVER_PORT, DEFAULT_SERVER_PORT);
+ String connectionType = props.getProperty(CONNECTION_TYPE, "active");
+
+ // If the connection type is active, controller connects to the ovsdb-server
+ if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_ACTIVE)) {
+ if (addressStr == null) {
+ Assert.fail(usage());
+ }
+
+ 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;
+ }
+
+ OvsdbConnection connection = OvsdbConnectionService.getService();
+ return connection.connect(address, port);
+ } else if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_PASSIVE)) {
+ ExecutorService executor = Executors.newFixedThreadPool(1);
+ Future<OvsdbClient> passiveConnection = executor.submit(new PassiveListener());
+ return passiveConnection.get(60, TimeUnit.SECONDS);
+ }
+ Assert.fail("Connection parameter ("+CONNECTION_TYPE+") must be either active or passive");
+ return null;
+ }
+
+ private String usage() {
+ return "Integration Test needs a valid connection configuration as follows :\n" +
+ "active connection : mvn -Pintegrationtest -Dovsdbserver.ipaddress=x.x.x.x -Dovsdbserver.port=yyyy verify\n"+
+ "passive connection : mvn -Pintegrationtest -Dovsdbserver.connection=passive verify\n";
+ }
+
+ public class PassiveListener implements Callable<OvsdbClient>, OvsdbConnectionListener {
+ OvsdbClient client = null;
+ @Override
+ public OvsdbClient call() throws Exception {
+ OvsdbConnection connection = OvsdbConnectionService.getService();
+ connection.registerForPassiveConnection(this);
+ while (client == null) {
+ Thread.sleep(500);
+ }
+ return client;
+ }
+
+ @Override
+ public void connected(OvsdbClient client) {
+ this.client = client;
+ }
+
+ @Override
+ public void disconnected(OvsdbClient client) {
+ Assert.assertEquals(this.client.getConnectionInfo(), client.getConnectionInfo());
+ this.client = null;
+ }
+ }
+}
--- /dev/null
+/*
+ * 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.junit.Assert.assertNull;
+import static org.opendaylight.ovsdb.lib.operations.Operations.op;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.math.BigInteger;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import junit.framework.Assert;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.ovsdb.lib.MonitorCallBack;
+import org.opendaylight.ovsdb.lib.MonitorHandle;
+import org.opendaylight.ovsdb.lib.OvsdbClient;
+import org.opendaylight.ovsdb.lib.message.MonitorRequest;
+import org.opendaylight.ovsdb.lib.message.MonitorRequestBuilder;
+import org.opendaylight.ovsdb.lib.message.MonitorSelect;
+import org.opendaylight.ovsdb.lib.message.TableUpdate;
+import org.opendaylight.ovsdb.lib.message.TableUpdates;
+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.TypedBaseTable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.ListenableFuture;
+
+public class TypedVSwitchdSchemaIT extends OvsdbTestBase {
+
+ Logger logger = LoggerFactory.getLogger(TypedVSwitchdSchemaIT.class);
+ OvsdbClient 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.monitorTables();
+ this.createTypedBridge();
+ this.createTypedController();
+ this.testCreateTypedPortandInterface();
+ this.testCreateTypedIpFix();
+ this.testCreateTypedNetFlow();
+ this.testCreateTypedSflow();
+ }
+
+ private void createTypedBridge() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ Bridge bridge = ovs.createTypedRowWrapper(Bridge.class);
+ bridge.setName(testBridgeName);
+ bridge.setStatus(ImmutableMap.of("key","value"));
+ bridge.setFloodVlans(Sets.newHashSet(34));
+
+ OpenVSwitch openVSwitch = ovs.createTypedRowWrapper(OpenVSwitch.class);
+ openVSwitch.setBridges(Sets.newHashSet(new UUID(testBridgeName)));
+
+ int insertOperationIndex = 0;
+
+ TransactionBuilder transactionBuilder = ovs.transactBuilder()
+ .add(op.insert(bridge.getSchema())
+ .withId(testBridgeName)
+ .value(bridge.getNameColumn()))
+ .add(op.update(bridge.getSchema())
+ .set(bridge.getStatusColumn())
+ .set(bridge.getFloodVlansColumn())
+ .where(bridge.getNameColumn().getSchema().opEqual(bridge.getName()))
+ .and(bridge.getNameColumn().getSchema().opEqual(bridge.getName())).build())
+ .add(op.mutate(openVSwitch.getSchema())
+ .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);
+ for (OperationResult result : operationResults) {
+ Assert.assertNull(result.getError());
+ }
+ testBridgeUuid = operationResults.get(insertOperationIndex).getUuid();
+
+ Row bridgeRow = tableCache.get(bridge.getSchema().getName()).get(testBridgeUuid);
+ Bridge monitoredBridge = ovs.getTypedRowWrapper(Bridge.class, bridgeRow);
+ Assert.assertEquals(monitoredBridge.getNameColumn().getData(), bridge.getNameColumn().getData());
+ Assert.assertNotNull(monitoredBridge.getUuid());
+ Assert.assertNotNull(monitoredBridge.getVersion());
+ Assert.assertNotNull(this.getOpenVSwitchTableUuid());
+ }
+
+ private void createTypedController() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ Controller controller1 = ovs.createTypedRowWrapper(Controller.class);
+ controller1.setTarget("tcp:1.1.1.1:6640");
+ Controller controller2 = ovs.createTypedRowWrapper(Controller.class);
+ controller2.setTarget("tcp:2.2.2.2:6640");
+
+ Bridge bridge = ovs.getTypedRowWrapper(Bridge.class, null);
+
+ String transactionUuidStr = "controller";
+ TransactionBuilder transactionBuilder = ovs.transactBuilder()
+ .add(op.insert(controller1.getSchema())
+ .withId(transactionUuidStr)
+ .value(controller1.getTargetColumn()))
+ .add(op.mutate(bridge.getSchema())
+ .addMutation(bridge.getControllerColumn().getSchema(), Mutator.INSERT,
+ Sets.newHashSet(new UUID(transactionUuidStr)))
+ .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 controller1 = " + operationResults);
+ // Check for any errors
+ for (OperationResult result : operationResults) {
+ Assert.assertNull(result.getError());
+ }
+
+ Row bridgeRow = tableCache.get(bridge.getSchema().getName()).get(testBridgeUuid);
+ Bridge monitoredBridge = ovs.getTypedRowWrapper(Bridge.class, bridgeRow);
+ Assert.assertEquals(1, monitoredBridge.getControllerColumn().getData().size());
+
+ transactionBuilder = ovs.transactBuilder()
+ .add(op.insert(controller2.getSchema())
+ .withId(transactionUuidStr)
+ .value(controller2.getTargetColumn()))
+ .add(op.mutate(bridge.getSchema())
+ .addMutation(bridge.getControllerColumn().getSchema(), Mutator.INSERT,
+ Sets.newHashSet(new UUID(transactionUuidStr)))
+ .where(bridge.getNameColumn().getSchema().opEqual(testBridgeName))
+ .build());
+
+ results = transactionBuilder.execute();
+ 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 controller2 = " + operationResults);
+ // Check for any errors
+ for (OperationResult result : operationResults) {
+ Assert.assertNull(result.getError());
+ }
+
+ bridgeRow = tableCache.get(bridge.getSchema().getName()).get(testBridgeUuid);
+ monitoredBridge = ovs.getTypedRowWrapper(Bridge.class, bridgeRow);
+ 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);
+ }
+
+ private void testCreateTypedIpFix() throws InterruptedException, ExecutionException, IllegalArgumentException{
+ String ipfixUuidStr = "testIpfix";
+ String ipfixTarget = "172.16.20.1:4739";
+ Integer obsDomainId = 112;
+ Integer obsPointId = 358;
+ Integer cacheMax = 132;
+ Integer cacheTimeout = 134;
+ Integer sampling = 558;
+ IPFIX ipfix = ovs.createTypedRowWrapper(IPFIX.class);
+ ipfix.setTargets(ImmutableSet.of(ipfixTarget));
+ ipfix.setObsDomainId(ImmutableSet.of(obsDomainId));
+ ipfix.setObsPointId(ImmutableSet.of(obsPointId));
+ ipfix.setCacheMaxFlows(ImmutableSet.of(cacheMax));
+ ipfix.setCacheActiveTimeout(ImmutableSet.of(cacheTimeout));
+ ipfix.setSampling(ImmutableSet.of(sampling));
+ ipfix.setExternalIds(ImmutableMap.of("<3", "ovs"));
+ Bridge bridge = ovs.getTypedRowWrapper(Bridge.class, null);
+ TransactionBuilder transactionBuilder = ovs.transactBuilder()
+ .add(op.insert(ipfix.getSchema())
+ .withId(ipfixUuidStr)
+ .value(ipfix.getTargetsColumn())
+ .value(ipfix.getObsDomainIdColumn())
+ .value(ipfix.getObsPointIdColumn())
+ .value(ipfix.getCacheMaxFlowsColumn())
+ .value(ipfix.getCacheActiveTimeoutColumn())
+ .value(ipfix.getSamplingColumn())
+ .value(ipfix.getExternalIdsColumn()))
+ .add(op.mutate(bridge.getSchema())
+ .addMutation(bridge.getIpfixColumn().getSchema(), Mutator.INSERT,
+ Sets.newHashSet(new UUID(ipfixUuidStr)))
+ .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());
+ for (OperationResult result : operationResults) Assert.assertNull(result.getError());
+ logger.info("Insert & Mutate operation results for IPFIX = {} ", operationResults);
+ }
+
+ private void testCreateTypedSflow() throws InterruptedException, ExecutionException, IllegalArgumentException{
+ String sFlowUuidStr = "testSFlow";
+ String sFlowTarget = "172.16.20.200:6343";
+ Integer header = 128;
+ Integer obsPointId = 358;
+ Integer polling = 10;
+ String agent = "172.16.20.210";
+ Integer sampling = 64;
+ SFlow sFlow = ovs.createTypedRowWrapper(SFlow.class);
+ sFlow.setTargets(ImmutableSet.of(sFlowTarget));
+ sFlow.setHeader(ImmutableSet.of(header));
+ sFlow.setPolling(ImmutableSet.of(obsPointId));
+ sFlow.setPolling(ImmutableSet.of(polling));
+ sFlow.setAgent(ImmutableSet.of(agent));
+ sFlow.setSampling(ImmutableSet.of(sampling));
+ sFlow.setExternalIds(ImmutableMap.of("kit", "tah"));
+ Bridge bridge = ovs.getTypedRowWrapper(Bridge.class, null);
+ TransactionBuilder transactionBuilder = ovs.transactBuilder()
+ .add(op.insert(sFlow.getSchema())
+ .withId(sFlowUuidStr)
+ .value(sFlow.getTargetsColumn())
+ .value(sFlow.getHeaderColumn())
+ .value(sFlow.getPollingColumn())
+ .value(sFlow.getAgentColumn())
+ .value(sFlow.getSamplingColumn())
+ .value(sFlow.getExternalIdsColumn()))
+ .add(op.mutate(bridge.getSchema())
+ .addMutation(bridge.getSflowColumn().getSchema(), Mutator.INSERT,
+ Sets.newHashSet(new UUID(sFlowUuidStr)))
+ .where(bridge.getNameColumn().getSchema().opEqual(testBridgeName))
+ .build());
+ ListenableFuture<List<OperationResult>> results = transactionBuilder.execute();
+ List<OperationResult> operationResults = results.get();
+ for (OperationResult result : operationResults) {
+ assertNull(result.getError());
+ }
+ Assert.assertFalse(operationResults.isEmpty());
+ // Check if Results matches the number of operations in transaction
+ Assert.assertEquals(transactionBuilder.getOperations().size(), operationResults.size());
+ logger.info("Insert & Mutate operation results for SFlow = {} ", operationResults);
+ }
+
+ private void testCreateTypedNetFlow() throws InterruptedException, ExecutionException, IllegalArgumentException{
+ String netFlowUuidStr = "testNetFlow";
+ String netFlowTargets = "172.16.20.200:6343";
+ BigInteger engineType = BigInteger.valueOf(128);
+ BigInteger engineID = BigInteger.valueOf(32);
+ Integer activityTimeout = 1;
+ NetFlow netFlow = ovs.createTypedRowWrapper(NetFlow.class);
+ netFlow.setTargets(ImmutableSet.of(netFlowTargets));
+ netFlow.setEngineType(ImmutableSet.of(engineType));
+ netFlow.setEngineId(ImmutableSet.of(engineID));
+ netFlow.setActivityTimeout(ImmutableSet.of(activityTimeout));
+ netFlow.setExternalIds(ImmutableMap.of("big", "baby"));
+ Bridge bridge = ovs.getTypedRowWrapper(Bridge.class, null);
+ TransactionBuilder transactionBuilder = ovs.transactBuilder()
+ .add(op.insert(netFlow.getSchema())
+ .withId(netFlowUuidStr)
+ .value(netFlow.getTargetsColumn())
+ .value(netFlow.getEngineTypeColumn())
+ .value(netFlow.getEngineIdColumn())
+ .value(netFlow.getActiveTimeoutColumn())
+ .value(netFlow.getExternalIdsColumn()))
+ .add(op.mutate(bridge.getSchema())
+ .addMutation(bridge.getNetflowColumn().getSchema(), Mutator.INSERT,
+ Sets.newHashSet(new UUID(netFlowUuidStr)))
+ .where(bridge.getNameColumn().getSchema().opEqual(testBridgeName))
+ .build());
+ ListenableFuture<List<OperationResult>> results = transactionBuilder.execute();
+ List<OperationResult> operationResults = results.get();
+ for (OperationResult result : operationResults) Assert.assertNull(result.getError());
+ Assert.assertFalse(operationResults.isEmpty());
+ // Check if Results matches the number of operations in transaction
+ Assert.assertEquals(transactionBuilder.getOperations().size(), operationResults.size());
+ logger.info("Insert & Mutate operation results for NetFlow = {} ", operationResults);
+ }
+
+ 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);
+ }
+
+ private UUID getOpenVSwitchTableUuid() {
+ OpenVSwitch openVSwitch = ovs.getTypedRowWrapper(OpenVSwitch.class, null);
+ Map<UUID, Row> ovsTable = tableCache.get(openVSwitch.getSchema().getName());
+ if (ovsTable != null) {
+ if (ovsTable.keySet().size() >= 1) {
+ return (UUID)ovsTable.keySet().toArray()[0];
+ }
+ }
+ return null;
+ }
+
+ public void monitorTables() throws ExecutionException, InterruptedException, IOException {
+ Assert.assertNotNull(dbSchema);
+
+ List<MonitorRequest<GenericTableSchema>> monitorRequests = Lists.newArrayList();
+ monitorRequests.add(this.getAllColumnsMonitorRequest(Bridge.class));
+ monitorRequests.add(this.getAllColumnsMonitorRequest(OpenVSwitch.class));
+
+ MonitorHandle monitor = ovs.monitor(dbSchema, monitorRequests, new UpdateMonitor());
+ Assert.assertNotNull(monitor);
+ }
+
+ /**
+ * As per RFC 7047, section 4.1.5, if a Monitor request is sent without any columns, the update response will not include
+ * the _uuid column.
+ * ----------------------------------------------------------------------------------------------------------------------------------
+ * Each <monitor-request> specifies one or more columns and the manner in which the columns (or the entire table) are to be monitored.
+ * The "columns" member specifies the columns whose values are monitored. It MUST NOT contain duplicates.
+ * If "columns" is omitted, all columns in the table, except for "_uuid", are monitored.
+ * ----------------------------------------------------------------------------------------------------------------------------------
+ * In order to overcome this limitation, this method
+ *
+ * @return MonitorRequest that includes all the Bridge Columns including _uuid
+ */
+ public <T extends TypedBaseTable> MonitorRequest<GenericTableSchema> getAllColumnsMonitorRequest (Class <T> klazz) {
+ TypedBaseTable table = ovs.createTypedRowWrapper(klazz);
+ GenericTableSchema bridgeSchema = table.getSchema();
+ Set<String> columns = bridgeSchema.getColumns();
+ MonitorRequestBuilder<GenericTableSchema> bridgeBuilder = MonitorRequestBuilder.builder(table.getSchema());
+ for (String column : columns) {
+ bridgeBuilder.addColumn(column);
+ }
+ return bridgeBuilder.with(new MonitorSelect(true, true, true, true)).build();
+ }
+
+ static Map<String, Map<UUID, Row>> tableCache = new HashMap<String, Map<UUID, Row>>();
+ private static class UpdateMonitor implements MonitorCallBack {
+ @Override
+ public void update(TableUpdates result) {
+ for (String tableName : result.getUpdates().keySet()) {
+ Map<UUID, Row> tUpdate = tableCache.get(tableName);
+ TableUpdate update = result.getUpdates().get(tableName);
+ if (update.getNew() != null) {
+ if (tUpdate == null) {
+ tUpdate = new HashMap<UUID, Row>();
+ tableCache.put(tableName, tUpdate);
+ }
+ tUpdate.put(update.getUuid(), update.getNew());
+ } else {
+ tUpdate.remove(update.getUuid());
+ }
+ }
+ }
+
+ @Override
+ public void exception(Throwable t) {
+ System.out.println("Exception t = " + t);
+ }
+ }
+
+ @Before
+ public void setUp() throws IOException, ExecutionException, InterruptedException, TimeoutException {
+ if (ovs != null) {
+ return;
+ }
+ ovs = getTestConnection();
+ testGetDBs();
+ dbSchema = ovs.getSchema(OPEN_VSWITCH_SCHEMA, true).get();
+ }
+
+ @After
+ public void tearDown() throws InterruptedException, ExecutionException {
+ Bridge bridge = ovs.getTypedRowWrapper(Bridge.class, null);
+ OpenVSwitch openVSwitch = ovs.getTypedRowWrapper(OpenVSwitch.class, null);
+
+ ListenableFuture<List<OperationResult>> results = ovs.transactBuilder()
+ .add(op.delete(bridge.getSchema())
+ .where(bridge.getNameColumn().getSchema().opEqual(testBridgeName))
+ .build())
+ .add(op.mutate(openVSwitch.getSchema())
+ .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);
+ tableCache = new HashMap<String, Map<UUID, Row>>();
+ }
+
+ @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
+
+ }
+}
--- /dev/null
+<?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
--- /dev/null
+<?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.hardware_vtep</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.schema.hardwarevtep</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>
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+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;
+
+@TypedTable(name="Arp_Sources_Local", database="hardware_vtep", fromVersion="1.2.0")
+public interface ArpSourcesLocal extends TypedBaseTable {
+ @TypedColumn(name="src_mac", method=MethodType.GETCOLUMN, fromVersion="1.2.0")
+ public Column<GenericTableSchema, String> getSrcMacColumn();
+
+ @TypedColumn(name="src_mac", method=MethodType.GETDATA, fromVersion="1.2.0")
+ public String getSrcMac();
+
+ @TypedColumn(name="src_mac", method=MethodType.SETDATA, fromVersion="1.2.0")
+ public void setSrcMac(String srcMac);
+
+ @TypedColumn(name="locator", method=MethodType.GETCOLUMN, fromVersion="1.2.0")
+ public Column<GenericTableSchema, UUID> getLocatorColumn();
+
+ @TypedColumn(name="locator", method=MethodType.SETDATA, fromVersion="1.2.0")
+ public void setLocator(UUID locator);
+}
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+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;
+
+@TypedTable(name="Arp_Sources_Remote", database="hardware_vtep", fromVersion="1.2.0")
+public interface ArpSourcesRemote extends TypedBaseTable {
+ @TypedColumn(name="src_mac", method=MethodType.GETCOLUMN, fromVersion="1.2.0")
+ public Column<GenericTableSchema, String> getSrcMacColumn();
+
+ @TypedColumn(name="src_mac", method=MethodType.GETDATA, fromVersion="1.2.0")
+ public String getSrcMac();
+
+ @TypedColumn(name="src_mac", method=MethodType.SETDATA, fromVersion="1.2.0")
+ public void setSrcMac(String srcMac);
+
+ @TypedColumn(name="locator", method=MethodType.GETCOLUMN, fromVersion="1.2.0")
+ public Column<GenericTableSchema, UUID> getLocatorColumn();
+
+ @TypedColumn(name="locator", method=MethodType.SETDATA, fromVersion="1.2.0")
+ public void setLocator(UUID locator);
+}
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+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;
+
+@TypedTable(name="Global", database="hardware_vtep", fromVersion="1.0.0")
+public interface Global extends TypedBaseTable {
+
+ @TypedColumn(name="managers", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getManagersColumn();
+
+ @TypedColumn(name="managers", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setManagers(Set<UUID> managers);
+
+ @TypedColumn(name="switches", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getSwitchesColumn();
+
+ @TypedColumn(name="switches", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setSwitches(Set<UUID> switches);
+}
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+import org.opendaylight.ovsdb.lib.notation.Column;
+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;
+
+@TypedTable(name="Logical_Binding_Stats", database="hardware_vtep", fromVersion="1.0.0")
+public interface LogicalBindingStats extends TypedBaseTable {
+
+ @TypedColumn(name="bytes_from_local", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Integer> getBytesFromLocalColumn();
+
+ @TypedColumn(name="bytes_from_local", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setBytesFromLocal(Integer bytesFromLocal);
+
+ @TypedColumn(name="packets_from_local", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Integer> getPacketsFromLocalColumn();
+
+ @TypedColumn(name="packets_from_local", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setPacketsFromLocal(Integer packetsFromLocal);
+
+ @TypedColumn(name="bytes_to_local", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Integer> getBytesToLocalColumn();
+
+ @TypedColumn(name="bytes_to_local", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setBytesToLocal(Integer bytesToLocal);
+
+ @TypedColumn(name="packets_to_local", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Integer> getPacketsToLocalColumn();
+
+ @TypedColumn(name="packets_to_local", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setPacketsToLocal(Integer packetsToLocal);
+}
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+import java.util.Map;
+
+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;
+
+@TypedTable(name="Logical_Router", database="hardware_vtep", fromVersion="1.0.0")
+public interface LogicalRouter extends TypedBaseTable {
+ @TypedColumn(name="name", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getNameColumn();
+
+ @TypedColumn(name="name", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getName();
+
+ @TypedColumn(name="name", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setName(String name);
+
+
+ @TypedColumn(name="description", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getDescriptionColumn();
+
+ @TypedColumn(name="description", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getDescription();
+
+ @TypedColumn(name="description", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setDescription(String description);
+
+
+ @TypedColumn(name="switch_binding", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Map<String, UUID>> getSwitchBindingColumn();
+
+ @TypedColumn(name="switch_binding", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setSwitchBinding(Map<String, UUID> switchBinding);
+
+
+ @TypedColumn(name="static_routes", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Map<String, String>> setStaticRoutesColumn();
+
+ @TypedColumn(name="static_routes", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setStaticRoutes(Map<String, String> staticRoutes);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+import java.util.Set;
+
+import org.opendaylight.ovsdb.lib.notation.Column;
+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;
+
+@TypedTable(name="Logical_Switch", database="hardware_vtep", fromVersion="1.0.0")
+public interface LogicalSwitch extends TypedBaseTable {
+ @TypedColumn(name="name", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getNameColumn();
+
+ @TypedColumn(name="name", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getName();
+
+ @TypedColumn(name="name", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setName(String name);
+
+
+ @TypedColumn(name="description", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getDescriptionColumn();
+
+ @TypedColumn(name="description", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getDescription();
+
+ @TypedColumn(name="description", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setDescription(String description);
+
+
+ @TypedColumn(name="tunnel_key", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<Integer>> getTunnelKeyColumn();
+
+ @TypedColumn(name="tunnel_key", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setTunnelKey(Set<Integer> tunnelKey);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.ovsdb.lib.notation.Column;
+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;
+
+@TypedTable(name="Manager", database="hardware_vtep", fromVersion="1.0.0")
+public interface Manager extends TypedBaseTable {
+
+ @TypedColumn(name="target", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getTargetColumn();
+
+ @TypedColumn(name="target", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setTarget(String target);
+
+ @TypedColumn(name="max_backoff", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<Integer>> getMaxBackoffColumn();
+
+ @TypedColumn(name="max_backoff", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setMaxBackoff(Set<Integer> maxBackoff);
+
+ @TypedColumn(name="inactivity_probe", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<Integer>> getInactivityProbeColumn();
+
+ @TypedColumn(name="inactivity_probe", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setInactivityProbe(Set<Integer> inactivityProbe);
+
+ @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="is_connected", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Boolean> getIsConnectedColumn();
+
+ @TypedColumn(name="is_connected", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setIsConnectedColumn(Boolean isConnected);
+
+ @TypedColumn(name="status", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Map<String, String>> getStatusColumn();
+
+ @TypedColumn(name="status", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setStatus(Map<String, String> status);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+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;
+
+@TypedTable(name="Mcast_Macs_Local", database="hardware_vtep", fromVersion="1.0.0")
+public interface McastMacsLocal extends TypedBaseTable {
+ @TypedColumn(name="MAC", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getMacColumn();
+
+ @TypedColumn(name="MAC", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getMac();
+
+ @TypedColumn(name="MAC", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setMac(String mac);
+
+
+ @TypedColumn(name="logical_switch", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, UUID> getLogicalSwitchColumn();
+
+ @TypedColumn(name="logical_switch", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setLogicalSwitch(UUID logicalSwitch);
+
+ @TypedColumn(name="locator_set", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, UUID> getLocatorSetColumn();
+
+ @TypedColumn(name="locator_set", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setLocatorSet(UUID locatorSet);
+
+
+ @TypedColumn(name="ipaddr", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getIpAddrColumn();
+
+ @TypedColumn(name="ipaddr", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getIpAddr();
+
+ @TypedColumn(name="ipaddr", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setIpAddress(String ipAddr);
+}
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+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;
+
+@TypedTable(name="Mcast_Macs_Remote", database="hardware_vtep", fromVersion="1.0.0")
+public interface McastMacsRemote extends TypedBaseTable {
+ @TypedColumn(name="MAC", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getMacColumn();
+
+ @TypedColumn(name="MAC", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getMac();
+
+ @TypedColumn(name="MAC", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setMac(String mac);
+
+
+ @TypedColumn(name="logical_switch", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, UUID> getLogicalSwitchColumn();
+
+ @TypedColumn(name="logical_switch", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setLogicalSwitch(UUID logicalSwitch);
+
+ @TypedColumn(name="locator_set", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, UUID> getLocatorSetColumn();
+
+ @TypedColumn(name="locator_set", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setLocatorSet(UUID locatorSet);
+
+
+ @TypedColumn(name="ipaddr", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getIpAddrColumn();
+
+ @TypedColumn(name="ipaddr", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getIpAddr();
+
+ @TypedColumn(name="ipaddr", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setIpAddress(String ipAddr);
+}
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+import java.util.Map;
+
+import org.opendaylight.ovsdb.lib.notation.Column;
+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;
+
+@TypedTable(name="Physical_Locator", database="hardware_vtep", fromVersion="1.0.0")
+public interface PhysicalLocator extends TypedBaseTable {
+ @TypedColumn(name="encapsulation_type", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getEncapsulationTypeColumn();
+
+ @TypedColumn(name="encapsulation_type", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setEncapsulationType(String encapsulationType);
+
+ @TypedColumn(name="dst_ip", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getDstIpColumn();
+
+ @TypedColumn(name="dst_ip", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setDstIp(String dstIp);
+
+ @TypedColumn(name="bfd", method=MethodType.GETCOLUMN, fromVersion="1.0.0", untilVersion="1.2.0")
+ public Column<GenericTableSchema, Map<String, String>> getBfdColumn();
+
+ @TypedColumn(name="bfd", method=MethodType.SETDATA, fromVersion="1.0.0", untilVersion="1.2.0")
+ public void setBfd(Map<String, String> bfd);
+
+ @TypedColumn(name="bfd_status", method=MethodType.GETCOLUMN, fromVersion="1.0.0", untilVersion="1.2.0")
+ public Column<GenericTableSchema, Map<String, String>> getBfdStatusColumn();
+
+ @TypedColumn(name="bfd_status", method=MethodType.SETDATA, fromVersion="1.0.0", untilVersion="1.2.0")
+ public void setBfdStatus(Map<String, String> bfdStatus);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+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;
+
+@TypedTable(name="Physical_Locator_Set", database="hardware_vtep", fromVersion="1.0.0")
+public interface PhysicalLocatorSet extends TypedBaseTable {
+ @TypedColumn(name="locators", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getLocatorsColumn();
+
+ @TypedColumn(name="locators", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setLocators(Set<UUID> locators);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+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;
+
+@TypedTable(name="Physical_Port", database="hardware_vtep", fromVersion="1.0.0")
+public interface PhysicalPort extends TypedBaseTable {
+ @TypedColumn(name="name", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getNameColumn();
+
+ @TypedColumn(name="name", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getName();
+
+ @TypedColumn(name="name", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setName(String name);
+
+
+ @TypedColumn(name="description", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getDescriptionColumn();
+
+ @TypedColumn(name="description", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getDescription();
+
+ @TypedColumn(name="description", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setDescription(String description);
+
+
+ @TypedColumn(name="vlan_bindings", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Map<Integer, UUID>> getVlanBindingsColumn();
+
+ @TypedColumn(name="vlan_bindings", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setVlanBindings(Map<Integer, UUID> vlanBindings);
+
+
+ @TypedColumn(name="vlan_stats", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Map<Integer, UUID>> getVlanStatsColumn();
+
+ @TypedColumn(name="vlan_stats", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setVlanStats(Map<Integer, UUID> vlanStats);
+
+
+ @TypedColumn(name="port_fault_status", method=MethodType.GETCOLUMN, fromVersion="1.1.0")
+ public Column<GenericTableSchema, Set<String>> getPortFaultStatusColumn();
+
+ @TypedColumn(name="port_fault_status", method=MethodType.SETDATA, fromVersion="1.1.0")
+ public void setPortFaultStatus(Set<String> portFaultStatus);
+}
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+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;
+
+@TypedTable(name="Physical_Switch", database="hardware_vtep", fromVersion="1.0.0")
+public interface PhysicalSwitch extends TypedBaseTable {
+ @TypedColumn(name="name", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getNameColumn();
+
+ @TypedColumn(name="name", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getName();
+
+ @TypedColumn(name="name", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setName(String name);
+
+
+ @TypedColumn(name="description", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getDescriptionColumn();
+
+ @TypedColumn(name="description", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getDescription();
+
+ @TypedColumn(name="description", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setDescription(String description);
+
+
+ @TypedColumn(name="ports", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<UUID>> getPortsColumn();
+
+ @TypedColumn(name="ports", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setPorts(Set<UUID> ports);
+
+
+ @TypedColumn(name="management_ips", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<String>> getManagementIpsColumn();
+
+ @TypedColumn(name="management_ips", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setManagementIps(Set<String> managementIps);
+
+
+ @TypedColumn(name="tunnel_ips", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, Set<String>> getTunnelIpsColumn();
+
+ @TypedColumn(name="tunnel_ips", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setTunnelIps(Set<String> tunnelIps);
+
+
+ @TypedColumn(name="tunnels", method=MethodType.GETCOLUMN, fromVersion="1.3.0")
+ public Column<GenericTableSchema, Set<UUID>> getTunnels();
+
+ @TypedColumn(name="tunnels", method=MethodType.SETDATA, fromVersion="1.3.0")
+ public void setTunnels(Set<UUID> tunnels);
+
+ @TypedColumn(name="switch_fault_status", method=MethodType.GETCOLUMN, fromVersion="1.1.0")
+ public Column<GenericTableSchema, Set<String>> getSwitchFaultStatusColumn();
+
+ @TypedColumn(name="switch_fault_status", method=MethodType.SETDATA, fromVersion="1.1.0")
+ public void setSwitchFaultStatus(Set<String> switchFaultStatus);
+}
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+import java.util.Map;
+
+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;
+
+@TypedTable(name="Tunnel", database="hardware_vtep", fromVersion="1.3.0")
+public interface Tunnel extends TypedBaseTable {
+ @TypedColumn(name="local", method=MethodType.GETCOLUMN, fromVersion="1.3.0")
+ public Column<GenericTableSchema, UUID> getLocalColumn();
+
+ @TypedColumn(name="local", method=MethodType.SETDATA, fromVersion="1.3.0")
+ public void setLocal(UUID local);
+
+ @TypedColumn(name="remote", method=MethodType.GETCOLUMN, fromVersion="1.3.0")
+ public Column<GenericTableSchema, UUID> getRemoteColumn();
+
+ @TypedColumn(name="remote", method=MethodType.SETDATA, fromVersion="1.3.0")
+ public void setRemote(UUID remote);
+
+ @TypedColumn(name="bfd_config_local", method=MethodType.GETCOLUMN, fromVersion="1.3.0")
+ public Column<GenericTableSchema, Map<String, String>> getBfdConfigLocalColumn();
+
+ @TypedColumn(name="bfd_config_local", method=MethodType.SETDATA, fromVersion="1.3.0")
+ public void setBfdConfigLocal(Map<String, String> bfdConfigLocal);
+
+ @TypedColumn(name="bfd_config_remote", method=MethodType.GETCOLUMN, fromVersion="1.3.0")
+ public Column<GenericTableSchema, Map<String, String>> getBfdConfigRemoteColumn();
+
+ @TypedColumn(name="bfd_config_remote", method=MethodType.SETDATA, fromVersion="1.3.0")
+ public void setBfdConfigRemote(Map<String, String> bfdConfigRemote);
+
+ @TypedColumn(name="bfd_params", method=MethodType.GETCOLUMN, fromVersion="1.3.0")
+ public Column<GenericTableSchema, Map<String, String>> getBfdParamsColumn();
+
+ @TypedColumn(name="bfd_params", method=MethodType.SETDATA, fromVersion="1.3.0")
+ public void setBfdParams(Map<String, String> bfdParams);
+
+ @TypedColumn(name="bfd_status", method=MethodType.GETCOLUMN, fromVersion="1.3.0")
+ public Column<GenericTableSchema, Map<String, String>> getBfdStatusColumn();
+
+ @TypedColumn(name="bfd_status", method=MethodType.SETDATA, fromVersion="1.3.0")
+ public void setBfdStatus(Map<String, String> bfdStatus);
+}
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+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;
+
+@TypedTable(name="Ucast_Macs_Local", database="hardware_vtep", fromVersion="1.0.0")
+public interface UcastMacsLocal extends TypedBaseTable {
+ @TypedColumn(name="MAC", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getMacColumn();
+
+ @TypedColumn(name="MAC", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getMac();
+
+ @TypedColumn(name="MAC", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setMac(String mac);
+
+
+ @TypedColumn(name="logical_switch", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, UUID> getLogicalSwitchColumn();
+
+ @TypedColumn(name="logical_switch", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setLogicalSwitch(UUID logicalSwitch);
+
+ @TypedColumn(name="locator", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, UUID> getLocatorColumn();
+
+ @TypedColumn(name="locator", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setLocator(UUID locator);
+
+
+ @TypedColumn(name="ipaddr", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getIpAddrColumn();
+
+ @TypedColumn(name="ipaddr", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getIpAddr();
+
+ @TypedColumn(name="ipaddr", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setIpAddress(String ipAddr);
+}
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+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;
+
+@TypedTable(name="Ucast_Macs_Remote", database="hardware_vtep", fromVersion="1.0.0")
+public interface UcastMacsRemote extends TypedBaseTable {
+ @TypedColumn(name="MAC", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getMacColumn();
+
+ @TypedColumn(name="MAC", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getMac();
+
+ @TypedColumn(name="MAC", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setMac(String mac);
+
+
+ @TypedColumn(name="logical_switch", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, UUID> getLogicalSwitchColumn();
+
+ @TypedColumn(name="logical_switch", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setLogicalSwitch(UUID logicalSwitch);
+
+ @TypedColumn(name="locator", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, UUID> getLocatorColumn();
+
+ @TypedColumn(name="locator", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setLocator(UUID locator);
+
+
+ @TypedColumn(name="ipaddr", method=MethodType.GETCOLUMN, fromVersion="1.0.0")
+ public Column<GenericTableSchema, String> getIpAddrColumn();
+
+ @TypedColumn(name="ipaddr", method=MethodType.GETDATA, fromVersion="1.0.0")
+ public String getIpAddr();
+
+ @TypedColumn(name="ipaddr", method=MethodType.SETDATA, fromVersion="1.0.0")
+ public void setIpAddress(String ipAddr);
+}
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import junit.framework.Assert;
+
+import org.opendaylight.ovsdb.lib.OvsdbClient;
+import org.opendaylight.ovsdb.lib.OvsdbConnection;
+import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
+import org.opendaylight.ovsdb.lib.impl.OvsdbConnectionService;
+import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
+
+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";
+ private final static String CONNECTION_TYPE = "ovsdbserver.connection";
+ private final static String CONNECTION_TYPE_ACTIVE = "active";
+ private final static String CONNECTION_TYPE_PASSIVE = "passive";
+
+ /**
+ * Represents the Hardware VTEP Schema
+ */
+ public final static String HARDWARE_VTEP_SCHEMA = "hardware_vtep";
+
+ public Properties loadProperties() {
+ Properties props = new Properties(System.getProperties());
+ return props;
+ }
+
+
+ public OvsdbClient getTestConnection() throws IOException, InterruptedException, ExecutionException, TimeoutException {
+ Properties props = loadProperties();
+ String addressStr = props.getProperty(SERVER_IPADDRESS);
+ String portStr = props.getProperty(SERVER_PORT, DEFAULT_SERVER_PORT);
+ String connectionType = props.getProperty(CONNECTION_TYPE, "active");
+
+ // If the connection type is active, controller connects to the ovsdb-server
+ if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_ACTIVE)) {
+ if (addressStr == null) {
+ Assert.fail(usage());
+ }
+
+ 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;
+ }
+
+ OvsdbConnection connection = OvsdbConnectionService.getService();
+ return connection.connect(address, port);
+ } else if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_PASSIVE)) {
+ ExecutorService executor = Executors.newFixedThreadPool(1);
+ Future<OvsdbClient> passiveConnection = executor.submit(new PassiveListener());
+ return passiveConnection.get(60, TimeUnit.SECONDS);
+ }
+ Assert.fail("Connection parameter ("+CONNECTION_TYPE+") must be either active or passive");
+ return null;
+ }
+
+ private String usage() {
+ return "Integration Test needs a valid connection configuration as follows :\n" +
+ "active connection : mvn -Pintegrationtest -Dovsdbserver.ipaddress=x.x.x.x -Dovsdbserver.port=yyyy verify\n"+
+ "passive connection : mvn -Pintegrationtest -Dovsdbserver.connection=passive verify\n";
+ }
+
+ public class PassiveListener implements Callable<OvsdbClient>, OvsdbConnectionListener {
+ OvsdbClient client = null;
+ @Override
+ public OvsdbClient call() throws Exception {
+ OvsdbConnection connection = OvsdbConnectionService.getService();
+ connection.registerForPassiveConnection(this);
+ while (client == null) {
+ Thread.sleep(500);
+ }
+ return client;
+ }
+
+ @Override
+ public void connected(OvsdbClient client) {
+ this.client = client;
+ }
+
+ @Override
+ public void disconnected(OvsdbClient client) {
+ Assert.assertEquals(this.client.getConnectionInfo(), client.getConnectionInfo());
+ this.client = null;
+ }
+ }
+}
--- /dev/null
+/*
+ * 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.hardwarevtep;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import junit.framework.Assert;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.ovsdb.lib.OvsdbClient;
+import org.opendaylight.ovsdb.lib.message.UpdateNotification;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+public class TypedHardwareVTepSchemaIT extends OvsdbTestBase {
+
+ Logger logger = LoggerFactory.getLogger(TypedHardwareVTepSchemaIT.class);
+ OvsdbClient ovs;
+ DatabaseSchema dbSchema = null;
+
+ @Test
+ public void testGetDBs() throws ExecutionException, InterruptedException {
+ ListenableFuture<List<String>> databases = ovs.getDatabases();
+ List<String> dbNames = databases.get();
+ Assert.assertNotNull(dbNames);
+ boolean hasHardwareVTepSchema = false;
+ for(String dbName : dbNames) {
+ if (dbName.equals(HARDWARE_VTEP_SCHEMA)) {
+ hasHardwareVTepSchema = true;
+ break;
+ }
+ }
+ Assert.assertTrue(HARDWARE_VTEP_SCHEMA+" schema is not supported by the switch", hasHardwareVTepSchema);
+ }
+
+ @Before
+ public void setUp() throws IOException, ExecutionException, InterruptedException, TimeoutException {
+ if (ovs != null) {
+ return;
+ }
+ ovs = getTestConnection();
+ testGetDBs();
+ dbSchema = ovs.getSchema(HARDWARE_VTEP_SCHEMA, true).get();
+ }
+
+ @After
+ public void tearDown() throws InterruptedException, ExecutionException {
+ }
+
+ @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
+
+ }
+}
--- /dev/null
+<?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