use of org.onosproject.ovsdb.controller.OvsdbConstant.UUID 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);
}
use of org.onosproject.ovsdb.controller.OvsdbConstant.UUID in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getElements.
private Set<?> getElements(Function<Row, ?> method) {
OvsdbTableStore tableStore = getTableStore(DATABASENAME);
if (tableStore == null) {
return null;
}
OvsdbRowStore rowStore = tableStore.getRows(INTERFACE);
if (rowStore == null) {
return null;
}
ConcurrentMap<String, Row> rows = rowStore.getRowStore();
return rows.keySet().stream().map(uuid -> getRow(DATABASENAME, INTERFACE, uuid)).map(method).filter(Objects::nonNull).collect(Collectors.toSet());
}
use of org.onosproject.ovsdb.controller.OvsdbConstant.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;
}
}
use of org.onosproject.ovsdb.controller.OvsdbConstant.UUID in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getOvsdbBridge.
private OvsdbBridge getOvsdbBridge(Row row, Uuid bridgeUuid) {
DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, row, OvsdbTable.BRIDGE);
if (bridge == null) {
return null;
}
OvsdbSet datapathIdSet = (OvsdbSet) bridge.getDatapathIdColumn().data();
@SuppressWarnings("unchecked") Set<String> datapathIds = datapathIdSet.set();
if (datapathIds == null || datapathIds.isEmpty()) {
return null;
}
String datapathId = (String) datapathIds.toArray()[0];
String bridgeName = bridge.getName();
if ((datapathId == null) || (bridgeName == null)) {
return null;
}
List<Controller> controllers = getControllers(bridgeUuid);
if (controllers != null) {
List<ControllerInfo> controllerInfos = controllers.stream().map(controller -> new ControllerInfo((String) controller.getTargetColumn().data())).collect(Collectors.toList());
return OvsdbBridge.builder().name(bridgeName).datapathId(datapathId).controllers(controllerInfos).build();
} else {
return OvsdbBridge.builder().name(bridgeName).datapathId(datapathId).build();
}
}
Aggregations