use of org.projectfloodlight.openflow.protocol.OFPortModProp in project onos by opennetworkinglab.
the class OpenFlowPowerConfig method setPortTargetPower.
private boolean setPortTargetPower(PortNumber port, double power) {
DeviceId deviceId = handler().data().deviceId();
final Dpid dpid = dpid(deviceId.uri());
OpenFlowSwitch sw = handler().get(OpenFlowController.class).getSwitch(dpid);
if (sw == null || !sw.isConnected()) {
log.error("Failed to change port on device {}", deviceId);
return false;
}
boolean enable = false;
for (OFPortDesc pd : getPortDescs()) {
if (pd.getPortNo().getPortNumber() == port.toLong()) {
enable = pd.getConfig().contains(OFPortConfig.PORT_DOWN);
break;
}
}
OFPortMod.Builder pmb = makePortMod(sw, port, enable);
double configure = OFOpticalPortFeaturesSerializerVer14.TX_PWR_VAL;
OFPortModPropOptical.Builder property = sw.factory().buildPortModPropOptical();
property.setTxPwr((long) power);
List<OFPortModProp> properties = new ArrayList<>();
properties.add(property.build());
pmb.setProperties(properties);
sw.sendMsg(Collections.singletonList(pmb.build()));
// TODO: We would need to report false in case of port mod failure.
return true;
}
Aggregations