Committed by
Brian O'Connor
[ONOS-1284][ONOS-1869]the implementation of tunnel subsystem.It includes
test commands, store, service. the store use eventually consistent. Change-Id: Id54224ff65f3f2fa0a1d7adb072a2fe664987d18
Showing
17 changed files
with
1117 additions
and
0 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 | + */ | ||
16 | +package org.onosproject.cli.net; | ||
17 | + | ||
18 | +import java.util.Collection; | ||
19 | +import java.util.Optional; | ||
20 | + | ||
21 | +import org.apache.karaf.shell.commands.Argument; | ||
22 | +import org.apache.karaf.shell.commands.Command; | ||
23 | +import org.onlab.packet.IpAddress; | ||
24 | +import org.onosproject.cli.AbstractShellCommand; | ||
25 | +import org.onosproject.core.ApplicationId; | ||
26 | +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.net.tunnel.DefaultOpticalTunnelEndPoint; | ||
31 | +import org.onosproject.net.tunnel.IpTunnelEndPoint; | ||
32 | +import org.onosproject.net.tunnel.OpticalLogicId; | ||
33 | +import org.onosproject.net.tunnel.OpticalTunnelEndPoint; | ||
34 | +import org.onosproject.net.tunnel.Tunnel; | ||
35 | +import org.onosproject.net.tunnel.TunnelEndPoint; | ||
36 | +import org.onosproject.net.tunnel.TunnelService; | ||
37 | + | ||
38 | +/** | ||
39 | + * Borrows all tunnels between specific source tunnel end point and specific | ||
40 | + * destination tunnel end point. Supports for IP address and optical as tunnel end point now. It's used by consumers. | ||
41 | + */ | ||
42 | +@Command(scope = "onos", name = "borrow-tunnels", | ||
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 BorrowTunnelCommand extends AbstractShellCommand { | ||
47 | + @Argument(index = 0, name = "consumerId", description = "consumer id means application id.", | ||
48 | + required = true, multiValued = false) | ||
49 | + String consumerId = null; | ||
50 | + @Argument(index = 1, name = "src", description = "Source tunnel point." | ||
51 | + + " 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." | ||
53 | + + " Otherwise src means IP address.", required = true, multiValued = false) | ||
54 | + String src = null; | ||
55 | + @Argument(index = 2, name = "dst", description = "Destination tunnel point." | ||
56 | + + " 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." | ||
58 | + + " Otherwise dst means IP address.", required = true, multiValued = false) | ||
59 | + String dst = null; | ||
60 | + | ||
61 | + @Argument(index = 3, name = "type", description = "The type of tunnels," | ||
62 | + + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false) | ||
63 | + String type = null; | ||
64 | + private static final String FMT = "src=%s, dst=%s," | ||
65 | + + "type=%s, state=%s, producerName=%s, tunnelName=%s," | ||
66 | + + "groupId=%s"; | ||
67 | + | ||
68 | + @Override | ||
69 | + protected void execute() { | ||
70 | + TunnelService service = get(TunnelService.class); | ||
71 | + ApplicationId appId = new DefaultApplicationId(1, consumerId); | ||
72 | + ProviderId producerName = new ProviderId("default", | ||
73 | + "org.onosproject.provider.tunnel.default"); | ||
74 | + TunnelEndPoint srcPoint = null; | ||
75 | + TunnelEndPoint dstPoint = null; | ||
76 | + if ("MPLS".equals(type) || "VLAN".equals(type) || "VXLAN".equals(type) | ||
77 | + || "GRE".equals(type)) { | ||
78 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | ||
79 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | ||
80 | + } else if ("ODUK".equals(type) || "OCH".equals(type)) { | ||
81 | + String[] srcArray = src.split("-"); | ||
82 | + String[] dstArray = dst.split("-"); | ||
83 | + srcPoint = new DefaultOpticalTunnelEndPoint( | ||
84 | + producerName, | ||
85 | + Optional.of(DeviceId | ||
86 | + .deviceId(srcArray[0])), | ||
87 | + Optional.of(PortNumber | ||
88 | + .portNumber(srcArray[1])), | ||
89 | + null, | ||
90 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
91 | + OpticalLogicId | ||
92 | + .logicId(0), | ||
93 | + true); | ||
94 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
95 | + producerName, | ||
96 | + Optional.of(DeviceId | ||
97 | + .deviceId(dstArray[0])), | ||
98 | + Optional.of(PortNumber | ||
99 | + .portNumber(dstArray[1])), | ||
100 | + null, | ||
101 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
102 | + OpticalLogicId | ||
103 | + .logicId(0), | ||
104 | + true); | ||
105 | + } else { | ||
106 | + print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | ||
107 | + return; | ||
108 | + } | ||
109 | + Collection<Tunnel> tunnelSet = service.borrowTunnel(appId, srcPoint, dstPoint); | ||
110 | + for (Tunnel tunnel : tunnelSet) { | ||
111 | + print(FMT, tunnel.src(), tunnel.dst(), tunnel.type(), | ||
112 | + tunnel.state(), tunnel.providerId(), tunnel.tunnelName(), | ||
113 | + tunnel.groupId()); | ||
114 | + } | ||
115 | + } | ||
116 | + | ||
117 | +} |
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.net.tunnel.DefaultOpticalTunnelEndPoint; | ||
28 | +import org.onosproject.net.tunnel.IpTunnelEndPoint; | ||
29 | +import org.onosproject.net.tunnel.OpticalLogicId; | ||
30 | +import org.onosproject.net.tunnel.OpticalTunnelEndPoint; | ||
31 | +import org.onosproject.net.tunnel.TunnelAdminService; | ||
32 | +import org.onosproject.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 DeleteTunnelCommand 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 | +} |
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.Collection; | ||
19 | +import java.util.Optional; | ||
20 | + | ||
21 | +import org.apache.karaf.shell.commands.Argument; | ||
22 | +import org.apache.karaf.shell.commands.Command; | ||
23 | +import org.onlab.packet.IpAddress; | ||
24 | +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.net.tunnel.DefaultOpticalTunnelEndPoint; | ||
29 | +import org.onosproject.net.tunnel.IpTunnelEndPoint; | ||
30 | +import org.onosproject.net.tunnel.OpticalLogicId; | ||
31 | +import org.onosproject.net.tunnel.OpticalTunnelEndPoint; | ||
32 | +import org.onosproject.net.tunnel.Tunnel; | ||
33 | +import org.onosproject.net.tunnel.TunnelEndPoint; | ||
34 | +import org.onosproject.net.tunnel.TunnelService; | ||
35 | + | ||
36 | +/** | ||
37 | + * Supports for querying all tunnels by using IP address and optical as tunnel | ||
38 | + * end point now. It's used by consumers. | ||
39 | + */ | ||
40 | +@Command(scope = "onos", name = "query-tunnels", description = "Supports for querying all tunnels by using IP address" | ||
41 | + + " and optical as tunnel end point now." | ||
42 | + + " It's used by consumers.") | ||
43 | +public class QueryTunnelCommand extends AbstractShellCommand { | ||
44 | + @Argument(index = 0, name = "src", description = "Source tunnel point." | ||
45 | + + " 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." | ||
47 | + + " Otherwise src means IP address.", required = true, multiValued = false) | ||
48 | + String src = null; | ||
49 | + @Argument(index = 1, name = "dst", description = "Destination tunnel point." | ||
50 | + + " 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 | + + " Otherwise dst means IP address.", required = true, multiValued = false) | ||
53 | + String dst = null; | ||
54 | + | ||
55 | + @Argument(index = 2, name = "type", description = "The type of tunnels," | ||
56 | + + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false) | ||
57 | + String type = null; | ||
58 | + | ||
59 | + private static final String FMT = "src=%s, dst=%s," | ||
60 | + + "type=%s, state=%s, producerName=%s, tunnelName=%s," | ||
61 | + + "groupId=%s"; | ||
62 | + | ||
63 | + @Override | ||
64 | + protected void execute() { | ||
65 | + TunnelService service = get(TunnelService.class); | ||
66 | + ProviderId producerName = new ProviderId("default", | ||
67 | + "org.onosproject.provider.tunnel.default"); | ||
68 | + TunnelEndPoint srcPoint = null; | ||
69 | + TunnelEndPoint dstPoint = null; | ||
70 | + if ("MPLS".equals(type) || "VLAN".equals(type) || "VXLAN".equals(type) | ||
71 | + || "GRE".equals(type)) { | ||
72 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | ||
73 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | ||
74 | + } else if ("ODUK".equals(type) || "OCH".equals(type)) { | ||
75 | + String[] srcArray = src.split("-"); | ||
76 | + String[] dstArray = dst.split("-"); | ||
77 | + srcPoint = new DefaultOpticalTunnelEndPoint( | ||
78 | + producerName, | ||
79 | + Optional.of(DeviceId | ||
80 | + .deviceId(srcArray[0])), | ||
81 | + Optional.of(PortNumber | ||
82 | + .portNumber(srcArray[1])), | ||
83 | + null, | ||
84 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
85 | + OpticalLogicId | ||
86 | + .logicId(0), | ||
87 | + true); | ||
88 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
89 | + producerName, | ||
90 | + Optional.of(DeviceId | ||
91 | + .deviceId(dstArray[0])), | ||
92 | + Optional.of(PortNumber | ||
93 | + .portNumber(dstArray[1])), | ||
94 | + null, | ||
95 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
96 | + OpticalLogicId | ||
97 | + .logicId(0), | ||
98 | + true); | ||
99 | + } else { | ||
100 | + print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | ||
101 | + return; | ||
102 | + } | ||
103 | + Collection<Tunnel> tunnelSet = service.queryTunnel(srcPoint, dstPoint); | ||
104 | + for (Tunnel tunnel : tunnelSet) { | ||
105 | + print(FMT, tunnel.src().toString(), tunnel.dst().toString(), tunnel.type(), | ||
106 | + tunnel.state(), tunnel.providerId(), tunnel.tunnelName(), | ||
107 | + tunnel.groupId()); | ||
108 | + } | ||
109 | + } | ||
110 | + | ||
111 | +} |
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.Collection; | ||
19 | + | ||
20 | +import org.apache.karaf.shell.commands.Argument; | ||
21 | +import org.apache.karaf.shell.commands.Command; | ||
22 | +import org.onosproject.cli.AbstractShellCommand; | ||
23 | +import org.onosproject.core.ApplicationId; | ||
24 | +import org.onosproject.core.DefaultApplicationId; | ||
25 | +import org.onosproject.net.tunnel.TunnelService; | ||
26 | +import org.onosproject.net.tunnel.TunnelSubscription; | ||
27 | + | ||
28 | +/** | ||
29 | + * Query all tunnel subscriptions of consumer by consumer id. | ||
30 | + * It's used by consumers. | ||
31 | + */ | ||
32 | +@Command(scope = "onos", name = "query-tunnel-subscriptions", | ||
33 | + description = "Query all request orders of consumer by consumer id. It's used by consumers.") | ||
34 | +public class QueryTunnelSubscriptionCommand extends AbstractShellCommand { | ||
35 | + @Argument(index = 0, name = "consumerId", | ||
36 | + description = "consumer id means provider id", | ||
37 | + required = true, multiValued = false) | ||
38 | + String consumerId = null; | ||
39 | + private static final String FMT = "appId=%s, src=%s, dst=%s," | ||
40 | + + "type=%s, tunnelId=%s"; | ||
41 | + | ||
42 | + @Override | ||
43 | + protected void execute() { | ||
44 | + TunnelService service = get(TunnelService.class); | ||
45 | + ApplicationId applicationId = new DefaultApplicationId(1, consumerId); | ||
46 | + Collection<TunnelSubscription> tunnelSet = service.queryTunnelSubscription(applicationId); | ||
47 | + for (TunnelSubscription order : tunnelSet) { | ||
48 | + print(FMT, order.consumerId(), order.src(), order.dst(), | ||
49 | + order.type(), order.tunnelId()); | ||
50 | + } | ||
51 | + } | ||
52 | + | ||
53 | +} |
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.core.ApplicationId; | ||
25 | +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.net.tunnel.DefaultOpticalTunnelEndPoint; | ||
30 | +import org.onosproject.net.tunnel.IpTunnelEndPoint; | ||
31 | +import org.onosproject.net.tunnel.OpticalLogicId; | ||
32 | +import org.onosproject.net.tunnel.OpticalTunnelEndPoint; | ||
33 | +import org.onosproject.net.tunnel.TunnelEndPoint; | ||
34 | +import org.onosproject.net.tunnel.TunnelService; | ||
35 | + | ||
36 | +/** | ||
37 | + * Returns all tunnels between specific source tunnel end point and specific | ||
38 | + * destination tunnel end point. Supports for IP address and optical as tunnel | ||
39 | + * end point now. It's used by consumers. | ||
40 | + */ | ||
41 | +@Command(scope = "onos", name = "return-tunnels", | ||
42 | +description = "Returns all tunnels between specific source tunnel end point and specific " | ||
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 ReturnTunnelCommand extends AbstractShellCommand { | ||
46 | + @Argument(index = 0, name = "consumerId", description = "consumer id means application id.", | ||
47 | + required = true, multiValued = false) | ||
48 | + String consumerId = null; | ||
49 | + @Argument(index = 1, name = "src", description = "Source tunnel point." | ||
50 | + + " 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 | + + " Otherwise src means IP address.", required = true, multiValued = false) | ||
53 | + String src = null; | ||
54 | + @Argument(index = 2, name = "dst", description = "Destination tunnel point." | ||
55 | + + " 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." | ||
57 | + + " Otherwise dst means IP address.", required = true, multiValued = false) | ||
58 | + String dst = null; | ||
59 | + | ||
60 | + @Argument(index = 3, name = "type", description = "The type of tunnels," | ||
61 | + + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false) | ||
62 | + String type = null; | ||
63 | + | ||
64 | + @Override | ||
65 | + protected void execute() { | ||
66 | + TunnelService service = get(TunnelService.class); | ||
67 | + ApplicationId appId = new DefaultApplicationId(1, consumerId); | ||
68 | + ProviderId producerName = new ProviderId("default", | ||
69 | + "org.onosproject.provider.tunnel.default"); | ||
70 | + TunnelEndPoint srcPoint = null; | ||
71 | + TunnelEndPoint dstPoint = null; | ||
72 | + if ("MPLS".equals(type) || "VLAN".equals(type) || "VXLAN".equals(type) | ||
73 | + || "GRE".equals(type)) { | ||
74 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | ||
75 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | ||
76 | + } else if ("ODUK".equals(type) || "OCH".equals(type)) { | ||
77 | + String[] srcArray = src.split("-"); | ||
78 | + String[] dstArray = dst.split("-"); | ||
79 | + srcPoint = new DefaultOpticalTunnelEndPoint( | ||
80 | + producerName, | ||
81 | + Optional.of(DeviceId | ||
82 | + .deviceId(srcArray[0])), | ||
83 | + Optional.of(PortNumber | ||
84 | + .portNumber(srcArray[1])), | ||
85 | + null, | ||
86 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
87 | + OpticalLogicId | ||
88 | + .logicId(0), | ||
89 | + true); | ||
90 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
91 | + producerName, | ||
92 | + Optional.of(DeviceId | ||
93 | + .deviceId(dstArray[0])), | ||
94 | + Optional.of(PortNumber | ||
95 | + .portNumber(dstArray[1])), | ||
96 | + null, | ||
97 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
98 | + OpticalLogicId | ||
99 | + .logicId(0), | ||
100 | + true); | ||
101 | + } else { | ||
102 | + print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | ||
103 | + return; | ||
104 | + } | ||
105 | + service.returnTunnel(appId, srcPoint, dstPoint); | ||
106 | + } | ||
107 | + | ||
108 | +} |
... | @@ -367,6 +367,22 @@ | ... | @@ -367,6 +367,22 @@ |
367 | <command> | 367 | <command> |
368 | <action class="org.onosproject.cli.net.ApplyLabelResourceCommand"/> | 368 | <action class="org.onosproject.cli.net.ApplyLabelResourceCommand"/> |
369 | </command> | 369 | </command> |
370 | + <!-- tunnel commands --> | ||
371 | + <command> | ||
372 | + <action class="org.onosproject.cli.net.DeleteTunnelCommand"/> | ||
373 | + </command> | ||
374 | + <command> | ||
375 | + <action class="org.onosproject.cli.net.BorrowTunnelCommand"/> | ||
376 | + </command> | ||
377 | + <command> | ||
378 | + <action class="org.onosproject.cli.net.ReturnTunnelCommand"/> | ||
379 | + </command> | ||
380 | + <command> | ||
381 | + <action class="org.onosproject.cli.net.QueryTunnelCommand"/> | ||
382 | + </command> | ||
383 | + <command> | ||
384 | + <action class="org.onosproject.cli.net.QueryTunnelSubscriptionCommand"/> | ||
385 | + </command> | ||
370 | </command-bundle> | 386 | </command-bundle> |
371 | 387 | ||
372 | <bean id="permAppNameCompleter" class="org.onosproject.cli.security.PermissionApplicationNameCompleter"/> | 388 | <bean id="permAppNameCompleter" class="org.onosproject.cli.security.PermissionApplicationNameCompleter"/> | ... | ... |
This diff is collapsed. Click to expand it.
core/store/dist/src/main/java/org/onosproject/store/tunnel/impl/DistributedTunnelStore.java
0 → 100644
This diff is collapsed. Click to expand it.
1 | +/* | ||
2 | + * Copyright 2014 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 | +/** | ||
18 | + * Implementation of distributed tunnel store using p2p synchronization protocol. | ||
19 | + */ | ||
20 | +package org.onosproject.store.tunnel.impl; |
... | @@ -37,6 +37,7 @@ | ... | @@ -37,6 +37,7 @@ |
37 | <module>host</module> | 37 | <module>host</module> |
38 | <module>netconf</module> | 38 | <module>netconf</module> |
39 | <module>null</module> | 39 | <module>null</module> |
40 | + <module>tunnel</module> | ||
40 | </modules> | 41 | </modules> |
41 | 42 | ||
42 | <dependencies> | 43 | <dependencies> | ... | ... |
providers/tunnel/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!-- | ||
3 | + ~ Copyright 2014 Open Networking Laboratory | ||
4 | + ~ | ||
5 | + ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | + ~ you may not use this file except in compliance with the License. | ||
7 | + ~ You may obtain a copy of the License at | ||
8 | + ~ | ||
9 | + ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | + ~ | ||
11 | + ~ Unless required by applicable law or agreed to in writing, software | ||
12 | + ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | + ~ See the License for the specific language governing permissions and | ||
15 | + ~ limitations under the License. | ||
16 | + --> | ||
17 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
18 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
19 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
20 | + <modelVersion>4.0.0</modelVersion> | ||
21 | + | ||
22 | + <parent> | ||
23 | + <groupId>org.onosproject</groupId> | ||
24 | + <artifactId>onos-providers</artifactId> | ||
25 | + <version>1.2.0-SNAPSHOT</version> | ||
26 | + <relativePath>../pom.xml</relativePath> | ||
27 | + </parent> | ||
28 | + | ||
29 | + <artifactId>onos-tunnel-provider</artifactId> | ||
30 | + <packaging>bundle</packaging> | ||
31 | + | ||
32 | + <description>tunnel southbound providers</description> | ||
33 | + | ||
34 | + <properties> | ||
35 | + <onos.app.name>org.onosproject.tunnel</onos.app.name> | ||
36 | + </properties> | ||
37 | + | ||
38 | + <dependencies> | ||
39 | + <dependency> | ||
40 | + <groupId>org.osgi</groupId> | ||
41 | + <artifactId>org.osgi.compendium</artifactId> | ||
42 | + </dependency> | ||
43 | + <dependency> | ||
44 | + <groupId>org.apache.karaf.shell</groupId> | ||
45 | + <artifactId>org.apache.karaf.shell.console</artifactId> | ||
46 | + </dependency> | ||
47 | + <dependency> | ||
48 | + <groupId>org.onosproject</groupId> | ||
49 | + <artifactId>onos-cli</artifactId> | ||
50 | + <version>${project.version}</version> | ||
51 | + </dependency> | ||
52 | + | ||
53 | + <dependency> | ||
54 | + <groupId>org.onosproject</groupId> | ||
55 | + <artifactId>onos-api</artifactId> | ||
56 | + <classifier>tests</classifier> | ||
57 | + <scope>test</scope> | ||
58 | + </dependency> | ||
59 | + </dependencies> | ||
60 | + | ||
61 | +</project> |
providers/tunnel/src/main/java/org/onosproject/provider/tunnel/DefaultTunnelProvider.java
0 → 100644
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 | +package org.onosproject.provider.tunnel; | ||
17 | + | ||
18 | +import static org.slf4j.LoggerFactory.getLogger; | ||
19 | + | ||
20 | +import org.apache.felix.scr.annotations.Activate; | ||
21 | +import org.apache.felix.scr.annotations.Component; | ||
22 | +import org.apache.felix.scr.annotations.Deactivate; | ||
23 | +import org.apache.felix.scr.annotations.Reference; | ||
24 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
25 | +import org.apache.felix.scr.annotations.Service; | ||
26 | +import org.onosproject.cfg.ComponentConfigService; | ||
27 | +import org.onosproject.net.ElementId; | ||
28 | +import org.onosproject.net.Path; | ||
29 | +import org.onosproject.net.provider.AbstractProvider; | ||
30 | +import org.onosproject.net.provider.ProviderId; | ||
31 | +import org.onosproject.net.tunnel.Tunnel; | ||
32 | +import org.onosproject.net.tunnel.TunnelDescription; | ||
33 | +import org.onosproject.net.tunnel.TunnelId; | ||
34 | +import org.onosproject.net.tunnel.TunnelProvider; | ||
35 | +import org.onosproject.net.tunnel.TunnelProviderRegistry; | ||
36 | +import org.onosproject.net.tunnel.TunnelProviderService; | ||
37 | +import org.osgi.service.component.ComponentContext; | ||
38 | +import org.slf4j.Logger; | ||
39 | + | ||
40 | +/** | ||
41 | + * Provider of a fake network environment, i.e. devices, links, hosts, etc. To | ||
42 | + * be used for benchmarking only. | ||
43 | + */ | ||
44 | +@Component(immediate = true) | ||
45 | +@Service | ||
46 | +public class DefaultTunnelProvider extends AbstractProvider | ||
47 | + implements TunnelProvider { | ||
48 | + | ||
49 | + private static final Logger log = getLogger(DefaultTunnelProvider.class); | ||
50 | + | ||
51 | + static final String PROVIDER_ID = "org.onosproject.provider.tunnel.default"; | ||
52 | + | ||
53 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
54 | + protected ComponentConfigService cfgService; | ||
55 | + | ||
56 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
57 | + protected TunnelProviderRegistry tunnelProviderRegistry; | ||
58 | + | ||
59 | + TunnelProviderService service; | ||
60 | + | ||
61 | + /** | ||
62 | + * Creates a Tunnel provider. | ||
63 | + */ | ||
64 | + public DefaultTunnelProvider() { | ||
65 | + super(new ProviderId("default", PROVIDER_ID)); | ||
66 | + } | ||
67 | + | ||
68 | + @Activate | ||
69 | + public void activate(ComponentContext context) { | ||
70 | + cfgService.registerProperties(getClass()); | ||
71 | + service = tunnelProviderRegistry.register(this); | ||
72 | + log.info("Started"); | ||
73 | + } | ||
74 | + | ||
75 | + @Deactivate | ||
76 | + public void deactivate(ComponentContext context) { | ||
77 | + cfgService.unregisterProperties(getClass(), false); | ||
78 | + tunnelProviderRegistry.unregister(this); | ||
79 | + log.info("Stopped"); | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
83 | + public void setupTunnel(Tunnel tunnel, Path path) { | ||
84 | + // TODO Auto-generated method stub | ||
85 | + | ||
86 | + } | ||
87 | + | ||
88 | + @Override | ||
89 | + public void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path) { | ||
90 | + // TODO Auto-generated method stub | ||
91 | + | ||
92 | + } | ||
93 | + | ||
94 | + @Override | ||
95 | + public void releaseTunnel(Tunnel tunnel) { | ||
96 | + // TODO Auto-generated method stub | ||
97 | + | ||
98 | + } | ||
99 | + | ||
100 | + @Override | ||
101 | + public void releaseTunnel(ElementId srcElement, Tunnel tunnel) { | ||
102 | + // TODO Auto-generated method stub | ||
103 | + | ||
104 | + } | ||
105 | + | ||
106 | + @Override | ||
107 | + public void updateTunnel(Tunnel tunnel, Path path) { | ||
108 | + // TODO Auto-generated method stub | ||
109 | + | ||
110 | + } | ||
111 | + | ||
112 | + @Override | ||
113 | + public void updateTunnel(ElementId srcElement, Tunnel tunnel, Path path) { | ||
114 | + // TODO Auto-generated method stub | ||
115 | + | ||
116 | + } | ||
117 | + | ||
118 | + @Override | ||
119 | + public TunnelId tunnelAdded(TunnelDescription tunnel) { | ||
120 | + return service.tunnelAdded(tunnel); | ||
121 | + } | ||
122 | + | ||
123 | + @Override | ||
124 | + public void tunnelRemoved(TunnelDescription tunnel) { | ||
125 | + service.tunnelRemoved(tunnel); | ||
126 | + } | ||
127 | + | ||
128 | + @Override | ||
129 | + public void tunnelUpdated(TunnelDescription tunnel) { | ||
130 | + service.tunnelUpdated(tunnel); | ||
131 | + } | ||
132 | + | ||
133 | +} |
providers/tunnel/src/main/java/org/onosproject/provider/tunnel/cli/CreateTunnelCommand.java
0 → 100644
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 | +package org.onosproject.provider.tunnel.cli; | ||
17 | + | ||
18 | +import static com.google.common.base.Preconditions.checkArgument; | ||
19 | + | ||
20 | +import java.util.Optional; | ||
21 | + | ||
22 | +import org.apache.karaf.shell.commands.Argument; | ||
23 | +import org.apache.karaf.shell.commands.Command; | ||
24 | +import org.onlab.packet.IpAddress; | ||
25 | +import org.onosproject.cli.AbstractShellCommand; | ||
26 | +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.net.tunnel.DefaultOpticalTunnelEndPoint; | ||
33 | +import org.onosproject.net.tunnel.DefaultTunnelDescription; | ||
34 | +import org.onosproject.net.tunnel.IpTunnelEndPoint; | ||
35 | +import org.onosproject.net.tunnel.OpticalLogicId; | ||
36 | +import org.onosproject.net.tunnel.OpticalTunnelEndPoint; | ||
37 | +import org.onosproject.net.tunnel.Tunnel; | ||
38 | +import org.onosproject.net.tunnel.TunnelDescription; | ||
39 | +import org.onosproject.net.tunnel.TunnelEndPoint; | ||
40 | +import org.onosproject.net.tunnel.TunnelId; | ||
41 | +import org.onosproject.net.tunnel.TunnelName; | ||
42 | +import org.onosproject.net.tunnel.TunnelProvider; | ||
43 | + | ||
44 | +/** | ||
45 | + * Supports for creating a tunnel by using IP address and optical as tunnel end | ||
46 | + * point. | ||
47 | + */ | ||
48 | +@Command(scope = "onos", name = "create-tunnels", | ||
49 | +description = "Supports for creating a tunnel by using IP address and optical as tunnel end point now.") | ||
50 | +public class CreateTunnelCommand extends AbstractShellCommand { | ||
51 | + | ||
52 | + @Argument(index = 0, name = "src", description = "Source tunnel point." | ||
53 | + + " 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." | ||
55 | + + " Otherwise src means IP address.", required = true, multiValued = false) | ||
56 | + String src = null; | ||
57 | + | ||
58 | + @Argument(index = 1, name = "dst", description = "Destination tunnel point." | ||
59 | + + " 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." | ||
61 | + + " Otherwise dst means IP address.", required = true, multiValued = false) | ||
62 | + String dst = null; | ||
63 | + @Argument(index = 2, name = "type", description = "The type of tunnels," | ||
64 | + + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false) | ||
65 | + String type = null; | ||
66 | + @Argument(index = 3, name = "groupId", | ||
67 | + description = "Group flow table id which a tunnel match up", required = true, multiValued = false) | ||
68 | + String groupId = null; | ||
69 | + | ||
70 | + @Argument(index = 4, name = "tunnelName", | ||
71 | + description = "The name of tunnels", required = false, multiValued = false) | ||
72 | + String tunnelName = null; | ||
73 | + | ||
74 | + @Argument(index = 5, name = "bandWith", | ||
75 | + description = "The bandWith attribute of tunnel", required = false, multiValued = false) | ||
76 | + String bandWith = null; | ||
77 | + | ||
78 | + private static final String FMT = "The tunnel identity is %s"; | ||
79 | + | ||
80 | + @Override | ||
81 | + protected void execute() { | ||
82 | + TunnelProvider service = get(TunnelProvider.class); | ||
83 | + ProviderId producerName = new ProviderId("default", | ||
84 | + "org.onosproject.provider.tunnel.default"); | ||
85 | + TunnelEndPoint srcPoint = null; | ||
86 | + TunnelEndPoint dstPoint = null; | ||
87 | + Tunnel.Type trueType = null; | ||
88 | + if ("MPLS".equals(type)) { | ||
89 | + trueType = Tunnel.Type.MPLS; | ||
90 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | ||
91 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | ||
92 | + } else if ("VLAN".equals(type)) { | ||
93 | + trueType = Tunnel.Type.VLAN; | ||
94 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | ||
95 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | ||
96 | + } else if ("VXLAN".equals(type)) { | ||
97 | + trueType = Tunnel.Type.VXLAN; | ||
98 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | ||
99 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | ||
100 | + } else if ("GRE".equals(type)) { | ||
101 | + trueType = Tunnel.Type.GRE; | ||
102 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | ||
103 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | ||
104 | + } else if ("ODUK".equals(type)) { | ||
105 | + trueType = Tunnel.Type.ODUK; | ||
106 | + String[] srcArray = src.split("||"); | ||
107 | + checkArgument(srcArray.length < 2, "Illegal src formatter."); | ||
108 | + String[] dstArray = dst.split("||"); | ||
109 | + checkArgument(dstArray.length < 2, "Illegal dst formatter."); | ||
110 | + srcPoint = new DefaultOpticalTunnelEndPoint( | ||
111 | + producerName, | ||
112 | + Optional.of(DeviceId | ||
113 | + .deviceId(srcArray[0])), | ||
114 | + Optional.of(PortNumber | ||
115 | + .portNumber(srcArray[1])), | ||
116 | + null, | ||
117 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
118 | + OpticalLogicId | ||
119 | + .logicId(0), | ||
120 | + true); | ||
121 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
122 | + producerName, | ||
123 | + Optional.of(DeviceId | ||
124 | + .deviceId(dstArray[0])), | ||
125 | + Optional.of(PortNumber | ||
126 | + .portNumber(dstArray[1])), | ||
127 | + null, | ||
128 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
129 | + OpticalLogicId | ||
130 | + .logicId(0), | ||
131 | + true); | ||
132 | + } else if ("OCH".equals(type)) { | ||
133 | + trueType = Tunnel.Type.OCH; | ||
134 | + String[] srcArray = src.split("-"); | ||
135 | + String[] dstArray = dst.split("-"); | ||
136 | + srcPoint = new DefaultOpticalTunnelEndPoint( | ||
137 | + producerName, | ||
138 | + Optional.of(DeviceId | ||
139 | + .deviceId(srcArray[0])), | ||
140 | + Optional.of(PortNumber | ||
141 | + .portNumber(srcArray[1])), | ||
142 | + null, | ||
143 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
144 | + OpticalLogicId | ||
145 | + .logicId(0), | ||
146 | + true); | ||
147 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
148 | + producerName, | ||
149 | + Optional.of(DeviceId | ||
150 | + .deviceId(dstArray[0])), | ||
151 | + Optional.of(PortNumber | ||
152 | + .portNumber(dstArray[1])), | ||
153 | + null, | ||
154 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
155 | + OpticalLogicId | ||
156 | + .logicId(0), | ||
157 | + true); | ||
158 | + } else { | ||
159 | + print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | ||
160 | + return; | ||
161 | + } | ||
162 | + | ||
163 | + SparseAnnotations annotations = DefaultAnnotations | ||
164 | + .builder() | ||
165 | + .set("bandWith", bandWith == null && "".equals(bandWith) ? "0" : bandWith) | ||
166 | + .build(); | ||
167 | + TunnelDescription tunnel = new DefaultTunnelDescription( | ||
168 | + null, | ||
169 | + srcPoint, | ||
170 | + dstPoint, | ||
171 | + trueType, | ||
172 | + new DefaultGroupId( | ||
173 | + Integer.valueOf(groupId) | ||
174 | + .intValue()), | ||
175 | + producerName, | ||
176 | + TunnelName | ||
177 | + .tunnelName(tunnelName), | ||
178 | + annotations); | ||
179 | + TunnelId tunnelId = service.tunnelAdded(tunnel); | ||
180 | + print(FMT, tunnelId.id()); | ||
181 | + } | ||
182 | + | ||
183 | +} |
providers/tunnel/src/main/java/org/onosproject/provider/tunnel/cli/RemoveTunnelCommand.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 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.net.tunnel.DefaultOpticalTunnelEndPoint; | ||
28 | +import org.onosproject.net.tunnel.DefaultTunnelDescription; | ||
29 | +import org.onosproject.net.tunnel.IpTunnelEndPoint; | ||
30 | +import org.onosproject.net.tunnel.OpticalLogicId; | ||
31 | +import org.onosproject.net.tunnel.OpticalTunnelEndPoint; | ||
32 | +import org.onosproject.net.tunnel.Tunnel; | ||
33 | +import org.onosproject.net.tunnel.TunnelDescription; | ||
34 | +import org.onosproject.net.tunnel.TunnelEndPoint; | ||
35 | +import org.onosproject.net.tunnel.TunnelProvider; | ||
36 | + | ||
37 | +/** | ||
38 | + * Supports for removing all tunnels by using IP address and optical as tunnel | ||
39 | + * end point now. It's used by producers. | ||
40 | + */ | ||
41 | +@Command(scope = "onos", name = "remove-tunnels", description = "Supports for removing all tunnels by using IP address" | ||
42 | + + " and optical as tunnel end point now. It's used by producers.") | ||
43 | +public class RemoveTunnelCommand extends AbstractShellCommand { | ||
44 | + @Argument(index = 0, name = "src", description = "Source tunnel point." | ||
45 | + + " 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." | ||
47 | + + " Otherwise src means IP address.", required = true, multiValued = false) | ||
48 | + String src = null; | ||
49 | + @Argument(index = 1, name = "dst", description = "Destination tunnel point." | ||
50 | + + " 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 | + + " Otherwise dst means IP address.", required = true, multiValued = false) | ||
53 | + String dst = null; | ||
54 | + | ||
55 | + @Argument(index = 2, name = "type", description = "The type of tunnels," | ||
56 | + + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false) | ||
57 | + String type = null; | ||
58 | + | ||
59 | + @Override | ||
60 | + protected void execute() { | ||
61 | + TunnelProvider service = get(TunnelProvider.class); | ||
62 | + ProviderId producerName = new ProviderId("default", | ||
63 | + "org.onosproject.provider.tunnel.default"); | ||
64 | + TunnelEndPoint srcPoint = null; | ||
65 | + TunnelEndPoint dstPoint = null; | ||
66 | + Tunnel.Type trueType = null; | ||
67 | + if ("MPLS".equals(type)) { | ||
68 | + trueType = Tunnel.Type.MPLS; | ||
69 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | ||
70 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | ||
71 | + } else if ("VLAN".equals(type)) { | ||
72 | + trueType = Tunnel.Type.VLAN; | ||
73 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | ||
74 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | ||
75 | + } else if ("VXLAN".equals(type)) { | ||
76 | + trueType = Tunnel.Type.VXLAN; | ||
77 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | ||
78 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | ||
79 | + } else if ("GRE".equals(type)) { | ||
80 | + trueType = Tunnel.Type.GRE; | ||
81 | + srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src)); | ||
82 | + dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst)); | ||
83 | + } else if ("ODUK".equals(type)) { | ||
84 | + trueType = Tunnel.Type.ODUK; | ||
85 | + String[] srcArray = src.split("-"); | ||
86 | + String[] dstArray = dst.split("-"); | ||
87 | + srcPoint = new DefaultOpticalTunnelEndPoint( | ||
88 | + producerName, | ||
89 | + Optional.of(DeviceId | ||
90 | + .deviceId(srcArray[0])), | ||
91 | + Optional.of(PortNumber | ||
92 | + .portNumber(srcArray[1])), | ||
93 | + null, | ||
94 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
95 | + OpticalLogicId | ||
96 | + .logicId(0), | ||
97 | + true); | ||
98 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
99 | + producerName, | ||
100 | + Optional.of(DeviceId | ||
101 | + .deviceId(dstArray[0])), | ||
102 | + Optional.of(PortNumber | ||
103 | + .portNumber(dstArray[1])), | ||
104 | + null, | ||
105 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
106 | + OpticalLogicId | ||
107 | + .logicId(0), | ||
108 | + true); | ||
109 | + } else if ("OCH".equals(type)) { | ||
110 | + trueType = Tunnel.Type.OCH; | ||
111 | + String[] srcArray = src.split("-"); | ||
112 | + String[] dstArray = dst.split("-"); | ||
113 | + srcPoint = new DefaultOpticalTunnelEndPoint( | ||
114 | + producerName, | ||
115 | + Optional.of(DeviceId | ||
116 | + .deviceId(srcArray[0])), | ||
117 | + Optional.of(PortNumber | ||
118 | + .portNumber(srcArray[1])), | ||
119 | + null, | ||
120 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
121 | + OpticalLogicId | ||
122 | + .logicId(0), | ||
123 | + true); | ||
124 | + dstPoint = new DefaultOpticalTunnelEndPoint( | ||
125 | + producerName, | ||
126 | + Optional.of(DeviceId | ||
127 | + .deviceId(dstArray[0])), | ||
128 | + Optional.of(PortNumber | ||
129 | + .portNumber(dstArray[1])), | ||
130 | + null, | ||
131 | + OpticalTunnelEndPoint.Type.LAMBDA, | ||
132 | + OpticalLogicId | ||
133 | + .logicId(0), | ||
134 | + true); | ||
135 | + } else { | ||
136 | + print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH."); | ||
137 | + return; | ||
138 | + } | ||
139 | + TunnelDescription tunnel = new DefaultTunnelDescription(null, srcPoint, | ||
140 | + dstPoint, | ||
141 | + trueType, null, | ||
142 | + producerName, | ||
143 | + null); | ||
144 | + service.tunnelRemoved(tunnel); | ||
145 | + } | ||
146 | + | ||
147 | +} |
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 | +/** | ||
18 | + * Null provider CLI commands and completers. | ||
19 | + */ | ||
20 | +package org.onosproject.provider.tunnel.cli; |
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 | +/** | ||
18 | + * Set of null south-bound providers which permit simulating a network | ||
19 | + * topology using fake devices, links, hosts, etc. | ||
20 | + */ | ||
21 | +package org.onosproject.provider.tunnel; |
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 | +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> | ||
17 | + | ||
18 | + <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> | ||
19 | + <command> | ||
20 | + <action class="org.onosproject.provider.tunnel.cli.CreateTunnelCommand"/> | ||
21 | + </command> | ||
22 | + <command> | ||
23 | + <action class="org.onosproject.provider.tunnel.cli.RemoveTunnelCommand"/> | ||
24 | + </command> | ||
25 | + </command-bundle> | ||
26 | +</blueprint> |
-
Please register or login to post a comment