blob: fa91b21c07266104a08bbffdb9e1aaea19d81fb0 [file] [log] [blame]
jccde3e92e2015-03-28 01:40:44 -07001package org.onosproject.cli.net;
2
3import org.apache.karaf.shell.commands.Argument;
4import org.apache.karaf.shell.commands.Command;
5import org.onosproject.cli.AbstractShellCommand;
6import org.onosproject.net.DeviceId;
Brian O'Connor6de2e202015-05-21 14:30:41 -07007import org.onosproject.incubator.net.resource.label.LabelResourcePool;
8import org.onosproject.incubator.net.resource.label.LabelResourceService;
jccde3e92e2015-03-28 01:40:44 -07009
10@Command(scope = "onos", name = "get-label-resource-pool",
11 description = "Gets label resource pool information by a specific device id")
12public 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}