public <T extends TypedBaseTable<?>> T getTypedRowWrapper(Class<T> klazz, Row<GenericTableSchema> row) { return client.getTypedRowWrapper(klazz, row); }
@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); }
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; }
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; }
private void handleSpecialInsertCase(OvsdbClient client, String databaseName, String tableName, String uuid, Row<GenericTableSchema> row, TransactionBuilder transactionBuilder) { Port port = client.getTypedRowWrapper(Port.class, null); if (databaseName.equals(OvsVswitchdSchemaConstants.DATABASE_NAME) && tableName.equals(port.getSchema().getName())) { port = client.getTypedRowWrapper(Port.class, row); DatabaseSchema dbSchema = client.getDatabaseSchema(databaseName); TableSchema<GenericTableSchema> tableSchema = dbSchema.table(tableName, GenericTableSchema.class); ColumnSchema<GenericTableSchema, Set<UUID>> columnSchema = tableSchema.multiValuedColumn("interfaces", UUID.class); String namedUuid = "Special_"+tableName; List<Operation> priorOperations = transactionBuilder.getOperations(); Insert portOperation = (Insert)priorOperations.get(0); portOperation.value(columnSchema, new UUID(namedUuid)); Column<GenericTableSchema, ?> nameColumn = port.getNameColumn(); List<Column<GenericTableSchema, ?>> columns = new ArrayList<Column<GenericTableSchema, ?>>(); columns.add(nameColumn); Row<GenericTableSchema> intfRow = new Row<GenericTableSchema>(tableSchema, columns); this.processTypedInsertTransaction(client, databaseName, "Interface", null, null, null, namedUuid, intfRow, transactionBuilder); } }
@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(); }