Search in sources :

Example 1 with OFPortModProp

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;
}
Also used : OFPortModPropOptical(org.projectfloodlight.openflow.protocol.OFPortModPropOptical) OFPortMod(org.projectfloodlight.openflow.protocol.OFPortMod) DeviceId(org.onosproject.net.DeviceId) Dpid(org.onosproject.openflow.controller.Dpid) OpenFlowController(org.onosproject.openflow.controller.OpenFlowController) ArrayList(java.util.ArrayList) OFPortModProp(org.projectfloodlight.openflow.protocol.OFPortModProp) OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) OpenFlowSwitch(org.onosproject.openflow.controller.OpenFlowSwitch)

Aggregations

ArrayList (java.util.ArrayList)1 DeviceId (org.onosproject.net.DeviceId)1 Dpid (org.onosproject.openflow.controller.Dpid)1 OpenFlowController (org.onosproject.openflow.controller.OpenFlowController)1 OpenFlowSwitch (org.onosproject.openflow.controller.OpenFlowSwitch)1 OFPortDesc (org.projectfloodlight.openflow.protocol.OFPortDesc)1 OFPortMod (org.projectfloodlight.openflow.protocol.OFPortMod)1 OFPortModProp (org.projectfloodlight.openflow.protocol.OFPortModProp)1 OFPortModPropOptical (org.projectfloodlight.openflow.protocol.OFPortModPropOptical)1