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
1050 additions
and
580 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; | ... | ... |
... | @@ -16,97 +16,189 @@ | ... | @@ -16,97 +16,189 @@ |
16 | package org.onosproject.cli.net; | 16 | package org.onosproject.cli.net; |
17 | 17 | ||
18 | import java.util.Collection; | 18 | import java.util.Collection; |
19 | +import java.util.HashSet; | ||
19 | import java.util.Optional; | 20 | import java.util.Optional; |
20 | 21 | ||
21 | import org.apache.karaf.shell.commands.Argument; | 22 | import org.apache.karaf.shell.commands.Argument; |
22 | import org.apache.karaf.shell.commands.Command; | 23 | import org.apache.karaf.shell.commands.Command; |
24 | +import org.apache.karaf.shell.commands.Option; | ||
23 | import org.onlab.packet.IpAddress; | 25 | import org.onlab.packet.IpAddress; |
24 | import org.onosproject.cli.AbstractShellCommand; | 26 | import org.onosproject.cli.AbstractShellCommand; |
25 | import org.onosproject.core.ApplicationId; | 27 | import org.onosproject.core.ApplicationId; |
26 | import org.onosproject.core.DefaultApplicationId; | 28 | import org.onosproject.core.DefaultApplicationId; |
27 | -import org.onosproject.net.DeviceId; | ||
28 | -import org.onosproject.net.PortNumber; | ||
29 | -import org.onosproject.net.provider.ProviderId; | ||
30 | import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint; | 29 | import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint; |
31 | import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; | 30 | import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; |
32 | import org.onosproject.incubator.net.tunnel.OpticalLogicId; | 31 | import org.onosproject.incubator.net.tunnel.OpticalLogicId; |
33 | import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint; | 32 | import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint; |
34 | import org.onosproject.incubator.net.tunnel.Tunnel; | 33 | import org.onosproject.incubator.net.tunnel.Tunnel; |
35 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; | 34 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; |
35 | +import org.onosproject.incubator.net.tunnel.TunnelId; | ||
36 | +import org.onosproject.incubator.net.tunnel.TunnelName; | ||
36 | import org.onosproject.incubator.net.tunnel.TunnelService; | 37 | import org.onosproject.incubator.net.tunnel.TunnelService; |
38 | +import org.onosproject.net.DeviceId; | ||
39 | +import org.onosproject.net.PortNumber; | ||
40 | +import org.onosproject.net.provider.ProviderId; | ||
37 | 41 | ||
38 | /** | 42 | /** |
39 | - * Borrows all tunnels between specific source tunnel end point and specific | 43 | + * Borrows tunnels. It's used by consumers. |
40 | - * destination tunnel end point. Supports for IP address and optical as tunnel end point now. It's used by consumers. | ||
41 | */ | 44 | */ |
42 | -@Command(scope = "onos", name = "borrow-tunnels", | 45 | +@Command(scope = "onos", name = "tunnel-borrow", description = "Borrows tunnels. It's used by consumers.") |
43 | -description = "Borrows all tunnels between specific source tunnel end point" | ||
44 | - + " and specific destination tunnel end point." | ||
45 | - + " Supports for IP address and optical as tunnel end point now. It's used by consumers.") | ||
46 | public class TunnelBorrowCommand extends AbstractShellCommand { | 46 | public class TunnelBorrowCommand extends AbstractShellCommand { |
47 | - @Argument(index = 0, name = "consumerId", description = "consumer id means application id.", | 47 | + |
48 | - required = true, multiValued = false) | 48 | + @Argument(index = 0, name = "consumerId", |
49 | + description = "consumer id means application id.", required = true, multiValued = false) | ||
49 | String consumerId = null; | 50 | String consumerId = null; |
50 | - @Argument(index = 1, name = "src", description = "Source tunnel point." | 51 | + |
52 | + @Option(name = "-s", aliases = "--src", description = "Source tunnel point." | ||
51 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." | 53 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." |
52 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." | 54 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." |
53 | - + " Otherwise src means IP address.", required = true, multiValued = false) | 55 | + + " Otherwise src means IP address.", required = false, multiValued = false) |
54 | String src = null; | 56 | String src = null; |
55 | - @Argument(index = 2, name = "dst", description = "Destination tunnel point." | 57 | + |
58 | + @Option(name = "-d", aliases = "--dst", description = "Destination tunnel point." | ||
56 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." | 59 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." |
57 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." | 60 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." |
58 | - + " Otherwise dst means IP address.", required = true, multiValued = false) | 61 | + + " Otherwise dst means IP address.", required = false, multiValued = false) |
59 | String dst = null; | 62 | String dst = null; |
60 | 63 | ||
61 | - @Argument(index = 3, name = "type", description = "The type of tunnels," | 64 | + @Option(name = "-t", aliases = "--type", description = "The type of tunnels," |
62 | - + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false) | 65 | + + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = false, multiValued = false) |
63 | String type = null; | 66 | String type = null; |
67 | + | ||
68 | + @Option(name = "-i", aliases = "--tunnelId", | ||
69 | + description = "the tunnel identity.", required = false, multiValued = false) | ||
70 | + String tunnelId = null; | ||
71 | + | ||
72 | + @Option(name = "-n", aliases = "--tunnelName", | ||
73 | + description = "The name of tunnels", required = false, multiValued = false) | ||
74 | + String tunnelName = null; | ||
64 | private static final String FMT = "src=%s, dst=%s," | 75 | private static final String FMT = "src=%s, dst=%s," |
65 | + "type=%s, state=%s, producerName=%s, tunnelName=%s," | 76 | + "type=%s, state=%s, producerName=%s, tunnelName=%s," |
66 | + "groupId=%s"; | 77 | + "groupId=%s"; |
67 | 78 | ||
68 | @Override | 79 | @Override |
69 | protected void execute() { | 80 | protected void execute() { |
81 | + Collection<Tunnel> tunnelSet = null; | ||
82 | + Tunnel.Type trueType = null; | ||
70 | TunnelService service = get(TunnelService.class); | 83 | TunnelService service = get(TunnelService.class); |
71 | ApplicationId appId = new DefaultApplicationId(1, consumerId); | 84 | ApplicationId appId = new DefaultApplicationId(1, consumerId); |
72 | ProviderId producerName = new ProviderId("default", | 85 | ProviderId producerName = new ProviderId("default", |
73 | "org.onosproject.provider.tunnel.default"); | 86 | "org.onosproject.provider.tunnel.default"); |
74 | - TunnelEndPoint srcPoint = null; | 87 | + if (!isNull(src) && !isNull(dst) && !isNull(type)) { |
75 | - TunnelEndPoint dstPoint = null; | 88 | + TunnelEndPoint srcPoint = null; |
76 | - if ("MPLS".equals(type) || "VLAN".equals(type) || "VXLAN".equals(type) | 89 | + TunnelEndPoint dstPoint = null; |
77 | - || "GRE".equals(type)) { | 90 | + if ("MPLS".equals(type)) { |
78 | - srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | 91 | + trueType = Tunnel.Type.MPLS; |
79 | - dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | 92 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
80 | - } else if ("ODUK".equals(type) || "OCH".equals(type)) { | 93 | + .valueOf(src)); |
81 | - String[] srcArray = src.split("-"); | 94 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
82 | - String[] dstArray = dst.split("-"); | 95 | + .valueOf(dst)); |
83 | - srcPoint = new DefaultOpticalTunnelEndPoint( | 96 | + } else if ("VXLAN".equals(type)) { |
84 | - producerName, | 97 | + trueType = Tunnel.Type.VXLAN; |
85 | - Optional.of(DeviceId | 98 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
86 | - .deviceId(srcArray[0])), | 99 | + .valueOf(src)); |
87 | - Optional.of(PortNumber | 100 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
88 | - .portNumber(srcArray[1])), | 101 | + .valueOf(dst)); |
89 | - null, | 102 | + } else if ("GRE".equals(type)) { |
90 | - OpticalTunnelEndPoint.Type.LAMBDA, | 103 | + trueType = Tunnel.Type.GRE; |
91 | - OpticalLogicId | 104 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
92 | - .logicId(0), | 105 | + .valueOf(src)); |
93 | - true); | 106 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
94 | - dstPoint = new DefaultOpticalTunnelEndPoint( | 107 | + .valueOf(dst)); |
95 | - producerName, | 108 | + } else if ("VLAN".equals(type)) { |
96 | - Optional.of(DeviceId | 109 | + trueType = Tunnel.Type.VLAN; |
97 | - .deviceId(dstArray[0])), | 110 | + String[] srcArray = src.split("-"); |
98 | - Optional.of(PortNumber | 111 | + String[] dstArray = dst.split("-"); |
99 | - .portNumber(dstArray[1])), | 112 | + srcPoint = new DefaultOpticalTunnelEndPoint( |
100 | - null, | 113 | + producerName, |
101 | - OpticalTunnelEndPoint.Type.LAMBDA, | 114 | + Optional.of(DeviceId |
102 | - OpticalLogicId | 115 | + .deviceId(srcArray[0])), |
103 | - .logicId(0), | 116 | + Optional.of(PortNumber |
104 | - true); | 117 | + .portNumber(srcArray[1])), |
105 | - } else { | 118 | + null, |
106 | - print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | 119 | + null, |
107 | - return; | 120 | + OpticalLogicId |
121 | + .logicId(0), | ||
122 | + true); | ||
123 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
124 | + producerName, | ||
125 | + Optional.of(DeviceId | ||
126 | + .deviceId(dstArray[0])), | ||
127 | + Optional.of(PortNumber | ||
128 | + .portNumber(dstArray[1])), | ||
129 | + null, | ||
130 | + null, | ||
131 | + OpticalLogicId | ||
132 | + .logicId(0), | ||
133 | + true); | ||
134 | + } else if ("ODUK".equals(type)) { | ||
135 | + trueType = Tunnel.Type.ODUK; | ||
136 | + String[] srcArray = src.split("-"); | ||
137 | + String[] dstArray = dst.split("-"); | ||
138 | + srcPoint = new DefaultOpticalTunnelEndPoint( | ||
139 | + producerName, | ||
140 | + Optional.of(DeviceId | ||
141 | + .deviceId(srcArray[0])), | ||
142 | + Optional.of(PortNumber | ||
143 | + .portNumber(srcArray[1])), | ||
144 | + null, | ||
145 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
146 | + OpticalLogicId | ||
147 | + .logicId(0), | ||
148 | + true); | ||
149 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
150 | + producerName, | ||
151 | + Optional.of(DeviceId | ||
152 | + .deviceId(dstArray[0])), | ||
153 | + Optional.of(PortNumber | ||
154 | + .portNumber(dstArray[1])), | ||
155 | + null, | ||
156 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
157 | + OpticalLogicId | ||
158 | + .logicId(0), | ||
159 | + true); | ||
160 | + } else if ("OCH".equals(type)) { | ||
161 | + trueType = Tunnel.Type.OCH; | ||
162 | + String[] srcArray = src.split("-"); | ||
163 | + String[] dstArray = dst.split("-"); | ||
164 | + srcPoint = new DefaultOpticalTunnelEndPoint( | ||
165 | + producerName, | ||
166 | + Optional.of(DeviceId | ||
167 | + .deviceId(srcArray[0])), | ||
168 | + Optional.of(PortNumber | ||
169 | + .portNumber(srcArray[1])), | ||
170 | + null, | ||
171 | + OpticalTunnelEndPoint.Type.TIMESLOT, | ||
172 | + OpticalLogicId | ||
173 | + .logicId(0), | ||
174 | + true); | ||
175 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
176 | + producerName, | ||
177 | + Optional.of(DeviceId | ||
178 | + .deviceId(dstArray[0])), | ||
179 | + Optional.of(PortNumber | ||
180 | + .portNumber(dstArray[1])), | ||
181 | + null, | ||
182 | + OpticalTunnelEndPoint.Type.TIMESLOT, | ||
183 | + OpticalLogicId | ||
184 | + .logicId(0), | ||
185 | + true); | ||
186 | + } else { | ||
187 | + print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | ||
188 | + return; | ||
189 | + } | ||
190 | + tunnelSet = service.borrowTunnel(appId, srcPoint, dstPoint, trueType); | ||
191 | + } | ||
192 | + if (!isNull(tunnelId)) { | ||
193 | + TunnelId id = TunnelId.valueOf(tunnelId); | ||
194 | + Tunnel tunnel = service.borrowTunnel(appId, id); | ||
195 | + tunnelSet = new HashSet<Tunnel>(); | ||
196 | + tunnelSet.add(tunnel); | ||
197 | + } | ||
198 | + if (!isNull(tunnelName)) { | ||
199 | + TunnelName name = TunnelName.tunnelName(tunnelName); | ||
200 | + tunnelSet = service.borrowTunnel(appId, name); | ||
108 | } | 201 | } |
109 | - Collection<Tunnel> tunnelSet = service.borrowTunnel(appId, srcPoint, dstPoint); | ||
110 | for (Tunnel tunnel : tunnelSet) { | 202 | for (Tunnel tunnel : tunnelSet) { |
111 | print(FMT, tunnel.src(), tunnel.dst(), tunnel.type(), | 203 | print(FMT, tunnel.src(), tunnel.dst(), tunnel.type(), |
112 | tunnel.state(), tunnel.providerId(), tunnel.tunnelName(), | 204 | tunnel.state(), tunnel.providerId(), tunnel.tunnelName(), |
... | @@ -114,4 +206,7 @@ public class TunnelBorrowCommand extends AbstractShellCommand { | ... | @@ -114,4 +206,7 @@ public class TunnelBorrowCommand extends AbstractShellCommand { |
114 | } | 206 | } |
115 | } | 207 | } |
116 | 208 | ||
209 | + private boolean isNull(String s) { | ||
210 | + return s == null || "".equals(s); | ||
211 | + } | ||
117 | } | 212 | } | ... | ... |
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 | -} |
... | @@ -16,96 +16,209 @@ | ... | @@ -16,96 +16,209 @@ |
16 | package org.onosproject.cli.net; | 16 | package org.onosproject.cli.net; |
17 | 17 | ||
18 | import java.util.Collection; | 18 | import java.util.Collection; |
19 | +import java.util.HashSet; | ||
19 | import java.util.Optional; | 20 | import java.util.Optional; |
20 | 21 | ||
21 | -import org.apache.karaf.shell.commands.Argument; | ||
22 | import org.apache.karaf.shell.commands.Command; | 22 | import org.apache.karaf.shell.commands.Command; |
23 | +import org.apache.karaf.shell.commands.Option; | ||
23 | import org.onlab.packet.IpAddress; | 24 | import org.onlab.packet.IpAddress; |
24 | import org.onosproject.cli.AbstractShellCommand; | 25 | import org.onosproject.cli.AbstractShellCommand; |
25 | -import org.onosproject.net.DeviceId; | ||
26 | -import org.onosproject.net.PortNumber; | ||
27 | -import org.onosproject.net.provider.ProviderId; | ||
28 | import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint; | 26 | import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint; |
29 | import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; | 27 | import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; |
30 | import org.onosproject.incubator.net.tunnel.OpticalLogicId; | 28 | import org.onosproject.incubator.net.tunnel.OpticalLogicId; |
31 | import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint; | 29 | import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint; |
32 | import org.onosproject.incubator.net.tunnel.Tunnel; | 30 | import org.onosproject.incubator.net.tunnel.Tunnel; |
33 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; | 31 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; |
32 | +import org.onosproject.incubator.net.tunnel.TunnelId; | ||
34 | import org.onosproject.incubator.net.tunnel.TunnelService; | 33 | import org.onosproject.incubator.net.tunnel.TunnelService; |
34 | +import org.onosproject.net.DeviceId; | ||
35 | +import org.onosproject.net.Link; | ||
36 | +import org.onosproject.net.Path; | ||
37 | +import org.onosproject.net.PortNumber; | ||
38 | +import org.onosproject.net.provider.ProviderId; | ||
35 | 39 | ||
36 | /** | 40 | /** |
37 | - * Supports for querying all tunnels by using IP address and optical as tunnel | 41 | + * Supports for querying tunnels. It's used by consumers. |
38 | - * end point now. It's used by consumers. | ||
39 | */ | 42 | */ |
40 | -@Command(scope = "onos", name = "query-tunnels", description = "Supports for querying all tunnels by using IP address" | 43 | +@Command(scope = "onos", name = "tunnels", description = "Supports for querying tunnels." |
41 | - + " and optical as tunnel end point now." | ||
42 | + " It's used by consumers.") | 44 | + " It's used by consumers.") |
43 | public class TunnelQueryCommand extends AbstractShellCommand { | 45 | public class TunnelQueryCommand extends AbstractShellCommand { |
44 | - @Argument(index = 0, name = "src", description = "Source tunnel point." | 46 | + @Option(name = "-s", aliases = "--src", description = "Source tunnel point." |
45 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." | 47 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." |
46 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." | 48 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." |
47 | - + " Otherwise src means IP address.", required = true, multiValued = false) | 49 | + + " Otherwise src means IP address.", required = false, multiValued = false) |
48 | String src = null; | 50 | String src = null; |
49 | - @Argument(index = 1, name = "dst", description = "Destination tunnel point." | 51 | + @Option(name = "-d", aliases = "--dst", description = "Destination tunnel point." |
50 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." | 52 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." |
51 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." | 53 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." |
52 | - + " Otherwise dst means IP address.", required = true, multiValued = false) | 54 | + + " Otherwise dst means IP address.", required = false, multiValued = false) |
53 | String dst = null; | 55 | String dst = null; |
54 | 56 | ||
55 | - @Argument(index = 2, name = "type", description = "The type of tunnels," | 57 | + @Option(name = "-t", aliases = "--type", description = "The type of tunnels," |
56 | - + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false) | 58 | + + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = false, multiValued = false) |
57 | String type = null; | 59 | String type = null; |
58 | 60 | ||
59 | - private static final String FMT = "src=%s, dst=%s," | 61 | + @Option(name = "-i", aliases = "--tunnelId", |
62 | + description = "the tunnel identity.", required = false, multiValued = false) | ||
63 | + String tunnelId = null; | ||
64 | + | ||
65 | + private static final String FMT = "tunnelId=%s, src=%s, dst=%s," | ||
60 | + "type=%s, state=%s, producerName=%s, tunnelName=%s," | 66 | + "type=%s, state=%s, producerName=%s, tunnelName=%s," |
61 | - + "groupId=%s"; | 67 | + + "groupId=%s, path=%s%s"; |
62 | 68 | ||
63 | @Override | 69 | @Override |
64 | protected void execute() { | 70 | protected void execute() { |
71 | + Tunnel.Type trueType = null; | ||
65 | TunnelService service = get(TunnelService.class); | 72 | TunnelService service = get(TunnelService.class); |
66 | ProviderId producerName = new ProviderId("default", | 73 | ProviderId producerName = new ProviderId("default", |
67 | "org.onosproject.provider.tunnel.default"); | 74 | "org.onosproject.provider.tunnel.default"); |
68 | - TunnelEndPoint srcPoint = null; | 75 | + Collection<Tunnel> tunnelSet = null; |
69 | - TunnelEndPoint dstPoint = null; | 76 | + if (isNull(src) && isNull(dst) && isNull(type) && isNull(tunnelId)) { |
70 | - if ("MPLS".equals(type) || "VLAN".equals(type) || "VXLAN".equals(type) | 77 | + tunnelSet = service.queryAllTunnels(); |
71 | - || "GRE".equals(type)) { | 78 | + } |
72 | - srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | 79 | + |
73 | - dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | 80 | + if (!isNull(src) && !isNull(dst) && !isNull(type)) { |
74 | - } else if ("ODUK".equals(type) || "OCH".equals(type)) { | 81 | + TunnelEndPoint srcPoint = null; |
75 | - String[] srcArray = src.split("-"); | 82 | + TunnelEndPoint dstPoint = null; |
76 | - String[] dstArray = dst.split("-"); | 83 | + if ("MPLS".equals(type) || "VXLAN".equals(type) |
77 | - srcPoint = new DefaultOpticalTunnelEndPoint( | 84 | + || "GRE".equals(type)) { |
78 | - producerName, | 85 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
79 | - Optional.of(DeviceId | 86 | + .valueOf(src)); |
80 | - .deviceId(srcArray[0])), | 87 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
81 | - Optional.of(PortNumber | 88 | + .valueOf(dst)); |
82 | - .portNumber(srcArray[1])), | 89 | + } else if ("VLAN".equals(type)) { |
83 | - null, | 90 | + String[] srcArray = src.split("-"); |
84 | - OpticalTunnelEndPoint.Type.LAMBDA, | 91 | + String[] dstArray = dst.split("-"); |
85 | - OpticalLogicId | 92 | + srcPoint = new DefaultOpticalTunnelEndPoint( |
86 | - .logicId(0), | 93 | + producerName, |
87 | - true); | 94 | + Optional.of(DeviceId |
88 | - dstPoint = new DefaultOpticalTunnelEndPoint( | 95 | + .deviceId(srcArray[0])), |
89 | - producerName, | 96 | + Optional.of(PortNumber |
90 | - Optional.of(DeviceId | 97 | + .portNumber(srcArray[1])), |
91 | - .deviceId(dstArray[0])), | 98 | + null, |
92 | - Optional.of(PortNumber | 99 | + null, |
93 | - .portNumber(dstArray[1])), | 100 | + OpticalLogicId |
94 | - null, | 101 | + .logicId(0), |
95 | - OpticalTunnelEndPoint.Type.LAMBDA, | 102 | + true); |
96 | - OpticalLogicId | 103 | + dstPoint = new DefaultOpticalTunnelEndPoint( |
97 | - .logicId(0), | 104 | + producerName, |
98 | - true); | 105 | + Optional.of(DeviceId |
99 | - } else { | 106 | + .deviceId(dstArray[0])), |
100 | - print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | 107 | + Optional.of(PortNumber |
101 | - return; | 108 | + .portNumber(dstArray[1])), |
109 | + null, | ||
110 | + null, | ||
111 | + OpticalLogicId | ||
112 | + .logicId(0), | ||
113 | + true); | ||
114 | + } else if ("ODUK".equals(type)) { | ||
115 | + String[] srcArray = src.split("-"); | ||
116 | + String[] dstArray = dst.split("-"); | ||
117 | + srcPoint = new DefaultOpticalTunnelEndPoint( | ||
118 | + producerName, | ||
119 | + Optional.of(DeviceId | ||
120 | + .deviceId(srcArray[0])), | ||
121 | + Optional.of(PortNumber | ||
122 | + .portNumber(srcArray[1])), | ||
123 | + null, | ||
124 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
125 | + OpticalLogicId | ||
126 | + .logicId(0), | ||
127 | + true); | ||
128 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
129 | + producerName, | ||
130 | + Optional.of(DeviceId | ||
131 | + .deviceId(dstArray[0])), | ||
132 | + Optional.of(PortNumber | ||
133 | + .portNumber(dstArray[1])), | ||
134 | + null, | ||
135 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
136 | + OpticalLogicId | ||
137 | + .logicId(0), | ||
138 | + true); | ||
139 | + } else if ("OCH".equals(type)) { | ||
140 | + String[] srcArray = src.split("-"); | ||
141 | + String[] dstArray = dst.split("-"); | ||
142 | + srcPoint = new DefaultOpticalTunnelEndPoint( | ||
143 | + producerName, | ||
144 | + Optional.of(DeviceId | ||
145 | + .deviceId(srcArray[0])), | ||
146 | + Optional.of(PortNumber | ||
147 | + .portNumber(srcArray[1])), | ||
148 | + null, | ||
149 | + OpticalTunnelEndPoint.Type.TIMESLOT, | ||
150 | + OpticalLogicId | ||
151 | + .logicId(0), | ||
152 | + true); | ||
153 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
154 | + producerName, | ||
155 | + Optional.of(DeviceId | ||
156 | + .deviceId(dstArray[0])), | ||
157 | + Optional.of(PortNumber | ||
158 | + .portNumber(dstArray[1])), | ||
159 | + null, | ||
160 | + OpticalTunnelEndPoint.Type.TIMESLOT, | ||
161 | + OpticalLogicId | ||
162 | + .logicId(0), | ||
163 | + true); | ||
164 | + } else { | ||
165 | + print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | ||
166 | + return; | ||
167 | + } | ||
168 | + tunnelSet = service.queryTunnel(srcPoint, dstPoint); | ||
169 | + } | ||
170 | + if (!isNull(type)) { | ||
171 | + if ("MPLS".equals(type)) { | ||
172 | + trueType = Tunnel.Type.MPLS; | ||
173 | + } else if ("VLAN".equals(type)) { | ||
174 | + trueType = Tunnel.Type.VLAN; | ||
175 | + } else if ("VXLAN".equals(type)) { | ||
176 | + trueType = Tunnel.Type.VXLAN; | ||
177 | + } else if ("GRE".equals(type)) { | ||
178 | + trueType = Tunnel.Type.GRE; | ||
179 | + } else if ("ODUK".equals(type)) { | ||
180 | + trueType = Tunnel.Type.ODUK; | ||
181 | + } else if ("OCH".equals(type)) { | ||
182 | + trueType = Tunnel.Type.OCH; | ||
183 | + } else { | ||
184 | + print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | ||
185 | + return; | ||
186 | + } | ||
187 | + tunnelSet = service.queryTunnel(trueType); | ||
188 | + } | ||
189 | + if (!isNull(tunnelId)) { | ||
190 | + TunnelId id = TunnelId.valueOf(tunnelId); | ||
191 | + Tunnel tunnel = service.queryTunnel(id); | ||
192 | + tunnelSet = new HashSet<Tunnel>(); | ||
193 | + tunnelSet.add(tunnel); | ||
194 | + } | ||
195 | + if (tunnelSet != null) { | ||
196 | + for (Tunnel tunnel : tunnelSet) { | ||
197 | + print(FMT, tunnel.tunnelId(), tunnel.src().toString(), tunnel.dst().toString(), | ||
198 | + tunnel.type(), tunnel.state(), tunnel.providerId(), | ||
199 | + tunnel.tunnelName(), tunnel.groupId(), | ||
200 | + showPath(tunnel.path()), | ||
201 | + annotations(tunnel.annotations())); | ||
202 | + } | ||
102 | } | 203 | } |
103 | - Collection<Tunnel> tunnelSet = service.queryTunnel(srcPoint, dstPoint); | 204 | + } |
104 | - for (Tunnel tunnel : tunnelSet) { | 205 | + |
105 | - print(FMT, tunnel.src().toString(), tunnel.dst().toString(), tunnel.type(), | 206 | + private String showPath(Path path) { |
106 | - tunnel.state(), tunnel.providerId(), tunnel.tunnelName(), | 207 | + if (path == null) { |
107 | - tunnel.groupId()); | 208 | + return ""; |
108 | } | 209 | } |
210 | + StringBuilder builder = new StringBuilder("("); | ||
211 | + for (Link link : path.links()) { | ||
212 | + builder.append("(DeviceId:" + link.src().deviceId() + " Port:" | ||
213 | + + link.src().port().toString()); | ||
214 | + builder.append(" DeviceId:" + link.dst().deviceId() + " Port:" | ||
215 | + + link.dst().port().toString() + ")"); | ||
216 | + } | ||
217 | + builder.append(annotations(path.annotations()) + ")"); | ||
218 | + return builder.toString(); | ||
109 | } | 219 | } |
110 | 220 | ||
221 | + private boolean isNull(String s) { | ||
222 | + return s == null || "".equals(s); | ||
223 | + } | ||
111 | } | 224 | } | ... | ... |
... | @@ -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", | ... | ... |
... | @@ -19,90 +19,180 @@ import java.util.Optional; | ... | @@ -19,90 +19,180 @@ import java.util.Optional; |
19 | 19 | ||
20 | import org.apache.karaf.shell.commands.Argument; | 20 | import org.apache.karaf.shell.commands.Argument; |
21 | import org.apache.karaf.shell.commands.Command; | 21 | import org.apache.karaf.shell.commands.Command; |
22 | +import org.apache.karaf.shell.commands.Option; | ||
22 | import org.onlab.packet.IpAddress; | 23 | import org.onlab.packet.IpAddress; |
23 | import org.onosproject.cli.AbstractShellCommand; | 24 | import org.onosproject.cli.AbstractShellCommand; |
24 | import org.onosproject.core.ApplicationId; | 25 | import org.onosproject.core.ApplicationId; |
25 | import org.onosproject.core.DefaultApplicationId; | 26 | import org.onosproject.core.DefaultApplicationId; |
26 | -import org.onosproject.net.DeviceId; | ||
27 | -import org.onosproject.net.PortNumber; | ||
28 | -import org.onosproject.net.provider.ProviderId; | ||
29 | import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint; | 27 | import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint; |
30 | import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; | 28 | import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; |
31 | import org.onosproject.incubator.net.tunnel.OpticalLogicId; | 29 | import org.onosproject.incubator.net.tunnel.OpticalLogicId; |
32 | import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint; | 30 | import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint; |
31 | +import org.onosproject.incubator.net.tunnel.Tunnel; | ||
33 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; | 32 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; |
33 | +import org.onosproject.incubator.net.tunnel.TunnelId; | ||
34 | +import org.onosproject.incubator.net.tunnel.TunnelName; | ||
34 | import org.onosproject.incubator.net.tunnel.TunnelService; | 35 | import org.onosproject.incubator.net.tunnel.TunnelService; |
36 | +import org.onosproject.net.DeviceId; | ||
37 | +import org.onosproject.net.PortNumber; | ||
38 | +import org.onosproject.net.provider.ProviderId; | ||
35 | 39 | ||
36 | /** | 40 | /** |
37 | - * Returns all tunnels between specific source tunnel end point and specific | 41 | + * Returns tunnels. It's used by consumers. |
38 | - * destination tunnel end point. Supports for IP address and optical as tunnel | ||
39 | - * end point now. It's used by consumers. | ||
40 | */ | 42 | */ |
41 | -@Command(scope = "onos", name = "return-tunnels", | 43 | +@Command(scope = "onos", name = "tunnel-return", |
42 | -description = "Returns all tunnels between specific source tunnel end point and specific " | 44 | +description = "Returns tunnels. It's used by consumers.") |
43 | - + " destination tunnel end point. Supports for IP address and optical as tunnel end point now." | ||
44 | - + " It's used by consumers.") | ||
45 | public class TunnelReturnCommand extends AbstractShellCommand { | 45 | public class TunnelReturnCommand extends AbstractShellCommand { |
46 | - @Argument(index = 0, name = "consumerId", description = "consumer id means application id.", | 46 | + @Argument(index = 0, name = "consumerId", |
47 | - required = true, multiValued = false) | 47 | + description = "consumer id means application id.", required = true, multiValued = false) |
48 | String consumerId = null; | 48 | String consumerId = null; |
49 | - @Argument(index = 1, name = "src", description = "Source tunnel point." | 49 | + |
50 | + @Option(name = "-s", aliases = "--src", description = "Source tunnel point." | ||
50 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." | 51 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." |
51 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." | 52 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." |
52 | - + " Otherwise src means IP address.", required = true, multiValued = false) | 53 | + + " Otherwise src means IP address.", required = false, multiValued = false) |
53 | String src = null; | 54 | String src = null; |
54 | - @Argument(index = 2, name = "dst", description = "Destination tunnel point." | 55 | + |
56 | + @Option(name = "-d", aliases = "--dst", description = "Destination tunnel point." | ||
55 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." | 57 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." |
56 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." | 58 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." |
57 | - + " Otherwise dst means IP address.", required = true, multiValued = false) | 59 | + + " Otherwise dst means IP address.", required = false, multiValued = false) |
58 | String dst = null; | 60 | String dst = null; |
59 | 61 | ||
60 | - @Argument(index = 3, name = "type", description = "The type of tunnels," | 62 | + @Option(name = "-t", aliases = "--type", description = "The type of tunnels," |
61 | - + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false) | 63 | + + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = false, multiValued = false) |
62 | String type = null; | 64 | String type = null; |
63 | 65 | ||
66 | + @Option(name = "-i", aliases = "--tunnelId", | ||
67 | + description = "the tunnel identity.", required = false, multiValued = false) | ||
68 | + String tunnelId = null; | ||
69 | + | ||
70 | + @Option(name = "-n", aliases = "--tunnelName", | ||
71 | + description = "The name of tunnels", required = false, multiValued = false) | ||
72 | + String tunnelName = null; | ||
73 | + | ||
64 | @Override | 74 | @Override |
65 | protected void execute() { | 75 | protected void execute() { |
76 | + Tunnel.Type trueType = null; | ||
66 | TunnelService service = get(TunnelService.class); | 77 | TunnelService service = get(TunnelService.class); |
67 | ApplicationId appId = new DefaultApplicationId(1, consumerId); | 78 | ApplicationId appId = new DefaultApplicationId(1, consumerId); |
68 | ProviderId producerName = new ProviderId("default", | 79 | ProviderId producerName = new ProviderId("default", |
69 | "org.onosproject.provider.tunnel.default"); | 80 | "org.onosproject.provider.tunnel.default"); |
70 | - TunnelEndPoint srcPoint = null; | 81 | + if (!isNull(src) && !isNull(dst) && !isNull(type)) { |
71 | - TunnelEndPoint dstPoint = null; | 82 | + TunnelEndPoint srcPoint = null; |
72 | - if ("MPLS".equals(type) || "VLAN".equals(type) || "VXLAN".equals(type) | 83 | + TunnelEndPoint dstPoint = null; |
73 | - || "GRE".equals(type)) { | 84 | + if ("MPLS".equals(type)) { |
74 | - srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | 85 | + trueType = Tunnel.Type.MPLS; |
75 | - dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | 86 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
76 | - } else if ("ODUK".equals(type) || "OCH".equals(type)) { | 87 | + .valueOf(src)); |
77 | - String[] srcArray = src.split("-"); | 88 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
78 | - String[] dstArray = dst.split("-"); | 89 | + .valueOf(dst)); |
79 | - srcPoint = new DefaultOpticalTunnelEndPoint( | 90 | + } else if ("VXLAN".equals(type)) { |
80 | - producerName, | 91 | + trueType = Tunnel.Type.VXLAN; |
81 | - Optional.of(DeviceId | 92 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
82 | - .deviceId(srcArray[0])), | 93 | + .valueOf(src)); |
83 | - Optional.of(PortNumber | 94 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
84 | - .portNumber(srcArray[1])), | 95 | + .valueOf(dst)); |
85 | - null, | 96 | + } else if ("GRE".equals(type)) { |
86 | - OpticalTunnelEndPoint.Type.LAMBDA, | 97 | + trueType = Tunnel.Type.GRE; |
87 | - OpticalLogicId | 98 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
88 | - .logicId(0), | 99 | + .valueOf(src)); |
89 | - true); | 100 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
90 | - dstPoint = new DefaultOpticalTunnelEndPoint( | 101 | + .valueOf(dst)); |
91 | - producerName, | 102 | + } else if ("VLAN".equals(type)) { |
92 | - Optional.of(DeviceId | 103 | + trueType = Tunnel.Type.VLAN; |
93 | - .deviceId(dstArray[0])), | 104 | + String[] srcArray = src.split("-"); |
94 | - Optional.of(PortNumber | 105 | + String[] dstArray = dst.split("-"); |
95 | - .portNumber(dstArray[1])), | 106 | + srcPoint = new DefaultOpticalTunnelEndPoint( |
96 | - null, | 107 | + producerName, |
97 | - OpticalTunnelEndPoint.Type.LAMBDA, | 108 | + Optional.of(DeviceId |
98 | - OpticalLogicId | 109 | + .deviceId(srcArray[0])), |
99 | - .logicId(0), | 110 | + Optional.of(PortNumber |
100 | - true); | 111 | + .portNumber(srcArray[1])), |
101 | - } else { | 112 | + null, |
102 | - print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | 113 | + null, |
103 | - return; | 114 | + OpticalLogicId |
115 | + .logicId(0), | ||
116 | + true); | ||
117 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
118 | + producerName, | ||
119 | + Optional.of(DeviceId | ||
120 | + .deviceId(dstArray[0])), | ||
121 | + Optional.of(PortNumber | ||
122 | + .portNumber(dstArray[1])), | ||
123 | + null, | ||
124 | + null, | ||
125 | + OpticalLogicId | ||
126 | + .logicId(0), | ||
127 | + true); | ||
128 | + } else if ("ODUK".equals(type)) { | ||
129 | + trueType = Tunnel.Type.ODUK; | ||
130 | + String[] srcArray = src.split("-"); | ||
131 | + String[] dstArray = dst.split("-"); | ||
132 | + srcPoint = new DefaultOpticalTunnelEndPoint( | ||
133 | + producerName, | ||
134 | + Optional.of(DeviceId | ||
135 | + .deviceId(srcArray[0])), | ||
136 | + Optional.of(PortNumber | ||
137 | + .portNumber(srcArray[1])), | ||
138 | + null, | ||
139 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
140 | + OpticalLogicId | ||
141 | + .logicId(0), | ||
142 | + true); | ||
143 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
144 | + producerName, | ||
145 | + Optional.of(DeviceId | ||
146 | + .deviceId(dstArray[0])), | ||
147 | + Optional.of(PortNumber | ||
148 | + .portNumber(dstArray[1])), | ||
149 | + null, | ||
150 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
151 | + OpticalLogicId | ||
152 | + .logicId(0), | ||
153 | + true); | ||
154 | + } else if ("OCH".equals(type)) { | ||
155 | + trueType = Tunnel.Type.OCH; | ||
156 | + String[] srcArray = src.split("-"); | ||
157 | + String[] dstArray = dst.split("-"); | ||
158 | + srcPoint = new DefaultOpticalTunnelEndPoint( | ||
159 | + producerName, | ||
160 | + Optional.of(DeviceId | ||
161 | + .deviceId(srcArray[0])), | ||
162 | + Optional.of(PortNumber | ||
163 | + .portNumber(srcArray[1])), | ||
164 | + null, | ||
165 | + OpticalTunnelEndPoint.Type.TIMESLOT, | ||
166 | + OpticalLogicId | ||
167 | + .logicId(0), | ||
168 | + true); | ||
169 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
170 | + producerName, | ||
171 | + Optional.of(DeviceId | ||
172 | + .deviceId(dstArray[0])), | ||
173 | + Optional.of(PortNumber | ||
174 | + .portNumber(dstArray[1])), | ||
175 | + null, | ||
176 | + OpticalTunnelEndPoint.Type.TIMESLOT, | ||
177 | + OpticalLogicId | ||
178 | + .logicId(0), | ||
179 | + true); | ||
180 | + } else { | ||
181 | + print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | ||
182 | + return; | ||
183 | + } | ||
184 | + service.returnTunnel(appId, srcPoint, dstPoint, trueType); | ||
185 | + } | ||
186 | + if (!isNull(tunnelId)) { | ||
187 | + TunnelId id = TunnelId.valueOf(tunnelId); | ||
188 | + service.returnTunnel(appId, id); | ||
189 | + } | ||
190 | + if (!isNull(tunnelName)) { | ||
191 | + TunnelName name = TunnelName.tunnelName(tunnelName); | ||
192 | + service.returnTunnel(appId, name); | ||
104 | } | 193 | } |
105 | - service.returnTunnel(appId, srcPoint, dstPoint); | ||
106 | } | 194 | } |
107 | - | 195 | + private boolean isNull(String s) { |
196 | + return s == null || "".equals(s); | ||
197 | + } | ||
108 | } | 198 | } | ... | ... |
... | @@ -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 | } | ... | ... |
incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/DefaultTunnelDescription.java
100644 → 100755
... | @@ -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 | } | ... | ... |
incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelDescription.java
100644 → 100755
... | @@ -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 | } | ... | ... |
... | @@ -15,7 +15,6 @@ import java.util.concurrent.Executors; | ... | @@ -15,7 +15,6 @@ import java.util.concurrent.Executors; |
15 | import java.util.concurrent.Future; | 15 | import java.util.concurrent.Future; |
16 | import java.util.concurrent.TimeUnit; | 16 | import java.util.concurrent.TimeUnit; |
17 | import java.util.concurrent.TimeoutException; | 17 | import java.util.concurrent.TimeoutException; |
18 | -import java.util.concurrent.locks.ReentrantReadWriteLock; | ||
19 | 18 | ||
20 | import org.apache.felix.scr.annotations.Activate; | 19 | import org.apache.felix.scr.annotations.Activate; |
21 | import org.apache.felix.scr.annotations.Component; | 20 | import org.apache.felix.scr.annotations.Component; |
... | @@ -25,9 +24,6 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; | ... | @@ -25,9 +24,6 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; |
25 | import org.apache.felix.scr.annotations.Service; | 24 | import org.apache.felix.scr.annotations.Service; |
26 | import org.onlab.util.KryoNamespace; | 25 | import org.onlab.util.KryoNamespace; |
27 | import org.onosproject.cluster.ClusterService; | 26 | import org.onosproject.cluster.ClusterService; |
28 | -import org.onosproject.net.Device; | ||
29 | -import org.onosproject.net.DeviceId; | ||
30 | -import org.onosproject.net.device.DeviceService; | ||
31 | import org.onosproject.incubator.net.resource.label.DefaultLabelResource; | 27 | import org.onosproject.incubator.net.resource.label.DefaultLabelResource; |
32 | import org.onosproject.incubator.net.resource.label.LabelResource; | 28 | import org.onosproject.incubator.net.resource.label.LabelResource; |
33 | import org.onosproject.incubator.net.resource.label.LabelResourceDelegate; | 29 | import org.onosproject.incubator.net.resource.label.LabelResourceDelegate; |
... | @@ -37,6 +33,9 @@ import org.onosproject.incubator.net.resource.label.LabelResourceId; | ... | @@ -37,6 +33,9 @@ import org.onosproject.incubator.net.resource.label.LabelResourceId; |
37 | import org.onosproject.incubator.net.resource.label.LabelResourcePool; | 33 | import org.onosproject.incubator.net.resource.label.LabelResourcePool; |
38 | import org.onosproject.incubator.net.resource.label.LabelResourceRequest; | 34 | import org.onosproject.incubator.net.resource.label.LabelResourceRequest; |
39 | import org.onosproject.incubator.net.resource.label.LabelResourceStore; | 35 | import org.onosproject.incubator.net.resource.label.LabelResourceStore; |
36 | +import org.onosproject.net.Device; | ||
37 | +import org.onosproject.net.DeviceId; | ||
38 | +import org.onosproject.net.device.DeviceService; | ||
40 | import org.onosproject.store.AbstractStore; | 39 | import org.onosproject.store.AbstractStore; |
41 | import org.onosproject.store.cluster.messaging.ClusterCommunicationService; | 40 | import org.onosproject.store.cluster.messaging.ClusterCommunicationService; |
42 | import org.onosproject.store.cluster.messaging.ClusterMessage; | 41 | import org.onosproject.store.cluster.messaging.ClusterMessage; |
... | @@ -44,11 +43,10 @@ import org.onosproject.store.cluster.messaging.ClusterMessageHandler; | ... | @@ -44,11 +43,10 @@ import org.onosproject.store.cluster.messaging.ClusterMessageHandler; |
44 | import org.onosproject.store.flow.ReplicaInfo; | 43 | import org.onosproject.store.flow.ReplicaInfo; |
45 | import org.onosproject.store.flow.ReplicaInfoService; | 44 | import org.onosproject.store.flow.ReplicaInfoService; |
46 | import org.onosproject.store.serializers.KryoNamespaces; | 45 | import org.onosproject.store.serializers.KryoNamespaces; |
47 | -import org.onosproject.store.serializers.KryoSerializer; | ||
48 | -import org.onosproject.store.serializers.custom.DistributedStoreSerializers; | ||
49 | import org.onosproject.store.service.ConsistentMap; | 46 | import org.onosproject.store.service.ConsistentMap; |
50 | import org.onosproject.store.service.Serializer; | 47 | import org.onosproject.store.service.Serializer; |
51 | import org.onosproject.store.service.StorageService; | 48 | import org.onosproject.store.service.StorageService; |
49 | +import org.onosproject.store.service.Versioned; | ||
52 | import org.slf4j.Logger; | 50 | import org.slf4j.Logger; |
53 | 51 | ||
54 | import com.google.common.collect.ImmutableSet; | 52 | import com.google.common.collect.ImmutableSet; |
... | @@ -67,9 +65,6 @@ public class DistributedLabelResourceStore | ... | @@ -67,9 +65,6 @@ public class DistributedLabelResourceStore |
67 | private static final String POOL_MAP_NAME = "labelresourcepool"; | 65 | private static final String POOL_MAP_NAME = "labelresourcepool"; |
68 | 66 | ||
69 | private static final String GLOBAL_RESOURCE_POOL_DEVICE_ID = "global_resource_pool_device_id"; | 67 | private static final String GLOBAL_RESOURCE_POOL_DEVICE_ID = "global_resource_pool_device_id"; |
70 | - // primary data: | ||
71 | - // read/write needs to be locked | ||
72 | - private final ReentrantReadWriteLock resourcePoolLock = new ReentrantReadWriteLock(); | ||
73 | 68 | ||
74 | private ConsistentMap<DeviceId, LabelResourcePool> resourcePool = null; | 69 | private ConsistentMap<DeviceId, LabelResourcePool> resourcePool = null; |
75 | 70 | ||
... | @@ -92,41 +87,24 @@ public class DistributedLabelResourceStore | ... | @@ -92,41 +87,24 @@ public class DistributedLabelResourceStore |
92 | private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 8; | 87 | private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 8; |
93 | private static final long PEER_REQUEST_TIMEOUT_MS = 5000; | 88 | private static final long PEER_REQUEST_TIMEOUT_MS = 5000; |
94 | 89 | ||
95 | - protected static final KryoSerializer SERIALIZER = new KryoSerializer() { | 90 | + private static final Serializer SERIALIZER = Serializer |
96 | - @Override | 91 | + .using(new KryoNamespace.Builder().register(KryoNamespaces.API) |
97 | - protected void setupKryoPool() { | ||
98 | - serializerPool = KryoNamespace.newBuilder() | ||
99 | - .register(DistributedStoreSerializers.STORE_COMMON) | ||
100 | - .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN) | ||
101 | .register(LabelResourceEvent.class) | 92 | .register(LabelResourceEvent.class) |
102 | .register(LabelResourcePool.class).register(DeviceId.class) | 93 | .register(LabelResourcePool.class).register(DeviceId.class) |
103 | .register(LabelResourceRequest.class) | 94 | .register(LabelResourceRequest.class) |
104 | .register(LabelResourceRequest.Type.class) | 95 | .register(LabelResourceRequest.Type.class) |
105 | .register(LabelResourceEvent.Type.class) | 96 | .register(LabelResourceEvent.Type.class) |
106 | .register(DefaultLabelResource.class) | 97 | .register(DefaultLabelResource.class) |
107 | - .register(LabelResourceId.class).build(); | 98 | + .register(LabelResourceId.class) |
108 | - } | 99 | + .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID).build()); |
109 | - }; | ||
110 | 100 | ||
111 | @Activate | 101 | @Activate |
112 | public void activate() { | 102 | public void activate() { |
113 | 103 | ||
114 | resourcePool = storageService | 104 | resourcePool = storageService |
115 | .<DeviceId, LabelResourcePool>consistentMapBuilder() | 105 | .<DeviceId, LabelResourcePool>consistentMapBuilder() |
116 | - .withName(POOL_MAP_NAME).withSerializer(new Serializer() { | 106 | + .withName(POOL_MAP_NAME).withSerializer(SERIALIZER) |
117 | - KryoNamespace kryo = new KryoNamespace.Builder() | 107 | + .withPartitionsDisabled().build(); |
118 | - .register(KryoNamespaces.API).build(); | ||
119 | - | ||
120 | - @Override | ||
121 | - public <T> byte[] encode(T object) { | ||
122 | - return kryo.serialize(object); | ||
123 | - } | ||
124 | - | ||
125 | - @Override | ||
126 | - public <T> T decode(byte[] bytes) { | ||
127 | - return kryo.deserialize(bytes); | ||
128 | - } | ||
129 | - }).withPartitionsDisabled().build(); | ||
130 | messageHandlingExecutor = Executors | 108 | messageHandlingExecutor = Executors |
131 | .newFixedThreadPool(MESSAGE_HANDLER_THREAD_POOL_SIZE, | 109 | .newFixedThreadPool(MESSAGE_HANDLER_THREAD_POOL_SIZE, |
132 | groupedThreads("onos/store/flow", | 110 | groupedThreads("onos/store/flow", |
... | @@ -142,7 +120,7 @@ public class DistributedLabelResourceStore | ... | @@ -142,7 +120,7 @@ public class DistributedLabelResourceStore |
142 | log.trace("received get flow entry request for {}", | 120 | log.trace("received get flow entry request for {}", |
143 | operation); | 121 | operation); |
144 | boolean b = internalCreate(operation); | 122 | boolean b = internalCreate(operation); |
145 | - message.respond(SERIALIZER.encode(b)); | 123 | + message.respond(SERIALIZER.encode(b)); |
146 | } | 124 | } |
147 | }, messageHandlingExecutor); | 125 | }, messageHandlingExecutor); |
148 | clusterCommunicator | 126 | clusterCommunicator |
... | @@ -156,7 +134,7 @@ public class DistributedLabelResourceStore | ... | @@ -156,7 +134,7 @@ public class DistributedLabelResourceStore |
156 | log.trace("received get flow entry request for {}", | 134 | log.trace("received get flow entry request for {}", |
157 | deviceId); | 135 | deviceId); |
158 | boolean b = internalDestroy(deviceId); | 136 | boolean b = internalDestroy(deviceId); |
159 | - message.respond(SERIALIZER.encode(b)); | 137 | + message.respond(SERIALIZER.encode(b)); |
160 | } | 138 | } |
161 | }, messageHandlingExecutor); | 139 | }, messageHandlingExecutor); |
162 | clusterCommunicator | 140 | clusterCommunicator |
... | @@ -170,8 +148,8 @@ public class DistributedLabelResourceStore | ... | @@ -170,8 +148,8 @@ public class DistributedLabelResourceStore |
170 | log.trace("received get flow entry request for {}", | 148 | log.trace("received get flow entry request for {}", |
171 | request); | 149 | request); |
172 | final Collection<LabelResource> resource = internalApply(request); | 150 | final Collection<LabelResource> resource = internalApply(request); |
173 | - message.respond(SERIALIZER | 151 | + message.respond(SERIALIZER |
174 | - .encode(resource)); | 152 | + .encode(resource)); |
175 | } | 153 | } |
176 | }, messageHandlingExecutor); | 154 | }, messageHandlingExecutor); |
177 | clusterCommunicator | 155 | clusterCommunicator |
... | @@ -185,8 +163,8 @@ public class DistributedLabelResourceStore | ... | @@ -185,8 +163,8 @@ public class DistributedLabelResourceStore |
185 | log.trace("received get flow entry request for {}", | 163 | log.trace("received get flow entry request for {}", |
186 | request); | 164 | request); |
187 | final boolean isSuccess = internalRelease(request); | 165 | final boolean isSuccess = internalRelease(request); |
188 | - message.respond(SERIALIZER | 166 | + message.respond(SERIALIZER |
189 | - .encode(isSuccess)); | 167 | + .encode(isSuccess)); |
190 | } | 168 | } |
191 | }, messageHandlingExecutor); | 169 | }, messageHandlingExecutor); |
192 | log.info("Started"); | 170 | log.info("Started"); |
... | @@ -256,18 +234,16 @@ public class DistributedLabelResourceStore | ... | @@ -256,18 +234,16 @@ public class DistributedLabelResourceStore |
256 | } | 234 | } |
257 | 235 | ||
258 | private boolean internalCreate(LabelResourcePool pool) { | 236 | private boolean internalCreate(LabelResourcePool pool) { |
259 | - resourcePoolLock.writeLock().lock(); | 237 | + Versioned<LabelResourcePool> poolOld = resourcePool |
260 | - LabelResourcePool poolOld = resourcePool.get(pool.deviceId()).value(); | 238 | + .get(pool.deviceId()); |
261 | if (poolOld == null) { | 239 | if (poolOld == null) { |
262 | resourcePool.put(pool.deviceId(), pool); | 240 | resourcePool.put(pool.deviceId(), pool); |
263 | - resourcePoolLock.writeLock().unlock(); | ||
264 | LabelResourceEvent event = new LabelResourceEvent( | 241 | LabelResourceEvent event = new LabelResourceEvent( |
265 | Type.POOL_CREATED, | 242 | Type.POOL_CREATED, |
266 | pool); | 243 | pool); |
267 | notifyDelegate(event); | 244 | notifyDelegate(event); |
268 | return true; | 245 | return true; |
269 | } | 246 | } |
270 | - resourcePoolLock.writeLock().unlock(); | ||
271 | return false; | 247 | return false; |
272 | } | 248 | } |
273 | 249 | ||
... | @@ -301,12 +277,12 @@ public class DistributedLabelResourceStore | ... | @@ -301,12 +277,12 @@ public class DistributedLabelResourceStore |
301 | } | 277 | } |
302 | 278 | ||
303 | private boolean internalDestroy(DeviceId deviceId) { | 279 | private boolean internalDestroy(DeviceId deviceId) { |
304 | - LabelResourcePool poolOld = resourcePool.get(deviceId).value(); | 280 | + Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId); |
305 | if (poolOld != null) { | 281 | if (poolOld != null) { |
306 | resourcePool.remove(deviceId); | 282 | resourcePool.remove(deviceId); |
307 | LabelResourceEvent event = new LabelResourceEvent( | 283 | LabelResourceEvent event = new LabelResourceEvent( |
308 | Type.POOL_CREATED, | 284 | Type.POOL_CREATED, |
309 | - poolOld); | 285 | + poolOld.value()); |
310 | notifyDelegate(event); | 286 | notifyDelegate(event); |
311 | } | 287 | } |
312 | log.info("success to destroy the label resource pool of device id {}", | 288 | log.info("success to destroy the label resource pool of device id {}", |
... | @@ -349,15 +325,14 @@ public class DistributedLabelResourceStore | ... | @@ -349,15 +325,14 @@ public class DistributedLabelResourceStore |
349 | } | 325 | } |
350 | 326 | ||
351 | private Collection<LabelResource> internalApply(LabelResourceRequest request) { | 327 | private Collection<LabelResource> internalApply(LabelResourceRequest request) { |
352 | - resourcePoolLock.writeLock().lock(); | ||
353 | DeviceId deviceId = request.deviceId(); | 328 | DeviceId deviceId = request.deviceId(); |
354 | long applyNum = request.applyNum(); | 329 | long applyNum = request.applyNum(); |
355 | - LabelResourcePool pool = resourcePool.get(deviceId).value(); | 330 | + Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId); |
331 | + LabelResourcePool pool = poolOld.value(); | ||
356 | Collection<LabelResource> result = new HashSet<LabelResource>(); | 332 | Collection<LabelResource> result = new HashSet<LabelResource>(); |
357 | long freeNum = this.getFreeNumOfDevicePool(deviceId); | 333 | long freeNum = this.getFreeNumOfDevicePool(deviceId); |
358 | if (applyNum > freeNum) { | 334 | if (applyNum > freeNum) { |
359 | log.info("the free number of the label resource pool of deviceId {} is not enough."); | 335 | log.info("the free number of the label resource pool of deviceId {} is not enough."); |
360 | - resourcePoolLock.writeLock().unlock(); | ||
361 | return Collections.emptyList(); | 336 | return Collections.emptyList(); |
362 | } | 337 | } |
363 | Set<LabelResource> releaseLabels = new HashSet<LabelResource>( | 338 | Set<LabelResource> releaseLabels = new HashSet<LabelResource>( |
... | @@ -393,7 +368,6 @@ public class DistributedLabelResourceStore | ... | @@ -393,7 +368,6 @@ public class DistributedLabelResourceStore |
393 | current, freeLabel); | 368 | current, freeLabel); |
394 | resourcePool.put(deviceId, newPool); | 369 | resourcePool.put(deviceId, newPool); |
395 | log.info("success to apply label resource"); | 370 | log.info("success to apply label resource"); |
396 | - resourcePoolLock.writeLock().unlock(); | ||
397 | return result; | 371 | return result; |
398 | } | 372 | } |
399 | 373 | ||
... | @@ -440,12 +414,11 @@ public class DistributedLabelResourceStore | ... | @@ -440,12 +414,11 @@ public class DistributedLabelResourceStore |
440 | } | 414 | } |
441 | 415 | ||
442 | private boolean internalRelease(LabelResourceRequest request) { | 416 | private boolean internalRelease(LabelResourceRequest request) { |
443 | - resourcePoolLock.writeLock().lock(); | ||
444 | DeviceId deviceId = request.deviceId(); | 417 | DeviceId deviceId = request.deviceId(); |
445 | Collection<LabelResource> release = request.releaseCollection(); | 418 | Collection<LabelResource> release = request.releaseCollection(); |
446 | - LabelResourcePool pool = resourcePool.get(deviceId).value(); | 419 | + Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId); |
420 | + LabelResourcePool pool = poolOld.value(); | ||
447 | if (pool == null) { | 421 | if (pool == null) { |
448 | - resourcePoolLock.writeLock().unlock(); | ||
449 | log.info("the label resource pool of device id {} does not exist"); | 422 | log.info("the label resource pool of device id {} does not exist"); |
450 | return false; | 423 | return false; |
451 | } | 424 | } |
... | @@ -480,34 +453,34 @@ public class DistributedLabelResourceStore | ... | @@ -480,34 +453,34 @@ public class DistributedLabelResourceStore |
480 | current, s); | 453 | current, s); |
481 | resourcePool.put(deviceId, newPool); | 454 | resourcePool.put(deviceId, newPool); |
482 | log.info("success to release label resource"); | 455 | log.info("success to release label resource"); |
483 | - resourcePoolLock.writeLock().unlock(); | ||
484 | return true; | 456 | return true; |
485 | } | 457 | } |
486 | 458 | ||
487 | @Override | 459 | @Override |
488 | public boolean isDevicePoolFull(DeviceId deviceId) { | 460 | public boolean isDevicePoolFull(DeviceId deviceId) { |
489 | - LabelResourcePool pool = resourcePool.get(deviceId).value(); | 461 | + Versioned<LabelResourcePool> pool = resourcePool.get(deviceId); |
490 | if (pool == null) { | 462 | if (pool == null) { |
491 | return true; | 463 | return true; |
492 | } | 464 | } |
493 | - return pool.currentUsedMaxLabelId() == pool.endLabel() | 465 | + return pool.value().currentUsedMaxLabelId() == pool.value().endLabel() |
494 | - && pool.releaseLabelId().size() == 0 ? true : false; | 466 | + && pool.value().releaseLabelId().size() == 0 ? true : false; |
495 | } | 467 | } |
496 | 468 | ||
497 | @Override | 469 | @Override |
498 | public long getFreeNumOfDevicePool(DeviceId deviceId) { | 470 | public long getFreeNumOfDevicePool(DeviceId deviceId) { |
499 | - LabelResourcePool pool = resourcePool.get(deviceId).value(); | 471 | + Versioned<LabelResourcePool> pool = resourcePool.get(deviceId); |
500 | if (pool == null) { | 472 | if (pool == null) { |
501 | return 0; | 473 | return 0; |
502 | } | 474 | } |
503 | - return pool.endLabel().labelId() | 475 | + return pool.value().endLabel().labelId() |
504 | - - pool.currentUsedMaxLabelId().labelId() | 476 | + - pool.value().currentUsedMaxLabelId().labelId() |
505 | - + pool.releaseLabelId().size(); | 477 | + + pool.value().releaseLabelId().size(); |
506 | } | 478 | } |
507 | 479 | ||
508 | @Override | 480 | @Override |
509 | public LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId) { | 481 | public LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId) { |
510 | - return resourcePool.get(deviceId).value(); | 482 | + Versioned<LabelResourcePool> pool = resourcePool.get(deviceId); |
483 | + return pool == null ? null : pool.value(); | ||
511 | } | 484 | } |
512 | 485 | ||
513 | @Override | 486 | @Override |
... | @@ -564,8 +537,7 @@ public class DistributedLabelResourceStore | ... | @@ -564,8 +537,7 @@ public class DistributedLabelResourceStore |
564 | 537 | ||
565 | private <T> T complete(Future<T> future) { | 538 | private <T> T complete(Future<T> future) { |
566 | try { | 539 | try { |
567 | - return future.get(PEER_REQUEST_TIMEOUT_MS, | 540 | + return future.get(PEER_REQUEST_TIMEOUT_MS, TimeUnit.MILLISECONDS); |
568 | - TimeUnit.MILLISECONDS); | ||
569 | } catch (InterruptedException e) { | 541 | } catch (InterruptedException e) { |
570 | Thread.currentThread().interrupt(); | 542 | Thread.currentThread().interrupt(); |
571 | log.error("Interrupted while waiting for operation to complete.", e); | 543 | log.error("Interrupted while waiting for operation to complete.", e); | ... | ... |
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()); | ... | ... |
... | @@ -17,13 +17,10 @@ package org.onosproject.provider.tunnel.cli; | ... | @@ -17,13 +17,10 @@ package org.onosproject.provider.tunnel.cli; |
17 | 17 | ||
18 | import java.util.Optional; | 18 | import java.util.Optional; |
19 | 19 | ||
20 | -import org.apache.karaf.shell.commands.Argument; | ||
21 | import org.apache.karaf.shell.commands.Command; | 20 | import org.apache.karaf.shell.commands.Command; |
21 | +import org.apache.karaf.shell.commands.Option; | ||
22 | import org.onlab.packet.IpAddress; | 22 | import org.onlab.packet.IpAddress; |
23 | import org.onosproject.cli.AbstractShellCommand; | 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; | 24 | import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint; |
28 | import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription; | 25 | import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription; |
29 | import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; | 26 | import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; |
... | @@ -32,116 +29,141 @@ import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint; | ... | @@ -32,116 +29,141 @@ import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint; |
32 | import org.onosproject.incubator.net.tunnel.Tunnel; | 29 | import org.onosproject.incubator.net.tunnel.Tunnel; |
33 | import org.onosproject.incubator.net.tunnel.TunnelDescription; | 30 | import org.onosproject.incubator.net.tunnel.TunnelDescription; |
34 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; | 31 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; |
32 | +import org.onosproject.incubator.net.tunnel.TunnelId; | ||
35 | import org.onosproject.incubator.net.tunnel.TunnelProvider; | 33 | import org.onosproject.incubator.net.tunnel.TunnelProvider; |
34 | +import org.onosproject.net.DeviceId; | ||
35 | +import org.onosproject.net.PortNumber; | ||
36 | +import org.onosproject.net.provider.ProviderId; | ||
36 | 37 | ||
37 | /** | 38 | /** |
38 | - * Supports for removing all tunnels by using IP address and optical as tunnel | 39 | + * Supports for removing tunnels. It's used by producers. |
39 | - * end point now. It's used by producers. | ||
40 | */ | 40 | */ |
41 | -@Command(scope = "onos", name = "remove-tunnels", description = "Supports for removing all tunnels by using IP address" | 41 | +@Command(scope = "onos", name = "tunnel-remove", description = "Supports for removing tunnels. It's used by producers.") |
42 | - + " and optical as tunnel end point now. It's used by producers.") | 42 | +public class TunnelRemoveCommand extends AbstractShellCommand { |
43 | -public class RemoveTunnelCommand extends AbstractShellCommand { | 43 | + @Option(name = "-s", aliases = "--src", description = "Source tunnel point." |
44 | - @Argument(index = 0, name = "src", description = "Source tunnel point." | ||
45 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." | 44 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." |
46 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." | 45 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." |
47 | - + " Otherwise src means IP address.", required = true, multiValued = false) | 46 | + + " Otherwise src means IP address.", required = false, multiValued = false) |
48 | String src = null; | 47 | String src = null; |
49 | - @Argument(index = 1, name = "dst", description = "Destination tunnel point." | 48 | + @Option(name = "-d", aliases = "--dst", description = "Destination tunnel point." |
50 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." | 49 | + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now." |
51 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." | 50 | + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber." |
52 | - + " Otherwise dst means IP address.", required = true, multiValued = false) | 51 | + + " Otherwise dst means IP address.", required = false, multiValued = false) |
53 | String dst = null; | 52 | String dst = null; |
54 | 53 | ||
55 | - @Argument(index = 2, name = "type", description = "The type of tunnels," | 54 | + @Option(name = "-t", aliases = "--type", description = "The type of tunnels," |
56 | - + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false) | 55 | + + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = false, multiValued = false) |
57 | String type = null; | 56 | String type = null; |
58 | 57 | ||
58 | + @Option(name = "-i", aliases = "--tunnelId", | ||
59 | + description = "the tunnel identity.", required = false, multiValued = false) | ||
60 | + String tunnelId = null; | ||
61 | + | ||
59 | @Override | 62 | @Override |
60 | protected void execute() { | 63 | protected void execute() { |
64 | + TunnelDescription tunnel = null; | ||
61 | TunnelProvider service = get(TunnelProvider.class); | 65 | TunnelProvider service = get(TunnelProvider.class); |
62 | ProviderId producerName = new ProviderId("default", | 66 | ProviderId producerName = new ProviderId("default", |
63 | "org.onosproject.provider.tunnel.default"); | 67 | "org.onosproject.provider.tunnel.default"); |
64 | - TunnelEndPoint srcPoint = null; | 68 | + if (!isNull(src) && !isNull(dst) && !isNull(type)) { |
65 | - TunnelEndPoint dstPoint = null; | 69 | + TunnelEndPoint srcPoint = null; |
66 | - Tunnel.Type trueType = null; | 70 | + TunnelEndPoint dstPoint = null; |
67 | - if ("MPLS".equals(type)) { | 71 | + Tunnel.Type trueType = null; |
68 | - trueType = Tunnel.Type.MPLS; | 72 | + if ("MPLS".equals(type)) { |
69 | - srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | 73 | + trueType = Tunnel.Type.MPLS; |
70 | - dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | 74 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
71 | - } else if ("VLAN".equals(type)) { | 75 | + .valueOf(src)); |
72 | - trueType = Tunnel.Type.VLAN; | 76 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
73 | - srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | 77 | + .valueOf(dst)); |
74 | - dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | 78 | + } else if ("VLAN".equals(type)) { |
75 | - } else if ("VXLAN".equals(type)) { | 79 | + trueType = Tunnel.Type.VLAN; |
76 | - trueType = Tunnel.Type.VXLAN; | 80 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
77 | - srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | 81 | + .valueOf(src)); |
78 | - dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | 82 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
79 | - } else if ("GRE".equals(type)) { | 83 | + .valueOf(dst)); |
80 | - trueType = Tunnel.Type.GRE; | 84 | + } else if ("VXLAN".equals(type)) { |
81 | - srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | 85 | + trueType = Tunnel.Type.VXLAN; |
82 | - dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | 86 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
83 | - } else if ("ODUK".equals(type)) { | 87 | + .valueOf(src)); |
84 | - trueType = Tunnel.Type.ODUK; | 88 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
85 | - String[] srcArray = src.split("-"); | 89 | + .valueOf(dst)); |
86 | - String[] dstArray = dst.split("-"); | 90 | + } else if ("GRE".equals(type)) { |
87 | - srcPoint = new DefaultOpticalTunnelEndPoint( | 91 | + trueType = Tunnel.Type.GRE; |
88 | - producerName, | 92 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
89 | - Optional.of(DeviceId | 93 | + .valueOf(src)); |
90 | - .deviceId(srcArray[0])), | 94 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress |
91 | - Optional.of(PortNumber | 95 | + .valueOf(dst)); |
92 | - .portNumber(srcArray[1])), | 96 | + } else if ("ODUK".equals(type)) { |
93 | - null, | 97 | + trueType = Tunnel.Type.ODUK; |
94 | - OpticalTunnelEndPoint.Type.LAMBDA, | 98 | + String[] srcArray = src.split("-"); |
95 | - OpticalLogicId | 99 | + String[] dstArray = dst.split("-"); |
96 | - .logicId(0), | 100 | + srcPoint = new DefaultOpticalTunnelEndPoint( |
97 | - true); | 101 | + producerName, |
98 | - dstPoint = new DefaultOpticalTunnelEndPoint( | 102 | + Optional.of(DeviceId |
99 | - producerName, | 103 | + .deviceId(srcArray[0])), |
100 | - Optional.of(DeviceId | 104 | + Optional.of(PortNumber |
101 | - .deviceId(dstArray[0])), | 105 | + .portNumber(srcArray[1])), |
102 | - Optional.of(PortNumber | 106 | + null, |
103 | - .portNumber(dstArray[1])), | 107 | + OpticalTunnelEndPoint.Type.LAMBDA, |
104 | - null, | 108 | + OpticalLogicId |
105 | - OpticalTunnelEndPoint.Type.LAMBDA, | 109 | + .logicId(0), |
106 | - OpticalLogicId | 110 | + true); |
107 | - .logicId(0), | 111 | + dstPoint = new DefaultOpticalTunnelEndPoint( |
108 | - true); | 112 | + producerName, |
109 | - } else if ("OCH".equals(type)) { | 113 | + Optional.of(DeviceId |
110 | - trueType = Tunnel.Type.OCH; | 114 | + .deviceId(dstArray[0])), |
111 | - String[] srcArray = src.split("-"); | 115 | + Optional.of(PortNumber |
112 | - String[] dstArray = dst.split("-"); | 116 | + .portNumber(dstArray[1])), |
113 | - srcPoint = new DefaultOpticalTunnelEndPoint( | 117 | + null, |
114 | - producerName, | 118 | + OpticalTunnelEndPoint.Type.LAMBDA, |
115 | - Optional.of(DeviceId | 119 | + OpticalLogicId |
116 | - .deviceId(srcArray[0])), | 120 | + .logicId(0), |
117 | - Optional.of(PortNumber | 121 | + true); |
118 | - .portNumber(srcArray[1])), | 122 | + } else if ("OCH".equals(type)) { |
119 | - null, | 123 | + trueType = Tunnel.Type.OCH; |
120 | - OpticalTunnelEndPoint.Type.LAMBDA, | 124 | + String[] srcArray = src.split("-"); |
121 | - OpticalLogicId | 125 | + String[] dstArray = dst.split("-"); |
122 | - .logicId(0), | 126 | + srcPoint = new DefaultOpticalTunnelEndPoint( |
123 | - true); | 127 | + producerName, |
124 | - dstPoint = new DefaultOpticalTunnelEndPoint( | 128 | + Optional.of(DeviceId |
125 | - producerName, | 129 | + .deviceId(srcArray[0])), |
126 | - Optional.of(DeviceId | 130 | + Optional.of(PortNumber |
127 | - .deviceId(dstArray[0])), | 131 | + .portNumber(srcArray[1])), |
128 | - Optional.of(PortNumber | 132 | + null, |
129 | - .portNumber(dstArray[1])), | 133 | + OpticalTunnelEndPoint.Type.LAMBDA, |
130 | - null, | 134 | + OpticalLogicId |
131 | - OpticalTunnelEndPoint.Type.LAMBDA, | 135 | + .logicId(0), |
132 | - OpticalLogicId | 136 | + true); |
133 | - .logicId(0), | 137 | + dstPoint = new DefaultOpticalTunnelEndPoint( |
134 | - true); | 138 | + producerName, |
135 | - } else { | 139 | + Optional.of(DeviceId |
136 | - print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | 140 | + .deviceId(dstArray[0])), |
137 | - return; | 141 | + Optional.of(PortNumber |
142 | + .portNumber(dstArray[1])), | ||
143 | + null, | ||
144 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
145 | + OpticalLogicId | ||
146 | + .logicId(0), | ||
147 | + true); | ||
148 | + } else { | ||
149 | + print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | ||
150 | + return; | ||
151 | + } | ||
152 | + | ||
153 | + tunnel = new DefaultTunnelDescription(null, srcPoint, dstPoint, | ||
154 | + trueType, null, producerName, | ||
155 | + null, null); | ||
156 | + service.tunnelRemoved(tunnel); | ||
157 | + } | ||
158 | + if (!isNull(tunnelId)) { | ||
159 | + TunnelId id = TunnelId.valueOf(tunnelId); | ||
160 | + tunnel = new DefaultTunnelDescription(id, null, null, null, null, | ||
161 | + producerName, null, null); | ||
162 | + service.tunnelRemoved(tunnel); | ||
138 | } | 163 | } |
139 | - TunnelDescription tunnel = new DefaultTunnelDescription(null, srcPoint, | ||
140 | - dstPoint, | ||
141 | - trueType, null, | ||
142 | - producerName, | ||
143 | - null); | ||
144 | - service.tunnelRemoved(tunnel); | ||
145 | } | 164 | } |
146 | 165 | ||
166 | + private boolean isNull(String s) { | ||
167 | + return s == null || "".equals(s); | ||
168 | + } | ||
147 | } | 169 | } | ... | ... |
providers/tunnel/src/main/java/org/onosproject/provider/tunnel/cli/TunnelUpdateCommand.java
0 → 100644
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> | ... | ... |
-
Please register or login to post a comment