public Insert(TableSchema<E> schema, Row<E> row) { super(schema, INSERT); Collection<Column<E,?>> columns = row.getColumns(); for (Column<E,?> column : columns) { this.value(column); } }
public Insert<E> insert() { return new Insert<>(this); }
/** * Extract the NamedUuid from the Insert. * If the Insert does not have a NamedUuid set, a random one will be * generated, set, and returned. * * @param insert - Insert from which to extract the NamedUuid * @return UUID - NamedUUID of the Insert */ public static UUID extractNamedUuid(Insert insert) { String uuidString = insert.getUuidName() != null ? insert.getUuidName() : SouthboundMapper.getRandomUuid(); insert.setUuidName(uuidString); return new UUID(uuidString); }
private void setPort(TransactionBuilder transaction, Bridge bridge, OvsdbBridgeAugmentation ovsdbManagedNode) { Insert<GenericTableSchema> interfaceInsert = setInterface(transaction,ovsdbManagedNode); // Port part String portNamedUuid = "Port_" + SouthboundMapper.getRandomUuid(); Port port = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Port.class); port.setName(ovsdbManagedNode.getBridgeName().getValue()); port.setInterfaces(Sets.newHashSet(TransactUtils.extractNamedUuid(interfaceInsert))); transaction.add(op.insert(port).withId(portNamedUuid)); bridge.setPorts(Sets.newHashSet(new UUID(portNamedUuid))); }
public Insert<E> on(TableSchema<E> schema) { this.setTableSchema(schema); return this; }
public Insert<E> withId(String name) { this.uuidName = name; this.setOp(INSERT); return this; }
TableSchema<GenericTableSchema> refTableSchema = dbSchema.table(referencedRow.getKey(), GenericTableSchema.class); transactionBuilder.add(op.insert(refTableSchema, referencedRow.getValue()) .withId(refUuid.toString()));
private Insert<GenericTableSchema> setInterface(TransactionBuilder transaction, OvsdbBridgeAugmentation ovsdbManagedNode) { // Interface part String interfaceNamedUuid = "Interface_" + SouthboundMapper.getRandomUuid(); Interface interfaceOvs = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Interface.class); interfaceOvs.setName(ovsdbManagedNode.getBridgeName().getValue()); interfaceOvs.setType(SouthboundMapper.createOvsdbInterfaceType(InterfaceTypeInternal.class)); Insert<GenericTableSchema> result = op.insert(interfaceOvs).withId(interfaceNamedUuid); transaction.add(result); return result; }
public <D, C extends TableSchema<C>> Insert<E> value(Column<C, D> column) { ColumnSchema<C, D> columnSchema = column.getSchema(); D value = column.getData(); return this.value(columnSchema, value); }
public <E extends TableSchema<E>> Insert<E> insert(TypedBaseTable<E> typedTable) { return new Insert<>(typedTable); }
String controllerNamedUuidString = SouthboundMapper.getRandomUuid(); UUID controllerNamedUuid = new UUID(controllerNamedUuidString); transaction.add(op.insert(controller).withId(controllerNamedUuidString));
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); } }
public <E extends TableSchema<E>> Insert<E> insert(TableSchema<E> schema, Row<E> row) { return new Insert<>(schema, row); }
UUID namedUuid = new UUID(SouthboundConstants.QUEUE_NAMED_UUID_PREFIX + TransactUtils.bytesToHexString(queueEntry.getQueueId().getValue().getBytes())); transaction.add(op.insert(queue).withId(namedUuid.toString())).build(); LOG.info("Added queue Uuid : {} for Ovsdb Node : {}", namedUuid, operNode);
public <E extends TableSchema<E>> Insert<E> insert(TableSchema<E> schema) { return new Insert<>(schema); }
TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Interface.class); createInterface(terminationPoint, ovsInterface); transaction.add(op.insert(ovsInterface).withId(interfaceUuid)); Port port = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Port.class); createPort(terminationPoint, port, interfaceUuid); transaction.add(op.insert(port).withId(portUuid)); LOG.info("Created Termination Point : {} with Uuid : {}", terminationPoint.getName(),
UUID namedUuid = new UUID(SouthboundConstants.QOS_NAMED_UUID_PREFIX + TransactUtils.bytesToHexString(qosEntry.getQosId().getValue().getBytes())); transaction.add(op.insert(qos).withId(namedUuid.toString())).build(); LOG.info("Added QoS Uuid: {} for node : {} ", namedUuid, operNode.getConnectionInfo()); } else {
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()); } }