use of org.onosproject.ovsdb.rfc.table.Qos in project onos by opennetworkinglab.
the class DefaultOvsdbClient method createQos.
@Override
public boolean createQos(OvsdbQos ovsdbQos) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
Qos qos = (Qos) TableGenerator.createTable(dbSchema, OvsdbTable.QOS);
OvsdbRowStore rowStore = getRowStore(DATABASENAME, QOS);
if (rowStore == null) {
log.debug("The qos uuid is null");
return false;
}
ArrayList<Operation> operations = Lists.newArrayList();
Set<String> types = Sets.newHashSet();
Map<Long, Uuid> queues = Maps.newHashMap();
types.add(ovsdbQos.qosType());
qos.setOtherConfig(ovsdbQos.otherConfigs());
qos.setExternalIds(ovsdbQos.externalIds());
qos.setType(types);
if (ovsdbQos.qosQueues().isPresent()) {
for (Map.Entry<Long, String> entry : ovsdbQos.qosQueues().get().entrySet()) {
OvsdbRowStore queueRowStore = getRowStore(DATABASENAME, QUEUE);
if (queueRowStore != null) {
ConcurrentMap<String, Row> queueTableRows = queueRowStore.getRowStore();
Row queueRow = queueTableRows.values().stream().filter(r -> {
OvsdbMap ovsdbMap = (OvsdbMap) (r.getColumn(EXTERNAL_ID).data());
return entry.getValue().equals(ovsdbMap.map().get(QUEUE_EXTERNAL_ID_KEY));
}).findFirst().orElse(null);
if (queueRow != null) {
queues.put(entry.getKey(), queueRow.uuid());
}
}
}
qos.setQueues(queues);
}
Insert qosInsert = new Insert(dbSchema.getTableSchema(QOS), QOS, qos.getRow());
operations.add(qosInsert);
try {
transactConfig(DATABASENAME, operations).get();
} catch (InterruptedException | ExecutionException e) {
return false;
}
return true;
}
use of org.onosproject.ovsdb.rfc.table.Qos in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getOvsdbQos.
private OvsdbQos getOvsdbQos(Row row) {
DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
Qos qos = (Qos) TableGenerator.getTable(dbSchema, row, OvsdbTable.QOS);
if (qos == null) {
return null;
}
String type = (String) qos.getTypeColumn().data();
Map<String, String> otherConfigs;
Map<String, String> externalIds;
Map<Long, String> queues;
otherConfigs = ((OvsdbMap) qos.getOtherConfigColumn().data()).map();
externalIds = ((OvsdbMap) qos.getExternalIdsColumn().data()).map();
queues = ((OvsdbMap) qos.getQueuesColumn().data()).map();
return OvsdbQos.builder().qosType(type).queues(queues).otherConfigs(otherConfigs).externalIds(externalIds).build();
}
Aggregations