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()));
}
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();
}
}
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());
}
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;
}
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);
}
Aggregations