Search in sources :

Example 1 with OFPortConfig

use of org.projectfloodlight.openflow.protocol.OFPortConfig in project open-kilda by telstra.

the class SwitchManager method updatePortStatus.

private void updatePortStatus(IOFSwitch sw, int portNumber, boolean isAdminDown) throws SwitchOperationException {
    Set<OFPortConfig> config = new HashSet<>(1);
    if (isAdminDown) {
        config.add(OFPortConfig.PORT_DOWN);
    }
    Set<OFPortConfig> portMask = ImmutableSet.of(OFPortConfig.PORT_DOWN);
    final OFFactory ofFactory = sw.getOFFactory();
    OFPortMod ofPortMod = ofFactory.buildPortMod().setPortNo(OFPort.of(portNumber)).setHwAddr(getPortHwAddress(sw, portNumber)).setConfig(config).setMask(portMask).build();
    if (!sw.write(ofPortMod)) {
        throw new SwitchOperationException(sw.getId(), format("Unable to update port configuration: %s", ofPortMod));
    }
    logger.debug("Successfully updated port status {}", ofPortMod);
}
Also used : SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) OFPortMod(org.projectfloodlight.openflow.protocol.OFPortMod) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFPortConfig(org.projectfloodlight.openflow.protocol.OFPortConfig) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)1 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)1 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)1 OFPortConfig (org.projectfloodlight.openflow.protocol.OFPortConfig)1 OFPortMod (org.projectfloodlight.openflow.protocol.OFPortMod)1