use of org.onosproject.net.behaviour.ControllerConfig in project onos by opennetworkinglab.
the class DeviceSetControllersCommand method doExecute.
@Override
protected void doExecute() {
if (controllersListStrings == null && !removeCont && !removeAll) {
print("No controller are given, skipping.");
return;
}
if (controllersListStrings != null) {
Arrays.asList(controllersListStrings).forEach(cInfoString -> {
ControllerInfo controllerInfo = parseCInfoString(cInfoString);
if (controllerInfo != null) {
controllers.add(controllerInfo);
}
});
}
DriverService service = get(DriverService.class);
deviceId = DeviceId.deviceId(uri);
DriverHandler h = service.createHandler(deviceId);
ControllerConfig config = h.behaviour(ControllerConfig.class);
print("before:");
config.getControllers().forEach(c -> print(c.target()));
try {
if (removeAll) {
if (!controllers.isEmpty()) {
print("Controllers list should be empty to remove all controllers");
} else {
List<ControllerInfo> controllersToRemove = config.getControllers();
controllersToRemove.forEach(c -> print("Will remove " + c.target()));
config.removeControllers(controllersToRemove);
}
} else {
if (controllers.isEmpty()) {
print("Controllers list is empty, cannot set/remove empty controllers");
} else {
if (removeCont) {
print("Will remove specified controllers");
config.removeControllers(controllers);
} else {
print("Will add specified controllers");
config.setControllers(controllers);
}
}
}
} catch (NullPointerException e) {
print("No Device with requested parameters {} ", uri);
}
print("after:");
config.getControllers().forEach(c -> print(c.target()));
print("size %d", config.getControllers().size());
}
use of org.onosproject.net.behaviour.ControllerConfig in project onos by opennetworkinglab.
the class DeviceControllersCommand method doExecute.
@Override
protected void doExecute() {
DriverService service = get(DriverService.class);
deviceId = DeviceId.deviceId(uri);
DriverHandler h = service.createHandler(deviceId);
ControllerConfig config = h.behaviour(ControllerConfig.class);
config.getControllers().forEach(c -> print(c.target()));
}
Aggregations