Search in sources :

Example 6 with MeterId

use of org.onosproject.net.meter.MeterId in project onos by opennetworkinglab.

the class OpenFlowPolicerConfigurable method allocatePolicerId.

@Override
public PolicerId allocatePolicerId() {
    // Init step
    DriverHandler handler = handler();
    // First step is to get MeterService
    MeterService meterService = handler.get(MeterService.class);
    // There was a problem, return none
    if (meterService == null) {
        log.warn("MeterService is null");
        return PolicerId.NONE;
    }
    // Let's get the device id
    DeviceId deviceId = handler.data().deviceId();
    // Double check correspondence between schemas
    if (!deviceId.uri().getScheme().equals(OF_SCHEME)) {
        log.warn("The device {} does not seem to be managed by OpenFlow", deviceId);
        return PolicerId.NONE;
    }
    // Get a new meter id
    MeterId meterId = meterService.allocateMeterId(deviceId);
    // There was a problem
    if (meterId == null) {
        log.warn("MeterService does not provide valid ids");
        return PolicerId.NONE;
    }
    // Create a policer id from the meter id
    return getPolicerIdFromMeterId(meterId);
}
Also used : DeviceId(org.onosproject.net.DeviceId) DriverHandler(org.onosproject.net.driver.DriverHandler) MeterService(org.onosproject.net.meter.MeterService) MeterId(org.onosproject.net.meter.MeterId)

Aggregations

MeterId (org.onosproject.net.meter.MeterId)6 DeviceId (org.onosproject.net.DeviceId)2 DriverHandler (org.onosproject.net.driver.DriverHandler)2 MeterService (org.onosproject.net.meter.MeterService)2 PiMeterId (org.onosproject.net.pi.model.PiMeterId)2 PiMeterCellId (org.onosproject.net.pi.runtime.PiMeterCellId)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Test (org.junit.Test)1 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)1 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)1 Instruction (org.onosproject.net.flow.instructions.Instruction)1 DefaultMeter (org.onosproject.net.meter.DefaultMeter)1 DefaultMeterFeatures (org.onosproject.net.meter.DefaultMeterFeatures)1 Meter (org.onosproject.net.meter.Meter)1 MeterFeatures (org.onosproject.net.meter.MeterFeatures)1 MeterTableKey (org.onosproject.net.meter.MeterTableKey)1