use of org.onosproject.ovsdb.rfc.notation.Uuid 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.notation.Uuid in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getPortError.
@Override
public boolean getPortError(List<OvsdbPortName> portNames, DeviceId bridgeId) {
Uuid bridgeUuid = getBridgeUuid(bridgeId);
List<Interface> interfaceList = portNames.stream().collect(Collectors.toMap(java.util.function.Function.identity(), port -> (Interface) getInterfacebyPort(getPortUuid(port.value(), bridgeUuid.value()), port.value()))).entrySet().stream().filter(intf -> Objects.nonNull(intf.getValue()) && ((OvsdbSet) intf.getValue().getOpenFlowPortColumn().data()).set().stream().findAny().orElse(OFPORT_ERROR_COMPARISON).equals(OFPORT_ERROR)).map(Map.Entry::getValue).collect(Collectors.toList());
interfaceList.forEach(intf -> ((Consumer<Interface>) intf1 -> {
try {
Set<String> setErrors = ((OvsdbSet) intf1.getErrorColumn().data()).set();
log.info("Port has errors. ofport value - {}, Interface - {} has error - {} ", intf1.getOpenFlowPortColumn().data(), intf1.getName(), setErrors.stream().findFirst().get());
} catch (ColumnSchemaNotFoundException | VersionMismatchException e) {
log.debug("Port has errors. ofport value - {}, Interface - {} has error - {} ", intf1.getOpenFlowPortColumn().data(), intf1.getName(), e);
}
}).accept(intf));
return !interfaceList.isEmpty();
}
use of org.onosproject.ovsdb.rfc.notation.Uuid in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getControllers.
private List<Controller> getControllers(Uuid bridgeUuid) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
if (dbSchema == null) {
return null;
}
OvsdbRowStore rowStore = getRowStore(DATABASENAME, BRIDGE);
if (rowStore == null) {
log.debug("There is no bridge table");
return null;
}
Row bridgeRow = rowStore.getRow(bridgeUuid.value());
Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeRow, OvsdbTable.BRIDGE);
// FIXME remove log
log.warn("type of controller column", bridge.getControllerColumn().data().getClass());
Set<Uuid> controllerUuids = (Set<Uuid>) ((OvsdbSet) bridge.getControllerColumn().data()).set();
OvsdbRowStore controllerRowStore = getRowStore(DATABASENAME, CONTROLLER);
if (controllerRowStore == null) {
log.debug("There is no controller table");
return null;
}
List<Controller> ovsdbControllers = new ArrayList<>();
ConcurrentMap<String, Row> controllerTableRows = controllerRowStore.getRowStore();
controllerTableRows.forEach((key, row) -> {
if (!controllerUuids.contains(Uuid.uuid(key))) {
return;
}
Controller controller = (Controller) TableGenerator.getTable(dbSchema, row, OvsdbTable.CONTROLLER);
ovsdbControllers.add(controller);
});
return ovsdbControllers;
}
use of org.onosproject.ovsdb.rfc.notation.Uuid 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.Uuid in project onos by opennetworkinglab.
the class DefaultOvsdbClient method dropInterface.
@Override
public boolean dropInterface(String ifaceName) {
OvsdbRowStore rowStore = getRowStore(DATABASENAME, BRIDGE);
if (rowStore == null) {
log.warn("Failed to get BRIDGE table");
return false;
}
ConcurrentMap<String, Row> bridgeTableRows = rowStore.getRowStore();
if (bridgeTableRows == null) {
log.warn("Failed to get BRIDGE table rows");
return false;
}
// interface name is unique
Optional<String> bridgeId = bridgeTableRows.keySet().stream().filter(uuid -> getPortUuid(ifaceName, uuid) != null).findFirst();
if (bridgeId.isPresent()) {
String portId = getPortUuid(ifaceName, bridgeId.get());
deleteConfig(PORT, UUID, portId, BRIDGE, PORTS, Uuid.uuid(portId));
return true;
} else {
log.warn("Unable to find the interface with name {}", ifaceName);
return false;
}
}
Aggregations