jcc | de3e92e | 2015-03-28 01:40:44 -0700 | [diff] [blame] | 1 | package org.onosproject.cli.net; |
| 2 | |
| 3 | import org.apache.karaf.shell.commands.Argument; |
| 4 | import org.apache.karaf.shell.commands.Command; |
| 5 | import org.onosproject.cli.AbstractShellCommand; |
| 6 | import org.onosproject.net.DeviceId; |
Brian O'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame^] | 7 | import org.onosproject.incubator.net.resource.label.LabelResourcePool; |
| 8 | import org.onosproject.incubator.net.resource.label.LabelResourceService; |
jcc | de3e92e | 2015-03-28 01:40:44 -0700 | [diff] [blame] | 9 | |
| 10 | @Command(scope = "onos", name = "get-label-resource-pool", |
| 11 | description = "Gets label resource pool information by a specific device id") |
| 12 | public class GetLabelResourceCommand extends AbstractShellCommand { |
| 13 | @Argument(index = 0, name = "deviceId", |
| 14 | description = "Device identity", required = true, multiValued = false) |
| 15 | String deviceId = null; |
| 16 | private static final String FMT = "deviceid=%s, beginLabel=%s," |
| 17 | + "endLabel=%s, totalNum=%s, usedNum=%s, currentUsedMaxLabelId=%s," |
| 18 | + "releaseLabelIds=%s"; |
| 19 | |
| 20 | @Override |
| 21 | protected void execute() { |
| 22 | LabelResourceService lrs = get(LabelResourceService.class); |
| 23 | LabelResourcePool pool = lrs.getDeviceLabelResourcePool(DeviceId |
| 24 | .deviceId(deviceId)); |
| 25 | if (pool != null) { |
| 26 | print(FMT, pool.deviceId().toString(), pool.beginLabel(), |
| 27 | pool.endLabel(), pool.totalNum(), pool.usedNum(), |
| 28 | pool.currentUsedMaxLabelId(), pool.releaseLabelId() |
| 29 | .toString()); |
| 30 | } else { |
| 31 | print(FMT, deviceId, null, null, null, null, null, null); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | } |