Search in sources :

Example 1 with MeteredFlowGenerator

use of org.openkilda.floodlight.switchmanager.factory.generator.MeteredFlowGenerator in project open-kilda by telstra.

the class SwitchManager method modifyDefaultMeter.

@Override
public void modifyDefaultMeter(DatapathId dpid, long meterId) throws SwitchNotFoundException, InvalidMeterIdException, UnsupportedSwitchOperationException, OfInstallException {
    if (!DEFAULT_METERS.contains(meterId)) {
        throw new InvalidMeterIdException(dpid, format("Could not modify meter '%d' onto switch '%s' because meter is invalid. " + "Valid default meter IDs are: %s", meterId, dpid, DEFAULT_METERS));
    }
    IOFSwitch sw = lookupSwitch(dpid);
    verifySwitchSupportsMeters(sw);
    MeteredFlowGenerator generator = getGeneratorByMeterId(meterId).orElseThrow(() -> new InvalidMeterIdException(dpid, format("Couldn't modify meter %d on switch %s. Meter ID is unknown.", meterId, dpid)));
    logger.info("Modifying meter {} on Switch {}", meterId, dpid);
    pushFlow(sw, "--ModifyMeter--", generator.generateMeterModify(sw));
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) MeteredFlowGenerator(org.openkilda.floodlight.switchmanager.factory.generator.MeteredFlowGenerator) InvalidMeterIdException(org.openkilda.floodlight.error.InvalidMeterIdException)

Aggregations

IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 InvalidMeterIdException (org.openkilda.floodlight.error.InvalidMeterIdException)1 MeteredFlowGenerator (org.openkilda.floodlight.switchmanager.factory.generator.MeteredFlowGenerator)1