YuanyouZhang
Committed by Gerrit Code Review

[ONOS-2162][ONOS-2259]-- OVSDB- The implementation of OvsdbProviderService

and OvsdbClientService.

Change-Id: I3e04d7c111adf16201f8ad7ec732eb81de05b960
......@@ -31,6 +31,11 @@
<artifactId>netty-transport-native-epoll</artifactId>
<version>${netty4.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-ovsdb-rfc</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
......
......@@ -15,14 +15,24 @@
*/
package org.onosproject.ovsdb.controller;
import java.util.List;
import java.util.Set;
import org.onlab.packet.IpAddress;
import org.onosproject.ovsdb.rfc.jsonrpc.OvsdbRPC;
import org.onosproject.ovsdb.rfc.message.OperationResult;
import org.onosproject.ovsdb.rfc.message.TableUpdates;
import org.onosproject.ovsdb.rfc.notation.Row;
import org.onosproject.ovsdb.rfc.operations.Operation;
import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Represents to provider facing side of a node.
*/
public interface OvsdbClientService {
public interface OvsdbClientService extends OvsdbRPC {
/**
* Gets the node identifier.
*
......@@ -104,4 +114,111 @@ public interface OvsdbClientService {
*/
boolean isConnected();
/**
* Gets the Bridge uuid.
*
* @param bridgeName bridge name
* @return bridge uuid, empty if no uuid is find
*/
String getBridgeUuid(String bridgeName);
/**
* Gets the Port uuid.
*
* @param portName port name
* @param bridgeUuid bridge uuid
* @return port uuid, empty if no uuid is find
*/
String getPortUuid(String portName, String bridgeUuid);
/**
* Gets the Interface uuid.
*
* @param portUuid port uuid
* @param portName port name
* @return interface uuid, empty if no uuid is find
*/
String getInterfaceUuid(String portUuid, String portName);
/**
* Gets the Controller uuid.
*
* @param controllerName controller name
* @param controllerTarget controller target
* @return controller uuid, empty if no uuid is find
*/
String getControllerUuid(String controllerName, String controllerTarget);
/**
* Gets the Ovs uuid.
*
* @param dbName database name
* @return ovs uuid, empty if no uuid is find
*/
String getOvsUuid(String dbName);
/**
* Gets the ovsdb database schema.
*
* @param dbName database name
* @return database schema
*/
ListenableFuture<DatabaseSchema> getOvsdbSchema(String dbName);
/**
* Gets the ovsdb table updates.
*
* @param dbName database name
* @param id random uuid
* @return table updates
*/
ListenableFuture<TableUpdates> monitorTables(String dbName, String id);
/**
* Gets the ovsdb config operation result.
*
* @param dbName database name
* @param operations the list of operations
* @return operation results
*/
ListenableFuture<List<OperationResult>> transactConfig(String dbName,
List<Operation> operations);
/**
* Gets the ovsdb database schema from local.
*
* @param dbName database name
* @return database schema
*/
DatabaseSchema getDatabaseSchema(String dbName);
/**
* Gets the ovsdb row from the local ovsdb store.
*
* @param dbName database name
* @param tableName table name
* @param uuid row uuid
* @return row ovsdb row
*/
Row getRow(String dbName, String tableName, String uuid);
/**
* Removes the ovsdb row from the local ovsdb store.
*
* @param dbName database name
* @param tableName table name
* @param uuid row uuid
*/
void removeRow(String dbName, String tableName, String uuid);
/**
* Update the local ovsdb store.
*
* @param dbName database name
* @param tableName table name
* @param uuid row uuid
* @param row ovsdb row
*/
void updateOvsdbStore(String dbName, String tableName, String uuid, Row row);
}
......
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ovsdb.controller;
/**
* Ovsdb related constants.
*/
public final class OvsdbConstant {
/**
* Default constructor.
*
* The constructor is private to prevent creating an instance of this
* utility class.
*/
private OvsdbConstant() {
}
/** Ovsdb database Open_vSwitch. */
public static final String DATABASENAME = "Open_vSwitch";
/** Ovsdb table Bridge. */
public static final String BRIDGE = "Bridge";
/** Ovsdb table Interface. */
public static final String INTERFACE = "Interface";
/** Ovsdb table Controller. */
public static final String CONTROLLER = "Controller";
/** Ovsdb table Port. */
public static final String PORT = "Port";
/** Ovsdb bridge name. */
public static final String INTEGRATION_BRIDGE = "br-int";
/** Ovsdb vxlan tunnel type. */
public static final String TYPEVXLAN = "vxlan";
/** Openflow version. */
public static final String OPENFLOW13 = "OpenFlow13";
/** Ovsdb external_id_interface_id.. */
public static final String EXTERNAL_ID_INTERFACE_ID = "iface-id";
/** Ovsdb external_id_vm_mac. */
public static final String EXTERNAL_ID_VM_MAC = "attached-mac";
/** Openflow port. */
public static final int OFPORT = 6633;
/** Ovsdb port. */
public static final int OVSDBPORT = 6640;
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ovsdb.controller;
import java.util.concurrent.ConcurrentMap;
import org.onosproject.ovsdb.rfc.notation.Row;
import com.google.common.collect.Maps;
/**
* The class representing a table data.
*/
public class OvsdbRowStore {
private final ConcurrentMap<String, Row> rowStore = Maps.newConcurrentMap();
/**
* Gets the row.
*
* @param uuid the key of the rowStore
* @return row the row of the rowStore
*/
public Row getRow(String uuid) {
return rowStore.get(uuid);
}
/**
* Inserts a row to rowStore.
*
* @param uuid key of the row
* @param row a row of the table
*/
public void insertRow(String uuid, Row row) {
rowStore.put(uuid, row);
}
/**
* Deletes a row to rowStore.
*
* @param uuid key of the row
*/
public void deleteRow(String uuid) {
rowStore.remove(uuid);
}
/**
* Gets the rowStore.
*
* @return rowStore
*/
public ConcurrentMap<String, Row> getRowStore() {
return rowStore;
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ovsdb.controller;
import java.util.concurrent.ConcurrentMap;
import com.google.common.collect.Maps;
/**
* The cache for local ovsdb database.
*/
public class OvsdbStore {
private final ConcurrentMap<String, OvsdbTableStore> ovsdbStore = Maps.newConcurrentMap();
/**
* Gets the OvsdbTableStore.
*
* @param dbName ovsdb database name
* @return tableStore OvsdbTableStore
*/
public OvsdbTableStore getOvsdbTableStore(String dbName) {
OvsdbTableStore tableStore = ovsdbStore.get(dbName);
if (tableStore == null) {
return null;
}
return tableStore;
}
/**
* Create or Update a value to ovsdbStore.
*
* @param dbName ovsdb database name
* @param tableStore a database tableStore.
*/
public void createOrUpdateOvsdbStore(String dbName, OvsdbTableStore tableStore) {
ovsdbStore.put(dbName, tableStore);
}
/**
* Drops a value to rowStore.
*
* @param dbName ovsdb database name
*/
public void dropOvsdbStore(String dbName) {
ovsdbStore.remove(dbName);
}
/**
* Gets the ovsdbStore.
*
* @return ovsdbStore
*/
public ConcurrentMap<String, OvsdbTableStore> getOvsdbStore() {
return ovsdbStore;
}
}
/*
* Copyright 2015 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ovsdb.controller;
import java.util.concurrent.ConcurrentMap;
import com.google.common.collect.Maps;
/**
* The class representing a database data.
*/
public class OvsdbTableStore {
private final ConcurrentMap<String, OvsdbRowStore> tableStore = Maps.newConcurrentMap();
/**
* Gets the ovsdbRowStore.
*
* @param tableName a ovsdb table name
* @return OvsdbRowStore the data of the table
*/
public OvsdbRowStore getRows(String tableName) {
return tableStore.get(tableName);
}
/**
* Create or update a value to tableStore.
*
* @param tableName key of the tableName
* @param rowStore a row of the table
*/
public void createOrUpdateTable(String tableName, OvsdbRowStore rowStore) {
tableStore.put(tableName, rowStore);
}
/**
* Drops a value to table data.
*
* @param tableName key of the tableName
*/
public void dropTable(String tableName) {
tableStore.remove(tableName);
}
/**
* Gets the tableStore.
*
* @return tableStore
*/
public ConcurrentMap<String, OvsdbRowStore> getTableStore() {
return tableStore;
}
}
......@@ -17,6 +17,10 @@ package org.onosproject.ovsdb.controller.driver;
import io.netty.channel.Channel;
import org.onosproject.ovsdb.rfc.jsonrpc.Callback;
import com.fasterxml.jackson.databind.JsonNode;
/**
* Represents the driver side of an ovsdb node. This interface should never be
* exposed to consumers.
......@@ -52,4 +56,26 @@ public interface OvsdbProviderService {
* @param connected whether the node is connected
*/
void setConnection(boolean connected);
/**
* Processes result from ovsdb.
*
* @param response JsonNode response from ovsdb
*/
void processResult(JsonNode response);
/**
* processes request from ovsdb.
*
* @param request JsonNode request from ovsdb
*/
void processRequest(JsonNode request);
/**
* Sets call back.
*
* @param monitorCallback the callback to set
*/
void setCallback(Callback monitorCallback);
}
......