public DatabaseSchema getDatabaseSchema(String dbName) { return client.getDatabaseSchema(dbName); }
private String getBackwardCompatibleTableName(OvsdbClient client, String databaseName, String tableName) { DatabaseSchema dbSchema = client.getDatabaseSchema(databaseName); if (dbSchema == null || tableName == null) { return tableName; } for (String dbTableName : dbSchema.getTables()) { if (dbTableName.equalsIgnoreCase(tableName)) { return dbTableName; } } return tableName; } }
private DatabaseSchema getDatabaseSchema (String databaseName) { OvsdbClient client = NodeResource.getOvsdbClient(nodeId, this); return client.getDatabaseSchema(databaseName); }
private DatabaseSchema getDatabaseSchema (String databaseName) { String csDatabaseName = this.caseSensitiveDatabaseName(databaseName); OvsdbClient client = NodeResource.getOvsdbClient(nodeId, this); return client.getDatabaseSchema(csDatabaseName); }
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); } }
DatabaseSchema dbSchema = client.getDatabaseSchema(databaseName); TableSchema<GenericTableSchema> parentTableSchema = dbSchema.table(parentTable, GenericTableSchema.class); parentColumn = this.getReferencingColumn(parentTableSchema, tableName); client.getConnectionInfo(), databaseName, tableName, rowUuid, parentTable, parentColumn); DatabaseSchema dbSchema = client.getDatabaseSchema(databaseName); TransactionBuilder transactionBuilder = client.transactBuilder(dbSchema); this.processDeleteTransaction(client, databaseName, tableName,
client.getConnectionInfo(), databaseName, tableName, uuid, parentColumn[0], parentColumn[1]); DatabaseSchema dbSchema = client.getDatabaseSchema(databaseName); TransactionBuilder transactionBuilder = client.transactBuilder(dbSchema); this.processDeleteTransaction(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName,
client.getConnectionInfo(), tableName, parentColumn[0], parentColumn[1], parentUuid, row); DatabaseSchema dbSchema = client.getDatabaseSchema(OvsVswitchdSchemaConstants.DATABASE_NAME); TransactionBuilder transactionBuilder = client.transactBuilder(dbSchema);
DatabaseSchema dbSchema = client.getDatabaseSchema(databaseName); TableSchema<GenericTableSchema> parentTableSchema = dbSchema.table(parentTable, GenericTableSchema.class); parentColumn = this.getReferencingColumn(parentTableSchema, tableName); DatabaseSchema dbSchema = client.getDatabaseSchema(OvsVswitchdSchemaConstants.DATABASE_NAME); TransactionBuilder transactionBuilder = client.transactBuilder(dbSchema);
client.getConnectionInfo(), databaseName, tableName, rowUuid, row.toString()); try{ DatabaseSchema dbSchema = client.getDatabaseSchema(databaseName); TransactionBuilder transactionBuilder = client.transactBuilder(dbSchema); TableSchema<GenericTableSchema> tableSchema = dbSchema.table(tableName, GenericTableSchema.class);
/** * 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(); }
private void processInsertTransaction(OvsdbClient client, String databaseName, String childTable, String parentTable, UUID parentUuid, String parentColumn, String namedUuid, Row<GenericTableSchema> row, TransactionBuilder transactionBuilder) { // Insert the row as the first transaction entry DatabaseSchema dbSchema = client.getDatabaseSchema(databaseName); TableSchema<GenericTableSchema> childTableSchema = dbSchema.table(childTable, GenericTableSchema.class); transactionBuilder.add(op.insert(childTableSchema, row) .withId(namedUuid)); // Followed by the Mutation if (parentColumn != null) { TableSchema<GenericTableSchema> parentTableSchema = dbSchema.table(parentTable, GenericTableSchema.class); ColumnSchema<GenericTableSchema, UUID> parentColumnSchema = parentTableSchema.column(parentColumn, UUID.class); ColumnSchema<GenericTableSchema, UUID> _uuid = parentTableSchema.column("_uuid", UUID.class); transactionBuilder .add(op.mutate(parentTableSchema) .addMutation(parentColumnSchema, Mutator.INSERT, new UUID(namedUuid)) .where(_uuid.opEqual(parentUuid)) .build()); } }
private void processDeleteTransaction(OvsdbClient client, String databaseName, String childTable, String parentTable, String parentColumn, String uuid, TransactionBuilder transactionBuilder) { DatabaseSchema dbSchema = client.getDatabaseSchema(databaseName); TableSchema<GenericTableSchema> childTableSchema = dbSchema.table(childTable, GenericTableSchema.class); if (parentColumn != null) { TableSchema<GenericTableSchema> parentTableSchema = dbSchema.table(parentTable, GenericTableSchema.class); ColumnSchema<GenericTableSchema, UUID> parentColumnSchema = parentTableSchema.column(parentColumn, UUID.class); transactionBuilder .add(op.mutate(parentTableSchema) .addMutation(parentColumnSchema, Mutator.DELETE, new UUID(uuid)) .where(parentColumnSchema.opIncludes(new UUID(uuid))) .build()); } ColumnSchema<GenericTableSchema, UUID> _uuid = childTableSchema.column("_uuid", UUID.class); transactionBuilder.add(op.delete(childTableSchema) .where(_uuid.opEqual(new UUID(uuid))) .build()); }