@Override public Connection getConnection(Node node) { return pluginOvsdbConnectionService.getConnection(NodeUtils.getMdsalNode(node)); }
@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); }
@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); }
private Connection getConnection (Node node) { Connection connection = connectionService.getConnection(node); if (connection == null || !connection.getClient().isActive()) { return null; } return connection; } /*
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; }
@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 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; }
public Status deleteRow(Node node, String tableName, String uuid) { String databaseName = OvsVswitchdSchemaConstants.DATABASE_NAME; Connection connection = connectionService.getConnection(node); OvsdbClient client = connection.getClient();
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); OvsdbRow localRow = OvsdbRow.fromJsonNode(client, OvsVswitchdSchemaConstants.DATABASE_NAME, rowJson);
@Override public void deleteRow(Node node, String databaseName, String tableName, String parentTable, UUID parentRowUuid, String parentColumn, UUID rowUuid) throws OvsdbPluginException { Connection connection = connectionService.getConnection(node); OvsdbClient client = connection.getClient();
public static Connection getOvsdbConnection(String nodeId, Object bundleClassRef) { OvsdbConnectionService connectionService = (OvsdbConnectionService)ServiceHelper. getGlobalInstance(OvsdbConnectionService.class, bundleClassRef); if (connectionService == null) { throw new ServiceUnavailableException("Ovsdb ConnectionService " + RestMessages.SERVICEUNAVAILABLE.toString()); } Node node = connectionService.getNode(nodeId); if (node == null) { throw new ResourceNotFoundException("Node "+nodeId+" not found"); } Connection connection = connectionService.getConnection(node); if (connection == null) { throw new ResourceNotFoundException("Connection for "+nodeId+" not available"); } return connection; }
public Row<GenericTableSchema> insertTree(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();
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);
String tableName, UUID rowUuid, Row<GenericTableSchema> row, 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);
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); Map<String, Row> rows = null;
/** * 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) {
Node node = connectionService.getNode(nodeId); OvsdbClient client = connectionService.getConnection(node).getClient(); OvsdbRow localRow = OvsdbRow.fromJsonNode(client, OvsVswitchdSchemaConstants.DATABASE_NAME, rowJson); String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);