@Override public <T extends TypedBaseTable<?>> T getTypedRow(Node node, Class<T> typedClass, Row row) { Connection connection = connectionService.getConnection(node); if (connection == null) { return null; } OvsdbClient client = connection.getClient(); return (T)client.getTypedRowWrapper(typedClass, row); }
private Connection getConnection (Node node) { Connection connection = connectionService.getConnection(node); if (connection == null || !connection.getClient().isActive()) { return null; } return connection; } /*
@Override public <T extends TypedBaseTable<?>> T createTypedRow(Node node, Class<T> typedClass) { Connection connection = connectionService.getConnection(node); if (connection == null) { return null; } OvsdbClient client = connection.getClient(); return client.createTypedRowWrapper(typedClass); }
public static OvsdbClient getOvsdbClient(String nodeId, Object bundleClassRef) { Connection connection = NodeResource.getOvsdbConnection(nodeId, bundleClassRef); OvsdbClient client = connection.getClient(); if (client == null) { throw new ResourceNotFoundException("No Ovsdb Client to handle Node "+nodeId); } return client; }
public String getSpecialCaseParentUUID(Node node, String databaseName, String childTableName) { if (!databaseName.equals(OvsVswitchdSchemaConstants.DATABASE_NAME)) return null; String[] parentColumn = OvsVswitchdSchemaConstants.getParentColumnToMutate(childTableName); if (parentColumn != null && parentColumn[0].equals(OvsVswitchdSchemaConstants.DATABASE_NAME)) { Connection connection = connectionService.getConnection(node); OpenVSwitch openVSwitch = connection.getClient().getTypedRowWrapper(OpenVSwitch.class, null); ConcurrentMap<String, Row> row = this.getRows(node, openVSwitch.getSchema().getName()); if (row == null || row.size() == 0) return null; return (String)row.keySet().toArray()[0]; } return null; }
controllerIP = connection.getClient().getConnectionInfo().getLocalAddress(); return controllerIP; } catch (Exception e) {
public Boolean setBridgeOFController(Node node, String bridgeIdentifier) { if (connectionService == null) { logger.error("Couldn't refer to the ConnectionService"); return false; } try{ Connection connection = connectionService.getConnection(node); Bridge bridge = connection.getClient().getTypedRowWrapper(Bridge.class, null); Map<String, Row> brTableCache = ovsdbInventoryService.getTableCache(node, OvsVswitchdSchemaConstants.DATABASE_NAME, bridge.getSchema().getName()); for (String uuid : brTableCache.keySet()) { bridge = connection.getClient().getTypedRowWrapper(Bridge.class, brTableCache.get(uuid)); if (bridge.getName().contains(bridgeIdentifier)) { return setOFController(node, uuid); } } } catch(Exception e) { logger.error("Error in setBridgeOFController()",e); } return false; }
@Override public <T extends TypedBaseTable<?>> String getTableName(Node node, Class<T> typedClass) { Connection connection = connectionService.getConnection(node); if (connection == null) { return null; } OvsdbClient client = connection.getClient(); TypedBaseTable<?> typedTable = client.getTypedRowWrapper(typedClass, null); if (typedTable == null) { return null; } return typedTable.getSchema().getName(); }
public TableUpdates monitorTables(Node node, DatabaseSchema dbSchema) throws ExecutionException, InterruptedException, IOException { Connection connection = getConnection(node); OvsdbClient client = connection.getClient(); if (dbSchema == null) { logger.error("Unable to get Database Schema for the ovsdb connection : {}", client.getConnectionInfo()); return null; } Set<String> tables = dbSchema.getTables(); if (tables == null) { logger.warn("Database {} without any tables. Strange !", dbSchema.getName()); return null; } List<MonitorRequest> monitorRequests = Lists.newArrayList(); for (String tableName : tables) { GenericTableSchema tableSchema = dbSchema.table(tableName, GenericTableSchema.class); monitorRequests.add(this.getAllColumnsMonitorRequest(tableSchema)); } return client.monitor(dbSchema, monitorRequests, new UpdateMonitor(node)); }
String databaseName = OvsVswitchdSchemaConstants.DATABASE_NAME; Connection connection = connectionService.getConnection(node); OvsdbClient client = connection.getClient();
private void initializeInventoryForNewNode (Connection connection) throws InterruptedException, ExecutionException, IOException { OvsdbClient client = connection.getClient(); InetAddress address = client.getConnectionInfo().getRemoteAddress(); int port = client.getConnectionInfo().getRemotePort(); List<String> databases = client.getDatabases().get(); if (databases == null) { logger.error("Unable to get Databases for the ovsdb connection : {}", client.getConnectionInfo()); return; } for (String database : databases) { DatabaseSchema dbSchema = client.getSchema(database).get(); TableUpdates updates = this.monitorTables(connection.getNode(), dbSchema); ovsdbInventoryService.processTableUpdates(connection.getNode(), dbSchema.getName(), updates); } logger.info("Notifying Inventory Listeners for Node Added: {}", connection.getNode().toString()); ovsdbInventoryService.notifyNodeAdded(connection.getNode(), address, port); }
OvsdbClient client = connection.getClient();
connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this); Node node = connectionService.getNode(nodeId); OvsdbClient client = connectionService.getConnection(node).getClient(); String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName); OvsdbRow localRow = OvsdbRow.fromJsonNode(client, OvsVswitchdSchemaConstants.DATABASE_NAME, rowJson);
String parentColumn, UUID rowUuid) throws OvsdbPluginException { Connection connection = connectionService.getConnection(node); OvsdbClient client = connection.getClient();
String parentColumn, Row<GenericTableSchema> row) throws OvsdbPluginException { Connection connection = connectionService.getConnection(node); OvsdbClient client = connection.getClient();
boolean overwrite) throws OvsdbPluginException { Connection connection = connectionService.getConnection(node); OvsdbClient client = connection.getClient();
connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this); Node node = connectionService.getNode(nodeId); OvsdbClient client = connectionService.getConnection(node).getClient(); String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
Bridge bridge = connection.getClient().createTypedRowWrapper(Bridge.class); short ofControllerPort = getControllerOFPort(); String newControllerTarget = "tcp:"+ofControllerAddr.getHostAddress()+":"+ofControllerPort; Controller newController = connection.getClient().createTypedRowWrapper(Controller.class); newController.setTarget(newControllerTarget); final String controllerTableName = newController.getSchema().getName(); bridge = connection.getClient().createTypedRowWrapper(Bridge.class); bridge.setController(Sets.newHashSet(currControllerUuid)); status = this.updateRow(node, bridge.getSchema().getName(), null, bridgeUUID, bridge.getRow());
/** * insert a Row in a Table of a specified Database Schema. * * This method can insert just a single Row specified in the row parameter. * But {@link #insertTree(Node, String, String, UUID, Row) insertTree} * can insert a hierarchy of rows with parent-child relationship. * * @param node OVSDB Node * @param databaseName Database Name that represents the Schema supported by the node. * @param tableName Table on which the row is inserted * @param parentTable Name of the Parent Table to which this operation will result in attaching/mutating. * @param parentUuid UUID of a Row in parent table to which this operation will result in attaching/mutating. * @param parentColumn Name of the Column in the Parent Table to be mutated with the UUID that results from the insert operation. * @param row Row of table Content to be inserted * @throws OvsdbPluginException Any failure during the insert transaction will result in a specific exception. * @return UUID of the inserted Row */ @Override public UUID insertRow(Node node, String databaseName, String tableName, String parentTable, UUID parentUuid, String parentColumn, Row<GenericTableSchema> row) throws OvsdbPluginException { Connection connection = connectionService.getConnection(node); OvsdbClient client = connection.getClient(); DatabaseSchema dbSchema = client.getDatabaseSchema(databaseName); TableSchema<GenericTableSchema> tableSchema = dbSchema.table(tableName, GenericTableSchema.class); Row<GenericTableSchema> processedRow = this.insertTree(node, databaseName, tableName, parentTable, parentUuid, parentColumn, row); ColumnSchema<GenericTableSchema, UUID> _uuid = tableSchema.column("_uuid", UUID.class); Column<GenericTableSchema, UUID> uuid = processedRow.getColumn(_uuid); return uuid.getData(); }
Map<UUID, Map.Entry<String, Row<GenericTableSchema>>> referencedRows, int namedUuidSuffix) { OvsdbClient client = connectionService.getConnection(node).getClient(); Collection<Column<GenericTableSchema, ?>> columns = row.getColumns(); for (Column column : columns) {