use of org.onosproject.net.behaviour.PowerConfig in project onos by opennetworkinglab.
the class RoadmManager method getPowerConfig.
private PowerConfig<Object> getPowerConfig(DeviceId deviceId) {
Device device = deviceService.getDevice(deviceId);
if (device != null && device.is(PowerConfig.class)) {
return device.as(PowerConfig.class);
}
// Do not need warning here for port polling.
log.debug("Unable to load PowerConfig for {}", deviceId);
return null;
}
use of org.onosproject.net.behaviour.PowerConfig in project onos by opennetworkinglab.
the class PowerConfigCommand method doExecute.
@Override
protected void doExecute() throws Exception {
DeviceService deviceService = get(DeviceService.class);
ConnectPoint cp = ConnectPoint.deviceConnectPoint(connectPoint);
Port port = deviceService.getPort(cp);
if (port == null) {
print("[ERROR] %s does not exist", cp);
return;
}
if (!port.type().equals(Port.Type.OCH) && !port.type().equals(Port.Type.OTU) && !port.type().equals(Port.Type.OMS)) {
log.warn("The power of selected port %s isn't editable.", port.number().toString());
print("The power of selected port %s isn't editable.", port.number().toString());
return;
}
Device device = deviceService.getDevice(cp.deviceId());
PowerConfig powerConfig = device.as(PowerConfig.class);
// <component> and <optical-channel>.
if (operation.equals("get")) {
Optional<Double> val = powerConfig.getTargetPower(cp.port(), Direction.ALL);
if (val.isPresent()) {
double power = val.orElse(Double.MIN_VALUE);
print("The target-output-power value in port %s on device %s is %f.", cp.port().toString(), cp.deviceId().toString(), power);
}
Optional<Double> currentPower = powerConfig.currentPower(cp.port(), Direction.ALL);
if (currentPower.isPresent()) {
double currentPowerVal = currentPower.orElse(Double.MIN_VALUE);
print("The current-output-power value in port %s on device %s is %f.", cp.port().toString(), cp.deviceId().toString(), currentPowerVal);
}
Optional<Double> currentInputPower = powerConfig.currentInputPower(cp.port(), Direction.ALL);
if (currentInputPower.isPresent()) {
double inputPowerVal = currentInputPower.orElse(Double.MIN_VALUE);
print("The current-input-power value in port %s on device %s is %f.", cp.port().toString(), cp.deviceId().toString(), inputPowerVal);
}
} else if (operation.equals("edit-config")) {
checkNotNull(value);
powerConfig.setTargetPower(cp.port(), Direction.ALL, value);
print("Set %f power on port", value, connectPoint);
} else {
print("Operation %s are not supported now.", operation);
}
}
Aggregations