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