jcc | de3e92e | 2015-03-28 01:40:44 -0700 | [diff] [blame] | 1 | package org.onosproject.cli.net; |
| 2 | |
| 3 | import java.util.HashSet; |
| 4 | import java.util.Set; |
| 5 | |
| 6 | import org.apache.karaf.shell.commands.Argument; |
| 7 | import org.apache.karaf.shell.commands.Command; |
| 8 | import org.onosproject.cli.AbstractShellCommand; |
| 9 | import org.onosproject.net.resource.LabelResourceId; |
| 10 | import org.onosproject.net.resource.LabelResourceService; |
| 11 | |
| 12 | @Command(scope = "onos", name = "release-global-label-resource-pool", |
| 13 | description = "Releases labels to global label resource pool.") |
| 14 | public class ReleaseGlobalLabelResourceCommand extends AbstractShellCommand { |
| 15 | @Argument(index = 0, name = "releaseLabelIds", |
| 16 | description = "Represents for the label ids that are released. They are splited by dot symbol", |
| 17 | required = true, multiValued = false) |
| 18 | String releaseLabelIds = null; |
| 19 | |
| 20 | @Override |
| 21 | protected void execute() { |
| 22 | LabelResourceService lrs = get(LabelResourceService.class); |
| 23 | Set<LabelResourceId> release = new HashSet<LabelResourceId>(); |
| 24 | String[] labelIds = releaseLabelIds.split(","); |
| 25 | LabelResourceId resource = null; |
| 26 | for (int i = 0; i < labelIds.length; i++) { |
| 27 | resource = LabelResourceId.labelResourceId(Long.parseLong(labelIds[i])); |
| 28 | release.add(resource); |
| 29 | } |
| 30 | lrs.releaseToGlobalPool(release); |
| 31 | } |
| 32 | |
| 33 | } |