use of org.onosproject.ovsdb.controller.OvsdbNodeId in project onos by opennetworkinglab.
the class OvsdbControllerConfig method getOvsdbClientService.
// Used for getting OvsdbClientService.
private OvsdbClientService getOvsdbClientService(DriverHandler handler) {
OvsdbController ovsController = handler.get(OvsdbController.class);
DeviceService deviceService = handler.get(DeviceService.class);
DeviceId ofDeviceId = handler.data().deviceId();
String[] mgmtAddress = deviceService.getDevice(ofDeviceId).annotations().value(AnnotationKeys.MANAGEMENT_ADDRESS).split(":");
String targetIp = mgmtAddress[0];
TpPort targetPort = null;
if (mgmtAddress.length > 1) {
targetPort = TpPort.tpPort(Integer.parseInt(mgmtAddress[1]));
}
List<OvsdbNodeId> nodeIds = ovsController.getNodeIds().stream().filter(nodeId -> nodeId.getIpAddress().equals(targetIp)).collect(Collectors.toList());
if (nodeIds.isEmpty()) {
// TODO decide what port?
ovsController.connect(IpAddress.valueOf(targetIp), targetPort == null ? TpPort.tpPort(OvsdbConstant.OVSDBPORT) : targetPort);
// FIXME... connect is async
delay(1000);
}
List<OvsdbClientService> clientServices = ovsController.getNodeIds().stream().filter(nodeId -> nodeId.getIpAddress().equals(targetIp)).map(ovsController::getOvsdbClient).filter(cs -> cs.getBridges().stream().anyMatch(b -> dpidMatches(b, ofDeviceId))).collect(Collectors.toList());
checkState(!clientServices.isEmpty(), "No clientServices found");
// FIXME add connection to management address if null --> done ?
return !clientServices.isEmpty() ? clientServices.get(0) : null;
}
use of org.onosproject.ovsdb.controller.OvsdbNodeId in project onos by opennetworkinglab.
the class OvsdbInterfaceConfig method getOvsdbClient.
private OvsdbClientService getOvsdbClient(DriverHandler handler) {
OvsdbController ovsController = handler.get(OvsdbController.class);
OvsdbNodeId nodeId = changeDeviceIdToNodeId(handler.data().deviceId());
return ovsController.getOvsdbClient(nodeId);
}
use of org.onosproject.ovsdb.controller.OvsdbNodeId in project onos by opennetworkinglab.
the class OvsdbPortConfig method changeDeviceIdToNodeId.
// OvsdbNodeId(IP) is used in the adaptor while DeviceId(ovsdb:IP)
// is used in the core. So DeviceId need be changed to OvsdbNodeId.
private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) {
String[] splits = deviceId.toString().split(":");
if (splits.length < 1) {
return null;
}
IpAddress ipAddress = IpAddress.valueOf(splits[1]);
return new OvsdbNodeId(ipAddress, 0);
}
use of org.onosproject.ovsdb.controller.OvsdbNodeId in project onos by opennetworkinglab.
the class OvsdbPortConfig method getOvsdbClient.
private OvsdbClientService getOvsdbClient(DriverHandler handler) {
OvsdbController ovsController = handler.get(OvsdbController.class);
OvsdbNodeId nodeId = changeDeviceIdToNodeId(handler.data().deviceId());
return ovsController.getOvsdbClient(nodeId);
}
use of org.onosproject.ovsdb.controller.OvsdbNodeId in project onos by opennetworkinglab.
the class OvsdbQueueConfig method changeDeviceIdToNodeId.
// OvsdbNodeId(IP) is used in the adaptor while DeviceId(ovsdb:IP)
// is used in the core. So DeviceId need be changed to OvsdbNodeId.
private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) {
String[] splits = deviceId.toString().split(":");
if (splits.length < 1) {
return null;
}
IpAddress ipAddress = IpAddress.valueOf(splits[1]);
return new OvsdbNodeId(ipAddress, 0);
}
Aggregations