use of org.onosproject.ovsdb.rfc.notation.OvsdbSet in project onos by opennetworkinglab.
the class OvsdbControllerImpl method getDataPathid.
/**
* Gets datapathid from table bridge.
*
* @param clientService OvsdbClientService instance
* @param dbSchema ovsdb database schema
* @return datapathid the bridge datapathid
*/
private long getDataPathid(OvsdbClientService clientService, DatabaseSchema dbSchema) {
String bridgeUuid = clientService.getBridgeUuid(OvsdbConstant.INTEGRATION_BRIDGE);
if (bridgeUuid == null) {
log.debug("Unable to spot bridge uuid for {} in {}", OvsdbConstant.INTEGRATION_BRIDGE, clientService);
return 0;
}
Row bridgeRow = clientService.getRow(OvsdbConstant.DATABASENAME, "Bridge", bridgeUuid);
Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeRow, OvsdbTable.BRIDGE);
OvsdbSet dpidSet = (OvsdbSet) bridge.getDatapathIdColumn().data();
@SuppressWarnings("unchecked") Set<String> dpids = dpidSet.set();
if (dpids == null || dpids.isEmpty()) {
return 0;
}
return stringToLong((String) dpids.toArray()[0]);
}
use of org.onosproject.ovsdb.rfc.notation.OvsdbSet in project onos by opennetworkinglab.
the class OvsdbControllerImpl method getOfPort.
/**
* Gets ofPorts number from table Interface.
*
* @param intf Interface instance
* @return ofport the ofport number
*/
private long getOfPort(Interface intf) {
OvsdbSet ofPortSet = (OvsdbSet) intf.getOpenFlowPortColumn().data();
@SuppressWarnings("unchecked") Set<Integer> ofPorts = ofPortSet.set();
if (ofPorts == null || ofPorts.isEmpty()) {
log.debug("The ofport is null in {}", intf.getName());
return -1;
}
Iterator<Integer> it = ofPorts.iterator();
return Long.parseLong(it.next().toString());
}
use of org.onosproject.ovsdb.rfc.notation.OvsdbSet in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getPortUuid.
@Override
public String getPortUuid(String portName, String bridgeUuid) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
Row bridgeRow = getRow(DATABASENAME, BRIDGE, bridgeUuid);
Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeRow, OvsdbTable.BRIDGE);
if (bridge != null) {
OvsdbSet setPorts = (OvsdbSet) bridge.getPortsColumn().data();
@SuppressWarnings("unchecked") Set<Uuid> ports = setPorts.set();
if (ports == null || ports.isEmpty()) {
log.warn("The port uuid is null");
return null;
}
for (Uuid uuid : ports) {
Row portRow = getRow(DATABASENAME, PORT, uuid.value());
Port port = (Port) TableGenerator.getTable(dbSchema, portRow, OvsdbTable.PORT);
if (port != null && portName.equalsIgnoreCase(port.getName())) {
return uuid.value();
}
}
}
return null;
}
use of org.onosproject.ovsdb.rfc.notation.OvsdbSet 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();
}
}
use of org.onosproject.ovsdb.rfc.notation.OvsdbSet in project onos by opennetworkinglab.
the class DefaultOvsdbClient method matchesDpid.
private static boolean matchesDpid(Bridge b, DeviceId deviceId) {
String ofDpid = deviceId.toString().replace("of:", "");
Set ofDeviceIds = ((OvsdbSet) b.getDatapathIdColumn().data()).set();
// TODO Set<String>
return ofDeviceIds.contains(ofDpid);
}
Aggregations