use of org.onosproject.ovsdb.rfc.notation.OvsdbMap 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.notation.OvsdbMap in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getIfaceid.
private String getIfaceid(Interface intf) {
OvsdbMap ovsdbMap = (OvsdbMap) intf.getExternalIdsColumn().data();
@SuppressWarnings("unchecked") Map<String, String> externalIds = ovsdbMap.map();
if (externalIds.isEmpty()) {
log.warn("The external_ids is null");
return null;
}
String ifaceid = externalIds.get(EXTERNAL_ID_INTERFACE_ID);
if (ifaceid == null) {
log.warn("The ifaceid is null");
return null;
}
return ifaceid;
}
use of org.onosproject.ovsdb.rfc.notation.OvsdbMap in project onos by opennetworkinglab.
the class DefaultOvsdbClient method dropQos.
@Override
public void dropQos(QosId qosId) {
OvsdbRowStore rowStore = getRowStore(DATABASENAME, QOS);
if (rowStore != null) {
ConcurrentMap<String, Row> qosTableRows = rowStore.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) {
deleteConfig(QOS, UUID, qosRow.uuid().value(), PORT, PORT_QOS, qosRow.uuid());
}
}
}
use of org.onosproject.ovsdb.rfc.notation.OvsdbMap in project onos by opennetworkinglab.
the class DefaultOvsdbClient method dropQueue.
@Override
public void dropQueue(QueueId queueId) {
OvsdbRowStore queueRowStore = getRowStore(DATABASENAME, QUEUE);
if (queueRowStore == null) {
return;
}
ConcurrentMap<String, Row> queueTableRows = queueRowStore.getRowStore();
Row queueRow = queueTableRows.values().stream().filter(r -> {
OvsdbMap ovsdbMap = (OvsdbMap) (r.getColumn(EXTERNAL_ID).data());
return queueId.name().equals(ovsdbMap.map().get(QUEUE_EXTERNAL_ID_KEY));
}).findFirst().orElse(null);
if (queueRow == null) {
return;
}
String queueUuid = queueRow.uuid().value();
OvsdbRowStore qosRowStore = getRowStore(DATABASENAME, QOS);
if (qosRowStore != null) {
Map<Long, Uuid> queueMap = new HashMap<>();
ConcurrentMap<String, Row> qosTableRows = qosRowStore.getRowStore();
qosTableRows.values().stream().filter(r -> {
Map<Integer, Uuid> ovsdbMap = ((OvsdbMap) r.getColumn(QUEUES).data()).map();
Set<Integer> keySet = ovsdbMap.keySet();
for (Integer keyId : keySet) {
if (ovsdbMap.get(keyId).equals(Uuid.uuid(queueUuid))) {
queueMap.put(keyId.longValue(), Uuid.uuid(queueUuid));
return true;
}
}
return false;
}).findFirst().orElse(null);
deleteConfig(QUEUE, UUID, queueUuid, QOS, QUEUES, OvsdbMap.ovsdbMap(queueMap));
} else {
deleteConfig(QUEUE, UUID, queueUuid, null, null, null);
}
}
use of org.onosproject.ovsdb.rfc.notation.OvsdbMap in project onos by opennetworkinglab.
the class DefaultOvsdbClient method unbindQueues.
@SuppressWarnings("unchecked")
@Override
public void unbindQueues(QosId qosId, List<Long> queueKeys) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
OvsdbRowStore qosRowStore = getRowStore(DATABASENAME, QOS);
if (qosRowStore == null) {
return;
}
ConcurrentMap<String, Row> qosTableRows = qosRowStore.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;
}
Map<Long, Uuid> deleteQueuesMap;
Map<Integer, Uuid> queuesMap = ((OvsdbMap) qosRow.getColumn(QUEUES).data()).map();
deleteQueuesMap = queueKeys.stream().filter(key -> queuesMap.containsKey(key.intValue())).collect(Collectors.toMap(key -> key, key -> queuesMap.get(key.intValue()), (a, b) -> b));
if (deleteQueuesMap.size() != 0) {
TableSchema parentTableSchema = dbSchema.getTableSchema(QOS);
ColumnSchema parentColumnSchema = parentTableSchema.getColumnSchema(QUEUES);
Mutation mutation = MutationUtil.delete(parentColumnSchema.name(), OvsdbMap.ovsdbMap(deleteQueuesMap));
List<Mutation> mutations = Collections.singletonList(mutation);
Condition condition = ConditionUtil.isEqual(UUID, qosRow.uuid());
List<Condition> conditionList = Collections.singletonList(condition);
List<Operation> operations = Collections.singletonList(new Mutate(parentTableSchema, conditionList, mutations));
transactConfig(DATABASENAME, operations);
}
}
Aggregations