+++ /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;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
-import org.opendaylight.ovsdb.lib.message.TransactBuilder;
-import org.opendaylight.ovsdb.lib.message.operations.ConditionalOperation;
-import org.opendaylight.ovsdb.lib.message.operations.Operation;
-import org.opendaylight.ovsdb.lib.message.operations.OperationResult;
-import org.opendaylight.ovsdb.lib.meta.ColumnSchema;
-import org.opendaylight.ovsdb.lib.meta.DatabaseSchema;
-import org.opendaylight.ovsdb.lib.meta.TableSchema;
-import org.opendaylight.ovsdb.lib.notation.Condition;
-import org.opendaylight.ovsdb.lib.notation.Function;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-import java.util.concurrent.ExecutorService;
-
-
-public class OpenVswitch {
-
- ExecutorService executorService;
- String schemaName;
- OvsdbRPC rpc;
- volatile DatabaseSchema schema;
- Queue<Throwable> exceptions;
-
- public OpenVswitch(OvsdbRPC rpc, ExecutorService executorService) {
- this.rpc = rpc;
- this.executorService = executorService;
- }
-
- public OpenVswitch() {
- }
-
-
- public void populateSchemaFromDevice() {
- final ListenableFuture<JsonNode> fOfSchema = rpc.get_schema(Lists.newArrayList(DatabaseSchema.OPEN_VSWITCH_SCHEMA_NAME));
- fOfSchema.addListener(new Runnable() {
- @Override
- public void run() {
- try {
- JsonNode jsonNode = fOfSchema.get();
- schema = DatabaseSchema.fromJson(jsonNode);
-
- } catch (Exception e) {
- exceptions.add(e);
- }
- }
- }, executorService);
- }
-
- public Transaction transact(){
- return new Transaction(this);
- }
-
- 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);
- }
-
- ListenableFuture<List<OperationResult>> transact = rpc.transact(builder);
- return transact;
- }
-
- public boolean isReady(long timeout) {
- //todo implement timeout
- return null != schema;
- }
-
- public DatabaseSchema schema() {
- return schema;
- }
-
-
- public static class Transaction {
-
- private DatabaseSchema eDatabaseSchema;
- OpenVswitch ovs;
- ArrayList<Operation> operations = Lists.newArrayList();
-
- public Transaction(OpenVswitch ovs) {
- this.ovs = ovs;
- }
-
- public Transaction(DatabaseSchema eDatabaseSchema) {
- this.eDatabaseSchema = eDatabaseSchema;
- }
-
- public Transaction add(Operation operation) {
- operations.add(operation);
- return this;
- }
-
- public List<Operation> build() {
- return operations;
- }
-
- public ListenableFuture<List<OperationResult>> execute() {
- return ovs.transact(operations);
- }
- }
-
- public static class Update<E extends TableSchema<E>> extends Operation<E> implements ConditionalOperation {
-
- 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);
- this.row.put(columnSchema.getName(), value);
- return this;
- }
-
- public Where where(Condition 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;
- }
- }
-
-
- public static 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 operation() {
- return (Operation) this.operation;
- }
-
- }
-
-
- public static 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 ExecutorService getExecutorService() {
- return executorService;
- }
-
- public void setExecutorService(ExecutorService executorService) {
- this.executorService = executorService;
- }
-
- public String getSchemaName() {
- return schemaName;
- }
-
- public void setSchemaName(String schemaName) {
- this.schemaName = schemaName;
- }
-
- public OvsdbRPC getRpc() {
- return rpc;
- }
-
- public void setRpc(OvsdbRPC rpc) {
- this.rpc = rpc;
- }
-
- public DatabaseSchema getSchema() {
- return schema;
- }
-
- public void setSchema(DatabaseSchema schema) {
- this.schema = schema;
- }
-
- public Queue<Throwable> getExceptions() {
- return exceptions;
- }
-
- public void setExceptions(Queue<Throwable> exceptions) {
- this.exceptions = exceptions;
- }
-
-}
--- /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 com.google.common.util.concurrent.ListenableFuture;
+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 java.util.List;
+
+/**
+ * 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 {
+
+ String OPEN_VSWITCH_SCHEMA = "Open_vSwitch";
+
+ /**
+ * Gets the list of database names exposed by this OVSDB capable device
+ * @return list of database names
+ */
+ ListenableFuture<List<String>> getDatabases();
+
+ /**
+ * Asynchronosly 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.
+ */
+ ListenableFuture<List<OperationResult>> transact(List<Operation> 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;
+
+import com.fasterxml.jackson.databind.JsonNode;
+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;
+import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
+import org.opendaylight.ovsdb.lib.message.TransactBuilder;
+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 java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.concurrent.ExecutorService;
+
+
+public class OvsDBClientImpl implements OvsDBClient {
+
+ ExecutorService executorService;
+ String schemaName;
+ OvsdbRPC rpc;
+ Map<String, DatabaseSchema> schema = Maps.newHashMap();
+ Queue<Throwable> exceptions;
+
+ public OvsDBClientImpl(OvsdbRPC rpc, ExecutorService executorService) {
+ this.rpc = rpc;
+ this.executorService = executorService;
+ }
+
+ public OvsDBClientImpl() {
+ }
+
+ @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);
+ }
+
+ ListenableFuture<List<OperationResult>> transact = rpc.transact(builder);
+ return transact;
+ }
+
+ @Override
+ public TransactionBuilder transactBuilder() {
+ return new TransactionBuilder(this);
+ }
+
+
+ public boolean isReady(long timeout) {
+ //todo implement timeout
+ return null != schema;
+ }
+
+ @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) {
+ ListenableFuture<Map<String, DatabaseSchema>> schemaFromDevice = getSchemaFromDevice(Lists.newArrayList(database));
+
+ final SettableFuture<DatabaseSchema> future = SettableFuture.create();
+ Futures.addCallback(schemaFromDevice, new FutureCallback<Map<String, DatabaseSchema>>() {
+ @Override
+ public void onSuccess(Map<String, DatabaseSchema> result) {
+ if (result.containsKey(database)) {
+ DatabaseSchema s = result.get(database);
+ if (cacheResult) {
+ OvsDBClientImpl.this.schema.put(database, s);
+ }
+ future.set(s);
+ } else {
+ future.set(null);
+ }
+ }
+
+ @Override
+ public void onFailure(Throwable t) {
+ //todo: should wrap
+ future.setException(t);
+ }
+ });
+ return future;
+
+ } 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(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;
+ }
+
+}
package org.opendaylight.ovsdb.lib.database;\r
\r
import com.fasterxml.jackson.annotation.JsonProperty;\r
-import org.opendaylight.ovsdb.lib.notation.Condition;\r
-import org.opendaylight.ovsdb.lib.notation.Function;\r
\r
public class ColumnSchema {\r
\r
this.name = name;\r
}\r
\r
- public Condition opEqual(String some) {\r
- return new Condition(this.getName(), Function.EQUALS, some);\r
- }\r
-\r
- public Condition opGreaterThan(Object val) {\r
- return new Condition(this.getName(), Function.GREATER_THAN, val);\r
- }\r
-\r
- public Condition opLesserThan(int val) {\r
- return new Condition(this.getName(), Function.GREATER_THAN, val);\r
- }\r
-\r
- public Condition opLesserThanOrEquals(Object val) {\r
- return new Condition(this.getName(), Function.LESS_THAN_OR_EQUALS, val);\r
- }\r
\r
@Override\r
public String toString() {\r
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;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.ovsdb.lib.message.operations.OperationResult;
+import org.opendaylight.ovsdb.lib.operations.OperationResult;
public interface OvsdbRPC {
public static final String REGISTER_CALLBACK_METHOD = "registerCallback";
public boolean registerCallback(Callback callback);
+
public static interface Callback {
public void update(Node node, UpdateNotification upadateNotification);
public void locked(Node node, List<String> ids);
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;
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;
}
--- /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.database.ColumnSchema;
+
+import java.util.Map;
+
+public class Row {
+ private Map<String, ColumnSchema> columnSchema;
+ private Map<String, Object> columns;
+
+
+
+}
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
public class AbortOperation extends Operation {
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
public class AssertOperation extends Operation {
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
public class CommentOperation extends Operation {
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
public class CommitOperation extends Operation {
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
import org.opendaylight.ovsdb.lib.notation.Condition;
/**
- * Represents an Operation type that accepts acondition, for e.g Update, Select etc
+ * Represents an Operation type that accepts a condition, for e.g Update, Select etc
*/
public interface ConditionalOperation {
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
import java.util.List;
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb;
+package org.opendaylight.ovsdb.lib.operations;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Maps;
-import org.opendaylight.ovsdb.lib.message.operations.Operation;
-import org.opendaylight.ovsdb.lib.meta.ColumnSchema;
-import org.opendaylight.ovsdb.lib.meta.TableSchema;
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
import java.util.Map;
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;
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
import java.util.List;
*
* Authors : Madhu Venugopal, Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
-import org.opendaylight.ovsdb.lib.meta.TableSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
public abstract class Operation<E extends TableSchema<E>> {
*
* Authors : Madhu Venugopal
*/
-package org.opendaylight.ovsdb.lib.message.operations;
+package org.opendaylight.ovsdb.lib.operations;
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.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);
+ }
+
+
+}
*
* 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 com.google.common.collect.Lists;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.ovsdb.lib.OvsDBClientImpl;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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 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 com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+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;
+import java.util.Map;
+
+public class Update<E extends TableSchema<E>> extends Operation<E> implements ConditionalOperation {
+
+ 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);
+ this.row.put(columnSchema.getName(), value);
+ return this;
+ }
+
+ public Where where(Condition 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;
*
* 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 operation() {
+ 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;
+
+public class ATableSchema extends TableSchema<ATableSchema> {
+}
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.meta;
+package org.opendaylight.ovsdb.lib.schema;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.Sets;
public void setEnums(Set<Integer> enums) {
this.enums = enums;
}
+
+ @Override
+ public String toString() {
+ return "IntegerBaseType";
+ }
}
public static class RealBaseType extends BaseType<RealBaseType> {
this.enums = enums;
}
-
+ @Override
+ public String toString() {
+ return "RealBaseType";
+ }
}
protected void getConstraints(BaseType baseType, JsonNode node) {
//no op
}
+
+ @Override
+ public String toString() {
+ return "BooleanBaseType";
+ }
}
public static class StringBaseType extends BaseType<StringBaseType> {
public void setEnums(Set<String> enums) {
this.enums = enums;
}
+
+ public String toString() {
+ return "StringBaseType";
+ }
+
}
public void setRefType(RefType refType) {
this.refType = refType;
}
+
+ public String toString() {
+ return "UuidBaseType";
+ }
}
}
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.meta;
+package org.opendaylight.ovsdb.lib.schema;
import com.fasterxml.jackson.databind.JsonNode;
import org.opendaylight.ovsdb.lib.notation.Condition;
public ColumnType getType() { return type; }
+ // --- Operations on the column ----------//
+
public Condition opEqual(D data) {
return new Condition(this.getName(), Function.EQUALS, data);
}
return new Condition(this.getName(), Function.LESS_THAN_OR_EQUALS, data);
}
+ // --- Operations on the column ----------//:w
+
@Override
public String toString() {
return "ColumnType [type=" + type + ", ephemeral=" + ephemeral
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.meta;
+package org.opendaylight.ovsdb.lib.schema;
import com.fasterxml.jackson.databind.JsonNode;
import org.opendaylight.ovsdb.lib.jsonrpc.JsonUtils;
this.baseType = baseType;
}
+ public BaseType getBaseType() {
+ return baseType;
+ }
+
/**
"type": {
"key": {
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.meta;
+package org.opendaylight.ovsdb.lib.schema;
import com.fasterxml.jackson.databind.JsonNode;
-import org.opendaylight.ovsdb.OpenVswitch;
+import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DatabaseSchema {
- public static Logger logger = LoggerFactory.getLogger(DatabaseSchema.class);
- public static String OPEN_VSWITCH_SCHEMA_NAME = "Open_vSwitch";
+ public static Logger logger = LoggerFactory.getLogger(DatabaseSchema.class);
public Map<String, TableSchema> tables;
this.tables = tables;
}
- public Set<String> getTables() { return this.tables.keySet(); }
+ public Set<String> getTables() {
+ return this.tables.keySet();
+ }
- public boolean hasTable(String table) { return this.getTables().contains(table); }
+ public boolean hasTable(String table) {
+ return this.getTables().contains(table);
+ }
- public TableSchema getTable(String table) { return this.tables.get(table); }
+ public TableSchema getTable(String table) {
+ return this.tables.get(table);
+ }
public static DatabaseSchema fromJson(JsonNode json) {
if (!json.isObject() || !json.has("tables")) {
Map<String, TableSchema> tables = new HashMap<>();
//Iterator<Map.Entry<String,JsonNode>> fields = json.fields();
- for(Iterator<Map.Entry<String,JsonNode>> iter = json.get("tables").fields(); iter.hasNext();) {
+ 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());
+ logger.debug("Read schema for table[{}]:{}", table.getKey(), table.getValue());
tables.put(table.getKey(), TableSchema.fromJson(table.getKey(), table.getValue()));
}
return new DatabaseSchema(tables);
}
- public OpenVswitch.Transaction beginTransaction() {
- return new OpenVswitch.Transaction(this);
+ public TransactionBuilder beginTransaction() {
+ return new TransactionBuilder(this);
}
public <E extends TableSchema<E>> TableSchema<E> table(String tableName) {
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.meta;
+package org.opendaylight.ovsdb.lib.schema;
import com.fasterxml.jackson.databind.JsonNode;
-import org.opendaylight.ovsdb.Insert;
+import org.opendaylight.ovsdb.lib.operations.Insert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TableSchema<E extends TableSchema<E>> {
+
protected static final Logger logger = LoggerFactory.getLogger(TableSchema.class);
private String name;
private Map<String, ColumnSchema> columns;
this.columns = columns;
}
- public Set<String> getColumns() { return this.columns.keySet(); }
+ public Set<String> getColumns() {
+ return this.columns.keySet();
+ }
- public boolean hasColumn(String column) { return this.getColumns().contains(column); }
+ public Map<String, ColumnSchema> getColumnSchemas() {
+ return columns;
+ }
- public ColumnSchema getColumn(String column) { return this.columns.get(column); }
+ public boolean hasColumn(String column) {
+ return this.getColumns().contains(column);
+ }
- public ColumnType getColumnType(String column) { return this.columns.get(column).getType(); }
+ public ColumnSchema getColumn(String column) {
+ return this.columns.get(column);
+ }
+
+ public ColumnType getColumnType(String column) {
+ return this.columns.get(column).getType();
+ }
public static TableSchema fromJson(String tableName, JsonNode json) {
columns.put(column.getKey(), ColumnSchema.fromJson(column.getKey(), column.getValue()));
}
- TableSchema tableSchema = new TableSchema(tableName, columns);
- return tableSchema;
+ TableSchema tableSchema = new TableSchema(tableName, columns);
+ return tableSchema;
}
public <E extends TableSchema<E>> E as(Class<E> clazz) {
return new Insert<>(this);
}
-
-
- public <D> ColumnSchema<E, D> column(String column) {
+ public <D> ColumnSchema<E, D> column(String column, Class<D> type) {
//todo exception handling
return columns.get(column);
}
this.name = name;
}
- public static class AnyTableSchema extends TableSchema<AnyTableSchema>{}
}
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;
/**
* Add a new bridge
* @param node Node serving this configuration service
- * @param bridgeConnectorIdentifier String representation of a Bridge Connector
+ * @param bridgeIdentifier String representation of a Bridge Connector
* @return Bridge Connector configurations
*/
@Override
* Implements the OVS Connection for Managers
*
* @param node Node serving this configuration service
- * @param String with IP and connection types
+ * @param managerip with IP and connection types
*/
@SuppressWarnings("unchecked")
public boolean setManager(Node node, String managerip) {
+++ /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;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import junit.framework.Assert;
-import org.junit.Test;
-import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
-import org.opendaylight.ovsdb.lib.message.operations.OperationResult;
-import org.opendaylight.ovsdb.lib.meta.ColumnSchema;
-import org.opendaylight.ovsdb.lib.meta.TableSchema;
-import org.opendaylight.ovsdb.plugin.OvsdbTestBase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import static org.opendaylight.ovsdb.OpenVswitch.Operations.op;
-
-
-public class OpenVswitchTestIT extends OvsdbTestBase {
- Logger logger = LoggerFactory.getLogger(OpenVswitchTestIT.class);
-
- @Test
- public void test() throws IOException, InterruptedException, ExecutionException {
- OpenVswitch ovs = getVswitch();
-
- TableSchema<TableSchema.AnyTableSchema> bridge = ovs.schema().table("Bridge");
- ColumnSchema<TableSchema.AnyTableSchema, String> name = bridge.column("name");
-
- ListenableFuture<List<OperationResult>> results = ovs.transact()
- .add(op.insert(bridge).value(name, "br-int"))
- .add(op.update(bridge)
- .set(name, "br-int")
- .where(name.opEqual("br-int"))
- .and(name.opEqual("br-int")).operation())
- .execute();
-
- List<OperationResult> operationResults = results.get();
- Assert.assertFalse(operationResults.isEmpty());
- System.out.println("operationResults = " + operationResults);
- }
-
-
- private OpenVswitch getVswitch() throws IOException, InterruptedException {
- TestObjects testConnection = getTestConnection();
- OvsdbRPC rpc = testConnection.connectionService.getConnection(testConnection.node).getRpc();
-
- ExecutorService executorService = Executors.newFixedThreadPool(3);
- OpenVswitch ovs = new OpenVswitch(rpc, executorService);
- ovs.populateSchemaFromDevice();
-
- for (int i = 0; i < 100; i++) {
- if (ovs.isReady(0)) {
- break;
- }
- Thread.sleep(1000);
- }
- return ovs;
- }
-
-}
--- /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 com.google.common.util.concurrent.ListenableFuture;
+import junit.framework.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
+import org.opendaylight.ovsdb.lib.operations.OperationResult;
+import org.opendaylight.ovsdb.lib.schema.ATableSchema;
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+import org.opendaylight.ovsdb.plugin.OvsdbTestBase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import static org.opendaylight.ovsdb.lib.operations.Operations.op;
+
+
+public class OvsDBClientTestIT extends OvsdbTestBase {
+ Logger logger = LoggerFactory.getLogger(OvsDBClientTestIT.class);
+
+ OvsDBClientImpl ovs;
+
+
+
+ @Test
+ public void testTransact() throws IOException, InterruptedException, ExecutionException {
+
+ ListenableFuture<DatabaseSchema> schema = ovs.getSchema(OvsDBClient.OPEN_VSWITCH_SCHEMA, true);
+ TableSchema<ATableSchema> bridge = schema.get().table("Bridge");
+
+ for (Map.Entry<String, ColumnSchema> names : bridge.getColumnSchemas().entrySet()) {
+ System.out.println("names = " + names.getKey());
+ System.out.println("names.getValue().getType() = " + names.getValue().getType().getBaseType());
+ }
+
+ ColumnSchema<ATableSchema, String> name = bridge.column("name", String.class);
+ ColumnSchema<ATableSchema, String> fail_mode = bridge.column("fail_mode", String.class);
+
+ ListenableFuture<List<OperationResult>> results = ovs.transactBuilder()
+ .add(op.insert(bridge).value(name, "br-int"))
+ .add(op.update(bridge)
+ .set(fail_mode, "secure")
+ .where(name.opEqual("br-int"))
+ //.and(name.opEqual("br-int"))
+ .operation())
+ .execute();
+
+ List<OperationResult> operationResults = results.get();
+ Assert.assertFalse(operationResults.isEmpty());
+ System.out.println("operationResults = " + operationResults);
+ }
+
+ @Test
+ public void testGetDBs() throws ExecutionException, InterruptedException {
+ ListenableFuture<List<String>> databases = ovs.getDatabases();
+ List<String> dbNames = databases.get();
+ Assert.assertNotNull(dbNames);
+ Assert.assertTrue(dbNames.size() > 0);
+ }
+
+ @Before
+ public void initalize() throws IOException {
+ if (ovs != null) {
+ return;
+ }
+ TestObjects testConnection = getTestConnection();
+ OvsdbRPC rpc = testConnection.connectionService.getConnection(testConnection.node).getRpc();
+
+ ExecutorService executorService = Executors.newFixedThreadPool(3);
+ ovs = new OvsDBClientImpl(rpc, executorService);
+ }
+
+}
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb;
+package org.opendaylight.ovsdb.lib;
import com.google.common.util.concurrent.ListenableFuture;
import junit.framework.Assert;
import org.junit.Test;
import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
-import org.opendaylight.ovsdb.lib.message.operations.OperationResult;
-import org.opendaylight.ovsdb.lib.meta.ColumnSchema;
-import org.opendaylight.ovsdb.lib.meta.TableSchema;
-import org.opendaylight.ovsdb.lib.meta.temp.Reference;
+import org.opendaylight.ovsdb.lib.operations.OperationResult;
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+import org.opendaylight.ovsdb.lib.schema.temp.Reference;
import org.opendaylight.ovsdb.plugin.OvsdbTestBase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import static org.opendaylight.ovsdb.OpenVswitch.Operations.op;
+import static org.opendaylight.ovsdb.lib.operations.Operations.op;
-public class OpenVswitchTestITTyped extends OvsdbTestBase {
+public class OvsDBClientTestITTyped extends OvsdbTestBase {
- Logger logger = LoggerFactory.getLogger(OpenVswitchTestITTyped.class);
+ Logger logger = LoggerFactory.getLogger(OvsDBClientTestITTyped.class);
static class Bridge extends TableSchema<Bridge> {
}
public ColumnSchema<Bridge, String> name() {
- return column("name");
+ return column("name", String.class);
}
public ColumnSchema<Bridge, Integer> floodVlans() {
- return column("flood_vlans");
+ return column("flood_vlans", Integer.class);
}
public ColumnSchema<Bridge, String> status() {
- return column("status");
+ return column("status", String.class);
}
public ColumnSchema<Bridge, Reference> netflow() {
- return column("netflow");
+ return column("netflow", Reference.class);
}
}
@Test
public void test() throws IOException, InterruptedException, ExecutionException {
- OpenVswitch ovs = getVswitch();
+ OvsDBClientImpl ovs = getVswitch();
- Bridge bridge = ovs.schema().table("Bridge", Bridge.class);
+ Bridge bridge = ovs.getSchema(OvsDBClient.OPEN_VSWITCH_SCHEMA, true).get().table("Bridge", Bridge.class);
- ListenableFuture<List<OperationResult>> results = ovs.transact()
+ ListenableFuture<List<OperationResult>> results = ovs.transactBuilder()
.add(op.insert(bridge).value(bridge.name(), "br-int"))
.add(op.update(bridge)
.set(bridge.status(), "br-blah")
- private OpenVswitch getVswitch() throws IOException, InterruptedException {
+ private OvsDBClientImpl getVswitch() throws IOException, InterruptedException {
TestObjects testConnection = getTestConnection();
OvsdbRPC rpc = testConnection.connectionService.getConnection(testConnection.node).getRpc();
ExecutorService executorService = Executors.newFixedThreadPool(3);
- OpenVswitch ovs = new OpenVswitch(rpc, executorService);
- ovs.populateSchemaFromDevice();
+ OvsDBClientImpl ovs = new OvsDBClientImpl(rpc, executorService);
for (int i = 0; i < 100; i++) {
if (ovs.isReady(0)) {
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.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.notation.Condition;
import org.opendaylight.ovsdb.lib.notation.Function;
import org.opendaylight.ovsdb.lib.notation.Mutation;
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.meta;
+package org.opendaylight.ovsdb.lib.schema;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.meta.temp;
+package org.opendaylight.ovsdb.lib.schema.temp;
public class Reference {
*
* Authors : Ashwin Raveendran
*/
-package org.opendaylight.ovsdb.lib.meta.temp;
+package org.opendaylight.ovsdb.lib.schema.temp;
-import org.opendaylight.ovsdb.OpenVswitch;
-import org.opendaylight.ovsdb.lib.meta.DatabaseSchema;
-import org.opendaylight.ovsdb.lib.meta.ColumnSchema;
-import org.opendaylight.ovsdb.lib.meta.TableSchema;
+import org.opendaylight.ovsdb.lib.OvsDBClient;
+import org.opendaylight.ovsdb.lib.OvsDBClientImpl;
+import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+import java.util.concurrent.ExecutionException;
public class SchemaObjs {
public Bridge(TableSchema<Bridge> target) {
this.target = target;
- name = target.column("name");
- flood_vlans = target.column("statistics");
+ name = target.column("name", String.class);
+ flood_vlans = target.column("statistics", Boolean.class);
}
}
public Port(TableSchema<Port> target) {
this.target = target;
- name = target.column("name");
- statistics = target.column("statistics");
+ name = target.column("name", String.class);
+ statistics = target.column("statistics", String.class);
}
}
- public static void main(String[] args) {
+ public static void main(String[] args) throws ExecutionException, InterruptedException {
- OpenVswitch ovs = new OpenVswitch(null, null);
- DatabaseSchema db = ovs.getSchema();
+ OvsDBClientImpl ovs = new OvsDBClientImpl(null, null);
+ DatabaseSchema db = ovs.getSchema(OvsDBClient.OPEN_VSWITCH_SCHEMA, true).get();
Bridge bridge = db.table(Bridge.NAME, Bridge.class);
Port port = db.table(Port.NAME, Port.class);