[ONOS-1959][ONOS-2007][ONOS-2008][ONOS-2009][ONOS-2010][ONOS-2011][ONOS-2016][ONOS-2017][ONOS-2018]
1.fix bug in query subscription command in Tunnel management
2.add RemoveTunnelByIdCommand
3.add UpdateTunnelBandWithCommand
4.add QueryAllTunnelsCommand
5.add queryAllTunnels api in TunnelService and TunnelStore
6.store the Path of the tunnel in the store
7.remove to check parameters iif they are null in the construtors of
DefaultTunnel.e.g
8.add the method of querying in SB
9.Fix the bug that the src/dst end point of Vlan-type tunnel is the
instance of OpticalTunnelEndPoint
10. invert the verb-noun into noun-verb for tunnel commands and label
commands

Change-Id: I90378b37c2bc73b58e6f8f234f009d64f07f758e
diff --git a/cli/src/main/java/org/onosproject/cli/net/DestroyGlobalLabelResourcePoolCommand.java b/cli/src/main/java/org/onosproject/cli/net/DestroyGlobalLabelResourcePoolCommand.java
deleted file mode 100644
index 31d38a4..0000000
--- a/cli/src/main/java/org/onosproject/cli/net/DestroyGlobalLabelResourcePoolCommand.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.onosproject.cli.net;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-
-@Command(scope = "onos", name = "destroy-global-label-resource-pool",
-description = "Destroys global label resource pool")
-public class DestroyGlobalLabelResourcePoolCommand extends AbstractShellCommand {
-    @Override
-    protected void execute() {
-        LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
-        lrs.destroyGlobalPool();
-    }
-
-}
diff --git a/cli/src/main/java/org/onosproject/cli/net/DestroyLabelResourcePoolCommand.java b/cli/src/main/java/org/onosproject/cli/net/DestroyLabelResourcePoolCommand.java
deleted file mode 100644
index 925f0f1..0000000
--- a/cli/src/main/java/org/onosproject/cli/net/DestroyLabelResourcePoolCommand.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.onosproject.cli.net;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-
-@Command(scope = "onos", name = "destroy-label-resource-pool",
-    description = "Destroys label resource pool by a specific device id")
-public class DestroyLabelResourcePoolCommand extends AbstractShellCommand {
-    @Argument(index = 0, name = "deviceId", description = "Device identity", required = true, multiValued = false)
-    String deviceId = null;
-
-    @Override
-    protected void execute() {
-        LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
-        lrs.destroyDevicePool(DeviceId.deviceId(deviceId));
-    }
-
-}
diff --git a/cli/src/main/java/org/onosproject/cli/net/GetGlobalLabelResourceCommand.java b/cli/src/main/java/org/onosproject/cli/net/GetGlobalLabelResourceCommand.java
deleted file mode 100644
index 9be6725..0000000
--- a/cli/src/main/java/org/onosproject/cli/net/GetGlobalLabelResourceCommand.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.onosproject.cli.net;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.resource.label.LabelResourcePool;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-
-@Command(scope = "onos", name = "get-global-label-resource-pool",
-      description = "Gets global label resource pool information.")
-public class GetGlobalLabelResourceCommand extends AbstractShellCommand {
-    private static final String FMT = "deviceid=%s, beginLabel=%s,"
-            + "endLabel=%s, totalNum=%s, usedNum=%s, currentUsedMaxLabelId=%s,"
-            + "releaseLabelIds=%s";
-
-    @Override
-    protected void execute() {
-        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/cli/src/main/java/org/onosproject/cli/net/ApplyGlobalLabelResourceCommand.java b/cli/src/main/java/org/onosproject/cli/net/GlobalLabelApplyCommand.java
similarity index 66%
rename from cli/src/main/java/org/onosproject/cli/net/ApplyGlobalLabelResourceCommand.java
rename to cli/src/main/java/org/onosproject/cli/net/GlobalLabelApplyCommand.java
index f9fd7e1..a8e8f2e 100644
--- a/cli/src/main/java/org/onosproject/cli/net/ApplyGlobalLabelResourceCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/GlobalLabelApplyCommand.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * 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.cli.net;
 
 import java.util.Collection;
@@ -10,9 +25,9 @@
 import org.onosproject.incubator.net.resource.label.LabelResource;
 import org.onosproject.incubator.net.resource.label.LabelResourceService;
 
-@Command(scope = "onos", name = "apply-global-label-resource-pool",
+@Command(scope = "onos", name = "global-label-apply",
       description = "Apply global labels from global resource pool")
-public class ApplyGlobalLabelResourceCommand extends AbstractShellCommand {
+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)
diff --git a/cli/src/main/java/org/onosproject/cli/net/GlobalLabelCommand.java b/cli/src/main/java/org/onosproject/cli/net/GlobalLabelCommand.java
new file mode 100644
index 0000000..92f39cc
--- /dev/null
+++ b/cli/src/main/java/org/onosproject/cli/net/GlobalLabelCommand.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * 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.cli.net;
+
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.incubator.net.resource.label.LabelResourcePool;
+import org.onosproject.incubator.net.resource.label.LabelResourceService;
+
+@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 execute() {
+        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/cli/src/main/java/org/onosproject/cli/net/CreateGlobalLabelResourcePoolCommand.java b/cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolCreateCommand.java
similarity index 60%
rename from cli/src/main/java/org/onosproject/cli/net/CreateGlobalLabelResourcePoolCommand.java
rename to cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolCreateCommand.java
index ef9fbe8..3e22667 100644
--- a/cli/src/main/java/org/onosproject/cli/net/CreateGlobalLabelResourcePoolCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolCreateCommand.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * 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.cli.net;
 
 import org.apache.karaf.shell.commands.Argument;
@@ -9,9 +24,9 @@
 /**
  * create label resource pool by specific device id.
  */
-@Command(scope = "onos", name = "create-global-label-resource-pool",
+@Command(scope = "onos", name = "global-label-pool-create",
 description = "Creates global label resource pool.")
-public class CreateGlobalLabelResourcePoolCommand extends AbstractShellCommand {
+public class GlobalLabelPoolCreateCommand extends AbstractShellCommand {
     @Argument(index = 0, name = "beginLabel",
             description = "The first label of global label resource pool.",
             required = true, multiValued = false)
diff --git a/cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolDestoryCommand.java b/cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolDestoryCommand.java
new file mode 100644
index 0000000..ae1bee6
--- /dev/null
+++ b/cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolDestoryCommand.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * 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.cli.net;
+
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
+
+@Command(scope = "onos", name = "global-label-pool-destroy",
+description = "Destroys global label resource pool")
+public class GlobalLabelPoolDestoryCommand extends AbstractShellCommand {
+    @Override
+    protected void execute() {
+        LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
+        lrs.destroyGlobalPool();
+    }
+
+}
diff --git a/cli/src/main/java/org/onosproject/cli/net/ReleaseGlobalLabelResourceCommand.java b/cli/src/main/java/org/onosproject/cli/net/GlobalLabelReleaseCommand.java
similarity index 61%
rename from cli/src/main/java/org/onosproject/cli/net/ReleaseGlobalLabelResourceCommand.java
rename to cli/src/main/java/org/onosproject/cli/net/GlobalLabelReleaseCommand.java
index 4a5718b..737f796 100644
--- a/cli/src/main/java/org/onosproject/cli/net/ReleaseGlobalLabelResourceCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/GlobalLabelReleaseCommand.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * 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.cli.net;
 
 import java.util.HashSet;
@@ -9,9 +24,9 @@
 import org.onosproject.incubator.net.resource.label.LabelResourceId;
 import org.onosproject.incubator.net.resource.label.LabelResourceService;
 
-@Command(scope = "onos", name = "release-global-label-resource-pool",
+@Command(scope = "onos", name = "global-label-release",
 description = "Releases labels to global label resource pool.")
-public class ReleaseGlobalLabelResourceCommand extends AbstractShellCommand {
+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)
diff --git a/cli/src/main/java/org/onosproject/cli/net/ApplyLabelResourceCommand.java b/cli/src/main/java/org/onosproject/cli/net/LabelApplyCommand.java
similarity index 70%
rename from cli/src/main/java/org/onosproject/cli/net/ApplyLabelResourceCommand.java
rename to cli/src/main/java/org/onosproject/cli/net/LabelApplyCommand.java
index dabd391..c88d41c 100644
--- a/cli/src/main/java/org/onosproject/cli/net/ApplyLabelResourceCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/LabelApplyCommand.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * 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.cli.net;
 
 import java.util.Collection;
@@ -11,9 +26,9 @@
 import org.onosproject.incubator.net.resource.label.LabelResource;
 import org.onosproject.incubator.net.resource.label.LabelResourceService;
 
-@Command(scope = "onos", name = "apply-label-resource-pool",
+@Command(scope = "onos", name = "label-apply",
       description = "Apply label resource from device pool by specific device id")
-public class ApplyLabelResourceCommand extends AbstractShellCommand {
+public class LabelApplyCommand extends AbstractShellCommand {
     @Argument(index = 0, name = "deviceId",
             description = "Device identity",
             required = true, multiValued = false)
diff --git a/cli/src/main/java/org/onosproject/cli/net/CreateLabelResourcePoolCommand.java b/cli/src/main/java/org/onosproject/cli/net/LabelPoolCreateCommand.java
similarity index 65%
rename from cli/src/main/java/org/onosproject/cli/net/CreateLabelResourcePoolCommand.java
rename to cli/src/main/java/org/onosproject/cli/net/LabelPoolCreateCommand.java
index 1be3e33..78a6d19 100644
--- a/cli/src/main/java/org/onosproject/cli/net/CreateLabelResourcePoolCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/LabelPoolCreateCommand.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * 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.cli.net;
 
 import org.apache.karaf.shell.commands.Argument;
@@ -10,9 +25,9 @@
 /**
  * create label resource pool by specific device id.
  */
-@Command(scope = "onos", name = "create-label-resource-pool",
+@Command(scope = "onos", name = "label-pool-create",
      description = "Creates label resource pool by a specific device id")
-public class CreateLabelResourcePoolCommand extends AbstractShellCommand {
+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",
diff --git a/cli/src/main/java/org/onosproject/cli/net/LabelPoolDestroyCommand.java b/cli/src/main/java/org/onosproject/cli/net/LabelPoolDestroyCommand.java
new file mode 100644
index 0000000..6445de6
--- /dev/null
+++ b/cli/src/main/java/org/onosproject/cli/net/LabelPoolDestroyCommand.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * 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.cli.net;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.DeviceId;
+import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
+
+@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 execute() {
+        LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
+        lrs.destroyDevicePool(DeviceId.deviceId(deviceId));
+    }
+
+}
diff --git a/cli/src/main/java/org/onosproject/cli/net/ReleaseLabelResourceCommand.java b/cli/src/main/java/org/onosproject/cli/net/LabelReleaseCommand.java
similarity index 71%
rename from cli/src/main/java/org/onosproject/cli/net/ReleaseLabelResourceCommand.java
rename to cli/src/main/java/org/onosproject/cli/net/LabelReleaseCommand.java
index 9805e0d..cc52204 100644
--- a/cli/src/main/java/org/onosproject/cli/net/ReleaseLabelResourceCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/LabelReleaseCommand.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * 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.cli.net;
 
 import org.apache.karaf.shell.commands.Argument;
@@ -12,9 +27,9 @@
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Multimap;
 
-@Command(scope = "onos", name = "release-label-resource-pool",
+@Command(scope = "onos", name = "label-release",
 description = "Releases label ids to label resource pool by a specific device id")
-public class ReleaseLabelResourceCommand extends AbstractShellCommand {
+public class LabelReleaseCommand extends AbstractShellCommand {
     @Argument(index = 0, name = "deviceId",
             description = "Device identity",
             required = true, multiValued = false)
diff --git a/cli/src/main/java/org/onosproject/cli/net/GetLabelResourceCommand.java b/cli/src/main/java/org/onosproject/cli/net/LabelResourceCommand.java
similarity index 66%
rename from cli/src/main/java/org/onosproject/cli/net/GetLabelResourceCommand.java
rename to cli/src/main/java/org/onosproject/cli/net/LabelResourceCommand.java
index fa91b21..fe263c6 100644
--- a/cli/src/main/java/org/onosproject/cli/net/GetLabelResourceCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/LabelResourceCommand.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * 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.cli.net;
 
 import org.apache.karaf.shell.commands.Argument;
@@ -7,9 +22,9 @@
 import org.onosproject.incubator.net.resource.label.LabelResourcePool;
 import org.onosproject.incubator.net.resource.label.LabelResourceService;
 
-@Command(scope = "onos", name = "get-label-resource-pool",
+@Command(scope = "onos", name = "label-pool",
       description = "Gets label resource pool information by a specific device id")
-public class GetLabelResourceCommand extends AbstractShellCommand {
+public class LabelResourceCommand extends AbstractShellCommand {
     @Argument(index = 0, name = "deviceId",
             description = "Device identity", required = true, multiValued = false)
     String deviceId = null;
diff --git a/cli/src/main/java/org/onosproject/cli/net/TunnelBorrowCommand.java b/cli/src/main/java/org/onosproject/cli/net/TunnelBorrowCommand.java
index 61188d2..3db4e86 100644
--- a/cli/src/main/java/org/onosproject/cli/net/TunnelBorrowCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/TunnelBorrowCommand.java
@@ -16,97 +16,189 @@
 package org.onosproject.cli.net;
 
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.Optional;
 
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
 import org.onlab.packet.IpAddress;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.DefaultApplicationId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
 import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
 import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
 import org.onosproject.incubator.net.tunnel.OpticalLogicId;
 import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
 import org.onosproject.incubator.net.tunnel.Tunnel;
 import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
+import org.onosproject.incubator.net.tunnel.TunnelId;
+import org.onosproject.incubator.net.tunnel.TunnelName;
 import org.onosproject.incubator.net.tunnel.TunnelService;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.provider.ProviderId;
 
 /**
- * Borrows all tunnels between specific source tunnel end point and specific
- * destination tunnel end point. Supports for IP address and optical as tunnel end point now. It's used by consumers.
+ * Borrows tunnels. It's used by consumers.
  */
-@Command(scope = "onos", name = "borrow-tunnels",
-description = "Borrows all tunnels between specific source tunnel end point"
-        + " and specific destination tunnel end point."
-        + " Supports for IP address and optical as tunnel end point now. It's used by consumers.")
+@Command(scope = "onos", name = "tunnel-borrow", description = "Borrows tunnels. It's used by consumers.")
 public class TunnelBorrowCommand extends AbstractShellCommand {
-    @Argument(index = 0, name = "consumerId", description = "consumer id means application id.",
-            required = true, multiValued = false)
+
+    @Argument(index = 0, name = "consumerId",
+            description = "consumer id means application id.", required = true, multiValued = false)
     String consumerId = null;
-    @Argument(index = 1, name = "src", description = "Source tunnel point."
+
+    @Option(name = "-s", aliases = "--src", description = "Source tunnel point."
             + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
             + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
-            + " Otherwise src means IP address.", required = true, multiValued = false)
+            + " Otherwise src means IP address.", required = false, multiValued = false)
     String src = null;
-    @Argument(index = 2, name = "dst", description = "Destination tunnel point."
+
+    @Option(name = "-d", aliases = "--dst", description = "Destination tunnel point."
             + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
             + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
-            + " Otherwise dst means IP address.", required = true, multiValued = false)
+            + " Otherwise dst means IP address.", required = false, multiValued = false)
     String dst = null;
 
-    @Argument(index = 3, name = "type", description = "The type of tunnels,"
-            + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false)
+    @Option(name = "-t", aliases = "--type", description = "The type of tunnels,"
+            + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = false, multiValued = false)
     String type = null;
+
+    @Option(name = "-i", aliases = "--tunnelId",
+            description = "the tunnel identity.", required = false, multiValued = false)
+    String tunnelId = null;
+
+    @Option(name = "-n", aliases = "--tunnelName",
+            description = "The name of tunnels", required = false, multiValued = false)
+    String tunnelName = null;
     private static final String FMT = "src=%s, dst=%s,"
             + "type=%s, state=%s, producerName=%s, tunnelName=%s,"
             + "groupId=%s";
 
     @Override
     protected void execute() {
+        Collection<Tunnel> tunnelSet = null;
+        Tunnel.Type trueType = null;
         TunnelService service = get(TunnelService.class);
         ApplicationId appId = new DefaultApplicationId(1, consumerId);
         ProviderId producerName = new ProviderId("default",
                                                  "org.onosproject.provider.tunnel.default");
-        TunnelEndPoint srcPoint = null;
-        TunnelEndPoint dstPoint = null;
-        if ("MPLS".equals(type) || "VLAN".equals(type) || "VXLAN".equals(type)
-                || "GRE".equals(type)) {
-            srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
-            dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
-        } else if ("ODUK".equals(type) || "OCH".equals(type)) {
-            String[] srcArray = src.split("-");
-            String[] dstArray = dst.split("-");
-            srcPoint = new DefaultOpticalTunnelEndPoint(
-                                                        producerName,
-                                                        Optional.of(DeviceId
-                                                                .deviceId(srcArray[0])),
-                                                        Optional.of(PortNumber
-                                                                .portNumber(srcArray[1])),
-                                                        null,
-                                                        OpticalTunnelEndPoint.Type.LAMBDA,
-                                                        OpticalLogicId
-                                                                .logicId(0),
-                                                        true);
-            dstPoint = new DefaultOpticalTunnelEndPoint(
-                                                        producerName,
-                                                        Optional.of(DeviceId
-                                                                .deviceId(dstArray[0])),
-                                                        Optional.of(PortNumber
-                                                                .portNumber(dstArray[1])),
-                                                        null,
-                                                        OpticalTunnelEndPoint.Type.LAMBDA,
-                                                        OpticalLogicId
-                                                                .logicId(0),
-                                                        true);
-        } else {
-            print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
-            return;
+        if (!isNull(src) && !isNull(dst) && !isNull(type)) {
+            TunnelEndPoint srcPoint = null;
+            TunnelEndPoint dstPoint = null;
+            if ("MPLS".equals(type)) {
+                trueType = Tunnel.Type.MPLS;
+                srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(src));
+                dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(dst));
+            } else if ("VXLAN".equals(type)) {
+                trueType = Tunnel.Type.VXLAN;
+                srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(src));
+                dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(dst));
+            } else if ("GRE".equals(type)) {
+                trueType = Tunnel.Type.GRE;
+                srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(src));
+                dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(dst));
+            } else if ("VLAN".equals(type)) {
+                trueType = Tunnel.Type.VLAN;
+                String[] srcArray = src.split("-");
+                String[] dstArray = dst.split("-");
+                srcPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(srcArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(srcArray[1])),
+                                                            null,
+                                                            null,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+                dstPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(dstArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(dstArray[1])),
+                                                            null,
+                                                            null,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+            } else if ("ODUK".equals(type)) {
+                trueType = Tunnel.Type.ODUK;
+                String[] srcArray = src.split("-");
+                String[] dstArray = dst.split("-");
+                srcPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(srcArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(srcArray[1])),
+                                                            null,
+                                                            OpticalTunnelEndPoint.Type.LAMBDA,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+                dstPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(dstArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(dstArray[1])),
+                                                            null,
+                                                            OpticalTunnelEndPoint.Type.LAMBDA,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+            } else if ("OCH".equals(type)) {
+                trueType = Tunnel.Type.OCH;
+                String[] srcArray = src.split("-");
+                String[] dstArray = dst.split("-");
+                srcPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(srcArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(srcArray[1])),
+                                                            null,
+                                                            OpticalTunnelEndPoint.Type.TIMESLOT,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+                dstPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(dstArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(dstArray[1])),
+                                                            null,
+                                                            OpticalTunnelEndPoint.Type.TIMESLOT,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+            } else {
+                print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
+                return;
+            }
+            tunnelSet = service.borrowTunnel(appId, srcPoint, dstPoint, trueType);
         }
-        Collection<Tunnel> tunnelSet = service.borrowTunnel(appId, srcPoint, dstPoint);
+        if (!isNull(tunnelId)) {
+            TunnelId id = TunnelId.valueOf(tunnelId);
+            Tunnel tunnel = service.borrowTunnel(appId, id);
+            tunnelSet = new HashSet<Tunnel>();
+            tunnelSet.add(tunnel);
+        }
+        if (!isNull(tunnelName)) {
+            TunnelName name = TunnelName.tunnelName(tunnelName);
+            tunnelSet = service.borrowTunnel(appId, name);
+        }
         for (Tunnel tunnel : tunnelSet) {
             print(FMT, tunnel.src(), tunnel.dst(), tunnel.type(),
                   tunnel.state(), tunnel.providerId(), tunnel.tunnelName(),
@@ -114,4 +206,7 @@
         }
     }
 
+    private boolean isNull(String s) {
+        return s == null || "".equals(s);
+    }
 }
diff --git a/cli/src/main/java/org/onosproject/cli/net/TunnelDeleteCommand.java b/cli/src/main/java/org/onosproject/cli/net/TunnelDeleteCommand.java
deleted file mode 100644
index 9be0da8..0000000
--- a/cli/src/main/java/org/onosproject/cli/net/TunnelDeleteCommand.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * 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.cli.net;
-
-import java.util.Optional;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.OpticalLogicId;
-import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelAdminService;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-
-/**
- * Supports for deleting all tunnels by using IP address and optical as tunnel
- * end point now. It's used by consumers.
- */
-@Command(scope = "onos", name = "delete-tunnels", description = "Supports for deleting all tunnels by using IP address"
-        + " and optical as tunnel end point now. It's used by consumers.")
-public class TunnelDeleteCommand extends AbstractShellCommand {
-    static String applicationId = "DEFAULT_APP_ID";
-    @Argument(index = 0, name = "src", description = "Source tunnel point."
-            + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
-            + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
-            + " Otherwise src means IP address.", required = true, multiValued = false)
-    String src = null;
-    @Argument(index = 1, name = "dst", description = "Destination tunnel point."
-            + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
-            + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
-            + " Otherwise dst means IP address.", required = true, multiValued = false)
-    String dst = null;
-
-    @Argument(index = 2, name = "type", description = "The type of tunnels,"
-            + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false)
-    String type = null;
-
-    @Override
-    protected void execute() {
-        TunnelAdminService adminService = get(TunnelAdminService.class);
-        ProviderId producerName = new ProviderId("default",
-                                                 "org.onosproject.provider.tunnel.default");
-        TunnelEndPoint srcPoint = null;
-        TunnelEndPoint dstPoint = null;
-        if ("MPLS".equals(type) || "VLAN".equals(type) || "VXLAN".equals(type) || "GRE".equals(type)) {
-            srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
-            dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
-        } else if ("ODUK".equals(type) || "OCH".equals(type)) {
-            String[] srcArray = src.split("-");
-            String[] dstArray = dst.split("-");
-            srcPoint = new DefaultOpticalTunnelEndPoint(
-                                                        producerName,
-                                                        Optional.of(DeviceId
-                                                                .deviceId(srcArray[0])),
-                                                        Optional.of(PortNumber
-                                                                .portNumber(srcArray[1])),
-                                                        null,
-                                                        OpticalTunnelEndPoint.Type.LAMBDA,
-                                                        OpticalLogicId
-                                                                .logicId(0),
-                                                        true);
-            dstPoint = new DefaultOpticalTunnelEndPoint(
-                                                        producerName,
-                                                        Optional.of(DeviceId
-                                                                .deviceId(dstArray[0])),
-                                                        Optional.of(PortNumber
-                                                                .portNumber(dstArray[1])),
-                                                        null,
-                                                        OpticalTunnelEndPoint.Type.LAMBDA,
-                                                        OpticalLogicId
-                                                                .logicId(0),
-                                                        true);
-        } else {
-            print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
-            return;
-        }
-
-        adminService.removeTunnels(srcPoint, dstPoint, producerName);
-    }
-
-}
diff --git a/cli/src/main/java/org/onosproject/cli/net/TunnelQueryCommand.java b/cli/src/main/java/org/onosproject/cli/net/TunnelQueryCommand.java
index 4e1fe28..e1bf52a 100644
--- a/cli/src/main/java/org/onosproject/cli/net/TunnelQueryCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/TunnelQueryCommand.java
@@ -16,96 +16,209 @@
 package org.onosproject.cli.net;
 
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.Optional;
 
-import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
 import org.onlab.packet.IpAddress;
 import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
 import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
 import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
 import org.onosproject.incubator.net.tunnel.OpticalLogicId;
 import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
 import org.onosproject.incubator.net.tunnel.Tunnel;
 import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
+import org.onosproject.incubator.net.tunnel.TunnelId;
 import org.onosproject.incubator.net.tunnel.TunnelService;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Link;
+import org.onosproject.net.Path;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.provider.ProviderId;
 
 /**
- * Supports for querying all tunnels by using IP address and optical as tunnel
- * end point now. It's used by consumers.
+ * Supports for querying tunnels. It's used by consumers.
  */
-@Command(scope = "onos", name = "query-tunnels", description = "Supports for querying all tunnels by using IP address"
-        + " and optical as tunnel end point now."
+@Command(scope = "onos", name = "tunnels", description = "Supports for querying tunnels."
         + " It's used by consumers.")
 public class TunnelQueryCommand extends AbstractShellCommand {
-    @Argument(index = 0, name = "src", description = "Source tunnel point."
+    @Option(name = "-s", aliases = "--src", description = "Source tunnel point."
             + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
             + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
-            + " Otherwise src means IP address.", required = true, multiValued = false)
+            + " Otherwise src means IP address.", required = false, multiValued = false)
     String src = null;
-    @Argument(index = 1, name = "dst", description = "Destination tunnel point."
+    @Option(name = "-d", aliases = "--dst", description = "Destination tunnel point."
             + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
             + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
-            + " Otherwise dst means IP address.", required = true, multiValued = false)
+            + " Otherwise dst means IP address.", required = false, multiValued = false)
     String dst = null;
 
-    @Argument(index = 2, name = "type", description = "The type of tunnels,"
-            + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false)
+    @Option(name = "-t", aliases = "--type", description = "The type of tunnels,"
+            + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = false, multiValued = false)
     String type = null;
 
-    private static final String FMT = "src=%s, dst=%s,"
+    @Option(name = "-i", aliases = "--tunnelId",
+            description = "the tunnel identity.", required = false, multiValued = false)
+    String tunnelId = null;
+
+    private static final String FMT = "tunnelId=%s, src=%s, dst=%s,"
             + "type=%s, state=%s, producerName=%s, tunnelName=%s,"
-            + "groupId=%s";
+            + "groupId=%s, path=%s%s";
 
     @Override
     protected void execute() {
+        Tunnel.Type trueType = null;
         TunnelService service = get(TunnelService.class);
         ProviderId producerName = new ProviderId("default",
                                                  "org.onosproject.provider.tunnel.default");
-        TunnelEndPoint srcPoint = null;
-        TunnelEndPoint dstPoint = null;
-        if ("MPLS".equals(type) || "VLAN".equals(type) || "VXLAN".equals(type)
-                || "GRE".equals(type)) {
-            srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
-            dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
-        } else if ("ODUK".equals(type) || "OCH".equals(type)) {
-            String[] srcArray = src.split("-");
-            String[] dstArray = dst.split("-");
-            srcPoint = new DefaultOpticalTunnelEndPoint(
-                                                        producerName,
-                                                        Optional.of(DeviceId
-                                                                .deviceId(srcArray[0])),
-                                                        Optional.of(PortNumber
-                                                                .portNumber(srcArray[1])),
-                                                        null,
-                                                        OpticalTunnelEndPoint.Type.LAMBDA,
-                                                        OpticalLogicId
-                                                                .logicId(0),
-                                                        true);
-            dstPoint = new DefaultOpticalTunnelEndPoint(
-                                                        producerName,
-                                                        Optional.of(DeviceId
-                                                                .deviceId(dstArray[0])),
-                                                        Optional.of(PortNumber
-                                                                .portNumber(dstArray[1])),
-                                                        null,
-                                                        OpticalTunnelEndPoint.Type.LAMBDA,
-                                                        OpticalLogicId
-                                                                .logicId(0),
-                                                        true);
-        } else {
-            print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
-            return;
+        Collection<Tunnel> tunnelSet = null;
+        if (isNull(src) && isNull(dst) && isNull(type) && isNull(tunnelId)) {
+            tunnelSet = service.queryAllTunnels();
         }
-        Collection<Tunnel> tunnelSet = service.queryTunnel(srcPoint, dstPoint);
-        for (Tunnel tunnel : tunnelSet) {
-            print(FMT, tunnel.src().toString(), tunnel.dst().toString(), tunnel.type(),
-                  tunnel.state(), tunnel.providerId(), tunnel.tunnelName(),
-                  tunnel.groupId());
+
+        if (!isNull(src) && !isNull(dst) && !isNull(type)) {
+            TunnelEndPoint srcPoint = null;
+            TunnelEndPoint dstPoint = null;
+            if ("MPLS".equals(type) || "VXLAN".equals(type)
+                    || "GRE".equals(type)) {
+                srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(src));
+                dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(dst));
+            } else if ("VLAN".equals(type)) {
+                String[] srcArray = src.split("-");
+                String[] dstArray = dst.split("-");
+                srcPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(srcArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(srcArray[1])),
+                                                            null,
+                                                            null,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+                dstPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(dstArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(dstArray[1])),
+                                                            null,
+                                                            null,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+            } else if ("ODUK".equals(type)) {
+                String[] srcArray = src.split("-");
+                String[] dstArray = dst.split("-");
+                srcPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(srcArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(srcArray[1])),
+                                                            null,
+                                                            OpticalTunnelEndPoint.Type.LAMBDA,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+                dstPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(dstArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(dstArray[1])),
+                                                            null,
+                                                            OpticalTunnelEndPoint.Type.LAMBDA,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+            } else if ("OCH".equals(type)) {
+                String[] srcArray = src.split("-");
+                String[] dstArray = dst.split("-");
+                srcPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(srcArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(srcArray[1])),
+                                                            null,
+                                                            OpticalTunnelEndPoint.Type.TIMESLOT,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+                dstPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(dstArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(dstArray[1])),
+                                                            null,
+                                                            OpticalTunnelEndPoint.Type.TIMESLOT,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+            } else {
+                print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
+                return;
+            }
+            tunnelSet = service.queryTunnel(srcPoint, dstPoint);
+        }
+        if (!isNull(type)) {
+            if ("MPLS".equals(type)) {
+                trueType = Tunnel.Type.MPLS;
+            } else if ("VLAN".equals(type)) {
+                trueType = Tunnel.Type.VLAN;
+            } else if ("VXLAN".equals(type)) {
+                trueType = Tunnel.Type.VXLAN;
+            } else if ("GRE".equals(type)) {
+                trueType = Tunnel.Type.GRE;
+            } else if ("ODUK".equals(type)) {
+                trueType = Tunnel.Type.ODUK;
+            } else if ("OCH".equals(type)) {
+                trueType = Tunnel.Type.OCH;
+            } else {
+                print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
+                return;
+            }
+            tunnelSet = service.queryTunnel(trueType);
+        }
+        if (!isNull(tunnelId)) {
+            TunnelId id = TunnelId.valueOf(tunnelId);
+            Tunnel tunnel = service.queryTunnel(id);
+            tunnelSet = new HashSet<Tunnel>();
+            tunnelSet.add(tunnel);
+        }
+        if (tunnelSet != null) {
+            for (Tunnel tunnel : tunnelSet) {
+                print(FMT, tunnel.tunnelId(), tunnel.src().toString(), tunnel.dst().toString(),
+                      tunnel.type(), tunnel.state(), tunnel.providerId(),
+                      tunnel.tunnelName(), tunnel.groupId(),
+                      showPath(tunnel.path()),
+                      annotations(tunnel.annotations()));
+            }
         }
     }
 
+    private String showPath(Path path) {
+        if (path == null) {
+            return "";
+        }
+        StringBuilder builder = new StringBuilder("(");
+        for (Link link : path.links()) {
+            builder.append("(DeviceId:" + link.src().deviceId() + " Port:"
+                    + link.src().port().toString());
+            builder.append(" DeviceId:" + link.dst().deviceId() + " Port:"
+                    + link.dst().port().toString() + ")");
+        }
+        builder.append(annotations(path.annotations()) + ")");
+        return builder.toString();
+    }
+
+    private boolean isNull(String s) {
+        return s == null || "".equals(s);
+    }
 }
diff --git a/cli/src/main/java/org/onosproject/cli/net/TunnelQuerySubscriptionCommand.java b/cli/src/main/java/org/onosproject/cli/net/TunnelQuerySubscriptionCommand.java
index 45d1e78..92db926 100644
--- a/cli/src/main/java/org/onosproject/cli/net/TunnelQuerySubscriptionCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/TunnelQuerySubscriptionCommand.java
@@ -29,7 +29,7 @@
  * Query all tunnel subscriptions of consumer by consumer id.
  * It's used by consumers.
  */
-@Command(scope = "onos", name = "query-tunnel-subscriptions",
+@Command(scope = "onos", name = "tunnel-subscriptions",
       description = "Query all request orders of consumer by consumer id. It's used by consumers.")
 public class TunnelQuerySubscriptionCommand extends AbstractShellCommand {
     @Argument(index = 0, name = "consumerId",
diff --git a/cli/src/main/java/org/onosproject/cli/net/TunnelReturnCommand.java b/cli/src/main/java/org/onosproject/cli/net/TunnelReturnCommand.java
index 3de8f00..2b7d7bb 100644
--- a/cli/src/main/java/org/onosproject/cli/net/TunnelReturnCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/TunnelReturnCommand.java
@@ -19,90 +19,180 @@
 
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
 import org.onlab.packet.IpAddress;
 import org.onosproject.cli.AbstractShellCommand;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.DefaultApplicationId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
 import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
 import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
 import org.onosproject.incubator.net.tunnel.OpticalLogicId;
 import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
+import org.onosproject.incubator.net.tunnel.Tunnel;
 import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
+import org.onosproject.incubator.net.tunnel.TunnelId;
+import org.onosproject.incubator.net.tunnel.TunnelName;
 import org.onosproject.incubator.net.tunnel.TunnelService;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.provider.ProviderId;
 
 /**
- * Returns all tunnels between specific source tunnel end point and specific
- * destination tunnel end point. Supports for IP address and optical as tunnel
- * end point now. It's used by consumers.
+ * Returns tunnels. It's used by consumers.
  */
-@Command(scope = "onos", name = "return-tunnels",
-description = "Returns all tunnels between specific source tunnel end point and specific "
-        + " destination tunnel end point. Supports for IP address and optical as tunnel end point now."
-        + " It's used by consumers.")
+@Command(scope = "onos", name = "tunnel-return",
+description = "Returns tunnels. It's used by consumers.")
 public class TunnelReturnCommand extends AbstractShellCommand {
-    @Argument(index = 0, name = "consumerId", description = "consumer id means application id.",
-            required = true, multiValued = false)
+    @Argument(index = 0, name = "consumerId",
+            description = "consumer id means application id.", required = true, multiValued = false)
     String consumerId = null;
-    @Argument(index = 1, name = "src", description = "Source tunnel point."
+
+    @Option(name = "-s", aliases = "--src", description = "Source tunnel point."
             + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
             + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
-            + " Otherwise src means IP address.", required = true, multiValued = false)
+            + " Otherwise src means IP address.", required = false, multiValued = false)
     String src = null;
-    @Argument(index = 2, name = "dst", description = "Destination tunnel point."
+
+    @Option(name = "-d", aliases = "--dst", description = "Destination tunnel point."
             + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
             + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
-            + " Otherwise dst means IP address.", required = true, multiValued = false)
+            + " Otherwise dst means IP address.", required = false, multiValued = false)
     String dst = null;
 
-    @Argument(index = 3, name = "type", description = "The type of tunnels,"
-            + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false)
+    @Option(name = "-t", aliases = "--type", description = "The type of tunnels,"
+            + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = false, multiValued = false)
     String type = null;
 
+    @Option(name = "-i", aliases = "--tunnelId",
+            description = "the tunnel identity.", required = false, multiValued = false)
+    String tunnelId = null;
+
+    @Option(name = "-n", aliases = "--tunnelName",
+            description = "The name of tunnels", required = false, multiValued = false)
+    String tunnelName = null;
+
     @Override
     protected void execute() {
+        Tunnel.Type trueType = null;
         TunnelService service = get(TunnelService.class);
         ApplicationId appId = new DefaultApplicationId(1, consumerId);
         ProviderId producerName = new ProviderId("default",
                                                  "org.onosproject.provider.tunnel.default");
-        TunnelEndPoint srcPoint = null;
-        TunnelEndPoint dstPoint = null;
-        if ("MPLS".equals(type) || "VLAN".equals(type) || "VXLAN".equals(type)
-                || "GRE".equals(type)) {
-            srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
-            dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
-        } else if ("ODUK".equals(type) || "OCH".equals(type)) {
-            String[] srcArray = src.split("-");
-            String[] dstArray = dst.split("-");
-            srcPoint = new DefaultOpticalTunnelEndPoint(
-                                                        producerName,
-                                                        Optional.of(DeviceId
-                                                                .deviceId(srcArray[0])),
-                                                        Optional.of(PortNumber
-                                                                .portNumber(srcArray[1])),
-                                                        null,
-                                                        OpticalTunnelEndPoint.Type.LAMBDA,
-                                                        OpticalLogicId
-                                                                .logicId(0),
-                                                        true);
-            dstPoint = new DefaultOpticalTunnelEndPoint(
-                                                        producerName,
-                                                        Optional.of(DeviceId
-                                                                .deviceId(dstArray[0])),
-                                                        Optional.of(PortNumber
-                                                                .portNumber(dstArray[1])),
-                                                        null,
-                                                        OpticalTunnelEndPoint.Type.LAMBDA,
-                                                        OpticalLogicId
-                                                                .logicId(0),
-                                                        true);
-        } else {
-            print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
-            return;
+        if (!isNull(src) && !isNull(dst) && !isNull(type)) {
+            TunnelEndPoint srcPoint = null;
+            TunnelEndPoint dstPoint = null;
+            if ("MPLS".equals(type)) {
+                trueType = Tunnel.Type.MPLS;
+                srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(src));
+                dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(dst));
+            } else if ("VXLAN".equals(type)) {
+                trueType = Tunnel.Type.VXLAN;
+                srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(src));
+                dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(dst));
+            } else if ("GRE".equals(type)) {
+                trueType = Tunnel.Type.GRE;
+                srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(src));
+                dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
+                        .valueOf(dst));
+            } else if ("VLAN".equals(type)) {
+                trueType = Tunnel.Type.VLAN;
+                String[] srcArray = src.split("-");
+                String[] dstArray = dst.split("-");
+                srcPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(srcArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(srcArray[1])),
+                                                            null,
+                                                            null,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+                dstPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(dstArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(dstArray[1])),
+                                                            null,
+                                                            null,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+            } else if ("ODUK".equals(type)) {
+                trueType = Tunnel.Type.ODUK;
+                String[] srcArray = src.split("-");
+                String[] dstArray = dst.split("-");
+                srcPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(srcArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(srcArray[1])),
+                                                            null,
+                                                            OpticalTunnelEndPoint.Type.LAMBDA,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+                dstPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(dstArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(dstArray[1])),
+                                                            null,
+                                                            OpticalTunnelEndPoint.Type.LAMBDA,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+            } else if ("OCH".equals(type)) {
+                trueType = Tunnel.Type.OCH;
+                String[] srcArray = src.split("-");
+                String[] dstArray = dst.split("-");
+                srcPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(srcArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(srcArray[1])),
+                                                            null,
+                                                            OpticalTunnelEndPoint.Type.TIMESLOT,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+                dstPoint = new DefaultOpticalTunnelEndPoint(
+                                                            producerName,
+                                                            Optional.of(DeviceId
+                                                                    .deviceId(dstArray[0])),
+                                                            Optional.of(PortNumber
+                                                                    .portNumber(dstArray[1])),
+                                                            null,
+                                                            OpticalTunnelEndPoint.Type.TIMESLOT,
+                                                            OpticalLogicId
+                                                                    .logicId(0),
+                                                            true);
+            } else {
+                print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
+                return;
+            }
+            service.returnTunnel(appId, srcPoint, dstPoint, trueType);
         }
-        service.returnTunnel(appId, srcPoint, dstPoint);
+        if (!isNull(tunnelId)) {
+            TunnelId id = TunnelId.valueOf(tunnelId);
+            service.returnTunnel(appId, id);
+        }
+        if (!isNull(tunnelName)) {
+            TunnelName name = TunnelName.tunnelName(tunnelName);
+            service.returnTunnel(appId, name);
+        }
     }
-
+    private boolean isNull(String s) {
+        return s == null || "".equals(s);
+    }
 }
diff --git a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index d92129a..5fbe61c 100644
--- a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -338,40 +338,37 @@
         </command>
         
         <command>
-            <action class="org.onosproject.cli.net.GetGlobalLabelResourceCommand"/>
+            <action class="org.onosproject.cli.net.GlobalLabelCommand"/>
         </command>
         <command>
-            <action class="org.onosproject.cli.net.GetLabelResourceCommand"/>
+            <action class="org.onosproject.cli.net.LabelResourceCommand"/>
         </command>
         <command>
-            <action class="org.onosproject.cli.net.CreateGlobalLabelResourcePoolCommand"/>
+            <action class="org.onosproject.cli.net.GlobalLabelPoolCreateCommand"/>
         </command>
         <command>
-            <action class="org.onosproject.cli.net.CreateLabelResourcePoolCommand"/>
+            <action class="org.onosproject.cli.net.LabelPoolCreateCommand"/>
         </command>
         <command>
-            <action class="org.onosproject.cli.net.DestroyGlobalLabelResourcePoolCommand"/>
+            <action class="org.onosproject.cli.net.GlobalLabelPoolDestoryCommand"/>
         </command>
         <command>
-            <action class="org.onosproject.cli.net.DestroyGlobalLabelResourcePoolCommand"/>
+            <action class="org.onosproject.cli.net.LabelPoolDestroyCommand"/>
         </command>
         <command>
-            <action class="org.onosproject.cli.net.ReleaseGlobalLabelResourceCommand"/>
+            <action class="org.onosproject.cli.net.GlobalLabelReleaseCommand"/>
         </command>
         <command>
-            <action class="org.onosproject.cli.net.ReleaseLabelResourceCommand"/>
+            <action class="org.onosproject.cli.net.LabelReleaseCommand"/>
         </command>
         <command>
-            <action class="org.onosproject.cli.net.ApplyGlobalLabelResourceCommand"/>
+            <action class="org.onosproject.cli.net.GlobalLabelApplyCommand"/>
         </command>
         <command>
-            <action class="org.onosproject.cli.net.ApplyLabelResourceCommand"/>
+            <action class="org.onosproject.cli.net.LabelApplyCommand"/>
         </command>
         <!-- tunnel commands -->
         <command>
-            <action class="org.onosproject.cli.net.TunnelDeleteCommand"/>
-        </command>
-        <command>
             <action class="org.onosproject.cli.net.TunnelBorrowCommand"/>
         </command>
         <command>