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))); }
Map.Entry<String, Row<GenericTableSchema>> referencedRow = referencedRows.get(refUuid); 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; }
String controllerNamedUuidString = SouthboundMapper.getRandomUuid(); UUID controllerNamedUuid = new UUID(controllerNamedUuidString); transaction.add(op.insert(controller).withId(controllerNamedUuidString));
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.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);
setName(bridge, ovsdbManagedNode,operationalBridgeOptional); setPort(transaction, bridge, ovsdbManagedNode); transaction.add(op.insert(bridge)); LOG.info("Added ovsdb Bridge name: {} uuid: {}", ovsdbManagedNode.getBridgeName(),
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()); } }