Detangling incubator: virtual nets, tunnels, resource labels, oh my

- virtual networking moved to /apps/virtual; with CLI & REST API
- tunnels and labels moved to /apps/tunnel; with CLI & REST API; UI disabled for now
- protobuf/models moved to /core/protobuf/models
- defunct grpc/rpc registry stuff left under /graveyard
- compile dependencies on /incubator moved to respective modules for compilation
- run-time dependencies will need to be re-tested for dependent apps

- /graveyard will be removed in not-too-distant future

Change-Id: I0a0b995c635487edcf95a352f50dd162186b0b39
diff --git a/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelApplyCommand.java b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelApplyCommand.java
new file mode 100644
index 0000000..c5d9e8e
--- /dev/null
+++ b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelApplyCommand.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.resource.label.cli;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
+import org.onosproject.incubator.net.resource.label.LabelResource;
+import org.onosproject.incubator.net.resource.label.LabelResourceService;
+
+@Service
+@Command(scope = "onos", name = "global-label-apply",
+      description = "Apply global labels from global resource pool")
+public class GlobalLabelApplyCommand extends AbstractShellCommand {
+    @Argument(index = 0, name = "applyNum",
+            description = "Applying number means how many labels applications want to use.",
+            required = true, multiValued = false)
+    String applyNum = null;
+
+    private static final String FMT = "deviceid=%s, labelresourceid=%s";
+
+    @Override
+    protected void doExecute() {
+        LabelResourceService lrs = get(LabelResourceService.class);
+        Collection<LabelResource> result =
+                lrs.applyFromGlobalPool(Long.parseLong(applyNum));
+        if (!result.isEmpty()) {
+            for (Iterator<LabelResource> iterator = result.iterator(); iterator
+                    .hasNext();) {
+                DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator
+                        .next();
+                print(FMT, defaultLabelResource.deviceId().toString(),
+                      defaultLabelResource.labelResourceId().toString());
+            }
+        }
+    }
+
+}
diff --git a/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelCommand.java b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelCommand.java
new file mode 100644
index 0000000..d93bf6f
--- /dev/null
+++ b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelCommand.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.resource.label.cli;
+
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.incubator.net.resource.label.LabelResourcePool;
+import org.onosproject.incubator.net.resource.label.LabelResourceService;
+
+@Service
+@Command(scope = "onos", name = "global-label-pool",
+      description = "Gets global label resource pool information.")
+public class GlobalLabelCommand extends AbstractShellCommand {
+    private static final String FMT = "deviceid=%s, beginLabel=%s,"
+            + "endLabel=%s, totalNum=%s, usedNum=%s, currentUsedMaxLabelId=%s,"
+            + "releaseLabelIds=%s";
+
+    @Override
+    protected void doExecute() {
+        LabelResourceService lrs = get(LabelResourceService.class);
+        LabelResourcePool pool = lrs.getGlobalLabelResourcePool();
+        if (pool != null) {
+            print(FMT, pool.deviceId().toString(), pool.beginLabel(),
+                  pool.endLabel(), pool.totalNum(), pool.usedNum(),
+                  pool.currentUsedMaxLabelId(), pool.releaseLabelId()
+                          .toString());
+        }
+    }
+
+}
diff --git a/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelPoolCreateCommand.java b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelPoolCreateCommand.java
new file mode 100644
index 0000000..605f7c2
--- /dev/null
+++ b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelPoolCreateCommand.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.resource.label.cli;
+
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
+import org.onosproject.incubator.net.resource.label.LabelResourceId;
+
+/**
+ * create label resource pool by specific device id.
+ */
+@Service
+@Command(scope = "onos", name = "global-label-pool-create",
+description = "Creates global label resource pool.")
+public class GlobalLabelPoolCreateCommand extends AbstractShellCommand {
+    @Argument(index = 0, name = "beginLabel",
+            description = "The first label of global label resource pool.",
+            required = true, multiValued = false)
+    String beginLabel = null;
+    @Argument(index = 1, name = "endLabel",
+            description = "The last label of global label resource pool.",
+            required = true, multiValued = false)
+    String endLabel = null;
+
+    @Override
+    protected void doExecute() {
+        LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
+        lrs.createGlobalPool(LabelResourceId.labelResourceId(Long
+                .parseLong(beginLabel)), LabelResourceId.labelResourceId(Long
+                .parseLong(endLabel)));
+    }
+
+}
diff --git a/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelPoolDestroyCommand.java b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelPoolDestroyCommand.java
new file mode 100644
index 0000000..09c70375
--- /dev/null
+++ b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelPoolDestroyCommand.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.resource.label.cli;
+
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
+
+@Service
+@Command(scope = "onos", name = "global-label-pool-destroy",
+description = "Destroys global label resource pool")
+public class GlobalLabelPoolDestroyCommand extends AbstractShellCommand {
+    @Override
+    protected void doExecute() {
+        LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
+        lrs.destroyGlobalPool();
+    }
+
+}
diff --git a/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelReleaseCommand.java b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelReleaseCommand.java
new file mode 100644
index 0000000..3a692be
--- /dev/null
+++ b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/GlobalLabelReleaseCommand.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.resource.label.cli;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.incubator.net.resource.label.LabelResourceId;
+import org.onosproject.incubator.net.resource.label.LabelResourceService;
+
+@Service
+@Command(scope = "onos", name = "global-label-release",
+description = "Releases labels to global label resource pool.")
+public class GlobalLabelReleaseCommand extends AbstractShellCommand {
+    @Argument(index = 0, name = "releaseLabelIds",
+            description = "Represents for the label ids that are released. They are splited by dot symbol",
+            required = true, multiValued = false)
+    String releaseLabelIds = null;
+
+    @Override
+    protected void doExecute() {
+        LabelResourceService lrs = get(LabelResourceService.class);
+        Set<LabelResourceId> release = new HashSet<LabelResourceId>();
+        String[] labelIds = releaseLabelIds.split(",");
+        LabelResourceId resource = null;
+        for (int i = 0; i < labelIds.length; i++) {
+            resource = LabelResourceId.labelResourceId(Long.parseLong(labelIds[i]));
+            release.add(resource);
+        }
+        lrs.releaseToGlobalPool(release);
+    }
+
+}
diff --git a/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelApplyCommand.java b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelApplyCommand.java
new file mode 100644
index 0000000..c7634fa
--- /dev/null
+++ b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelApplyCommand.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.resource.label.cli;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.DeviceId;
+import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
+import org.onosproject.incubator.net.resource.label.LabelResource;
+import org.onosproject.incubator.net.resource.label.LabelResourceService;
+
+@Service
+@Command(scope = "onos", name = "label-apply",
+      description = "Apply label resource from device pool by specific device id")
+public class LabelApplyCommand extends AbstractShellCommand {
+    @Argument(index = 0, name = "deviceId",
+            description = "Device identity",
+            required = true, multiValued = false)
+    String deviceId = null;
+    @Argument(index = 1, name = "applyNum",
+            description = "Applying number means how many labels applications want to use.",
+            required = true, multiValued = false)
+    String applyNum = null;
+
+    private static final String FMT = "deviceid=%s, labelresourceid=%s";
+
+    @Override
+    protected void doExecute() {
+        LabelResourceService lrs = get(LabelResourceService.class);
+        Collection<LabelResource> result = lrs.applyFromDevicePool(DeviceId
+                .deviceId(deviceId), Long.parseLong(applyNum));
+        if (!result.isEmpty()) {
+            for (Iterator<LabelResource> iterator = result.iterator(); iterator
+                    .hasNext();) {
+                DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator
+                        .next();
+                print(FMT, defaultLabelResource.deviceId().toString(),
+                      defaultLabelResource.labelResourceId().toString());
+            }
+        }
+    }
+
+}
diff --git a/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelPoolCreateCommand.java b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelPoolCreateCommand.java
new file mode 100644
index 0000000..775c269
--- /dev/null
+++ b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelPoolCreateCommand.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.resource.label.cli;
+
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.DeviceId;
+import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
+import org.onosproject.incubator.net.resource.label.LabelResourceId;
+
+/**
+ * create label resource pool by specific device id.
+ */
+@Service
+@Command(scope = "onos", name = "label-pool-create",
+     description = "Creates label resource pool by a specific device id")
+public class LabelPoolCreateCommand extends AbstractShellCommand {
+    @Argument(index = 0, name = "deviceId", description = "Device identity", required = true, multiValued = false)
+    String deviceId = null;
+    @Argument(index = 1, name = "beginLabel",
+            description = "The first label of global label resource pool.", required = true, multiValued = false)
+    String beginLabel = null;
+    @Argument(index = 2, name = "endLabel",
+            description = "The last label of global label resource pool.", required = true, multiValued = false)
+    String endLabel = null;
+
+    @Override
+    protected void doExecute() {
+        LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
+        lrs.createDevicePool(DeviceId.deviceId(deviceId), LabelResourceId
+                .labelResourceId(Long.parseLong(beginLabel)), LabelResourceId
+                .labelResourceId(Long.parseLong(endLabel)));
+    }
+
+}
diff --git a/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelPoolDestroyCommand.java b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelPoolDestroyCommand.java
new file mode 100644
index 0000000..c875cd8
--- /dev/null
+++ b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelPoolDestroyCommand.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.resource.label.cli;
+
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.DeviceId;
+import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
+
+@Service
+@Command(scope = "onos", name = "label-pool-destroy",
+    description = "Destroys label resource pool by a specific device id")
+public class LabelPoolDestroyCommand extends AbstractShellCommand {
+    @Argument(index = 0, name = "deviceId", description = "Device identity", required = true, multiValued = false)
+    String deviceId = null;
+
+    @Override
+    protected void doExecute() {
+        LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
+        lrs.destroyDevicePool(DeviceId.deviceId(deviceId));
+    }
+
+}
diff --git a/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelReleaseCommand.java b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelReleaseCommand.java
new file mode 100644
index 0000000..c511642
--- /dev/null
+++ b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelReleaseCommand.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.resource.label.cli;
+
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.DeviceId;
+import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
+import org.onosproject.incubator.net.resource.label.LabelResource;
+import org.onosproject.incubator.net.resource.label.LabelResourceId;
+import org.onosproject.incubator.net.resource.label.LabelResourceService;
+
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+
+@Service
+@Command(scope = "onos", name = "label-release",
+description = "Releases label ids to label resource pool by a specific device id")
+public class LabelReleaseCommand extends AbstractShellCommand {
+    @Argument(index = 0, name = "deviceId",
+            description = "Device identity",
+            required = true, multiValued = false)
+    String deviceId = null;
+    @Argument(index = 1, name = "releaseLabelIds",
+            description = "Represents for the label ids that are released. They are splited by dot symbol",
+            required = true, multiValued = false)
+    String releaseLabelIds = null;
+
+    @Override
+    protected void doExecute() {
+        LabelResourceService lrs = get(LabelResourceService.class);
+        Multimap<DeviceId, LabelResource> map = ArrayListMultimap
+                .create();
+        String[] labelIds = releaseLabelIds.split(",");
+        DefaultLabelResource resource = null;
+        for (int i = 0; i < labelIds.length; i++) {
+            resource = new DefaultLabelResource(
+                                                DeviceId.deviceId(deviceId),
+                                                LabelResourceId.labelResourceId(Long
+                                                        .parseLong(labelIds[i])));
+            map.put(DeviceId.deviceId(deviceId), resource);
+        }
+        lrs.releaseToDevicePool(map);
+    }
+
+}
diff --git a/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelResourceCommand.java b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelResourceCommand.java
new file mode 100644
index 0000000..84c8f65
--- /dev/null
+++ b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/LabelResourceCommand.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.incubator.net.resource.label.cli;
+
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.DeviceId;
+import org.onosproject.incubator.net.resource.label.LabelResourcePool;
+import org.onosproject.incubator.net.resource.label.LabelResourceService;
+
+@Service
+@Command(scope = "onos", name = "label-pool",
+      description = "Gets label resource pool information by a specific device id")
+public class LabelResourceCommand extends AbstractShellCommand {
+    @Argument(index = 0, name = "deviceId",
+            description = "Device identity", required = true, multiValued = false)
+    String deviceId = null;
+    private static final String FMT = "deviceid=%s, beginLabel=%s,"
+            + "endLabel=%s, totalNum=%s, usedNum=%s, currentUsedMaxLabelId=%s,"
+            + "releaseLabelIds=%s";
+
+    @Override
+    protected void doExecute() {
+        LabelResourceService lrs = get(LabelResourceService.class);
+        LabelResourcePool pool = lrs.getDeviceLabelResourcePool(DeviceId
+                .deviceId(deviceId));
+        if (pool != null) {
+            print(FMT, pool.deviceId().toString(), pool.beginLabel(),
+                  pool.endLabel(), pool.totalNum(), pool.usedNum(),
+                  pool.currentUsedMaxLabelId(), pool.releaseLabelId()
+                          .toString());
+        } else {
+            print(FMT, deviceId, null, null, null, null, null, null);
+        }
+    }
+
+}
diff --git a/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/package-info.java b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/package-info.java
new file mode 100644
index 0000000..0e8608f
--- /dev/null
+++ b/apps/tunnel/app/src/main/java/org/onosproject/incubator/net/resource/label/cli/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * CLIs for the resource label subsystem.
+ */
+package org.onosproject.incubator.net.resource.label.cli;