Search in sources :

Example 21 with OpenFlowSwitch

use of org.onosproject.openflow.controller.OpenFlowSwitch in project onos by opennetworkinglab.

the class OpenFlowDeviceProvider method changePortState.

@Override
public void changePortState(DeviceId deviceId, PortNumber portNumber, boolean enable) {
    final Dpid dpid = dpid(deviceId.uri());
    OpenFlowSwitch sw = controller.getSwitch(dpid);
    if (sw == null || !sw.isConnected()) {
        LOG.error("Failed to change portState on device {}", deviceId);
        return;
    }
    OFPortMod.Builder pmb = sw.factory().buildPortMod();
    OFPort port = OFPort.of((int) portNumber.toLong());
    pmb.setPortNo(port);
    Set<OFPortConfig> portConfig = EnumSet.noneOf(OFPortConfig.class);
    if (!enable) {
        portConfig.add(OFPortConfig.PORT_DOWN);
    }
    pmb.setConfig(portConfig);
    Set<OFPortConfig> portMask = EnumSet.noneOf(OFPortConfig.class);
    portMask.add(OFPortConfig.PORT_DOWN);
    pmb.setMask(portMask);
    pmb.setAdvertise(0x0);
    for (OFPortDesc pd : sw.getPorts()) {
        if (pd.getPortNo().equals(port)) {
            pmb.setHwAddr(pd.getHwAddr());
            break;
        }
    }
    sw.sendMsg(Collections.singletonList(pmb.build()));
}
Also used : OFPortMod(org.projectfloodlight.openflow.protocol.OFPortMod) OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) Dpid(org.onosproject.openflow.controller.Dpid) OpenFlowSwitch(org.onosproject.openflow.controller.OpenFlowSwitch) OFPort(org.projectfloodlight.openflow.types.OFPort) OFPortConfig(org.projectfloodlight.openflow.protocol.OFPortConfig)

Example 22 with OpenFlowSwitch

use of org.onosproject.openflow.controller.OpenFlowSwitch in project onos by opennetworkinglab.

the class OpenFlowDeviceProvider method triggerDisconnect.

@Override
public void triggerDisconnect(DeviceId deviceId) {
    Dpid dpid = dpid(deviceId.uri());
    OpenFlowSwitch sw = controller.getSwitch(dpid);
    if (sw != null) {
        LOG.debug("Forcing disconnect for device {}", deviceId);
        // TODO: Further consolidate clean-up on device disconnect
        listener.switchRemoved(dpid);
        sw.disconnectSwitch();
    }
}
Also used : Dpid(org.onosproject.openflow.controller.Dpid) OpenFlowSwitch(org.onosproject.openflow.controller.OpenFlowSwitch)

Example 23 with OpenFlowSwitch

use of org.onosproject.openflow.controller.OpenFlowSwitch in project onos by opennetworkinglab.

the class OplinkPowerConfigUtil method setPortPower.

/**
 * Sets specified port power value.
 *
 * @param portNum the port number
 * @param power power value
 */
private void setPortPower(PortNumber portNum, long power) {
    OpenFlowSwitch device = getOpenFlowDevice();
    // Check if switch is connected
    if (device == null) {
        return;
    }
    device.sendMsg(device.factory().buildOplinkPortPowerSet().setXid(xidCounter.getAndIncrement()).setPort((int) portNum.toLong()).setPowerValue((int) power).build());
}
Also used : OpenFlowSwitch(org.onosproject.openflow.controller.OpenFlowSwitch)

Example 24 with OpenFlowSwitch

use of org.onosproject.openflow.controller.OpenFlowSwitch in project onos by opennetworkinglab.

the class OplinkPowerConfigUtil method getChannelAttenuationRange.

/**
 * Returns the acceptable attenuation range for a connection (represented as
 * a flow with attenuation instruction). Port can be either the input or
 * output port of the connection. Returns null if the connection does not
 * support attenuation.
 *
 * @param portNum the port number
 * @return attenuation range
 */
private Range<Long> getChannelAttenuationRange(PortNumber portNum) {
    OpenFlowSwitch ofs = getOpenFlowDevice();
    if (ofs == null) {
        return null;
    }
    if (ofs.deviceType() != Type.ROADM) {
        return null;
    }
    PortDescType portType = getPortDescType((OpenFlowOpticalSwitch) ofs, portNum);
    // The port type and attenuation range will be obtained from physical device in the future.
    if (portType == PortDescType.PA_LINE_OUT || portType == PortDescType.EXP_IN || portType == PortDescType.AUX_IN) {
        return Range.closed(ROADM_MIN_ATTENUATION, ROADM_MAX_ATTENUATION);
    }
    // Unexpected port. Do not need warning here for port polling.
    return null;
}
Also used : OpenFlowSwitch(org.onosproject.openflow.controller.OpenFlowSwitch)

Example 25 with OpenFlowSwitch

use of org.onosproject.openflow.controller.OpenFlowSwitch in project onos by opennetworkinglab.

the class OpenFlowControllerImpl method setRole.

@Override
public void setRole(Dpid dpid, RoleState role) {
    final OpenFlowSwitch sw = getSwitch(dpid);
    if (sw == null) {
        log.debug("Switch not connected. Ignoring setRole({}, {})", dpid, role);
        return;
    }
    sw.setRole(role);
}
Also used : OpenFlowSwitch(org.onosproject.openflow.controller.OpenFlowSwitch)

Aggregations

OpenFlowSwitch (org.onosproject.openflow.controller.OpenFlowSwitch)29 Dpid (org.onosproject.openflow.controller.Dpid)17 OpenFlowController (org.onosproject.openflow.controller.OpenFlowController)5 DeviceId (org.onosproject.net.DeviceId)4 OFPortDesc (org.projectfloodlight.openflow.protocol.OFPortDesc)4 Test (org.junit.Test)3 OpenFlowSwitchListener (org.onosproject.openflow.controller.OpenFlowSwitchListener)3 ArrayList (java.util.ArrayList)2 Type (org.onosproject.net.Device.Type)2 ExtensionTreatmentType (org.onosproject.net.flow.instructions.ExtensionTreatmentType)2 PortDescPropertyType (org.onosproject.openflow.controller.PortDescPropertyType)2 OFFlowLightweightStatsReply (org.projectfloodlight.openflow.protocol.OFFlowLightweightStatsReply)2 OFFlowStatsReply (org.projectfloodlight.openflow.protocol.OFFlowStatsReply)2 OFTableStatsEntry (org.projectfloodlight.openflow.protocol.OFTableStatsEntry)2 OFTableStatsReply (org.projectfloodlight.openflow.protocol.OFTableStatsReply)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 Cache (com.google.common.cache.Cache)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 RemovalCause (com.google.common.cache.RemovalCause)1