samuel
Committed by Gerrit Code Review

[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
Showing 37 changed files with 440 additions and 262 deletions
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
1 package org.onosproject.cli.net; 16 package org.onosproject.cli.net;
2 17
3 import java.util.Collection; 18 import java.util.Collection;
...@@ -10,9 +25,9 @@ import org.onosproject.incubator.net.resource.label.DefaultLabelResource; ...@@ -10,9 +25,9 @@ import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
10 import org.onosproject.incubator.net.resource.label.LabelResource; 25 import org.onosproject.incubator.net.resource.label.LabelResource;
11 import org.onosproject.incubator.net.resource.label.LabelResourceService; 26 import org.onosproject.incubator.net.resource.label.LabelResourceService;
12 27
13 -@Command(scope = "onos", name = "apply-global-label-resource-pool", 28 +@Command(scope = "onos", name = "global-label-apply",
14 description = "Apply global labels from global resource pool") 29 description = "Apply global labels from global resource pool")
15 -public class ApplyGlobalLabelResourceCommand extends AbstractShellCommand { 30 +public class GlobalLabelApplyCommand extends AbstractShellCommand {
16 @Argument(index = 0, name = "applyNum", 31 @Argument(index = 0, name = "applyNum",
17 description = "Applying number means how many labels applications want to use.", 32 description = "Applying number means how many labels applications want to use.",
18 required = true, multiValued = false) 33 required = true, multiValued = false)
......
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
1 package org.onosproject.cli.net; 16 package org.onosproject.cli.net;
2 17
3 import org.apache.karaf.shell.commands.Command; 18 import org.apache.karaf.shell.commands.Command;
...@@ -5,9 +20,9 @@ import org.onosproject.cli.AbstractShellCommand; ...@@ -5,9 +20,9 @@ import org.onosproject.cli.AbstractShellCommand;
5 import org.onosproject.incubator.net.resource.label.LabelResourcePool; 20 import org.onosproject.incubator.net.resource.label.LabelResourcePool;
6 import org.onosproject.incubator.net.resource.label.LabelResourceService; 21 import org.onosproject.incubator.net.resource.label.LabelResourceService;
7 22
8 -@Command(scope = "onos", name = "get-global-label-resource-pool", 23 +@Command(scope = "onos", name = "global-label-pool",
9 description = "Gets global label resource pool information.") 24 description = "Gets global label resource pool information.")
10 -public class GetGlobalLabelResourceCommand extends AbstractShellCommand { 25 +public class GlobalLabelCommand extends AbstractShellCommand {
11 private static final String FMT = "deviceid=%s, beginLabel=%s," 26 private static final String FMT = "deviceid=%s, beginLabel=%s,"
12 + "endLabel=%s, totalNum=%s, usedNum=%s, currentUsedMaxLabelId=%s," 27 + "endLabel=%s, totalNum=%s, usedNum=%s, currentUsedMaxLabelId=%s,"
13 + "releaseLabelIds=%s"; 28 + "releaseLabelIds=%s";
......
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
1 package org.onosproject.cli.net; 16 package org.onosproject.cli.net;
2 17
3 import org.apache.karaf.shell.commands.Argument; 18 import org.apache.karaf.shell.commands.Argument;
...@@ -9,9 +24,9 @@ import org.onosproject.incubator.net.resource.label.LabelResourceId; ...@@ -9,9 +24,9 @@ import org.onosproject.incubator.net.resource.label.LabelResourceId;
9 /** 24 /**
10 * create label resource pool by specific device id. 25 * create label resource pool by specific device id.
11 */ 26 */
12 -@Command(scope = "onos", name = "create-global-label-resource-pool", 27 +@Command(scope = "onos", name = "global-label-pool-create",
13 description = "Creates global label resource pool.") 28 description = "Creates global label resource pool.")
14 -public class CreateGlobalLabelResourcePoolCommand extends AbstractShellCommand { 29 +public class GlobalLabelPoolCreateCommand extends AbstractShellCommand {
15 @Argument(index = 0, name = "beginLabel", 30 @Argument(index = 0, name = "beginLabel",
16 description = "The first label of global label resource pool.", 31 description = "The first label of global label resource pool.",
17 required = true, multiValued = false) 32 required = true, multiValued = false)
......
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
1 package org.onosproject.cli.net; 16 package org.onosproject.cli.net;
2 17
3 import org.apache.karaf.shell.commands.Command; 18 import org.apache.karaf.shell.commands.Command;
4 import org.onosproject.cli.AbstractShellCommand; 19 import org.onosproject.cli.AbstractShellCommand;
5 import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; 20 import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
6 21
7 -@Command(scope = "onos", name = "destroy-global-label-resource-pool", 22 +@Command(scope = "onos", name = "global-label-pool-destroy",
8 description = "Destroys global label resource pool") 23 description = "Destroys global label resource pool")
9 -public class DestroyGlobalLabelResourcePoolCommand extends AbstractShellCommand { 24 +public class GlobalLabelPoolDestoryCommand extends AbstractShellCommand {
10 @Override 25 @Override
11 protected void execute() { 26 protected void execute() {
12 LabelResourceAdminService lrs = get(LabelResourceAdminService.class); 27 LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
......
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
1 package org.onosproject.cli.net; 16 package org.onosproject.cli.net;
2 17
3 import java.util.HashSet; 18 import java.util.HashSet;
...@@ -9,9 +24,9 @@ import org.onosproject.cli.AbstractShellCommand; ...@@ -9,9 +24,9 @@ import org.onosproject.cli.AbstractShellCommand;
9 import org.onosproject.incubator.net.resource.label.LabelResourceId; 24 import org.onosproject.incubator.net.resource.label.LabelResourceId;
10 import org.onosproject.incubator.net.resource.label.LabelResourceService; 25 import org.onosproject.incubator.net.resource.label.LabelResourceService;
11 26
12 -@Command(scope = "onos", name = "release-global-label-resource-pool", 27 +@Command(scope = "onos", name = "global-label-release",
13 description = "Releases labels to global label resource pool.") 28 description = "Releases labels to global label resource pool.")
14 -public class ReleaseGlobalLabelResourceCommand extends AbstractShellCommand { 29 +public class GlobalLabelReleaseCommand extends AbstractShellCommand {
15 @Argument(index = 0, name = "releaseLabelIds", 30 @Argument(index = 0, name = "releaseLabelIds",
16 description = "Represents for the label ids that are released. They are splited by dot symbol", 31 description = "Represents for the label ids that are released. They are splited by dot symbol",
17 required = true, multiValued = false) 32 required = true, multiValued = false)
......
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
1 package org.onosproject.cli.net; 16 package org.onosproject.cli.net;
2 17
3 import java.util.Collection; 18 import java.util.Collection;
...@@ -11,9 +26,9 @@ import org.onosproject.incubator.net.resource.label.DefaultLabelResource; ...@@ -11,9 +26,9 @@ import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
11 import org.onosproject.incubator.net.resource.label.LabelResource; 26 import org.onosproject.incubator.net.resource.label.LabelResource;
12 import org.onosproject.incubator.net.resource.label.LabelResourceService; 27 import org.onosproject.incubator.net.resource.label.LabelResourceService;
13 28
14 -@Command(scope = "onos", name = "apply-label-resource-pool", 29 +@Command(scope = "onos", name = "label-apply",
15 description = "Apply label resource from device pool by specific device id") 30 description = "Apply label resource from device pool by specific device id")
16 -public class ApplyLabelResourceCommand extends AbstractShellCommand { 31 +public class LabelApplyCommand extends AbstractShellCommand {
17 @Argument(index = 0, name = "deviceId", 32 @Argument(index = 0, name = "deviceId",
18 description = "Device identity", 33 description = "Device identity",
19 required = true, multiValued = false) 34 required = true, multiValued = false)
......
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
1 package org.onosproject.cli.net; 16 package org.onosproject.cli.net;
2 17
3 import org.apache.karaf.shell.commands.Argument; 18 import org.apache.karaf.shell.commands.Argument;
...@@ -10,9 +25,9 @@ import org.onosproject.incubator.net.resource.label.LabelResourceId; ...@@ -10,9 +25,9 @@ import org.onosproject.incubator.net.resource.label.LabelResourceId;
10 /** 25 /**
11 * create label resource pool by specific device id. 26 * create label resource pool by specific device id.
12 */ 27 */
13 -@Command(scope = "onos", name = "create-label-resource-pool", 28 +@Command(scope = "onos", name = "label-pool-create",
14 description = "Creates label resource pool by a specific device id") 29 description = "Creates label resource pool by a specific device id")
15 -public class CreateLabelResourcePoolCommand extends AbstractShellCommand { 30 +public class LabelPoolCreateCommand extends AbstractShellCommand {
16 @Argument(index = 0, name = "deviceId", description = "Device identity", required = true, multiValued = false) 31 @Argument(index = 0, name = "deviceId", description = "Device identity", required = true, multiValued = false)
17 String deviceId = null; 32 String deviceId = null;
18 @Argument(index = 1, name = "beginLabel", 33 @Argument(index = 1, name = "beginLabel",
......
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
1 package org.onosproject.cli.net; 16 package org.onosproject.cli.net;
2 17
3 import org.apache.karaf.shell.commands.Argument; 18 import org.apache.karaf.shell.commands.Argument;
...@@ -6,9 +21,9 @@ import org.onosproject.cli.AbstractShellCommand; ...@@ -6,9 +21,9 @@ import org.onosproject.cli.AbstractShellCommand;
6 import org.onosproject.net.DeviceId; 21 import org.onosproject.net.DeviceId;
7 import org.onosproject.incubator.net.resource.label.LabelResourceAdminService; 22 import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
8 23
9 -@Command(scope = "onos", name = "destroy-label-resource-pool", 24 +@Command(scope = "onos", name = "label-pool-destroy",
10 description = "Destroys label resource pool by a specific device id") 25 description = "Destroys label resource pool by a specific device id")
11 -public class DestroyLabelResourcePoolCommand extends AbstractShellCommand { 26 +public class LabelPoolDestroyCommand extends AbstractShellCommand {
12 @Argument(index = 0, name = "deviceId", description = "Device identity", required = true, multiValued = false) 27 @Argument(index = 0, name = "deviceId", description = "Device identity", required = true, multiValued = false)
13 String deviceId = null; 28 String deviceId = null;
14 29
......
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
1 package org.onosproject.cli.net; 16 package org.onosproject.cli.net;
2 17
3 import org.apache.karaf.shell.commands.Argument; 18 import org.apache.karaf.shell.commands.Argument;
...@@ -12,9 +27,9 @@ import org.onosproject.incubator.net.resource.label.LabelResourceService; ...@@ -12,9 +27,9 @@ import org.onosproject.incubator.net.resource.label.LabelResourceService;
12 import com.google.common.collect.ArrayListMultimap; 27 import com.google.common.collect.ArrayListMultimap;
13 import com.google.common.collect.Multimap; 28 import com.google.common.collect.Multimap;
14 29
15 -@Command(scope = "onos", name = "release-label-resource-pool", 30 +@Command(scope = "onos", name = "label-release",
16 description = "Releases label ids to label resource pool by a specific device id") 31 description = "Releases label ids to label resource pool by a specific device id")
17 -public class ReleaseLabelResourceCommand extends AbstractShellCommand { 32 +public class LabelReleaseCommand extends AbstractShellCommand {
18 @Argument(index = 0, name = "deviceId", 33 @Argument(index = 0, name = "deviceId",
19 description = "Device identity", 34 description = "Device identity",
20 required = true, multiValued = false) 35 required = true, multiValued = false)
......
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
1 package org.onosproject.cli.net; 16 package org.onosproject.cli.net;
2 17
3 import org.apache.karaf.shell.commands.Argument; 18 import org.apache.karaf.shell.commands.Argument;
...@@ -7,9 +22,9 @@ import org.onosproject.net.DeviceId; ...@@ -7,9 +22,9 @@ import org.onosproject.net.DeviceId;
7 import org.onosproject.incubator.net.resource.label.LabelResourcePool; 22 import org.onosproject.incubator.net.resource.label.LabelResourcePool;
8 import org.onosproject.incubator.net.resource.label.LabelResourceService; 23 import org.onosproject.incubator.net.resource.label.LabelResourceService;
9 24
10 -@Command(scope = "onos", name = "get-label-resource-pool", 25 +@Command(scope = "onos", name = "label-pool",
11 description = "Gets label resource pool information by a specific device id") 26 description = "Gets label resource pool information by a specific device id")
12 -public class GetLabelResourceCommand extends AbstractShellCommand { 27 +public class LabelResourceCommand extends AbstractShellCommand {
13 @Argument(index = 0, name = "deviceId", 28 @Argument(index = 0, name = "deviceId",
14 description = "Device identity", required = true, multiValued = false) 29 description = "Device identity", required = true, multiValued = false)
15 String deviceId = null; 30 String deviceId = null;
......
1 -/*
2 - * Copyright 2014-2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.cli.net;
17 -
18 -import java.util.Optional;
19 -
20 -import org.apache.karaf.shell.commands.Argument;
21 -import org.apache.karaf.shell.commands.Command;
22 -import org.onlab.packet.IpAddress;
23 -import org.onosproject.cli.AbstractShellCommand;
24 -import org.onosproject.net.DeviceId;
25 -import org.onosproject.net.PortNumber;
26 -import org.onosproject.net.provider.ProviderId;
27 -import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
28 -import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
29 -import org.onosproject.incubator.net.tunnel.OpticalLogicId;
30 -import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
31 -import org.onosproject.incubator.net.tunnel.TunnelAdminService;
32 -import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
33 -
34 -/**
35 - * Supports for deleting all tunnels by using IP address and optical as tunnel
36 - * end point now. It's used by consumers.
37 - */
38 -@Command(scope = "onos", name = "delete-tunnels", description = "Supports for deleting all tunnels by using IP address"
39 - + " and optical as tunnel end point now. It's used by consumers.")
40 -public class TunnelDeleteCommand extends AbstractShellCommand {
41 - static String applicationId = "DEFAULT_APP_ID";
42 - @Argument(index = 0, name = "src", description = "Source tunnel point."
43 - + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
44 - + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
45 - + " Otherwise src means IP address.", required = true, multiValued = false)
46 - String src = null;
47 - @Argument(index = 1, name = "dst", description = "Destination tunnel point."
48 - + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
49 - + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
50 - + " Otherwise dst means IP address.", required = true, multiValued = false)
51 - String dst = null;
52 -
53 - @Argument(index = 2, name = "type", description = "The type of tunnels,"
54 - + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false)
55 - String type = null;
56 -
57 - @Override
58 - protected void execute() {
59 - TunnelAdminService adminService = get(TunnelAdminService.class);
60 - ProviderId producerName = new ProviderId("default",
61 - "org.onosproject.provider.tunnel.default");
62 - TunnelEndPoint srcPoint = null;
63 - TunnelEndPoint dstPoint = null;
64 - if ("MPLS".equals(type) || "VLAN".equals(type) || "VXLAN".equals(type) || "GRE".equals(type)) {
65 - srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
66 - dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
67 - } else if ("ODUK".equals(type) || "OCH".equals(type)) {
68 - String[] srcArray = src.split("-");
69 - String[] dstArray = dst.split("-");
70 - srcPoint = new DefaultOpticalTunnelEndPoint(
71 - producerName,
72 - Optional.of(DeviceId
73 - .deviceId(srcArray[0])),
74 - Optional.of(PortNumber
75 - .portNumber(srcArray[1])),
76 - null,
77 - OpticalTunnelEndPoint.Type.LAMBDA,
78 - OpticalLogicId
79 - .logicId(0),
80 - true);
81 - dstPoint = new DefaultOpticalTunnelEndPoint(
82 - producerName,
83 - Optional.of(DeviceId
84 - .deviceId(dstArray[0])),
85 - Optional.of(PortNumber
86 - .portNumber(dstArray[1])),
87 - null,
88 - OpticalTunnelEndPoint.Type.LAMBDA,
89 - OpticalLogicId
90 - .logicId(0),
91 - true);
92 - } else {
93 - print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
94 - return;
95 - }
96 -
97 - adminService.removeTunnels(srcPoint, dstPoint, producerName);
98 - }
99 -
100 -}
...@@ -29,7 +29,7 @@ import org.onosproject.incubator.net.tunnel.TunnelSubscription; ...@@ -29,7 +29,7 @@ import org.onosproject.incubator.net.tunnel.TunnelSubscription;
29 * Query all tunnel subscriptions of consumer by consumer id. 29 * Query all tunnel subscriptions of consumer by consumer id.
30 * It's used by consumers. 30 * It's used by consumers.
31 */ 31 */
32 -@Command(scope = "onos", name = "query-tunnel-subscriptions", 32 +@Command(scope = "onos", name = "tunnel-subscriptions",
33 description = "Query all request orders of consumer by consumer id. It's used by consumers.") 33 description = "Query all request orders of consumer by consumer id. It's used by consumers.")
34 public class TunnelQuerySubscriptionCommand extends AbstractShellCommand { 34 public class TunnelQuerySubscriptionCommand extends AbstractShellCommand {
35 @Argument(index = 0, name = "consumerId", 35 @Argument(index = 0, name = "consumerId",
......
...@@ -338,40 +338,37 @@ ...@@ -338,40 +338,37 @@
338 </command> 338 </command>
339 339
340 <command> 340 <command>
341 - <action class="org.onosproject.cli.net.GetGlobalLabelResourceCommand"/> 341 + <action class="org.onosproject.cli.net.GlobalLabelCommand"/>
342 </command> 342 </command>
343 <command> 343 <command>
344 - <action class="org.onosproject.cli.net.GetLabelResourceCommand"/> 344 + <action class="org.onosproject.cli.net.LabelResourceCommand"/>
345 </command> 345 </command>
346 <command> 346 <command>
347 - <action class="org.onosproject.cli.net.CreateGlobalLabelResourcePoolCommand"/> 347 + <action class="org.onosproject.cli.net.GlobalLabelPoolCreateCommand"/>
348 </command> 348 </command>
349 <command> 349 <command>
350 - <action class="org.onosproject.cli.net.CreateLabelResourcePoolCommand"/> 350 + <action class="org.onosproject.cli.net.LabelPoolCreateCommand"/>
351 </command> 351 </command>
352 <command> 352 <command>
353 - <action class="org.onosproject.cli.net.DestroyGlobalLabelResourcePoolCommand"/> 353 + <action class="org.onosproject.cli.net.GlobalLabelPoolDestoryCommand"/>
354 </command> 354 </command>
355 <command> 355 <command>
356 - <action class="org.onosproject.cli.net.DestroyGlobalLabelResourcePoolCommand"/> 356 + <action class="org.onosproject.cli.net.LabelPoolDestroyCommand"/>
357 </command> 357 </command>
358 <command> 358 <command>
359 - <action class="org.onosproject.cli.net.ReleaseGlobalLabelResourceCommand"/> 359 + <action class="org.onosproject.cli.net.GlobalLabelReleaseCommand"/>
360 </command> 360 </command>
361 <command> 361 <command>
362 - <action class="org.onosproject.cli.net.ReleaseLabelResourceCommand"/> 362 + <action class="org.onosproject.cli.net.LabelReleaseCommand"/>
363 </command> 363 </command>
364 <command> 364 <command>
365 - <action class="org.onosproject.cli.net.ApplyGlobalLabelResourceCommand"/> 365 + <action class="org.onosproject.cli.net.GlobalLabelApplyCommand"/>
366 </command> 366 </command>
367 <command> 367 <command>
368 - <action class="org.onosproject.cli.net.ApplyLabelResourceCommand"/> 368 + <action class="org.onosproject.cli.net.LabelApplyCommand"/>
369 </command> 369 </command>
370 <!-- tunnel commands --> 370 <!-- tunnel commands -->
371 <command> 371 <command>
372 - <action class="org.onosproject.cli.net.TunnelDeleteCommand"/>
373 - </command>
374 - <command>
375 <action class="org.onosproject.cli.net.TunnelBorrowCommand"/> 372 <action class="org.onosproject.cli.net.TunnelBorrowCommand"/>
376 </command> 373 </command>
377 <command> 374 <command>
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 */ 15 */
16 package org.onosproject.incubator.net.tunnel; 16 package org.onosproject.incubator.net.tunnel;
17 17
18 -import static com.google.common.base.Preconditions.checkNotNull;
19 import static com.google.common.base.MoreObjects.toStringHelper; 18 import static com.google.common.base.MoreObjects.toStringHelper;
20 19
21 import java.util.Objects; 20 import java.util.Objects;
...@@ -55,9 +54,6 @@ public class DefaultOpticalTunnelEndPoint extends AbstractModel implements Optic ...@@ -55,9 +54,6 @@ public class DefaultOpticalTunnelEndPoint extends AbstractModel implements Optic
55 Optional<PortNumber> number, Optional<OpticalTunnelEndPoint> parentPoint, 54 Optional<PortNumber> number, Optional<OpticalTunnelEndPoint> parentPoint,
56 Type type, OpticalLogicId id, boolean isGlobal, Annotations... annotations) { 55 Type type, OpticalLogicId id, boolean isGlobal, Annotations... annotations) {
57 super(providerId, annotations); 56 super(providerId, annotations);
58 - checkNotNull(type, "type cannot be null");
59 - checkNotNull(id, "id cannot be null");
60 - checkNotNull(isGlobal, "isGlobal cannot be null");
61 this.elementId = elementId; 57 this.elementId = elementId;
62 this.portNumber = number; 58 this.portNumber = number;
63 this.parentPoint = parentPoint; 59 this.parentPoint = parentPoint;
......
1 /* 1 /*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2014-2015 Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,10 +13,8 @@ ...@@ -13,10 +13,8 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -
17 package org.onosproject.incubator.net.tunnel; 16 package org.onosproject.incubator.net.tunnel;
18 17
19 -import static com.google.common.base.Preconditions.checkNotNull;
20 import static com.google.common.base.MoreObjects.toStringHelper; 18 import static com.google.common.base.MoreObjects.toStringHelper;
21 19
22 import java.util.Objects; 20 import java.util.Objects;
...@@ -25,6 +23,7 @@ import org.onosproject.core.DefaultGroupId; ...@@ -25,6 +23,7 @@ import org.onosproject.core.DefaultGroupId;
25 import org.onosproject.net.AbstractModel; 23 import org.onosproject.net.AbstractModel;
26 import org.onosproject.net.Annotations; 24 import org.onosproject.net.Annotations;
27 import org.onosproject.net.NetworkResource; 25 import org.onosproject.net.NetworkResource;
26 +import org.onosproject.net.Path;
28 import org.onosproject.net.provider.ProviderId; 27 import org.onosproject.net.provider.ProviderId;
29 28
30 /** 29 /**
...@@ -43,6 +42,7 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel { ...@@ -43,6 +42,7 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
43 private final TunnelId tunnelId; // tunnel identify generated by 42 private final TunnelId tunnelId; // tunnel identify generated by
44 // ONOS as primary key 43 // ONOS as primary key
45 private final TunnelName tunnelName; // name of a tunnel 44 private final TunnelName tunnelName; // name of a tunnel
45 + private final Path path;
46 46
47 /** 47 /**
48 * Creates an active infrastructure tunnel using the supplied information. 48 * Creates an active infrastructure tunnel using the supplied information.
...@@ -54,14 +54,15 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel { ...@@ -54,14 +54,15 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
54 * @param groupId groupId 54 * @param groupId groupId
55 * @param tunnelId tunnelId 55 * @param tunnelId tunnelId
56 * @param tunnelName tunnel name 56 * @param tunnelName tunnel name
57 + * @param path the path of tunnel
57 * @param annotations optional key/value annotations 58 * @param annotations optional key/value annotations
58 */ 59 */
59 public DefaultTunnel(ProviderId producerName, TunnelEndPoint src, 60 public DefaultTunnel(ProviderId producerName, TunnelEndPoint src,
60 TunnelEndPoint dst, Type type, DefaultGroupId groupId, 61 TunnelEndPoint dst, Type type, DefaultGroupId groupId,
61 - TunnelId tunnelId, TunnelName tunnelName, 62 + TunnelId tunnelId, TunnelName tunnelName, Path path,
62 Annotations... annotations) { 63 Annotations... annotations) {
63 this(producerName, src, dst, type, Tunnel.State.ACTIVE, groupId, 64 this(producerName, src, dst, type, Tunnel.State.ACTIVE, groupId,
64 - tunnelId, tunnelName, annotations); 65 + tunnelId, tunnelName, path, annotations);
65 } 66 }
66 67
67 /** 68 /**
...@@ -75,18 +76,14 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel { ...@@ -75,18 +76,14 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
75 * @param groupId groupId 76 * @param groupId groupId
76 * @param tunnelId tunnelId 77 * @param tunnelId tunnelId
77 * @param tunnelName tunnel name 78 * @param tunnelName tunnel name
79 + * @param path the path of tunnel
78 * @param annotations optional key/value annotations 80 * @param annotations optional key/value annotations
79 */ 81 */
80 public DefaultTunnel(ProviderId producerName, TunnelEndPoint src, 82 public DefaultTunnel(ProviderId producerName, TunnelEndPoint src,
81 TunnelEndPoint dst, Type type, State state, 83 TunnelEndPoint dst, Type type, State state,
82 DefaultGroupId groupId, TunnelId tunnelId, 84 DefaultGroupId groupId, TunnelId tunnelId,
83 - TunnelName tunnelName, Annotations... annotations) { 85 + TunnelName tunnelName, Path path, Annotations... annotations) {
84 super(producerName, annotations); 86 super(producerName, annotations);
85 - checkNotNull(producerName, "producerName cannot be null");
86 - checkNotNull(src, "src cannot be null");
87 - checkNotNull(dst, "dst cannot be null");
88 - checkNotNull(type, "type cannot be null");
89 - checkNotNull(state, "state cannot be null");
90 this.src = src; 87 this.src = src;
91 this.dst = dst; 88 this.dst = dst;
92 this.type = type; 89 this.type = type;
...@@ -94,6 +91,7 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel { ...@@ -94,6 +91,7 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
94 this.groupId = groupId; 91 this.groupId = groupId;
95 this.tunnelId = tunnelId; 92 this.tunnelId = tunnelId;
96 this.tunnelName = tunnelName; 93 this.tunnelName = tunnelName;
94 + this.path = path;
97 } 95 }
98 96
99 @Override 97 @Override
...@@ -136,10 +134,16 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel { ...@@ -136,10 +134,16 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
136 return tunnelName; 134 return tunnelName;
137 } 135 }
138 136
137 +
138 + @Override
139 + public Path path() {
140 + return path;
141 + }
142 +
139 @Override 143 @Override
140 public int hashCode() { 144 public int hashCode() {
141 return Objects.hash(src, dst, type, groupId, tunnelId, tunnelName, 145 return Objects.hash(src, dst, type, groupId, tunnelId, tunnelName,
142 - state); 146 + state, path);
143 } 147 }
144 148
145 @Override 149 @Override
...@@ -155,7 +159,8 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel { ...@@ -155,7 +159,8 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
155 && Objects.equals(this.groupId, other.groupId) 159 && Objects.equals(this.groupId, other.groupId)
156 && Objects.equals(this.tunnelId, other.tunnelId) 160 && Objects.equals(this.tunnelId, other.tunnelId)
157 && Objects.equals(this.tunnelName, other.tunnelName) 161 && Objects.equals(this.tunnelName, other.tunnelName)
158 - && Objects.equals(this.state, other.state); 162 + && Objects.equals(this.state, other.state)
163 + && Objects.equals(this.path, other.path);
159 } 164 }
160 return false; 165 return false;
161 } 166 }
...@@ -165,7 +170,7 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel { ...@@ -165,7 +170,7 @@ public final class DefaultTunnel extends AbstractModel implements Tunnel {
165 return toStringHelper(this).add("src", src).add("dst", dst) 170 return toStringHelper(this).add("src", src).add("dst", dst)
166 .add("type", type).add("state", state).add("groupId", groupId) 171 .add("type", type).add("state", state).add("groupId", groupId)
167 .add("producerTunnelId", tunnelId) 172 .add("producerTunnelId", tunnelId)
168 - .add("tunnelName", tunnelName).toString(); 173 + .add("tunnelName", tunnelName)
174 + .add("path", path).toString();
169 } 175 }
170 -
171 } 176 }
......
...@@ -13,12 +13,11 @@ ...@@ -13,12 +13,11 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -
17 package org.onosproject.incubator.net.tunnel; 16 package org.onosproject.incubator.net.tunnel;
18 17
19 -import static com.google.common.base.Preconditions.checkNotNull;
20 import org.onosproject.core.DefaultGroupId; 18 import org.onosproject.core.DefaultGroupId;
21 import org.onosproject.net.AbstractDescription; 19 import org.onosproject.net.AbstractDescription;
20 +import org.onosproject.net.Path;
22 import org.onosproject.net.SparseAnnotations; 21 import org.onosproject.net.SparseAnnotations;
23 import org.onosproject.net.provider.ProviderId; 22 import org.onosproject.net.provider.ProviderId;
24 23
...@@ -39,6 +38,7 @@ public class DefaultTunnelDescription extends AbstractDescription ...@@ -39,6 +38,7 @@ public class DefaultTunnelDescription extends AbstractDescription
39 // tunnel producer 38 // tunnel producer
40 private final ProviderId producerName; // tunnel producer name 39 private final ProviderId producerName; // tunnel producer name
41 private final TunnelName tunnelName; // name of a tunnel 40 private final TunnelName tunnelName; // name of a tunnel
41 + private final Path path;
42 42
43 /** 43 /**
44 * Creates a tunnel description using the supplied information. 44 * Creates a tunnel description using the supplied information.
...@@ -50,6 +50,7 @@ public class DefaultTunnelDescription extends AbstractDescription ...@@ -50,6 +50,7 @@ public class DefaultTunnelDescription extends AbstractDescription
50 * @param groupId groupId 50 * @param groupId groupId
51 * @param producerName tunnel producer 51 * @param producerName tunnel producer
52 * @param tunnelName tunnel name 52 * @param tunnelName tunnel name
53 + * @param path the path of tunnel
53 * @param annotations optional key/value annotations 54 * @param annotations optional key/value annotations
54 */ 55 */
55 public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src, 56 public DefaultTunnelDescription(TunnelId id, TunnelEndPoint src,
...@@ -57,12 +58,9 @@ public class DefaultTunnelDescription extends AbstractDescription ...@@ -57,12 +58,9 @@ public class DefaultTunnelDescription extends AbstractDescription
57 DefaultGroupId groupId, 58 DefaultGroupId groupId,
58 ProviderId producerName, 59 ProviderId producerName,
59 TunnelName tunnelName, 60 TunnelName tunnelName,
61 + Path path,
60 SparseAnnotations... annotations) { 62 SparseAnnotations... annotations) {
61 super(annotations); 63 super(annotations);
62 - checkNotNull(producerName, "producerName cannot be null");
63 - checkNotNull(src, "src cannot be null");
64 - checkNotNull(dst, "dst cannot be null");
65 - checkNotNull(type, "type cannot be null");
66 this.tunnelId = id; 64 this.tunnelId = id;
67 this.src = src; 65 this.src = src;
68 this.dst = dst; 66 this.dst = dst;
...@@ -70,6 +68,7 @@ public class DefaultTunnelDescription extends AbstractDescription ...@@ -70,6 +68,7 @@ public class DefaultTunnelDescription extends AbstractDescription
70 this.groupId = groupId; 68 this.groupId = groupId;
71 this.producerName = producerName; 69 this.producerName = producerName;
72 this.tunnelName = tunnelName; 70 this.tunnelName = tunnelName;
71 + this.path = path;
73 } 72 }
74 73
75 @Override 74 @Override
...@@ -107,6 +106,12 @@ public class DefaultTunnelDescription extends AbstractDescription ...@@ -107,6 +106,12 @@ public class DefaultTunnelDescription extends AbstractDescription
107 return tunnelName; 106 return tunnelName;
108 } 107 }
109 108
109 +
110 + @Override
111 + public Path path() {
112 + return path;
113 + }
114 +
110 @Override 115 @Override
111 public String toString() { 116 public String toString() {
112 return MoreObjects.toStringHelper(this) 117 return MoreObjects.toStringHelper(this)
...@@ -117,7 +122,7 @@ public class DefaultTunnelDescription extends AbstractDescription ...@@ -117,7 +122,7 @@ public class DefaultTunnelDescription extends AbstractDescription
117 .add("tunnelName", tunnelName()) 122 .add("tunnelName", tunnelName())
118 .add("producerName", producerName()) 123 .add("producerName", producerName())
119 .add("groupId", groupId()) 124 .add("groupId", groupId())
125 + .add("path", path)
120 .toString(); 126 .toString();
121 } 127 }
122 -
123 } 128 }
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -
17 package org.onosproject.incubator.net.tunnel; 16 package org.onosproject.incubator.net.tunnel;
18 17
19 import org.onosproject.core.DefaultGroupId; 18 import org.onosproject.core.DefaultGroupId;
20 import org.onosproject.net.Annotated; 19 import org.onosproject.net.Annotated;
21 import org.onosproject.net.NetworkResource; 20 import org.onosproject.net.NetworkResource;
21 +import org.onosproject.net.Path;
22 import org.onosproject.net.Provided; 22 import org.onosproject.net.Provided;
23 23
24 /** 24 /**
...@@ -144,4 +144,10 @@ public interface Tunnel extends Annotated, Provided, NetworkResource { ...@@ -144,4 +144,10 @@ public interface Tunnel extends Annotated, Provided, NetworkResource {
144 */ 144 */
145 NetworkResource resource(); 145 NetworkResource resource();
146 146
147 + /**
148 + * Returns the path of the tunnel.
149 + *
150 + * @return the path of the tunnel
151 + */
152 + Path path();
147 } 153 }
......
...@@ -13,14 +13,14 @@ ...@@ -13,14 +13,14 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -
17 package org.onosproject.incubator.net.tunnel; 16 package org.onosproject.incubator.net.tunnel;
18 17
19 import org.onosproject.core.DefaultGroupId; 18 import org.onosproject.core.DefaultGroupId;
19 +import org.onosproject.incubator.net.tunnel.Tunnel.Type;
20 import org.onosproject.net.Annotated; 20 import org.onosproject.net.Annotated;
21 import org.onosproject.net.Description; 21 import org.onosproject.net.Description;
22 +import org.onosproject.net.Path;
22 import org.onosproject.net.provider.ProviderId; 23 import org.onosproject.net.provider.ProviderId;
23 -import org.onosproject.incubator.net.tunnel.Tunnel.Type;
24 24
25 /** 25 /**
26 * Describes a tunnel. 26 * Describes a tunnel.
...@@ -75,4 +75,11 @@ public interface TunnelDescription extends Description, Annotated { ...@@ -75,4 +75,11 @@ public interface TunnelDescription extends Description, Annotated {
75 * @return Tunnel Name 75 * @return Tunnel Name
76 */ 76 */
77 TunnelName tunnelName(); 77 TunnelName tunnelName();
78 +
79 + /**
80 + * Returns the path of the tunnel.
81 + *
82 + * @return the path of the tunnel
83 + */
84 + Path path();
78 } 85 }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
16 16
17 package org.onosproject.incubator.net.tunnel; 17 package org.onosproject.incubator.net.tunnel;
18 18
19 -import static com.google.common.base.Preconditions.checkArgument;
20 19
21 /** 20 /**
22 * Representation of a Tunnel Id. 21 * Representation of a Tunnel Id.
...@@ -35,8 +34,7 @@ public final class TunnelId { ...@@ -35,8 +34,7 @@ public final class TunnelId {
35 } 34 }
36 35
37 public static TunnelId valueOf(String value) { 36 public static TunnelId valueOf(String value) {
38 - checkArgument(value.startsWith("0x")); 37 + return new TunnelId(Long.parseLong(value));
39 - return new TunnelId(Long.parseLong(value.substring("0x".length()), 16));
40 } 38 }
41 39
42 /** 40 /**
......
...@@ -102,4 +102,12 @@ public interface TunnelProvider extends Provider { ...@@ -102,4 +102,12 @@ public interface TunnelProvider extends Provider {
102 * @param tunnel tunnel information 102 * @param tunnel tunnel information
103 */ 103 */
104 void tunnelUpdated(TunnelDescription tunnel); 104 void tunnelUpdated(TunnelDescription tunnel);
105 +
106 + /**
107 + * Signals that the a tunnel was queried.
108 + * It's used by producers.
109 + * @param tunnelId tunnel identity
110 + * @return tunnel entity
111 + */
112 + Tunnel tunnelQueryById(TunnelId tunnelId);
105 } 113 }
......
...@@ -45,4 +45,12 @@ public interface TunnelProviderService extends ProviderService<TunnelProvider> { ...@@ -45,4 +45,12 @@ public interface TunnelProviderService extends ProviderService<TunnelProvider> {
45 */ 45 */
46 void tunnelUpdated(TunnelDescription tunnel); 46 void tunnelUpdated(TunnelDescription tunnel);
47 47
48 + /**
49 + * Signals that the a tunnel was queried.
50 + *
51 + * @param tunnelId tunnel identity
52 + * @return tunnel entity
53 + */
54 + Tunnel tunnelQueryById(TunnelId tunnelId);
55 +
48 } 56 }
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -
17 package org.onosproject.incubator.net.tunnel; 16 package org.onosproject.incubator.net.tunnel;
18 17
19 import java.util.Collection; 18 import java.util.Collection;
20 19
21 import org.onosproject.core.ApplicationId; 20 import org.onosproject.core.ApplicationId;
21 +import org.onosproject.incubator.net.tunnel.Tunnel.Type;
22 import org.onosproject.net.Annotations; 22 import org.onosproject.net.Annotations;
23 23
24 /** 24 /**
...@@ -83,7 +83,7 @@ public interface TunnelService { ...@@ -83,7 +83,7 @@ public interface TunnelService {
83 * @return collection of available Tunnels 83 * @return collection of available Tunnels
84 */ 84 */
85 Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, 85 Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src,
86 - TunnelEndPoint dst, Tunnel.Type type, 86 + TunnelEndPoint dst, Type type,
87 Annotations... annotations); 87 Annotations... annotations);
88 88
89 /** 89 /**
...@@ -122,7 +122,7 @@ public interface TunnelService { ...@@ -122,7 +122,7 @@ public interface TunnelService {
122 * @return success or fail 122 * @return success or fail
123 */ 123 */
124 boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, 124 boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src,
125 - TunnelEndPoint dst, Tunnel.Type type, 125 + TunnelEndPoint dst, Type type,
126 Annotations... annotations); 126 Annotations... annotations);
127 127
128 /** 128 /**
...@@ -160,7 +160,7 @@ public interface TunnelService { ...@@ -160,7 +160,7 @@ public interface TunnelService {
160 * @param type tunnel type 160 * @param type tunnel type
161 * @return Collection of tunnels 161 * @return Collection of tunnels
162 */ 162 */
163 - Collection<Tunnel> queryTunnel(Tunnel.Type type); 163 + Collection<Tunnel> queryTunnel(Type type);
164 164
165 /** 165 /**
166 * Returns all tunnels between source point and destination point. 166 * Returns all tunnels between source point and destination point.
...@@ -174,6 +174,13 @@ public interface TunnelService { ...@@ -174,6 +174,13 @@ public interface TunnelService {
174 /** 174 /**
175 * Returns all tunnels. 175 * Returns all tunnels.
176 * 176 *
177 + * @return Collection of tunnels
178 + */
179 + Collection<Tunnel> queryAllTunnels();
180 +
181 + /**
182 + * Returns all tunnels.
183 + *
177 * @return all tunnels 184 * @return all tunnels
178 */ 185 */
179 int tunnelCount(); 186 int tunnelCount();
......
...@@ -13,15 +13,14 @@ ...@@ -13,15 +13,14 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -
17 package org.onosproject.incubator.net.tunnel; 16 package org.onosproject.incubator.net.tunnel;
18 17
19 import java.util.Collection; 18 import java.util.Collection;
20 19
21 import org.onosproject.core.ApplicationId; 20 import org.onosproject.core.ApplicationId;
21 +import org.onosproject.incubator.net.tunnel.Tunnel.Type;
22 import org.onosproject.net.Annotations; 22 import org.onosproject.net.Annotations;
23 import org.onosproject.net.provider.ProviderId; 23 import org.onosproject.net.provider.ProviderId;
24 -import org.onosproject.incubator.net.tunnel.Tunnel.Type;
25 import org.onosproject.store.Store; 24 import org.onosproject.store.Store;
26 25
27 /** 26 /**
...@@ -215,6 +214,13 @@ public interface TunnelStore extends Store<TunnelEvent, TunnelStoreDelegate> { ...@@ -215,6 +214,13 @@ public interface TunnelStore extends Store<TunnelEvent, TunnelStoreDelegate> {
215 214
216 /** 215 /**
217 * Returns all tunnels. 216 * Returns all tunnels.
217 + *
218 + * @return Collection of tunnels
219 + */
220 + Collection<Tunnel> queryAllTunnels();
221 +
222 + /**
223 + * Returns all tunnels.
218 * @return all tunnels 224 * @return all tunnels
219 */ 225 */
220 int tunnelCount(); 226 int tunnelCount();
......
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 package org.onosproject.incubator.net.tunnel; 1 package org.onosproject.incubator.net.tunnel;
18 2
19 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; 3 import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
...@@ -50,13 +34,13 @@ public class DefaultTunnelTest { ...@@ -50,13 +34,13 @@ public class DefaultTunnelTest {
50 ProviderId producerName2 = new ProviderId("producer2", "13"); 34 ProviderId producerName2 = new ProviderId("producer2", "13");
51 Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, 35 Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
52 Tunnel.State.ACTIVE, groupId, tunnelId, 36 Tunnel.State.ACTIVE, groupId, tunnelId,
53 - tunnelName); 37 + tunnelName, null);
54 Tunnel p2 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, 38 Tunnel p2 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
55 Tunnel.State.ACTIVE, groupId, tunnelId, 39 Tunnel.State.ACTIVE, groupId, tunnelId,
56 - tunnelName); 40 + tunnelName, null);
57 Tunnel p3 = new DefaultTunnel(producerName2, src, dst, Tunnel.Type.OCH, 41 Tunnel p3 = new DefaultTunnel(producerName2, src, dst, Tunnel.Type.OCH,
58 Tunnel.State.ACTIVE, groupId, tunnelId, 42 Tunnel.State.ACTIVE, groupId, tunnelId,
59 - tunnelName); 43 + tunnelName, null);
60 new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3) 44 new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)
61 .testEquals(); 45 .testEquals();
62 } 46 }
......
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 package org.onosproject.incubator.net.tunnel; 1 package org.onosproject.incubator.net.tunnel;
18 2
19 import static org.hamcrest.MatcherAssert.assertThat; 3 import static org.hamcrest.MatcherAssert.assertThat;
...@@ -53,7 +37,7 @@ public class TunnelEventTest { ...@@ -53,7 +37,7 @@ public class TunnelEventTest {
53 ProviderId producerName1 = new ProviderId("producer1", "13"); 37 ProviderId producerName1 = new ProviderId("producer1", "13");
54 Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, 38 Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN,
55 Tunnel.State.ACTIVE, groupId, tunnelId, 39 Tunnel.State.ACTIVE, groupId, tunnelId,
56 - tunnelName); 40 + tunnelName, null);
57 TunnelEvent e1 = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, p1); 41 TunnelEvent e1 = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, p1);
58 assertThat(e1, is(notNullValue())); 42 assertThat(e1, is(notNullValue()));
59 assertThat(e1.type(), is(TunnelEvent.Type.TUNNEL_ADDED)); 43 assertThat(e1.type(), is(TunnelEvent.Type.TUNNEL_ADDED));
......
...@@ -91,9 +91,9 @@ public class LabelResourceManager ...@@ -91,9 +91,9 @@ public class LabelResourceManager
91 checkNotNull(deviceId, "deviceId is not null"); 91 checkNotNull(deviceId, "deviceId is not null");
92 checkNotNull(beginLabel, "beginLabel is not null"); 92 checkNotNull(beginLabel, "beginLabel is not null");
93 checkNotNull(endLabel, "beginLabel is not null"); 93 checkNotNull(endLabel, "beginLabel is not null");
94 - checkArgument(beginLabel.labelId() < 0 || endLabel.labelId() < 0, 94 + checkArgument(beginLabel.labelId() >= 0 || endLabel.labelId() >= 0,
95 "The value of beginLabel and the value of endLabel must be both positive number."); 95 "The value of beginLabel and the value of endLabel must be both positive number.");
96 - checkArgument(beginLabel.labelId() > endLabel.labelId(), 96 + checkArgument(beginLabel.labelId() <= endLabel.labelId(),
97 "The value of endLabel must be greater than the value of endLabel."); 97 "The value of endLabel must be greater than the value of endLabel.");
98 return store.createDevicePool(deviceId, beginLabel, endLabel); 98 return store.createDevicePool(deviceId, beginLabel, endLabel);
99 } 99 }
...@@ -103,10 +103,10 @@ public class LabelResourceManager ...@@ -103,10 +103,10 @@ public class LabelResourceManager
103 LabelResourceId endLabel) { 103 LabelResourceId endLabel) {
104 checkNotNull(beginLabel, "beginLabel is not null"); 104 checkNotNull(beginLabel, "beginLabel is not null");
105 checkNotNull(endLabel, "beginLabel is not null"); 105 checkNotNull(endLabel, "beginLabel is not null");
106 - checkArgument(beginLabel.labelId() < 0 || endLabel.labelId() < 0, 106 + checkArgument(beginLabel.labelId() >= 0 && endLabel.labelId() >= 0,
107 - "The value of beginLabel and the value of endLabel must be both positive number."); 107 + "The value of beginLabel and the value of endLabel must be both positive number.");
108 - checkArgument(beginLabel.labelId() > endLabel.labelId(), 108 + checkArgument(beginLabel.labelId() <= endLabel.labelId(),
109 - "The value of endLabel must be greater than the value of endLabel."); 109 + "The value of endLabel must be greater than the value of endLabel.");
110 return store.createGlobalPool(beginLabel, endLabel); 110 return store.createGlobalPool(beginLabel, endLabel);
111 } 111 }
112 112
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -
17 package org.onosproject.incubator.net.tunnel.impl; 16 package org.onosproject.incubator.net.tunnel.impl;
18 17
19 import static com.google.common.base.Preconditions.checkNotNull; 18 import static com.google.common.base.Preconditions.checkNotNull;
...@@ -31,14 +30,9 @@ import org.apache.felix.scr.annotations.Service; ...@@ -31,14 +30,9 @@ import org.apache.felix.scr.annotations.Service;
31 import org.onosproject.core.ApplicationId; 30 import org.onosproject.core.ApplicationId;
32 import org.onosproject.event.EventDeliveryService; 31 import org.onosproject.event.EventDeliveryService;
33 import org.onosproject.event.ListenerRegistry; 32 import org.onosproject.event.ListenerRegistry;
34 -import org.onosproject.net.Annotations;
35 -import org.onosproject.net.Path;
36 -import org.onosproject.net.provider.AbstractProviderRegistry;
37 -import org.onosproject.net.provider.AbstractProviderService;
38 -import org.onosproject.net.provider.ProviderId;
39 import org.onosproject.incubator.net.tunnel.DefaultTunnel; 33 import org.onosproject.incubator.net.tunnel.DefaultTunnel;
40 -import org.onosproject.incubator.net.tunnel.Tunnel;
41 import org.onosproject.incubator.net.tunnel.Tunnel.Type; 34 import org.onosproject.incubator.net.tunnel.Tunnel.Type;
35 +import org.onosproject.incubator.net.tunnel.Tunnel;
42 import org.onosproject.incubator.net.tunnel.TunnelAdminService; 36 import org.onosproject.incubator.net.tunnel.TunnelAdminService;
43 import org.onosproject.incubator.net.tunnel.TunnelDescription; 37 import org.onosproject.incubator.net.tunnel.TunnelDescription;
44 import org.onosproject.incubator.net.tunnel.TunnelEndPoint; 38 import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
...@@ -53,6 +47,11 @@ import org.onosproject.incubator.net.tunnel.TunnelService; ...@@ -53,6 +47,11 @@ import org.onosproject.incubator.net.tunnel.TunnelService;
53 import org.onosproject.incubator.net.tunnel.TunnelStore; 47 import org.onosproject.incubator.net.tunnel.TunnelStore;
54 import org.onosproject.incubator.net.tunnel.TunnelStoreDelegate; 48 import org.onosproject.incubator.net.tunnel.TunnelStoreDelegate;
55 import org.onosproject.incubator.net.tunnel.TunnelSubscription; 49 import org.onosproject.incubator.net.tunnel.TunnelSubscription;
50 +import org.onosproject.net.Annotations;
51 +import org.onosproject.net.Path;
52 +import org.onosproject.net.provider.AbstractProviderRegistry;
53 +import org.onosproject.net.provider.AbstractProviderService;
54 +import org.onosproject.net.provider.ProviderId;
56 import org.slf4j.Logger; 55 import org.slf4j.Logger;
57 56
58 /** 57 /**
...@@ -277,6 +276,12 @@ public class TunnelManager ...@@ -277,6 +276,12 @@ public class TunnelManager
277 return store.queryTunnel(src, dst); 276 return store.queryTunnel(src, dst);
278 } 277 }
279 278
279 +
280 + @Override
281 + public Collection<Tunnel> queryAllTunnels() {
282 + return store.queryAllTunnels();
283 + }
284 +
280 @Override 285 @Override
281 public int tunnelCount() { 286 public int tunnelCount() {
282 return store.tunnelCount(); 287 return store.tunnelCount();
...@@ -313,6 +318,7 @@ public class TunnelManager ...@@ -313,6 +318,7 @@ public class TunnelManager
313 tunnel.groupId(), 318 tunnel.groupId(),
314 tunnel.id(), 319 tunnel.id(),
315 tunnel.tunnelName(), 320 tunnel.tunnelName(),
321 + tunnel.path(),
316 tunnel.annotations()); 322 tunnel.annotations());
317 return store.createOrUpdateTunnel(storedTunnel); 323 return store.createOrUpdateTunnel(storedTunnel);
318 } 324 }
...@@ -325,6 +331,7 @@ public class TunnelManager ...@@ -325,6 +331,7 @@ public class TunnelManager
325 tunnel.groupId(), 331 tunnel.groupId(),
326 tunnel.id(), 332 tunnel.id(),
327 tunnel.tunnelName(), 333 tunnel.tunnelName(),
334 + tunnel.path(),
328 tunnel.annotations()); 335 tunnel.annotations());
329 store.createOrUpdateTunnel(storedTunnel); 336 store.createOrUpdateTunnel(storedTunnel);
330 } 337 }
...@@ -333,18 +340,28 @@ public class TunnelManager ...@@ -333,18 +340,28 @@ public class TunnelManager
333 public void tunnelRemoved(TunnelDescription tunnel) { 340 public void tunnelRemoved(TunnelDescription tunnel) {
334 if (tunnel.id() != null) { 341 if (tunnel.id() != null) {
335 store.deleteTunnel(tunnel.id()); 342 store.deleteTunnel(tunnel.id());
343 + return;
336 } 344 }
337 if (tunnel.src() != null && tunnel.dst() != null 345 if (tunnel.src() != null && tunnel.dst() != null
338 && tunnel.type() != null) { 346 && tunnel.type() != null) {
339 store.deleteTunnel(tunnel.src(), tunnel.dst(), tunnel.type(), 347 store.deleteTunnel(tunnel.src(), tunnel.dst(), tunnel.type(),
340 provider().id()); 348 provider().id());
349 + return;
341 } 350 }
342 if (tunnel.src() != null && tunnel.dst() != null 351 if (tunnel.src() != null && tunnel.dst() != null
343 && tunnel.type() == null) { 352 && tunnel.type() == null) {
344 store.deleteTunnel(tunnel.src(), tunnel.dst(), provider().id()); 353 store.deleteTunnel(tunnel.src(), tunnel.dst(), provider().id());
354 + return;
345 } 355 }
346 } 356 }
347 357
358 +
359 + @Override
360 + public Tunnel tunnelQueryById(TunnelId tunnelId) {
361 + return store.queryTunnel(tunnelId);
362 + }
363 +
364 +
348 } 365 }
349 366
350 private class InternalStoreDelegate implements TunnelStoreDelegate { 367 private class InternalStoreDelegate implements TunnelStoreDelegate {
...@@ -355,4 +372,5 @@ public class TunnelManager ...@@ -355,4 +372,5 @@ public class TunnelManager
355 } 372 }
356 } 373 }
357 } 374 }
375 +
358 } 376 }
......
1 /* 1 /*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2014-2015 Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -
17 package org.onosproject.incubator.store.tunnel.impl; 16 package org.onosproject.incubator.store.tunnel.impl;
18 17
19 import static org.slf4j.LoggerFactory.getLogger; 18 import static org.slf4j.LoggerFactory.getLogger;
...@@ -37,8 +36,6 @@ import org.onosproject.cluster.ClusterService; ...@@ -37,8 +36,6 @@ import org.onosproject.cluster.ClusterService;
37 import org.onosproject.core.ApplicationId; 36 import org.onosproject.core.ApplicationId;
38 import org.onosproject.core.CoreService; 37 import org.onosproject.core.CoreService;
39 import org.onosproject.core.IdGenerator; 38 import org.onosproject.core.IdGenerator;
40 -import org.onosproject.net.Annotations;
41 -import org.onosproject.net.provider.ProviderId;
42 import org.onosproject.incubator.net.tunnel.DefaultTunnel; 39 import org.onosproject.incubator.net.tunnel.DefaultTunnel;
43 import org.onosproject.incubator.net.tunnel.Tunnel; 40 import org.onosproject.incubator.net.tunnel.Tunnel;
44 import org.onosproject.incubator.net.tunnel.Tunnel.Type; 41 import org.onosproject.incubator.net.tunnel.Tunnel.Type;
...@@ -49,6 +46,10 @@ import org.onosproject.incubator.net.tunnel.TunnelName; ...@@ -49,6 +46,10 @@ import org.onosproject.incubator.net.tunnel.TunnelName;
49 import org.onosproject.incubator.net.tunnel.TunnelStore; 46 import org.onosproject.incubator.net.tunnel.TunnelStore;
50 import org.onosproject.incubator.net.tunnel.TunnelStoreDelegate; 47 import org.onosproject.incubator.net.tunnel.TunnelStoreDelegate;
51 import org.onosproject.incubator.net.tunnel.TunnelSubscription; 48 import org.onosproject.incubator.net.tunnel.TunnelSubscription;
49 +import org.onosproject.net.Annotations;
50 +import org.onosproject.net.DefaultAnnotations;
51 +import org.onosproject.net.SparseAnnotations;
52 +import org.onosproject.net.provider.ProviderId;
52 import org.onosproject.store.AbstractStore; 53 import org.onosproject.store.AbstractStore;
53 import org.onosproject.store.app.GossipApplicationStore.InternalState; 54 import org.onosproject.store.app.GossipApplicationStore.InternalState;
54 import org.onosproject.store.cluster.messaging.ClusterCommunicationService; 55 import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
...@@ -126,6 +127,10 @@ public class DistributedTunnelStore ...@@ -126,6 +127,10 @@ public class DistributedTunnelStore
126 .<Tunnel.Type, Set<TunnelId>>eventuallyConsistentMapBuilder() 127 .<Tunnel.Type, Set<TunnelId>>eventuallyConsistentMapBuilder()
127 .withName("type_tunnel").withSerializer(serializer) 128 .withName("type_tunnel").withSerializer(serializer)
128 .withClockService(new WallclockClockManager<>()).build(); 129 .withClockService(new WallclockClockManager<>()).build();
130 + orderRelationship = storageService
131 + .<ApplicationId, Set<TunnelSubscription>>eventuallyConsistentMapBuilder()
132 + .withName("type_tunnel").withSerializer(serializer)
133 + .withClockService(new WallclockClockManager<>()).build();
129 idGenerator = coreService.getIdGenerator(runnelOpTopoic); 134 idGenerator = coreService.getIdGenerator(runnelOpTopoic);
130 log.info("Started"); 135 log.info("Started");
131 } 136 }
...@@ -148,13 +153,15 @@ public class DistributedTunnelStore ...@@ -148,13 +153,15 @@ public class DistributedTunnelStore
148 log.info("This tunnel[" + tunnel.tunnelId() + "] is not available."); 153 log.info("This tunnel[" + tunnel.tunnelId() + "] is not available.");
149 return tunnel.tunnelId(); 154 return tunnel.tunnelId();
150 } 155 }
151 - Tunnel newT = new DefaultTunnel(tunnel.providerId(), tunnel.src(), 156 + DefaultAnnotations oldAnno = (DefaultAnnotations) old.annotations();
152 - tunnel.dst(), tunnel.type(), 157 + SparseAnnotations newAnno = (SparseAnnotations) tunnel.annotations();
153 - tunnel.state(), tunnel.groupId(), 158 + Tunnel newT = new DefaultTunnel(old.providerId(), old.src(),
159 + old.dst(), old.type(),
160 + old.state(), old.groupId(),
154 old.tunnelId(), 161 old.tunnelId(),
155 - tunnel.tunnelName(), 162 + old.tunnelName(),
156 - tunnel.annotations()); 163 + old.path(),
157 - tunnelIdAsKeyStore.remove(tunnel.tunnelId()); 164 + DefaultAnnotations.merge(oldAnno, newAnno));
158 tunnelIdAsKeyStore.put(tunnel.tunnelId(), newT); 165 tunnelIdAsKeyStore.put(tunnel.tunnelId(), newT);
159 TunnelEvent event = new TunnelEvent( 166 TunnelEvent event = new TunnelEvent(
160 TunnelEvent.Type.TUNNEL_UPDATED, 167 TunnelEvent.Type.TUNNEL_UPDATED,
...@@ -168,6 +175,7 @@ public class DistributedTunnelStore ...@@ -168,6 +175,7 @@ public class DistributedTunnelStore
168 tunnel.state(), tunnel.groupId(), 175 tunnel.state(), tunnel.groupId(),
169 tunnelId, 176 tunnelId,
170 tunnel.tunnelName(), 177 tunnel.tunnelName(),
178 + tunnel.path(),
171 tunnel.annotations()); 179 tunnel.annotations());
172 TunnelKey key = TunnelKey.tunnelKey(tunnel.src(), tunnel.dst()); 180 TunnelKey key = TunnelKey.tunnelKey(tunnel.src(), tunnel.dst());
173 tunnelIdAsKeyStore.put(tunnelId, newT); 181 tunnelIdAsKeyStore.put(tunnelId, newT);
...@@ -463,6 +471,11 @@ public class DistributedTunnelStore ...@@ -463,6 +471,11 @@ public class DistributedTunnelStore
463 } 471 }
464 472
465 @Override 473 @Override
474 + public Collection<Tunnel> queryAllTunnels() {
475 + return tunnelIdAsKeyStore.values();
476 + }
477 +
478 + @Override
466 public int tunnelCount() { 479 public int tunnelCount() {
467 return tunnelIdAsKeyStore.size(); 480 return tunnelIdAsKeyStore.size();
468 } 481 }
...@@ -515,5 +528,4 @@ public class DistributedTunnelStore ...@@ -515,5 +528,4 @@ public class DistributedTunnelStore
515 .add("dst", dst).toString(); 528 .add("dst", dst).toString();
516 } 529 }
517 } 530 }
518 -
519 } 531 }
......
...@@ -67,14 +67,12 @@ public class DefaultTunnelProvider extends AbstractProvider ...@@ -67,14 +67,12 @@ public class DefaultTunnelProvider extends AbstractProvider
67 67
68 @Activate 68 @Activate
69 public void activate(ComponentContext context) { 69 public void activate(ComponentContext context) {
70 - cfgService.registerProperties(getClass());
71 service = tunnelProviderRegistry.register(this); 70 service = tunnelProviderRegistry.register(this);
72 log.info("Started"); 71 log.info("Started");
73 } 72 }
74 73
75 @Deactivate 74 @Deactivate
76 public void deactivate(ComponentContext context) { 75 public void deactivate(ComponentContext context) {
77 - cfgService.unregisterProperties(getClass(), false);
78 tunnelProviderRegistry.unregister(this); 76 tunnelProviderRegistry.unregister(this);
79 log.info("Stopped"); 77 log.info("Stopped");
80 } 78 }
...@@ -130,4 +128,9 @@ public class DefaultTunnelProvider extends AbstractProvider ...@@ -130,4 +128,9 @@ public class DefaultTunnelProvider extends AbstractProvider
130 service.tunnelUpdated(tunnel); 128 service.tunnelUpdated(tunnel);
131 } 129 }
132 130
131 + @Override
132 + public Tunnel tunnelQueryById(TunnelId tunnelId) {
133 + return service.tunnelQueryById(tunnelId);
134 + }
135 +
133 } 136 }
......
...@@ -15,20 +15,14 @@ ...@@ -15,20 +15,14 @@
15 */ 15 */
16 package org.onosproject.provider.tunnel.cli; 16 package org.onosproject.provider.tunnel.cli;
17 17
18 -import static com.google.common.base.Preconditions.checkArgument;
19 -
20 import java.util.Optional; 18 import java.util.Optional;
21 19
22 import org.apache.karaf.shell.commands.Argument; 20 import org.apache.karaf.shell.commands.Argument;
23 import org.apache.karaf.shell.commands.Command; 21 import org.apache.karaf.shell.commands.Command;
22 +import org.apache.karaf.shell.commands.Option;
24 import org.onlab.packet.IpAddress; 23 import org.onlab.packet.IpAddress;
25 import org.onosproject.cli.AbstractShellCommand; 24 import org.onosproject.cli.AbstractShellCommand;
26 import org.onosproject.core.DefaultGroupId; 25 import org.onosproject.core.DefaultGroupId;
27 -import org.onosproject.net.DefaultAnnotations;
28 -import org.onosproject.net.DeviceId;
29 -import org.onosproject.net.PortNumber;
30 -import org.onosproject.net.SparseAnnotations;
31 -import org.onosproject.net.provider.ProviderId;
32 import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint; 26 import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
33 import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription; 27 import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
34 import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; 28 import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
...@@ -40,40 +34,45 @@ import org.onosproject.incubator.net.tunnel.TunnelEndPoint; ...@@ -40,40 +34,45 @@ import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
40 import org.onosproject.incubator.net.tunnel.TunnelId; 34 import org.onosproject.incubator.net.tunnel.TunnelId;
41 import org.onosproject.incubator.net.tunnel.TunnelName; 35 import org.onosproject.incubator.net.tunnel.TunnelName;
42 import org.onosproject.incubator.net.tunnel.TunnelProvider; 36 import org.onosproject.incubator.net.tunnel.TunnelProvider;
37 +import org.onosproject.net.DefaultAnnotations;
38 +import org.onosproject.net.DeviceId;
39 +import org.onosproject.net.PortNumber;
40 +import org.onosproject.net.SparseAnnotations;
41 +import org.onosproject.net.provider.ProviderId;
43 42
44 /** 43 /**
45 * Supports for creating a tunnel by using IP address and optical as tunnel end 44 * Supports for creating a tunnel by using IP address and optical as tunnel end
46 * point. 45 * point.
47 */ 46 */
48 -@Command(scope = "onos", name = "create-tunnels", 47 +@Command(scope = "onos", name = "tunnel-create",
49 description = "Supports for creating a tunnel by using IP address and optical as tunnel end point now.") 48 description = "Supports for creating a tunnel by using IP address and optical as tunnel end point now.")
50 -public class CreateTunnelCommand extends AbstractShellCommand { 49 +public class TunnelCreateCommand extends AbstractShellCommand {
51 50
52 @Argument(index = 0, name = "src", description = "Source tunnel point." 51 @Argument(index = 0, name = "src", description = "Source tunnel point."
53 + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." 52 + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
54 - + " If creates a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." 53 + + " If creates a ODUK or OCH or VLAN type tunnel, the formatter of this argument is DeviceId-PortNumber."
55 + " Otherwise src means IP address.", required = true, multiValued = false) 54 + " Otherwise src means IP address.", required = true, multiValued = false)
56 String src = null; 55 String src = null;
57 56
58 @Argument(index = 1, name = "dst", description = "Destination tunnel point." 57 @Argument(index = 1, name = "dst", description = "Destination tunnel point."
59 + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." 58 + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
60 - + " If creates a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." 59 + + " If creates a ODUK or OCH or VLAN type tunnel, the formatter of this argument is DeviceId-PortNumber."
61 + " Otherwise dst means IP address.", required = true, multiValued = false) 60 + " Otherwise dst means IP address.", required = true, multiValued = false)
62 String dst = null; 61 String dst = null;
63 @Argument(index = 2, name = "type", description = "The type of tunnels," 62 @Argument(index = 2, name = "type", description = "The type of tunnels,"
64 + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false) 63 + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false)
65 String type = null; 64 String type = null;
66 - @Argument(index = 3, name = "groupId", 65 + @Option(name = "-g", aliases = "--groupId",
67 - description = "Group flow table id which a tunnel match up", required = true, multiValued = false) 66 + description = "Group flow table id which a tunnel match up", required = false, multiValued = false)
68 String groupId = null; 67 String groupId = null;
69 68
70 - @Argument(index = 4, name = "tunnelName", 69 + @Option(name = "-n", aliases = "--tunnelName",
71 description = "The name of tunnels", required = false, multiValued = false) 70 description = "The name of tunnels", required = false, multiValued = false)
72 String tunnelName = null; 71 String tunnelName = null;
73 72
74 - @Argument(index = 5, name = "bandWith", 73 + @Option(name = "-b", aliases = "--bandwidth",
75 - description = "The bandWith attribute of tunnel", required = false, multiValued = false) 74 + description = "The bandwidth attribute of tunnel", required = false, multiValued = false)
76 - String bandWith = null; 75 + String bandwidth = null;
77 76
78 private static final String FMT = "The tunnel identity is %s"; 77 private static final String FMT = "The tunnel identity is %s";
79 78
...@@ -91,8 +90,30 @@ public class CreateTunnelCommand extends AbstractShellCommand { ...@@ -91,8 +90,30 @@ public class CreateTunnelCommand extends AbstractShellCommand {
91 dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); 90 dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
92 } else if ("VLAN".equals(type)) { 91 } else if ("VLAN".equals(type)) {
93 trueType = Tunnel.Type.VLAN; 92 trueType = Tunnel.Type.VLAN;
94 - srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); 93 + String[] srcArray = src.split("-");
95 - dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); 94 + String[] dstArray = dst.split("-");
95 + srcPoint = new DefaultOpticalTunnelEndPoint(
96 + producerName,
97 + Optional.of(DeviceId
98 + .deviceId(srcArray[0])),
99 + Optional.of(PortNumber
100 + .portNumber(srcArray[1])),
101 + null,
102 + null,
103 + OpticalLogicId
104 + .logicId(0),
105 + true);
106 + dstPoint = new DefaultOpticalTunnelEndPoint(
107 + producerName,
108 + Optional.of(DeviceId
109 + .deviceId(dstArray[0])),
110 + Optional.of(PortNumber
111 + .portNumber(dstArray[1])),
112 + null,
113 + null,
114 + OpticalLogicId
115 + .logicId(0),
116 + true);
96 } else if ("VXLAN".equals(type)) { 117 } else if ("VXLAN".equals(type)) {
97 trueType = Tunnel.Type.VXLAN; 118 trueType = Tunnel.Type.VXLAN;
98 srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); 119 srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
...@@ -103,10 +124,8 @@ public class CreateTunnelCommand extends AbstractShellCommand { ...@@ -103,10 +124,8 @@ public class CreateTunnelCommand extends AbstractShellCommand {
103 dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); 124 dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
104 } else if ("ODUK".equals(type)) { 125 } else if ("ODUK".equals(type)) {
105 trueType = Tunnel.Type.ODUK; 126 trueType = Tunnel.Type.ODUK;
106 - String[] srcArray = src.split("||"); 127 + String[] srcArray = src.split("-");
107 - checkArgument(srcArray.length < 2, "Illegal src formatter."); 128 + String[] dstArray = dst.split("-");
108 - String[] dstArray = dst.split("||");
109 - checkArgument(dstArray.length < 2, "Illegal dst formatter.");
110 srcPoint = new DefaultOpticalTunnelEndPoint( 129 srcPoint = new DefaultOpticalTunnelEndPoint(
111 producerName, 130 producerName,
112 Optional.of(DeviceId 131 Optional.of(DeviceId
...@@ -140,7 +159,7 @@ public class CreateTunnelCommand extends AbstractShellCommand { ...@@ -140,7 +159,7 @@ public class CreateTunnelCommand extends AbstractShellCommand {
140 Optional.of(PortNumber 159 Optional.of(PortNumber
141 .portNumber(srcArray[1])), 160 .portNumber(srcArray[1])),
142 null, 161 null,
143 - OpticalTunnelEndPoint.Type.LAMBDA, 162 + OpticalTunnelEndPoint.Type.TIMESLOT,
144 OpticalLogicId 163 OpticalLogicId
145 .logicId(0), 164 .logicId(0),
146 true); 165 true);
...@@ -151,7 +170,7 @@ public class CreateTunnelCommand extends AbstractShellCommand { ...@@ -151,7 +170,7 @@ public class CreateTunnelCommand extends AbstractShellCommand {
151 Optional.of(PortNumber 170 Optional.of(PortNumber
152 .portNumber(dstArray[1])), 171 .portNumber(dstArray[1])),
153 null, 172 null,
154 - OpticalTunnelEndPoint.Type.LAMBDA, 173 + OpticalTunnelEndPoint.Type.TIMESLOT,
155 OpticalLogicId 174 OpticalLogicId
156 .logicId(0), 175 .logicId(0),
157 true); 176 true);
...@@ -162,7 +181,7 @@ public class CreateTunnelCommand extends AbstractShellCommand { ...@@ -162,7 +181,7 @@ public class CreateTunnelCommand extends AbstractShellCommand {
162 181
163 SparseAnnotations annotations = DefaultAnnotations 182 SparseAnnotations annotations = DefaultAnnotations
164 .builder() 183 .builder()
165 - .set("bandWith", bandWith == null && "".equals(bandWith) ? "0" : bandWith) 184 + .set("bandwidth", bandwidth == null && "".equals(bandwidth) ? "0" : bandwidth)
166 .build(); 185 .build();
167 TunnelDescription tunnel = new DefaultTunnelDescription( 186 TunnelDescription tunnel = new DefaultTunnelDescription(
168 null, 187 null,
...@@ -175,6 +194,7 @@ public class CreateTunnelCommand extends AbstractShellCommand { ...@@ -175,6 +194,7 @@ public class CreateTunnelCommand extends AbstractShellCommand {
175 producerName, 194 producerName,
176 TunnelName 195 TunnelName
177 .tunnelName(tunnelName), 196 .tunnelName(tunnelName),
197 + null,
178 annotations); 198 annotations);
179 TunnelId tunnelId = service.tunnelAdded(tunnel); 199 TunnelId tunnelId = service.tunnelAdded(tunnel);
180 print(FMT, tunnelId.id()); 200 print(FMT, tunnelId.id());
......
1 +/*
2 + * Copyright 2014-2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.provider.tunnel.cli;
17 +
18 +import org.apache.karaf.shell.commands.Argument;
19 +import org.apache.karaf.shell.commands.Command;
20 +import org.apache.karaf.shell.commands.Option;
21 +import org.onosproject.cli.AbstractShellCommand;
22 +import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
23 +import org.onosproject.incubator.net.tunnel.TunnelDescription;
24 +import org.onosproject.incubator.net.tunnel.TunnelId;
25 +import org.onosproject.incubator.net.tunnel.TunnelProvider;
26 +import org.onosproject.net.DefaultAnnotations;
27 +import org.onosproject.net.SparseAnnotations;
28 +
29 +/**
30 + * Supports for updating a tunnel by tunnel identity.
31 + * It's used by producers.
32 + */
33 +@Command(scope = "onos", name = "tunnel-update",
34 +description = "Supports for updating a tunnel by tunnel identity."
35 + + " It's used by producers.")
36 +public class TunnelUpdateCommand extends AbstractShellCommand {
37 + @Argument(index = 0, name = "tunnelId", description = "the tunnel identity.",
38 + required = true, multiValued = false)
39 + String tunnelId = null;
40 +
41 + @Option(name = "-b", aliases = "--bandwidth",
42 + description = "The bandwidth attribute of tunnel", required = false, multiValued = false)
43 + String bandwidth = null;
44 +
45 + @Override
46 + protected void execute() {
47 + TunnelProvider service = get(TunnelProvider.class);
48 + TunnelId id = TunnelId.valueOf(tunnelId);
49 + SparseAnnotations annotations = DefaultAnnotations
50 + .builder()
51 + .set("bandwidth", bandwidth)
52 + .build();
53 + TunnelDescription tunnel = new DefaultTunnelDescription(id, null,
54 + null,
55 + null, null,
56 + null,
57 + null, null, annotations);
58 + service.tunnelUpdated(tunnel);
59 + }
60 +
61 +}
...@@ -17,10 +17,13 @@ ...@@ -17,10 +17,13 @@
17 17
18 <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> 18 <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
19 <command> 19 <command>
20 - <action class="org.onosproject.provider.tunnel.cli.CreateTunnelCommand"/> 20 + <action class="org.onosproject.provider.tunnel.cli.TunnelCreateCommand"/>
21 </command> 21 </command>
22 <command> 22 <command>
23 - <action class="org.onosproject.provider.tunnel.cli.RemoveTunnelCommand"/> 23 + <action class="org.onosproject.provider.tunnel.cli.TunnelRemoveCommand"/>
24 + </command>
25 + <command>
26 + <action class="org.onosproject.provider.tunnel.cli.TunnelUpdateCommand"/>
24 </command> 27 </command>
25 </command-bundle> 28 </command-bundle>
26 </blueprint> 29 </blueprint>
......