use of org.onosproject.ovsdb.rfc.schema.DatabaseSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method bindQueues.
@Override
public void bindQueues(QosId qosId, Map<Long, QueueDescription> queues) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
OvsdbRowStore qosRowStore = getRowStore(DATABASENAME, QOS);
if (qosRowStore == null) {
log.debug("The qos uuid is null");
return;
}
OvsdbRowStore queueRowStore = getRowStore(DATABASENAME, QUEUE);
if (queueRowStore == null) {
log.debug("The queue uuid is null");
return;
}
ConcurrentMap<String, Row> qosTableRows = qosRowStore.getRowStore();
ConcurrentMap<String, Row> queueTableRows = queueRowStore.getRowStore();
Row qosRow = qosTableRows.values().stream().filter(r -> {
OvsdbMap ovsdbMap = (OvsdbMap) (r.getColumn(EXTERNAL_ID).data());
return qosId.name().equals(ovsdbMap.map().get(QOS_EXTERNAL_ID_KEY));
}).findFirst().orElse(null);
if (qosRow == null) {
log.warn("Can't find QoS {}", qosId);
return;
}
Uuid qosUuid = qosRow.uuid();
Map<Long, Uuid> newQueues = new HashMap<>();
for (Map.Entry<Long, QueueDescription> entry : queues.entrySet()) {
Row queueRow = queueTableRows.values().stream().filter(r -> {
OvsdbMap ovsdbMap = (OvsdbMap) (r.getColumn(EXTERNAL_ID).data());
return entry.getValue().queueId().name().equals(ovsdbMap.map().get(QUEUE_EXTERNAL_ID_KEY));
}).findFirst().orElse(null);
if (queueRow != null) {
newQueues.put(entry.getKey(), queueRow.uuid());
}
}
// update the qos table
ArrayList<Operation> operations = Lists.newArrayList();
Condition condition = ConditionUtil.isEqual(UUID, qosUuid);
Mutation mutation = MutationUtil.insert(QUEUES, newQueues);
List<Condition> conditions = Collections.singletonList(condition);
List<Mutation> mutations = Collections.singletonList(mutation);
operations.add(new Mutate(dbSchema.getTableSchema(QOS), conditions, mutations));
transactConfig(DATABASENAME, operations);
}
use of org.onosproject.ovsdb.rfc.schema.DatabaseSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getInterface.
private Interface getInterface(Row row) {
DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
Interface intf = (Interface) TableGenerator.getTable(dbSchema, row, OvsdbTable.INTERFACE);
if (intf == null) {
return null;
}
return intf;
}
use of org.onosproject.ovsdb.rfc.schema.DatabaseSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method createPort.
@Override
public void createPort(String bridgeName, String portName) {
String bridgeUuid = getBridgeUuid(bridgeName);
if (bridgeUuid == null) {
log.error("Can't find bridge {} in {}", bridgeName, nodeId.getIpAddress());
return;
}
DatabaseSchema dbSchema = schema.get(DATABASENAME);
String portUuid = getPortUuid(portName, bridgeUuid);
Port port = (Port) TableGenerator.createTable(dbSchema, OvsdbTable.PORT);
port.setName(portName);
if (portUuid == null) {
insertConfig(PORT, UUID, BRIDGE, PORTS, bridgeUuid, port.getRow());
}
}
use of org.onosproject.ovsdb.rfc.schema.DatabaseSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getOvsdbSchema.
@Override
public ListenableFuture<DatabaseSchema> getOvsdbSchema(String dbName) {
if (dbName == null) {
return null;
}
DatabaseSchema databaseSchema = schema.get(dbName);
if (databaseSchema == null) {
List<String> dbNames = new ArrayList<>();
dbNames.add(dbName);
Function<JsonNode, DatabaseSchema> rowFunction = input -> {
log.debug("Get ovsdb database schema {}", dbName);
DatabaseSchema dbSchema = FromJsonUtil.jsonNodeToDbSchema(dbName, input);
if (dbSchema == null) {
log.debug("Get ovsdb database schema error");
return null;
}
schema.put(dbName, dbSchema);
return dbSchema;
};
ListenableFuture<JsonNode> input = getSchema(dbNames);
if (input != null) {
return futureTransform(input, rowFunction);
}
return null;
} else {
return Futures.immediateFuture(databaseSchema);
}
}
use of org.onosproject.ovsdb.rfc.schema.DatabaseSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getBridgeUuid.
@Override
public String getBridgeUuid(String bridgeName) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
OvsdbRowStore rowStore = getRowStore(DATABASENAME, BRIDGE);
if (rowStore == null) {
log.debug("The bridge uuid is null");
return null;
}
ConcurrentMap<String, Row> bridgeTableRows = rowStore.getRowStore();
if (bridgeTableRows == null) {
log.debug("The bridge uuid is null");
return null;
}
for (String uuid : bridgeTableRows.keySet()) {
Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeTableRows.get(uuid), OvsdbTable.BRIDGE);
if (bridge.getName().equals(bridgeName)) {
return uuid;
}
}
return null;
}
Aggregations