use of org.onosproject.ovsdb.rfc.schema.DatabaseSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getMirrorings.
/**
* Helper method which retrieves mirrorings statistics using bridge uuid.
*
* @param bridgeUuid the uuid of the bridge
* @return the list of the mirrorings statistics.
*/
private List<MirroringStatistics> getMirrorings(Uuid bridgeUuid) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
if (dbSchema == null) {
log.warn("Unable to retrieve dbSchema {}", DATABASENAME);
return null;
}
OvsdbRowStore rowStore = getRowStore(DATABASENAME, BRIDGE);
if (rowStore == null) {
log.warn("Unable to retrieve rowStore {} of {}", BRIDGE, DATABASENAME);
return null;
}
Row bridgeRow = rowStore.getRow(bridgeUuid.value());
Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeRow, OvsdbTable.BRIDGE);
Set<Uuid> mirroringsUuids = (Set<Uuid>) ((OvsdbSet) bridge.getMirrorsColumn().data()).set();
OvsdbRowStore mirrorRowStore = getRowStore(DATABASENAME, MIRROR);
if (mirrorRowStore == null) {
log.warn("Unable to retrieve rowStore {} of {}", MIRROR, DATABASENAME);
return null;
}
List<MirroringStatistics> mirroringStatistics = new ArrayList<>();
ConcurrentMap<String, Row> mirrorTableRows = mirrorRowStore.getRowStore();
mirrorTableRows.forEach((key, row) -> {
if (!mirroringsUuids.contains(Uuid.uuid(key))) {
return;
}
Mirror mirror = (Mirror) TableGenerator.getTable(dbSchema, row, OvsdbTable.MIRROR);
mirroringStatistics.add(MirroringStatistics.mirroringStatistics(mirror.getName(), (Map<String, Integer>) ((OvsdbMap) mirror.getStatisticsColumn().data()).map()));
});
return ImmutableList.copyOf(mirroringStatistics);
}
use of org.onosproject.ovsdb.rfc.schema.DatabaseSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method createQueue.
@Override
public boolean createQueue(OvsdbQueue ovsdbQueue) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
Queue queue = (Queue) TableGenerator.createTable(dbSchema, OvsdbTable.QUEUE);
ArrayList<Operation> operations = Lists.newArrayList();
OvsdbRowStore rowStore = getRowStore(DATABASENAME, QUEUE);
if (rowStore == null) {
log.debug("The queue uuid is null");
return false;
}
if (ovsdbQueue.dscp().isPresent()) {
queue.setDscp(ImmutableSet.of(ovsdbQueue.dscp().get()));
}
queue.setOtherConfig(ovsdbQueue.otherConfigs());
queue.setExternalIds(ovsdbQueue.externalIds());
Insert queueInsert = new Insert(dbSchema.getTableSchema(QUEUE), QUEUE, queue.getRow());
operations.add(queueInsert);
try {
transactConfig(DATABASENAME, operations).get();
} catch (InterruptedException | ExecutionException e) {
log.error("createQueue transactConfig get exception !");
}
return true;
}
use of org.onosproject.ovsdb.rfc.schema.DatabaseSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method updateConfig.
/**
* Update transact config.
*
* @param tableName table name
* @param columnName column name
* @param uuid uuid
* @param row the config data
*/
private void updateConfig(String tableName, String columnName, String uuid, Row row) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
TableSchema tableSchema = dbSchema.getTableSchema(tableName);
List<Condition> conditions = Lists.newArrayList();
Condition condition = ConditionUtil.isEqual(columnName, Uuid.uuid(uuid));
conditions.add(condition);
Update update = new Update(tableSchema, row, conditions);
ArrayList<Operation> operations = Lists.newArrayList();
operations.add(update);
transactConfig(DATABASENAME, operations);
}
use of org.onosproject.ovsdb.rfc.schema.DatabaseSchema 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();
}
use of org.onosproject.ovsdb.rfc.schema.DatabaseSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getInterfacebyPort.
private Interface getInterfacebyPort(String portUuid, String portName) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
Row portRow = getRow(DATABASENAME, PORT, portUuid);
Port port = (Port) TableGenerator.getTable(dbSchema, portRow, OvsdbTable.PORT);
if (port == null) {
return null;
}
OvsdbSet setInterfaces = (OvsdbSet) port.getInterfacesColumn().data();
Set<Uuid> interfaces = setInterfaces.set();
return interfaces.stream().map(intf -> (Interface) TableGenerator.getTable(dbSchema, getRow(DATABASENAME, INTERFACE, intf.value()), OvsdbTable.INTERFACE)).filter(intf -> Objects.nonNull(intf) && portName.equalsIgnoreCase(intf.getName())).findFirst().orElse(null);
}
Aggregations