blob: 6cf924aad578142fc6d310849ed14004065ef8b6 [file] [log] [blame]
jccde3e92e2015-03-28 01:40:44 -07001package org.onosproject.cli.net;
2
3import java.util.Collection;
4import java.util.Iterator;
5
6import org.apache.karaf.shell.commands.Argument;
7import org.apache.karaf.shell.commands.Command;
8import org.onosproject.cli.AbstractShellCommand;
9import org.onosproject.net.resource.DefaultLabelResource;
10import org.onosproject.net.resource.LabelResource;
11import org.onosproject.net.resource.LabelResourceService;
12
13@Command(scope = "onos", name = "apply-global-label-resource-pool",
14 description = "Apply global labels from global resource pool")
15public class ApplyGlobalLabelResourceCommand extends AbstractShellCommand {
16 @Argument(index = 0, name = "applyNum",
17 description = "Applying number means how many labels applications want to use.",
18 required = true, multiValued = false)
19 String applyNum = null;
20
21 private static final String FMT = "deviceid=%s, labelresourceid=%s";
22
23 @Override
24 protected void execute() {
25 LabelResourceService lrs = get(LabelResourceService.class);
26 Collection<LabelResource> result =
27 lrs.applyFromGlobalPool(Long.parseLong(applyNum));
28 if (result.size() > 0) {
29 for (Iterator<LabelResource> iterator = result.iterator(); iterator
30 .hasNext();) {
31 DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator
32 .next();
33 print(FMT, defaultLabelResource.deviceId().toString(),
34 defaultLabelResource.labelResourceId().toString());
35 }
36 }
37 }
38
39}