sangho
Committed by Gerrit Code Review

Refactoring of OpenstackSwitching and OpenstackRouting

Change-Id: Ib7caea98006274dcdfebfe27c07e3533730ab23e
Showing 54 changed files with 2039 additions and 258 deletions
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
103 </dependency> 103 </dependency>
104 <dependency> 104 <dependency>
105 <groupId>org.onosproject</groupId> 105 <groupId>org.onosproject</groupId>
106 - <artifactId>onos-app-openstackswitching-api</artifactId> 106 + <artifactId>onos-app-openstacknetworking-api</artifactId>
107 <version>${project.version}</version> 107 <version>${project.version}</version>
108 </dependency> 108 </dependency>
109 <dependency> 109 <dependency>
......
...@@ -19,8 +19,8 @@ import com.google.common.base.MoreObjects; ...@@ -19,8 +19,8 @@ import com.google.common.base.MoreObjects;
19 import org.onlab.packet.IpAddress; 19 import org.onlab.packet.IpAddress;
20 import org.onlab.packet.IpPrefix; 20 import org.onlab.packet.IpPrefix;
21 import org.onosproject.net.Host; 21 import org.onosproject.net.Host;
22 -import org.onosproject.openstackswitching.OpenstackNetwork; 22 +import org.onosproject.openstacknetworking.OpenstackNetwork;
23 -import org.onosproject.openstackswitching.OpenstackSubnet; 23 +import org.onosproject.openstacknetworking.OpenstackSubnet;
24 24
25 import java.util.Map; 25 import java.util.Map;
26 import java.util.Objects; 26 import java.util.Objects;
......
...@@ -62,10 +62,10 @@ import org.onosproject.net.packet.PacketProcessor; ...@@ -62,10 +62,10 @@ import org.onosproject.net.packet.PacketProcessor;
62 import org.onosproject.net.packet.PacketService; 62 import org.onosproject.net.packet.PacketService;
63 import org.onosproject.net.provider.AbstractProvider; 63 import org.onosproject.net.provider.AbstractProvider;
64 import org.onosproject.net.provider.ProviderId; 64 import org.onosproject.net.provider.ProviderId;
65 -import org.onosproject.openstackswitching.OpenstackNetwork; 65 +import org.onosproject.openstacknetworking.OpenstackNetworkingService;
66 -import org.onosproject.openstackswitching.OpenstackPort; 66 +import org.onosproject.openstacknetworking.OpenstackNetwork;
67 -import org.onosproject.openstackswitching.OpenstackSubnet; 67 +import org.onosproject.openstacknetworking.OpenstackPort;
68 -import org.onosproject.openstackswitching.OpenstackSwitchingService; 68 +import org.onosproject.openstacknetworking.OpenstackSubnet;
69 import org.slf4j.Logger; 69 import org.slf4j.Logger;
70 70
71 import java.util.List; 71 import java.util.List;
...@@ -123,7 +123,7 @@ public class CordVtn extends AbstractProvider implements CordVtnService, HostPro ...@@ -123,7 +123,7 @@ public class CordVtn extends AbstractProvider implements CordVtnService, HostPro
123 protected GroupService groupService; 123 protected GroupService groupService;
124 124
125 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 125 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
126 - protected OpenstackSwitchingService openstackService; 126 + protected OpenstackNetworkingService openstackService;
127 127
128 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 128 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
129 protected DhcpService dhcpService; 129 protected DhcpService dhcpService;
......
...@@ -71,8 +71,8 @@ import org.onosproject.net.group.GroupBuckets; ...@@ -71,8 +71,8 @@ import org.onosproject.net.group.GroupBuckets;
71 import org.onosproject.net.group.GroupDescription; 71 import org.onosproject.net.group.GroupDescription;
72 import org.onosproject.net.group.GroupKey; 72 import org.onosproject.net.group.GroupKey;
73 import org.onosproject.net.group.GroupService; 73 import org.onosproject.net.group.GroupService;
74 -import org.onosproject.openstackswitching.OpenstackNetwork; 74 +import org.onosproject.openstacknetworking.OpenstackNetwork;
75 -import org.onosproject.openstackswitching.OpenstackSubnet; 75 +import org.onosproject.openstacknetworking.OpenstackSubnet;
76 import org.slf4j.Logger; 76 import org.slf4j.Logger;
77 77
78 import java.util.ArrayList; 78 import java.util.ArrayList;
......
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- 2 <!--
3 - ~ Copyright 2015 Open Networking Laboratory 3 + ~ Copyright 2016 Open Networking Laboratory
4 ~ 4 ~
5 ~ Licensed under the Apache License, Version 2.0 (the "License"); 5 ~ Licensed under the Apache License, Version 2.0 (the "License");
6 ~ you may not use this file except in compliance with the License. 6 ~ you may not use this file except in compliance with the License.
...@@ -16,35 +16,34 @@ ...@@ -16,35 +16,34 @@
16 --> 16 -->
17 <project xmlns="http://maven.apache.org/POM/4.0.0" 17 <project xmlns="http://maven.apache.org/POM/4.0.0"
18 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"> 19 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20 <modelVersion>4.0.0</modelVersion> 20 <modelVersion>4.0.0</modelVersion>
21 21
22 <parent> 22 <parent>
23 <groupId>org.onosproject</groupId> 23 <groupId>org.onosproject</groupId>
24 - <artifactId>onos-openstackswitching</artifactId> 24 + <artifactId>onos-app-openstacknetworking</artifactId>
25 <version>1.5.0-SNAPSHOT</version> 25 <version>1.5.0-SNAPSHOT</version>
26 <relativePath>../pom.xml</relativePath> 26 <relativePath>../pom.xml</relativePath>
27 </parent> 27 </parent>
28 28
29 - <artifactId>onos-app-openstackswitching-api</artifactId> 29 + <artifactId>onos-app-openstacknetworking-api</artifactId>
30 <packaging>bundle</packaging> 30 <packaging>bundle</packaging>
31 31
32 - <description>SONA Openstack Switching application API</description>
33 -
34 <dependencies> 32 <dependencies>
35 <dependency> 33 <dependency>
36 - <groupId>org.onosproject</groupId>
37 - <artifactId>onos-api</artifactId>
38 - <version>${project.version}</version>
39 - </dependency>
40 - <dependency>
41 <groupId>org.osgi</groupId> 34 <groupId>org.osgi</groupId>
42 <artifactId>org.osgi.compendium</artifactId> 35 <artifactId>org.osgi.compendium</artifactId>
43 </dependency> 36 </dependency>
44 <dependency> 37 <dependency>
45 - <groupId>org.osgi</groupId> 38 + <groupId>org.onosproject</groupId>
46 - <artifactId>org.osgi.core</artifactId> 39 + <artifactId>onos-api</artifactId>
40 + </dependency>
41 + <dependency>
42 + <groupId>org.onosproject</groupId>
43 + <artifactId>onos-core-serializers</artifactId>
44 + <version>${project.version}</version>
47 </dependency> 45 </dependency>
48 </dependencies> 46 </dependencies>
49 47
50 </project> 48 </project>
49 +
......
1 +/*
2 + * Copyright 2016 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.openstacknetworking;
17 +
18 +import com.google.common.collect.Maps;
19 +import org.onlab.packet.Ip4Address;
20 +import java.util.Map;
21 +import java.util.Objects;
22 +
23 +/**
24 + * A configurable external gateway modes extension model in openstack router.
25 + */
26 +public final class OpenstackExternalGateway {
27 +
28 + private final String networkId;
29 + private final boolean enablePnat;
30 + private final Map<String, Ip4Address> externalFixedIps;
31 +
32 + private OpenstackExternalGateway(String networkId, boolean enablePnat,
33 + Map<String, Ip4Address> externalFixedIps) {
34 + this.networkId = networkId;
35 + this.enablePnat = enablePnat;
36 + this.externalFixedIps = externalFixedIps;
37 + }
38 +
39 + /**
40 + * Returns network ID.
41 + *
42 + * @return Network ID
43 + */
44 + public String networkId() {
45 + return networkId;
46 + }
47 +
48 + /**
49 + * Returns the PNAT status for external gateway.
50 + *
51 + * @return PNAT status
52 + */
53 + public boolean isEnablePnat() {
54 + return enablePnat;
55 + }
56 +
57 + /**
58 + * Returns external fixed IP informations.
59 + *
60 + * @return External fixed IP informations
61 + */
62 + public Map<String, Ip4Address> externalFixedIps() {
63 + return externalFixedIps;
64 + }
65 +
66 + @Override
67 + public boolean equals(Object o) {
68 + if (this == o) {
69 + return true;
70 + }
71 +
72 + if (o instanceof OpenstackExternalGateway) {
73 + OpenstackExternalGateway that = (OpenstackExternalGateway) o;
74 +
75 + return this.networkId.equals(that.networkId) &&
76 + this.enablePnat == that.enablePnat &&
77 + this.externalFixedIps.equals(that.externalFixedIps);
78 + }
79 +
80 + return false;
81 + }
82 +
83 + @Override
84 + public int hashCode() {
85 + return Objects.hash(networkId, enablePnat, externalFixedIps);
86 + }
87 +
88 + /**
89 + * An Openstack External Gateway Builder class.
90 + */
91 + public static final class Builder {
92 + private String networkId;
93 + private boolean enablePnat;
94 + private Map<String, Ip4Address> externalFixedIps;
95 +
96 + public Builder() {
97 + externalFixedIps = Maps.newHashMap();
98 + }
99 +
100 + /**
101 + * Sets network ID.
102 + *
103 + * @param networkId Network ID
104 + * @return Builder object
105 + */
106 + public Builder networkId(String networkId) {
107 + this.networkId = networkId;
108 + return this;
109 + }
110 +
111 + /**
112 + * Sets whether PNAT status is enabled or not.
113 + *
114 + * @param enablePnat true if PNAT status is enabled, false otherwise
115 + * @return Builder object
116 + */
117 + public Builder enablePnat(boolean enablePnat) {
118 + this.enablePnat = enablePnat;
119 + return this;
120 + }
121 +
122 + /**
123 + * Sets external fixed IP address information.
124 + *
125 + * @param externalFixedIps External fixed IP information
126 + * @return Builder object
127 + */
128 +
129 + public Builder externalFixedIps(Map<String, Ip4Address> externalFixedIps) {
130 + this.externalFixedIps.putAll(externalFixedIps);
131 + return this;
132 + }
133 +
134 + /**
135 + * Builds an OpenstackExternalGateway object.
136 + *
137 + * @return OpenstackExternalGateway object
138 + */
139 + public OpenstackExternalGateway build() {
140 + return new OpenstackExternalGateway(networkId, enablePnat, externalFixedIps);
141 + }
142 + }
143 +
144 +}
1 +/*
2 + * Copyright 2016 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.openstacknetworking;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +
20 +import java.util.Objects;
21 +
22 +/**
23 + * An Openstack Neutron Floating IP Model.
24 + */
25 +public final class OpenstackFloatingIP {
26 +
27 + public enum FloatingIPStatus {
28 + UP,
29 + DOWN,
30 + ACTIVE,
31 + }
32 +
33 + private final String tenantId;
34 + private final String networkId;
35 + private final Ip4Address fixedIpAddress;
36 + private final String portId;
37 + private final String routerId;
38 + private final String id;
39 + private final Ip4Address floatingIpAddress;
40 + private final FloatingIPStatus status;
41 +
42 + private OpenstackFloatingIP(FloatingIPStatus status, String id, String tenantId,
43 + String networkId, Ip4Address fixedIpAddress, String portId,
44 + String routerId, Ip4Address floatingIpAddress) {
45 + this.status = status;
46 + this.id = id;
47 + this.tenantId = tenantId;
48 + this.networkId = networkId;
49 + this.fixedIpAddress = fixedIpAddress;
50 + this.portId = portId;
51 + this.routerId = routerId;
52 + this.floatingIpAddress = floatingIpAddress;
53 + }
54 +
55 + /**
56 + * Returns floating IP status.
57 + *
58 + * @return floating IP status
59 + */
60 + public FloatingIPStatus status() {
61 + return status;
62 + }
63 +
64 + /**
65 + * Returns floating IP`s ID.
66 + *
67 + * @return floating IP`s ID
68 + */
69 + public String id() {
70 + return id;
71 + }
72 +
73 + /**
74 + * Returns tenant ID.
75 + *
76 + * @return tenant ID
77 + */
78 + public String tenantId() {
79 + return tenantId;
80 + }
81 +
82 + /**
83 + * Returns network ID.
84 + *
85 + * @return network ID
86 + */
87 + public String networkId() {
88 + return networkId;
89 + }
90 +
91 + /**
92 + * Returns fixed IP Address.
93 + *
94 + * @return fixed IP Address
95 + */
96 + public Ip4Address fixedIpAddress() {
97 + return fixedIpAddress;
98 + }
99 +
100 + /**
101 + * Returns port ID.
102 + *
103 + * @return port ID
104 + */
105 + public String portId() {
106 + return portId;
107 + }
108 +
109 + /**
110 + * Returns router ID.
111 + *
112 + * @return router ID
113 + */
114 + public String routerId() {
115 + return routerId;
116 + }
117 +
118 + /**
119 + * Returns floating IP address.
120 + *
121 + * @return Floating IP address
122 + */
123 + public Ip4Address floatingIpAddress() {
124 + return floatingIpAddress;
125 + }
126 +
127 + @Override
128 + public boolean equals(Object o) {
129 + if (this == o) {
130 + return true;
131 + }
132 +
133 + if (o instanceof OpenstackFloatingIP) {
134 + OpenstackFloatingIP that = (OpenstackFloatingIP) o;
135 +
136 + return this.status.equals(that.status) &&
137 + this.id.equals(that.id) &&
138 + this.tenantId.equals(that.tenantId) &&
139 + this.networkId.equals(that.networkId) &&
140 + this.fixedIpAddress.equals(that.fixedIpAddress) &&
141 + this.floatingIpAddress.equals(that.floatingIpAddress) &&
142 + this.portId.equals(that.portId) &&
143 + this.routerId.equals(that.routerId);
144 + }
145 +
146 + return false;
147 + }
148 +
149 + @Override
150 + public int hashCode() {
151 + return Objects.hash(status, id, tenantId, networkId, floatingIpAddress, fixedIpAddress, portId, routerId);
152 + }
153 +
154 + /**
155 + * An Openstack Floating IP Builder class.
156 + */
157 + public static final class Builder {
158 + private String tenantId;
159 + private String networkId;
160 + private Ip4Address fixedIpAddress;
161 + private String portId;
162 + private String routerId;
163 + private String id;
164 + private Ip4Address floatingIpAddress;
165 + private FloatingIPStatus status;
166 +
167 + /**
168 + * Sets tenant ID.
169 + *
170 + * @param tenantId tenant ID
171 + * @return Builder object
172 + */
173 + public Builder tenantId(String tenantId) {
174 + this.tenantId = tenantId;
175 + return this;
176 + }
177 +
178 + /**
179 + * Sets floating IP status.
180 + *
181 + * @param status Floating IP status
182 + * @return Builder object
183 + */
184 + public Builder status(FloatingIPStatus status) {
185 + this.status = status;
186 + return this;
187 + }
188 +
189 + /**
190 + * Sets Floating IP`s ID.
191 + *
192 + * @param id Floating IP`s ID
193 + * @return Builder object
194 + */
195 + public Builder id(String id) {
196 + this.id = id;
197 + return this;
198 + }
199 +
200 + /**
201 + * Sets network ID.
202 + *
203 + * @param networkId Network ID
204 + * @return Builder object
205 + */
206 + public Builder networkId(String networkId) {
207 + this.networkId = networkId;
208 + return this;
209 + }
210 +
211 + /**
212 + * Sets fixed IP address.
213 + *
214 + * @param fixedIpAddress Fixed IP address
215 + * @return Builder object
216 + */
217 + public Builder fixedIpAddress(Ip4Address fixedIpAddress) {
218 + this.fixedIpAddress = fixedIpAddress;
219 + return this;
220 + }
221 +
222 + /**
223 + * Sets port ID.
224 + *
225 + * @param portId port ID
226 + * @return Builder object
227 + */
228 + public Builder portId(String portId) {
229 + this.portId = portId;
230 + return this;
231 + }
232 +
233 + /**
234 + * Sets router ID.
235 + *
236 + * @param routerId router ID
237 + * @return Builder object
238 + */
239 + public Builder routerId(String routerId) {
240 + this.routerId = routerId;
241 + return this;
242 + }
243 +
244 + /**
245 + * Sets floating IP address.
246 + *
247 + * @param floatingIpAddress Floating IP address
248 + * @return Builder object
249 + */
250 + public Builder floatingIpAddress(Ip4Address floatingIpAddress) {
251 + this.floatingIpAddress = floatingIpAddress;
252 + return this;
253 + }
254 +
255 + /**
256 + * Builds an OpenstackFloatingIP object.
257 + *
258 + * @return OpenstackFloatingIP object
259 + */
260 + public OpenstackFloatingIP build() {
261 + return new OpenstackFloatingIP(status, id, tenantId, networkId,
262 + fixedIpAddress, portId, routerId, floatingIpAddress);
263 +
264 + }
265 + }
266 +}
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching; 16 +package org.onosproject.openstacknetworking;
17 17
18 import java.util.Collection; 18 import java.util.Collection;
19 19
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching.impl; 16 +package org.onosproject.openstacknetworking;
17 17
18 import org.onosproject.core.ApplicationId; 18 import org.onosproject.core.ApplicationId;
19 import org.onosproject.net.config.Config; 19 import org.onosproject.net.config.Config;
...@@ -22,7 +22,7 @@ import org.onosproject.net.config.basics.BasicElementConfig; ...@@ -22,7 +22,7 @@ import org.onosproject.net.config.basics.BasicElementConfig;
22 /** 22 /**
23 * Handles configuration for OpenstackSwitching app. 23 * Handles configuration for OpenstackSwitching app.
24 */ 24 */
25 -public class OpenstackSwitchingConfig extends Config<ApplicationId> { 25 +public class OpenstackNetworkingConfig extends Config<ApplicationId> {
26 public static final String DONOTPUSH = "do_not_push_flows"; 26 public static final String DONOTPUSH = "do_not_push_flows";
27 public static final String NEUTRON_SERVER = "neutron_server"; 27 public static final String NEUTRON_SERVER = "neutron_server";
28 public static final String KEYSTONE_SERVER = "keystone_server"; 28 public static final String KEYSTONE_SERVER = "keystone_server";
......
...@@ -13,53 +13,17 @@ ...@@ -13,53 +13,17 @@
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 -package org.onosproject.openstackswitching; 16 +package org.onosproject.openstacknetworking;
17 17
18 import org.onosproject.net.Port; 18 import org.onosproject.net.Port;
19 -import org.onosproject.openstackrouting.OpenstackRouter;
20 -import org.onosproject.openstackrouting.OpenstackRouterInterface;
21 19
22 import java.util.Collection; 20 import java.util.Collection;
21 +import java.util.Map;
23 22
24 /** 23 /**
25 * Handles port management REST API from Openstack for VMs. 24 * Handles port management REST API from Openstack for VMs.
26 */ 25 */
27 -public interface OpenstackSwitchingService { 26 +public interface OpenstackNetworkingService {
28 -
29 - /**
30 - * Store the port information created by Openstack.
31 - *
32 - * @param openstackPort port information
33 - */
34 - void createPorts(OpenstackPort openstackPort);
35 -
36 - /**
37 - * Removes flow rules corresponding to the port removed by Openstack.
38 - *
39 - * @param uuid UUID
40 - */
41 - void deletePort(String uuid);
42 -
43 - /**
44 - * Updates flow rules corresponding to the port information updated by Openstack.
45 - *
46 - * @param openstackPort OpenStack port
47 - */
48 - void updatePort(OpenstackPort openstackPort);
49 -
50 - /**
51 - * Stores the network information created by openstack.
52 - *
53 - * @param openstackNetwork network information
54 - */
55 - void createNetwork(OpenstackNetwork openstackNetwork);
56 -
57 - /**
58 - * Stores the subnet information created by openstack.
59 - *
60 - * @param openstackSubnet subnet information
61 - */
62 - void createSubnet(OpenstackSubnet openstackSubnet);
63 27
64 /** 28 /**
65 * Returns port information list for the network ID given. 29 * Returns port information list for the network ID given.
...@@ -95,10 +59,16 @@ public interface OpenstackSwitchingService { ...@@ -95,10 +59,16 @@ public interface OpenstackSwitchingService {
95 * Returns network information list for the network ID given. 59 * Returns network information list for the network ID given.
96 * 60 *
97 * @param networkId Network ID 61 * @param networkId Network ID
98 - * @return network information list, or null if not present 62 + * @return network information, or null if not present
99 */ 63 */
100 OpenstackNetwork network(String networkId); 64 OpenstackNetwork network(String networkId);
101 65
66 + /**
67 + * Returns the information of all openstack networks.
68 + *
69 + * @return collection of network information
70 + */
71 + Collection<OpenstackNetwork> networks();
102 72
103 /** 73 /**
104 * Returns subnet information for the subnet ID give. 74 * Returns subnet information for the subnet ID give.
...@@ -109,37 +79,11 @@ public interface OpenstackSwitchingService { ...@@ -109,37 +79,11 @@ public interface OpenstackSwitchingService {
109 OpenstackSubnet subnet(String subnetId); 79 OpenstackSubnet subnet(String subnetId);
110 80
111 /** 81 /**
112 - * Sends the created router information to OpenstackRouting service. 82 + * Returns collection of openstack subnet information.
113 - *
114 - * @param openstackRouter Router Information
115 - */
116 - void createRouter(OpenstackRouter openstackRouter);
117 - /**
118 - * Sends the updated router information to OpenstackRouting service.
119 - *
120 - * @param routerId Router ID
121 - */
122 - void updateRouter(String routerId);
123 - /**
124 - * Sends the removed router information to OpenstackRouting service.
125 - *
126 - * @param routerId Router ID
127 - */
128 - void deleteRouter(String routerId);
129 -
130 - /**
131 - * Sends the updated router interface information to OpenstackRouting service.
132 - *
133 - * @param openstackRouterInterface Router interface information
134 - */
135 - void updateRouterInterface(OpenstackRouterInterface openstackRouterInterface);
136 -
137 - /**
138 - * Sends the removed router interface information to OpenstackRouting service.
139 * 83 *
140 - * @param openstackRouterInterface Router interface information 84 + * @return collection of openststack subnet information
141 */ 85 */
142 - void removeRouterInterface(OpenstackRouterInterface openstackRouterInterface); 86 + Collection<OpenstackSubnet> subnets();
143 87
144 /** 88 /**
145 * Returns the router information list. 89 * Returns the router information list.
...@@ -157,18 +101,28 @@ public interface OpenstackSwitchingService { ...@@ -157,18 +101,28 @@ public interface OpenstackSwitchingService {
157 OpenstackRouter router(String routerId); 101 OpenstackRouter router(String routerId);
158 102
159 /** 103 /**
160 - * Returns the OpensatckPortInfo list. 104 + * Retruns OpenstackPortInfo map.
161 * 105 *
162 - * @return OpensatckPortInfo list 106 + * @return OpenstackPortInfo map
163 */ 107 */
164 - Collection<OpenstackPortInfo> portInfos(); 108 + Map<String, OpenstackPortInfo> openstackPortInfo();
165 109
166 /** 110 /**
167 - * Returns the MacAddress for physical router. 111 + * Sets configurations specified by net-config.xml file.
168 * 112 *
169 - * @return physical router mac 113 + * @param neutronUrl neutron server url
114 + * @param keystoneUrl keystone server url
115 + * @param userName horizon user name
116 + * @param pass horizon passowrd
170 */ 117 */
171 - String physicalRouterMac(); 118 + void setConfigurations(String neutronUrl, String keystoneUrl, String userName, String pass);
172 119
120 + /**
121 + * Returns Security Group information of the security groupd id given.
122 + *
123 + * @param id security group id
124 + * @return security group information
125 + */
126 + OpenstackSecurityGroup getSecurityGroup(String id);
173 127
174 } 128 }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching; 16 +package org.onosproject.openstacknetworking;
17 17
18 import com.google.common.collect.Maps; 18 import com.google.common.collect.Maps;
19 import org.onlab.packet.Ip4Address; 19 import org.onlab.packet.Ip4Address;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching; 16 +package org.onosproject.openstacknetworking;
17 17
18 import org.onlab.packet.Ip4Address; 18 import org.onlab.packet.Ip4Address;
19 import org.onlab.packet.MacAddress; 19 import org.onlab.packet.MacAddress;
......
1 +/*
2 + * Copyright 2016 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.openstacknetworking;
17 +
18 +import java.util.Objects;
19 +
20 +/**
21 + * An Openstack Neutron Router Model.
22 + */
23 +public final class OpenstackRouter {
24 +
25 + public enum RouterStatus {
26 + UP,
27 + DOWN,
28 + ACTIVE,
29 + }
30 +
31 + private final String tenantId;
32 + private final String id;
33 + private final String name;
34 + private final RouterStatus status;
35 + private final boolean adminStateUp;
36 + private final OpenstackExternalGateway gatewayExternalInfo;
37 +
38 + private OpenstackRouter(String id, String tenantId, String name, RouterStatus status,
39 + boolean adminStateUp, OpenstackExternalGateway gatewayExternalInfo) {
40 + this.id = id;
41 + this.tenantId = tenantId;
42 + this.name = name;
43 + this.status = status;
44 + this.adminStateUp = adminStateUp;
45 + this.gatewayExternalInfo = gatewayExternalInfo;
46 +
47 + }
48 +
49 + /**
50 + * Returns tenant ID.
51 + *
52 + * @return tenant ID
53 + */
54 + public String tenantId() {
55 + return tenantId;
56 + }
57 +
58 + /**
59 + * Returns router ID.
60 + *
61 + * @return router ID
62 + */
63 + public String id() {
64 + return id;
65 + }
66 +
67 + /**
68 + * Returns router name.
69 + *
70 + * @return router name
71 + */
72 + public String name() {
73 + return name;
74 + }
75 +
76 + /**
77 + * Returns router status.
78 + *
79 + * @return router stauts
80 + */
81 + public RouterStatus status() {
82 + return status;
83 + }
84 +
85 + /**
86 + * Returns whether admin state up or not.
87 + *
88 + * @return true if admin state up, false otherwise
89 + */
90 + public boolean adminStateUp() {
91 + return adminStateUp;
92 + }
93 +
94 + /**
95 + * Returns external gateway information.
96 + *
97 + * @return external gateway information
98 + */
99 + public OpenstackExternalGateway gatewayExternalInfo() {
100 + return gatewayExternalInfo;
101 + }
102 +
103 + @Override
104 + public boolean equals(Object o) {
105 + if (this == o) {
106 + return true;
107 + }
108 +
109 + if (o instanceof OpenstackRouter) {
110 + OpenstackRouter that = (OpenstackRouter) o;
111 +
112 + return this.adminStateUp == that.adminStateUp &&
113 + this.gatewayExternalInfo.equals(that.gatewayExternalInfo) &&
114 + this.id.equals(that.id) &&
115 + this.name.equals(that.name) &&
116 + this.status.equals(that.status) &&
117 + this.tenantId.equals(that.tenantId);
118 + }
119 +
120 + return false;
121 + }
122 +
123 + @Override
124 + public int hashCode() {
125 + return Objects.hash(adminStateUp, gatewayExternalInfo, id, name, status, tenantId);
126 + }
127 +
128 + /**
129 + * An Openstack Router Builder class.
130 + */
131 + public static final class Builder {
132 +
133 + private String tenantId;
134 + private String id;
135 + private String name;
136 + private RouterStatus status;
137 + private Boolean adminStateUp;
138 + private OpenstackExternalGateway gatewayExternalInfo;
139 +
140 + /**
141 + * Sets router ID.
142 + *
143 + * @param id router ID
144 + * @return Builder object
145 + */
146 + public Builder id(String id) {
147 + this.id = id;
148 + return this;
149 + }
150 +
151 + /**
152 + * Sets router name.
153 + *
154 + * @param name router name
155 + * @return Builder object
156 + */
157 + public Builder name(String name) {
158 + this.name = name;
159 + return this;
160 + }
161 +
162 + /**
163 + * Sets router status.
164 + *
165 + * @param status router status
166 + * @return Builder object
167 + */
168 + public Builder status(RouterStatus status) {
169 + this.status = status;
170 + return this;
171 + }
172 +
173 + /**
174 + * Sets tenant ID.
175 + *
176 + * @param tenantId Tenant ID
177 + * @return Builder object
178 + */
179 + public Builder tenantId(String tenantId) {
180 + this.tenantId = tenantId;
181 + return this;
182 + }
183 +
184 + /**
185 + * Sets whether admin state up or not.
186 + *
187 + * @param adminStateUp true if admin state is up, false otherwise
188 + * @return Builder object
189 + */
190 + public Builder adminStateUp(boolean adminStateUp) {
191 + this.adminStateUp = adminStateUp;
192 + return this;
193 + }
194 +
195 + /**
196 + * Sets external gateway information.
197 + *
198 + * @param gatewayExternalInfo external gateway information
199 + * @return Builder object
200 + */
201 + public Builder gatewayExternalInfo(OpenstackExternalGateway gatewayExternalInfo) {
202 + this.gatewayExternalInfo = gatewayExternalInfo;
203 + return this;
204 + }
205 +
206 + /**
207 + * Builds an OpenstackRouter object.
208 + *
209 + * @return OpenstasckRouter object
210 + */
211 + public OpenstackRouter build() {
212 + return new OpenstackRouter(id, tenantId, name, status,
213 + adminStateUp, gatewayExternalInfo);
214 + }
215 + }
216 +
217 +
218 +}
1 +/*
2 + * Copyright 2016 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.openstacknetworking;
17 +
18 +import java.util.Objects;
19 +
20 +import static com.google.common.base.Preconditions.checkNotNull;
21 +
22 +/**
23 + * An Openstack Neutron Router Interface Model.
24 + */
25 +public final class OpenstackRouterInterface {
26 + private final String id;
27 + private final String tenantId;
28 + private final String subnetId;
29 + private final String portId;
30 +
31 + private OpenstackRouterInterface(String id, String tenantId,
32 + String subnetId, String portId) {
33 + this.id = checkNotNull(id);
34 + this.tenantId = checkNotNull(tenantId);
35 + this.subnetId = checkNotNull(subnetId);
36 + this.portId = checkNotNull(portId);
37 + }
38 +
39 + /**
40 + * Returns Router Interface ID.
41 + *
42 + * @return router interface ID
43 + */
44 + public String id() {
45 + return id;
46 + }
47 +
48 + /**
49 + * Returns tenant ID.
50 + *
51 + * @return tenant ID
52 + */
53 + public String tenantId() {
54 + return tenantId;
55 + }
56 +
57 + /**
58 + * Returns subnet ID.
59 + *
60 + * @return subnet ID
61 + */
62 + public String subnetId() {
63 + return subnetId;
64 + }
65 +
66 + /**
67 + * Returns port ID.
68 + *
69 + * @return port ID
70 + */
71 + public String portId() {
72 + return portId;
73 + }
74 +
75 + @Override
76 + public boolean equals(Object o) {
77 + if (this == o) {
78 + return true;
79 + }
80 +
81 + if (o instanceof OpenstackRouterInterface) {
82 + OpenstackRouterInterface that = (OpenstackRouterInterface) o;
83 +
84 + return this.id.equals(that.id) &&
85 + this.portId.equals(that.portId) &&
86 + this.subnetId.equals(that.subnetId) &&
87 + this.tenantId.equals(that.tenantId);
88 + }
89 +
90 + return false;
91 + }
92 +
93 + @Override
94 + public int hashCode() {
95 + return Objects.hash(id, portId, subnetId, tenantId);
96 + }
97 +
98 + /**
99 + * An Openstack Router Interface Builder class.
100 + */
101 + public static final class Builder {
102 + private String id;
103 + private String tenantId;
104 + private String subnetId;
105 + private String portId;
106 +
107 + /**
108 + * Sets Router Interface ID.
109 + *
110 + * @param id router interface ID
111 + * @return Builder object
112 + */
113 + public Builder id(String id) {
114 + this.id = id;
115 + return this;
116 + }
117 +
118 + /**
119 + * Sets tenant ID.
120 + *
121 + * @param tenantId tenant ID
122 + * @return Builder object
123 + */
124 + public Builder tenantId(String tenantId) {
125 + this.tenantId = tenantId;
126 + return this;
127 + }
128 +
129 + /**
130 + * Sets subnet ID.
131 + *
132 + * @param subnetId subnet ID
133 + * @return Builder object
134 + */
135 + public Builder subnetId(String subnetId) {
136 + this.subnetId = subnetId;
137 + return this;
138 + }
139 +
140 + /**
141 + * Sets port ID.
142 + *
143 + * @param portId port ID
144 + * @return Builder object
145 + */
146 + public Builder portId(String portId) {
147 + this.portId = portId;
148 + return this;
149 + }
150 +
151 +
152 + /**
153 + * Builds an Openstack Router Interface object.
154 + *
155 + * @return OpenstackRouterInterface object
156 + */
157 + public OpenstackRouterInterface build() {
158 + return new OpenstackRouterInterface(id, tenantId, subnetId, portId);
159 + }
160 +
161 + }
162 +}
1 +/*
2 + * Copyright 2016 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.openstacknetworking;
17 +
18 +/**
19 + * The Interface of Openstack Routing.
20 + */
21 +public interface OpenstackRoutingService {
22 +
23 + /**
24 + * Stores the Floating IP information created by Openstack.
25 + *
26 + * @param openstackFloatingIP Floating IP information
27 + */
28 + void createFloatingIP(OpenstackFloatingIP openstackFloatingIP);
29 +
30 + /**
31 + * Updates flow rules corresponding to the Floating IP information updated by Openstack.
32 + *
33 + * @param openstackFloatingIP Floating IP information
34 + */
35 + void updateFloatingIP(OpenstackFloatingIP openstackFloatingIP);
36 +
37 + /**
38 + * Removes flow rules corresponding to Floating IP information removed by Openstack.
39 + *
40 + * @param id Deleted Floating IP`s ID
41 + */
42 + void deleteFloatingIP(String id);
43 +
44 + /**
45 + * Stores the router information created by Openstack.
46 + *
47 + * @param openstackRouter Floating IP information
48 + */
49 + void createRouter(OpenstackRouter openstackRouter);
50 +
51 + /**
52 + * Updates flow rules corresponding to the router information updated by Openstack.
53 + *
54 + * @param openstackRouter Router information
55 + */
56 + void updateRouter(OpenstackRouter openstackRouter);
57 +
58 + /**
59 + * Removes flow rules corresponding to the router information removed by Openstack.
60 + *
61 + * @param id Deleted router`s ID
62 + */
63 + void deleteRouter(String id);
64 +
65 + /**
66 + * Updates flow rules corresponding to the router information updated by Openstack.
67 + *
68 + * @param openstackRouterInterface Router information
69 + */
70 + void updateRouterInterface(OpenstackRouterInterface openstackRouterInterface);
71 +
72 + /**
73 + * Removes flow rules corresponding to the router information removed by Openstack.
74 + *
75 + * @param openstackRouterInterface Router information
76 + */
77 + void removeRouterInterface(OpenstackRouterInterface openstackRouterInterface);
78 +
79 +
80 +}
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching.impl; 16 +package org.onosproject.openstacknetworking;
17 17
18 import java.util.Collection; 18 import java.util.Collection;
19 import java.util.Collections; 19 import java.util.Collections;
...@@ -112,7 +112,7 @@ public final class OpenstackSecurityGroup { ...@@ -112,7 +112,7 @@ public final class OpenstackSecurityGroup {
112 this.rules.containsAll(that.rules); 112 this.rules.containsAll(that.rules);
113 } 113 }
114 114
115 - return true; 115 + return false;
116 } 116 }
117 117
118 @Override 118 @Override
......
...@@ -13,23 +13,27 @@ ...@@ -13,23 +13,27 @@
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 -package org.onosproject.openstackswitching.impl; 16 +package org.onosproject.openstacknetworking;
17 +
18 +import java.util.Objects;
19 +
20 +import static com.google.common.base.Preconditions.checkNotNull;
17 21
18 /** 22 /**
19 * Represents Openstack Security Group Rules. 23 * Represents Openstack Security Group Rules.
20 */ 24 */
21 public final class OpenstackSecurityGroupRule { 25 public final class OpenstackSecurityGroupRule {
22 26
23 - private String direction; 27 + private final String direction;
24 - private String ethertype; 28 + private final String ethertype;
25 - private String id; 29 + private final String id;
26 - private String portRangeMax; 30 + private final String portRangeMax;
27 - private String portRangeMin; 31 + private final String portRangeMin;
28 - private String protocol; 32 + private final String protocol;
29 - private String remoteGroupId; 33 + private final String remoteGroupId;
30 - private String remoteIpPrefix; 34 + private final String remoteIpPrefix;
31 - private String secuityGroupId; 35 + private final String secuityGroupId;
32 - private String tenantId; 36 + private final String tenantId;
33 37
34 private OpenstackSecurityGroupRule(String direction, 38 private OpenstackSecurityGroupRule(String direction,
35 String ethertype, 39 String ethertype,
...@@ -43,7 +47,7 @@ public final class OpenstackSecurityGroupRule { ...@@ -43,7 +47,7 @@ public final class OpenstackSecurityGroupRule {
43 String tenantId) { 47 String tenantId) {
44 this.direction = direction; 48 this.direction = direction;
45 this.ethertype = ethertype; 49 this.ethertype = ethertype;
46 - this.id = id; 50 + this.id = checkNotNull(id);
47 this.portRangeMax = portRangeMax; 51 this.portRangeMax = portRangeMax;
48 this.portRangeMin = portRangeMin; 52 this.portRangeMin = portRangeMin;
49 this.protocol = protocol; 53 this.protocol = protocol;
...@@ -53,15 +57,6 @@ public final class OpenstackSecurityGroupRule { ...@@ -53,15 +57,6 @@ public final class OpenstackSecurityGroupRule {
53 this.tenantId = tenantId; 57 this.tenantId = tenantId;
54 } 58 }
55 59
56 - /**
57 - * Returns the builder object for the OpenstackSecurityGroupRule.
58 - *
59 - * @return OpenstackSecurityGroupRule builder object
60 - */
61 - public static OpenstackSecurityGroupRule.Builder builder() {
62 - return new Builder();
63 - }
64 -
65 @Override 60 @Override
66 public String toString() { 61 public String toString() {
67 return new StringBuilder(" [") 62 return new StringBuilder(" [")
...@@ -78,6 +73,35 @@ public final class OpenstackSecurityGroupRule { ...@@ -78,6 +73,35 @@ public final class OpenstackSecurityGroupRule {
78 .toString(); 73 .toString();
79 } 74 }
80 75
76 + @Override
77 + public boolean equals(Object o) {
78 + if (this == o) {
79 + return true;
80 + }
81 +
82 + if (this instanceof OpenstackSecurityGroupRule) {
83 + OpenstackSecurityGroupRule that = (OpenstackSecurityGroupRule) o;
84 + return this.direction.equals(that.direction) &&
85 + this.ethertype.equals(that.direction) &&
86 + this.id.equals(that.id) &&
87 + this.portRangeMax.equals(that.portRangeMax) &&
88 + this.portRangeMin.equals(that.portRangeMin) &&
89 + this.protocol.equals(that.protocol) &&
90 + this.remoteGroupId.equals(that.remoteGroupId) &&
91 + this.secuityGroupId.equals(that.secuityGroupId) &&
92 + this.remoteIpPrefix.equals(that.remoteIpPrefix) &&
93 + this.tenantId.equals(that.tenantId);
94 + }
95 +
96 + return false;
97 + }
98 +
99 + @Override
100 + public int hashCode() {
101 + return Objects.hash(direction, ethertype, id, portRangeMax, portRangeMin, protocol,
102 + remoteGroupId, remoteIpPrefix, secuityGroupId, tenantId);
103 + }
104 +
81 /** 105 /**
82 * Represents a security group rule builder object. 106 * Represents a security group rule builder object.
83 */ 107 */
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching; 16 +package org.onosproject.openstacknetworking;
17 17
18 import org.onlab.packet.Ip4Address; 18 import org.onlab.packet.Ip4Address;
19 19
......
1 +/*
2 + * Copyright 2015-2016 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.openstacknetworking;
17 +
18 +import java.util.Map;
19 +
20 +/**
21 + * Handles port management REST API from Openstack for VMs.
22 + */
23 +public interface OpenstackSwitchingService {
24 +
25 + /**
26 + * Store the port information created by Openstack.
27 + *
28 + * @param openstackPort port information
29 + */
30 + void createPorts(OpenstackPort openstackPort);
31 +
32 + /**
33 + * Removes flow rules corresponding to the port removed by Openstack.
34 + *
35 + * @param uuid UUID
36 + */
37 + void removePort(String uuid);
38 +
39 + /**
40 + * Updates flow rules corresponding to the port information updated by Openstack.
41 + *
42 + * @param openstackPort OpenStack port
43 + */
44 + void updatePort(OpenstackPort openstackPort);
45 +
46 + /**
47 + * Stores the network information created by openstack.
48 + *
49 + * @param openstackNetwork network information
50 + */
51 + void createNetwork(OpenstackNetwork openstackNetwork);
52 +
53 + /**
54 + * Stores the subnet information created by openstack.
55 + *
56 + * @param openstackSubnet subnet information
57 + */
58 + void createSubnet(OpenstackSubnet openstackSubnet);
59 +
60 + /**
61 + * Retruns OpenstackPortInfo map.
62 + *
63 + * @return OpenstackPortInfo map
64 + */
65 + Map<String, OpenstackPortInfo> openstackPortInfo();
66 +
67 +}
1 /* 1 /*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2016 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.
...@@ -15,6 +15,6 @@ ...@@ -15,6 +15,6 @@
15 */ 15 */
16 16
17 /** 17 /**
18 - * OpenStack switching REST API. 18 + * Application for OpenstackRouting.
19 */ 19 */
20 -package org.onosproject.openstackswitching.web; 20 +package org.onosproject.openstacknetworking;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -14,12 +14,15 @@ ...@@ -14,12 +14,15 @@
14 ~ See the License for the specific language governing permissions and 14 ~ See the License for the specific language governing permissions and
15 ~ limitations under the License. 15 ~ limitations under the License.
16 --> 16 -->
17 -<app name="org.onosproject.openstackswitching" origin="ON.Lab" version="${project.version}" 17 +<app name="org.onosproject.openstacknetworking" origin="ON.Lab" version="${project.version}"
18 category="default" url="http://onosproject.org" 18 category="default" url="http://onosproject.org"
19 featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features" 19 featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
20 features="${project.artifactId}"> 20 features="${project.artifactId}">
21 <description>${project.description}</description> 21 <description>${project.description}</description>
22 + <artifact>mvn:${project.groupId}/onos-app-openstacknetworking-api/${project.version}</artifact>
23 + <artifact>mvn:${project.groupId}/onos-app-openstacknetworking-web/${project.version}</artifact>
22 <artifact>mvn:${project.groupId}/onos-app-openstackswitching/${project.version}</artifact> 24 <artifact>mvn:${project.groupId}/onos-app-openstackswitching/${project.version}</artifact>
25 + <artifact>mvn:${project.groupId}/onos-app-openstackrouting/${project.version}</artifact>
23 <artifact>mvn:${project.groupId}/onos-app-dhcp-api/${project.version}</artifact> 26 <artifact>mvn:${project.groupId}/onos-app-dhcp-api/${project.version}</artifact>
24 <artifact>mvn:${project.groupId}/onos-app-dhcp/${project.version}</artifact> 27 <artifact>mvn:${project.groupId}/onos-app-dhcp/${project.version}</artifact>
25 </app> 28 </app>
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
18 <feature name="${project.artifactId}" version="${project.version}" 18 <feature name="${project.artifactId}" version="${project.version}"
19 description="${project.description}"> 19 description="${project.description}">
20 <feature>onos-api</feature> 20 <feature>onos-api</feature>
21 - <bundle>mvn:${project.groupId}/onos-app-openstackswitching-api/${project.version}</bundle> 21 + <bundle>mvn:${project.groupId}/onos-app-openstacknetworking-api/${project.version}</bundle>
22 + <bundle>mvn:${project.groupId}/onos-app-openstacknetworking-web/${project.version}</bundle>
22 <bundle>mvn:${project.groupId}/onos-app-openstackswitching/${project.version}</bundle> 23 <bundle>mvn:${project.groupId}/onos-app-openstackswitching/${project.version}</bundle>
23 <bundle>mvn:${project.groupId}/onos-app-dhcp-api/${project.version}</bundle> 24 <bundle>mvn:${project.groupId}/onos-app-dhcp-api/${project.version}</bundle>
24 <bundle>mvn:${project.groupId}/onos-app-dhcp/${project.version}</bundle> 25 <bundle>mvn:${project.groupId}/onos-app-dhcp/${project.version}</bundle>
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016 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/xsd/maven-4.0.0.xsd">
20 + <modelVersion>4.0.0</modelVersion>
21 +
22 + <parent>
23 + <groupId>org.onosproject</groupId>
24 + <artifactId>onos-app-openstacknetworking</artifactId>
25 + <version>1.5.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-app-openstacknetworking-app</artifactId>
30 + <packaging>pom</packaging>
31 +
32 + <properties>
33 + <onos.app.name>org.onosproject.openstacknetworking</onos.app.name>
34 + <onos.app.category>default</onos.app.category>
35 + <onos.app.url>http://onosproject.org</onos.app.url>
36 + <onos.app.readme>Openstack Networking Application.</onos.app.readme>
37 + </properties>
38 +
39 + <description>SONA Openstack Networking main Application</description>
40 +
41 + <dependencies>
42 + <dependency>
43 + <groupId>org.onosproject</groupId>
44 + <artifactId>onos-app-openstackswitching</artifactId>
45 + <version>${project.version}</version>
46 + </dependency>
47 + <dependency>
48 + <groupId>org.onosproject</groupId>
49 + <artifactId>onos-app-openstackrouting</artifactId>
50 + <version>${project.version}</version>
51 + </dependency>
52 + <dependency>
53 + <groupId>org.onosproject</groupId>
54 + <artifactId>onos-app-openstacknetworking-api</artifactId>
55 + <version>${project.version}</version>
56 + </dependency>
57 + <dependency>
58 + <groupId>org.onosproject</groupId>
59 + <artifactId>onos-app-openstacknetworking-web</artifactId>
60 + <version>${project.version}</version>
61 + </dependency>
62 + </dependencies>
63 +</project>
1 +{
2 + "apps" : {
3 + "org.onosproject.openstackswitching" : {
4 + "openstackswitching" : {
5 + "do_not_push_flows" : "false",
6 + "neutron_server" : "http://192.168.56.103:9696/v2.0/",
7 + "keystone_server" : "http://192.168.56.103:5000/v2.0/",
8 + "user_name" : "admin",
9 + "password" : "nova",
10 + "physicalRouterMac" : "00:00:00:00:00:20",
11 + "nodes" : [
12 + {
13 + "hostname" : "compute-01",
14 + "ovsdbIp" : "192.168.56.102",
15 + "ovsdbPort" : "6640",
16 + "bridgeId" : "of:0000000000000001",
17 + "openstackNodeType" : "COMPUTENODE"
18 + },
19 + {
20 + "hostname" : "compute-02",
21 + "ovsdbIp" : "192.168.56.101",
22 + "ovsdbPort" : "6640",
23 + "bridgeId" : "of:0000000000000002",
24 + "openstackNodeType" : "COMPUTENODE"
25 + },
26 + {
27 + "hostname" : "network",
28 + "ovsdbIp" : "192.168.56.106",
29 + "ovsdbPort" : "6640",
30 + "bridgeId" : "of:0000000000000003",
31 + "openstackNodeType" : "GATEWAYNODE",
32 + "externalIfName" : "eth3",
33 + "externalIfMacAddress" : "00:00:00:00:00:11"
34 + }
35 + ]
36 + }
37 + }
38 + },
39 + "devices" : {
40 + "of:0000000000000001" : {
41 + "basic" : {
42 + "driver" : "sona"
43 + }
44 + },
45 + "of:0000000000000002" : {
46 + "basic" : {
47 + "driver" : "sona"
48 + }
49 + }
50 + }
51 +}
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016 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/xsd/maven-4.0.0.xsd">
20 + <modelVersion>4.0.0</modelVersion>
21 +
22 + <parent>
23 + <groupId>org.onosproject</groupId>
24 + <artifactId>onos-app-openstacknetworking</artifactId>
25 + <version>1.5.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-app-openstackrouting</artifactId>
30 + <packaging>bundle</packaging>
31 +
32 + <dependencies>
33 + <dependency>
34 + <groupId>org.osgi</groupId>
35 + <artifactId>org.osgi.compendium</artifactId>
36 + </dependency>
37 + <dependency>
38 + <groupId>org.onosproject</groupId>
39 + <artifactId>onos-api</artifactId>
40 + </dependency>
41 + <dependency>
42 + <groupId>org.onosproject</groupId>
43 + <artifactId>onos-core-serializers</artifactId>
44 + <version>${project.version}</version>
45 + </dependency>
46 + <dependency>
47 + <groupId>org.onosproject</groupId>
48 + <artifactId>onos-app-openstacknetworking-api</artifactId>
49 + <version>${project.version}</version>
50 + </dependency>
51 + </dependencies>
52 +
53 +</project>
54 +
1 +/*
2 + * Copyright 2016 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.openstacknetworking.routing;
17 +
18 +import org.onosproject.event.AbstractEvent;
19 +
20 +/**
21 + * Handle FloatingIP Event for Managing Flow Rules In Openstack Nodes.
22 + */
23 +public class OpenstackFloatingIPHandler implements Runnable {
24 +
25 + volatile AbstractEvent event;
26 + OpenstackFloatingIPHandler(AbstractEvent event) {
27 + this.event = event;
28 + }
29 +
30 + @Override
31 + public void run() {
32 +
33 + }
34 +}
1 +/*
2 + * Copyright 2016 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.openstacknetworking.routing;
17 +
18 +import org.onosproject.net.packet.PacketContext;
19 +
20 +/**
21 + * Handle ICMP packet processing for Managing Flow Rules In Openstack Nodes.
22 + */
23 +public class OpenstackIcmpHandler implements Runnable {
24 +
25 + volatile PacketContext context;
26 + private OpenstackRoutingRulePopulator rulePopulator;
27 + OpenstackIcmpHandler(OpenstackRoutingRulePopulator rulePopulator, PacketContext context) {
28 + this.context = context;
29 + this.rulePopulator = rulePopulator;
30 + }
31 +
32 + @Override
33 + public void run() {
34 + }
35 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 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.openstacknetworking.routing;
17 +
18 +import org.onlab.packet.Ethernet;
19 +import org.onlab.packet.IPv4;
20 +import org.onlab.packet.MacAddress;
21 +import org.onlab.packet.TCP;
22 +import org.onlab.packet.UDP;
23 +import org.onosproject.net.DeviceId;
24 +import org.onosproject.net.PortNumber;
25 +import org.onosproject.net.flow.DefaultTrafficTreatment;
26 +import org.onosproject.net.flow.TrafficTreatment;
27 +import org.onosproject.net.packet.DefaultOutboundPacket;
28 +import org.onosproject.net.packet.InboundPacket;
29 +import org.onosproject.net.packet.PacketContext;
30 +import org.onosproject.net.packet.PacketService;
31 +import org.onosproject.openstacknetworking.OpenstackPort;
32 +import org.slf4j.Logger;
33 +import org.slf4j.LoggerFactory;
34 +
35 +import java.nio.ByteBuffer;
36 +
37 +import static com.google.common.base.Preconditions.checkNotNull;
38 +
39 +
40 +/**
41 + * Handle NAT packet processing for Managing Flow Rules In Openstack Nodes.
42 + */
43 +public class OpenstackPnatHandler implements Runnable {
44 +
45 + volatile PacketContext context;
46 + private final Logger log = LoggerFactory.getLogger(getClass());
47 +
48 + protected PacketService packetService;
49 +
50 + private final OpenstackRoutingRulePopulator rulePopulator;
51 + private final int portNum;
52 + private final OpenstackPort openstackPort;
53 +
54 + OpenstackPnatHandler(OpenstackRoutingRulePopulator rulePopulator, PacketContext context,
55 + int portNum, OpenstackPort openstackPort) {
56 + this.rulePopulator = checkNotNull(rulePopulator);
57 + this.context = checkNotNull(context);
58 + this.portNum = checkNotNull(portNum);
59 + this.openstackPort = checkNotNull(openstackPort);
60 + }
61 +
62 + @Override
63 + public void run() {
64 + InboundPacket inboundPacket = context.inPacket();
65 + Ethernet ethernet = checkNotNull(inboundPacket.parsed());
66 +
67 + //TODO: Considers IPV6
68 + if (ethernet.getEtherType() != Ethernet.TYPE_IPV4) {
69 + log.warn("Now, we just consider IP version 4");
70 + return;
71 + }
72 +
73 + packetOut(inboundPacket, portNum);
74 +
75 + rulePopulator.populatePnatFlowRules(inboundPacket, openstackPort, portNum,
76 + getExternalInterfaceMacAddress(), getExternalRouterMacAddress());
77 + }
78 +
79 + private void packetOut(InboundPacket inboundPacket, int portNum) {
80 + Ethernet ethernet = checkNotNull(inboundPacket.parsed());
81 + IPv4 iPacket = (IPv4) ethernet.getPayload();
82 +
83 + TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
84 +
85 + switch (iPacket.getProtocol()) {
86 + case IPv4.PROTOCOL_TCP:
87 + TCP tcpPacket = (TCP) iPacket.getPayload();
88 + tcpPacket.setSourcePort(portNum);
89 + tcpPacket.resetChecksum();
90 + tcpPacket.setParent(iPacket);
91 + iPacket.setPayload(tcpPacket);
92 + break;
93 + case IPv4.PROTOCOL_UDP:
94 + UDP udpPacket = (UDP) iPacket.getPayload();
95 + udpPacket.setSourcePort(portNum);
96 + udpPacket.resetChecksum();
97 + udpPacket.setParent(iPacket);
98 + iPacket.setPayload(udpPacket);
99 + break;
100 + default:
101 + break;
102 + }
103 +
104 + iPacket.resetChecksum();
105 + iPacket.setPayload(ethernet);
106 + ethernet.setSourceMACAddress(getExternalInterfaceMacAddress())
107 + .setDestinationMACAddress(getExternalRouterMacAddress());
108 + ethernet.resetChecksum();
109 +
110 + treatment.setOutput(getExternalPort(inboundPacket.receivedFrom().deviceId()));
111 +
112 + packetService.emit(new DefaultOutboundPacket(inboundPacket.receivedFrom().deviceId(),
113 + treatment.build(), ByteBuffer.wrap(ethernet.serialize())));
114 + }
115 +
116 + private PortNumber getExternalPort(DeviceId deviceId) {
117 + // TODO
118 + return null;
119 + }
120 + private MacAddress getExternalInterfaceMacAddress() {
121 + // TODO
122 + return null;
123 + }
124 + private MacAddress getExternalRouterMacAddress() {
125 + // TODO
126 + return null;
127 + }
128 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 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.openstacknetworking.routing;
17 +
18 +import com.google.common.collect.Lists;
19 +import com.google.common.collect.Maps;
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.onlab.packet.Ethernet;
27 +import org.onlab.packet.IPv4;
28 +import org.onlab.packet.Ip4Address;
29 +import org.onlab.packet.MacAddress;
30 +import org.onosproject.core.ApplicationId;
31 +import org.onosproject.core.CoreService;
32 +import org.onosproject.net.device.DeviceService;
33 +import org.onosproject.net.driver.DriverService;
34 +import org.onosproject.net.flowobjective.FlowObjectiveService;
35 +import org.onosproject.net.packet.InboundPacket;
36 +import org.onosproject.net.packet.PacketContext;
37 +import org.onosproject.net.packet.PacketProcessor;
38 +import org.onosproject.net.packet.PacketService;
39 +import org.onosproject.openstacknetworking.OpenstackFloatingIP;
40 +import org.onosproject.openstacknetworking.OpenstackNetworkingService;
41 +import org.onosproject.openstacknetworking.OpenstackPort;
42 +import org.onosproject.openstacknetworking.OpenstackRouter;
43 +import org.onosproject.openstacknetworking.OpenstackRouterInterface;
44 +import org.onosproject.openstacknetworking.OpenstackRoutingService;
45 +import org.slf4j.Logger;
46 +import org.slf4j.LoggerFactory;
47 +
48 +import java.util.Collection;
49 +import java.util.List;
50 +import java.util.Map;
51 +import java.util.concurrent.ExecutorService;
52 +import java.util.concurrent.Executors;
53 +import java.util.stream.Collectors;
54 +
55 +import static com.google.common.base.Preconditions.checkNotNull;
56 +import static org.onlab.util.Tools.groupedThreads;
57 +
58 +@Service
59 +@Component(immediate = true)
60 +/**
61 + * Populates flow rules about L3 functionality for VMs in Openstack.
62 + */
63 +public class OpenstackRoutingManager implements OpenstackRoutingService {
64 + private final Logger log = LoggerFactory
65 + .getLogger(getClass());
66 +
67 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
68 + protected CoreService coreService;
69 +
70 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
71 + protected PacketService packetService;
72 +
73 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
74 + protected DeviceService deviceService;
75 +
76 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
77 + protected OpenstackNetworkingService openstackService;
78 +
79 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
80 + protected FlowObjectiveService flowObjectiveService;
81 +
82 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
83 + protected DriverService driverService;
84 +
85 + private ApplicationId appId;
86 + private Map<String, OpenstackRouterInterface> routerInterfaceMap = Maps.newHashMap();
87 + private Map<Integer, String> portNumMap = initPortNumMap();
88 + private static final String APP_ID = "org.onosproject.openstackrouting";
89 + private Map<Integer, String> initPortNumMap() {
90 + Map<Integer, String> map = Maps.newHashMap();
91 + for (int i = 1024; i < 65535; i++) {
92 + map.put(i, "");
93 + }
94 + return map;
95 + }
96 +
97 + private InternalPacketProcessor internalPacketProcessor = new InternalPacketProcessor();
98 + private ExecutorService l3EventExecutorService =
99 + Executors.newSingleThreadExecutor(groupedThreads("onos/openstackrouting", "L3-event"));
100 + private ExecutorService icmpEventExecutorService =
101 + Executors.newSingleThreadExecutor(groupedThreads("onos/openstackrouting", "icmp-event"));
102 +
103 + @Activate
104 + protected void activate() {
105 + appId = coreService.registerApplication(APP_ID);
106 + packetService.addProcessor(internalPacketProcessor, PacketProcessor.director(1));
107 +
108 + log.info("onos-openstackrouting started");
109 + }
110 +
111 + @Deactivate
112 + protected void deactivate() {
113 + packetService.removeProcessor(internalPacketProcessor);
114 + log.info("onos-openstackrouting stopped");
115 + }
116 +
117 +
118 + @Override
119 + public void createFloatingIP(OpenstackFloatingIP openstackFloatingIP) {
120 +
121 + }
122 +
123 + @Override
124 + public void updateFloatingIP(OpenstackFloatingIP openstackFloatingIP) {
125 +
126 + }
127 +
128 + @Override
129 + public void deleteFloatingIP(String id) {
130 +
131 + }
132 +
133 + @Override
134 + public void createRouter(OpenstackRouter openstackRouter) {
135 + checkExternalConnection(openstackRouter, getOpenstackRouterInterface(openstackRouter));
136 + }
137 +
138 + @Override
139 + public void updateRouter(OpenstackRouter openstackRouter) {
140 + checkExternalConnection(openstackRouter, getOpenstackRouterInterface(openstackRouter));
141 + }
142 +
143 + @Override
144 + public void deleteRouter(String id) {
145 + //TODO
146 + }
147 +
148 + @Override
149 + public void updateRouterInterface(OpenstackRouterInterface routerInterface) {
150 + routerInterfaceMap.putIfAbsent(routerInterface.portId(), routerInterface);
151 + List<OpenstackRouterInterface> routerInterfaces = Lists.newArrayList();
152 + routerInterfaces.add(routerInterface);
153 + checkExternalConnection(getOpenstackRouter(routerInterface.tenantId()), routerInterfaces);
154 + }
155 +
156 + @Override
157 + public void removeRouterInterface(OpenstackRouterInterface routerInterface) {
158 + OpenstackRoutingRulePopulator rulePopulator = new OpenstackRoutingRulePopulator(appId,
159 + openstackService, flowObjectiveService, deviceService, driverService);
160 + rulePopulator.removeExternalRules(routerInterface);
161 + routerInterfaceMap.remove(routerInterface.portId());
162 + }
163 + private class InternalPacketProcessor implements PacketProcessor {
164 +
165 + @Override
166 + public void process(PacketContext context) {
167 +
168 + if (context.isHandled()) {
169 + return;
170 + }
171 +
172 + InboundPacket pkt = context.inPacket();
173 + Ethernet ethernet = pkt.parsed();
174 +
175 + if (ethernet != null && ethernet.getEtherType() == Ethernet.TYPE_IPV4) {
176 + IPv4 iPacket = (IPv4) ethernet.getPayload();
177 + OpenstackRoutingRulePopulator rulePopulator = new OpenstackRoutingRulePopulator(appId,
178 + openstackService, flowObjectiveService, deviceService,
179 + driverService);
180 + switch (iPacket.getProtocol()) {
181 + case IPv4.PROTOCOL_ICMP:
182 + icmpEventExecutorService.execute(new OpenstackIcmpHandler(rulePopulator, context));
183 + break;
184 + default:
185 + int portNum = getPortNum(ethernet.getSourceMAC(), iPacket.getDestinationAddress());
186 + OpenstackPort openstackPort = getOpenstackPort(ethernet.getSourceMAC(),
187 + Ip4Address.valueOf(iPacket.getSourceAddress()));
188 + l3EventExecutorService.execute(new OpenstackPnatHandler(rulePopulator, context,
189 + portNum, openstackPort));
190 + break;
191 + }
192 +
193 + }
194 + }
195 +
196 + private int getPortNum(MacAddress sourceMac, int destinationAddress) {
197 + int portNum = portNumMap.keySet().stream()
198 + .filter(k -> portNumMap.get(k).equals("")).findFirst().orElse(0);
199 + portNumMap.replace(portNum, sourceMac.toString().concat(":").concat(String.valueOf(destinationAddress)));
200 + return portNum;
201 + }
202 + }
203 +
204 + private void checkExternalConnection(OpenstackRouter router,
205 + Collection<OpenstackRouterInterface> routerInterfaces) {
206 + checkNotNull(router, "Router can not be null");
207 + checkNotNull(routerInterfaces, "RouterInterfaces can not be null");
208 + Ip4Address externalIp = router.gatewayExternalInfo().externalFixedIps()
209 + .values().stream().findFirst().orElse(null);
210 + if ((externalIp == null) || (!router.gatewayExternalInfo().isEnablePnat())) {
211 + log.debug("Failed to set pnat configuration");
212 + return;
213 + }
214 + routerInterfaces.forEach(routerInterface -> {
215 + initiateL3Rule(router, routerInterface);
216 + });
217 + }
218 +
219 + private void initiateL3Rule(OpenstackRouter router, OpenstackRouterInterface routerInterface) {
220 + long vni = Long.parseLong(openstackService.network(openstackService
221 + .port(routerInterface.portId()).networkId()).segmentId());
222 + OpenstackRoutingRulePopulator rulePopulator = new OpenstackRoutingRulePopulator(appId,
223 + openstackService, flowObjectiveService, deviceService, driverService);
224 + rulePopulator.populateExternalRules(vni, router, routerInterface);
225 + }
226 +
227 + private Collection<OpenstackRouterInterface> getOpenstackRouterInterface(OpenstackRouter router) {
228 + return routerInterfaceMap.values().stream().filter(i -> i.id().equals(router.id()))
229 + .collect(Collectors.toList());
230 + }
231 +
232 + private OpenstackRouter getOpenstackRouter(String tenantId) {
233 + return openstackService.routers().stream().filter(r ->
234 + r.tenantId().equals(tenantId)).findFirst().orElse(null);
235 + }
236 +
237 + private OpenstackPort getOpenstackPort(MacAddress sourceMac, Ip4Address ip4Address) {
238 + OpenstackPort openstackPort = openstackService.ports("").stream()
239 + .filter(p -> p.macAddress().equals(sourceMac)).findFirst().orElse(null);
240 + return openstackPort.fixedIps().values().stream().findFirst().orElse(null)
241 + .equals(ip4Address) ? openstackPort : null;
242 + }
243 +
244 +}
1 +/*
2 + * Copyright 2016 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 + * Application for OpenstackRouting.
19 + */
20 +package org.onosproject.openstacknetworking.routing;
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2015-2016 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-app-openstacknetworking</artifactId>
25 + <version>1.5.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-app-openstackswitching</artifactId>
30 + <packaging>bundle</packaging>
31 +
32 + <dependencies>
33 + <dependency>
34 + <groupId>org.onosproject</groupId>
35 + <artifactId>onos-app-openstacknetworking-api</artifactId>
36 + <version>${project.version}</version>
37 + </dependency>
38 + <dependency>
39 + <groupId>org.onosproject</groupId>
40 + <artifactId>onos-app-dhcp</artifactId>
41 + <version>1.5.0-SNAPSHOT</version>
42 + </dependency>
43 + <dependency>
44 + <groupId>org.onosproject</groupId>
45 + <artifactId>onos-app-dhcp-api</artifactId>
46 + <version>1.5.0-SNAPSHOT</version>
47 + </dependency>
48 + <dependency>
49 + <groupId>org.onosproject</groupId>
50 + <artifactId>onos-rest</artifactId>
51 + <version>${project.version}</version>
52 + </dependency>
53 + <dependency>
54 + <groupId>org.onosproject</groupId>
55 + <artifactId>onlab-rest</artifactId>
56 + <version>${project.version}</version>
57 + </dependency>
58 + <dependency>
59 + <groupId>org.onosproject</groupId>
60 + <artifactId>onlab-misc</artifactId>
61 + <version>${project.version}</version>
62 + </dependency>
63 + </dependencies>
64 +
65 +
66 +</project>
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching.impl; 16 +package org.onosproject.openstacknetworking.switching;
17 17
18 import org.onlab.packet.ARP; 18 import org.onlab.packet.ARP;
19 import org.onlab.packet.Ethernet; 19 import org.onlab.packet.Ethernet;
...@@ -27,8 +27,9 @@ import org.onosproject.net.host.HostService; ...@@ -27,8 +27,9 @@ import org.onosproject.net.host.HostService;
27 import org.onosproject.net.packet.DefaultOutboundPacket; 27 import org.onosproject.net.packet.DefaultOutboundPacket;
28 import org.onosproject.net.packet.InboundPacket; 28 import org.onosproject.net.packet.InboundPacket;
29 import org.onosproject.net.packet.PacketService; 29 import org.onosproject.net.packet.PacketService;
30 -import org.onosproject.openstackswitching.OpenstackPort; 30 +import org.onosproject.openstacknetworking.OpenstackNetworkingService;
31 -import org.onosproject.openstackswitching.OpenstackPortInfo; 31 +import org.onosproject.openstacknetworking.OpenstackPort;
32 +import org.onosproject.openstacknetworking.OpenstackPortInfo;
32 import org.slf4j.Logger; 33 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory; 34 import org.slf4j.LoggerFactory;
34 import java.nio.ByteBuffer; 35 import java.nio.ByteBuffer;
...@@ -45,19 +46,19 @@ public class OpenstackArpHandler { ...@@ -45,19 +46,19 @@ public class OpenstackArpHandler {
45 .getLogger(OpenstackArpHandler.class); 46 .getLogger(OpenstackArpHandler.class);
46 private static final MacAddress GATEWAY_MAC = MacAddress.valueOf("1f:1f:1f:1f:1f:1f"); 47 private static final MacAddress GATEWAY_MAC = MacAddress.valueOf("1f:1f:1f:1f:1f:1f");
47 private PacketService packetService; 48 private PacketService packetService;
48 - private OpenstackRestHandler restHandler; 49 + private OpenstackNetworkingService openstackService;
49 private HostService hostService; 50 private HostService hostService;
50 51
51 /** 52 /**
52 * Returns OpenstackArpHandler reference. 53 * Returns OpenstackArpHandler reference.
53 * 54 *
54 - * @param restHandler rest API handler reference 55 + * @param openstackService OpenstackNetworkingService reference
55 * @param packetService PacketService reference 56 * @param packetService PacketService reference
56 * @param hostService host service 57 * @param hostService host service
57 */ 58 */
58 - public OpenstackArpHandler(OpenstackRestHandler restHandler, PacketService packetService, 59 + public OpenstackArpHandler(OpenstackNetworkingService openstackService, PacketService packetService,
59 HostService hostService) { 60 HostService hostService) {
60 - this.restHandler = checkNotNull(restHandler); 61 + this.openstackService = openstackService;
61 this.packetService = packetService; 62 this.packetService = packetService;
62 this.hostService = hostService; 63 this.hostService = hostService;
63 } 64 }
...@@ -123,7 +124,7 @@ public class OpenstackArpHandler { ...@@ -123,7 +124,7 @@ public class OpenstackArpHandler {
123 private MacAddress getMacFromOpenstack(IpAddress targetIp) { 124 private MacAddress getMacFromOpenstack(IpAddress targetIp) {
124 checkNotNull(targetIp); 125 checkNotNull(targetIp);
125 126
126 - OpenstackPort openstackPort = restHandler.getPorts() 127 + OpenstackPort openstackPort = openstackService.ports()
127 .stream() 128 .stream()
128 .filter(port -> port.fixedIps().containsValue(targetIp)) 129 .filter(port -> port.fixedIps().containsValue(targetIp))
129 .findFirst() 130 .findFirst()
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.openstackswitching.impl; 17 +package org.onosproject.openstacknetworking.switching;
18 18
19 import org.onlab.packet.Ethernet; 19 import org.onlab.packet.Ethernet;
20 import org.onlab.packet.Ip4Address; 20 import org.onlab.packet.Ip4Address;
...@@ -40,9 +40,10 @@ import org.onosproject.net.flow.instructions.ExtensionTreatmentType; ...@@ -40,9 +40,10 @@ import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
40 import org.onosproject.net.flowobjective.DefaultForwardingObjective; 40 import org.onosproject.net.flowobjective.DefaultForwardingObjective;
41 import org.onosproject.net.flowobjective.FlowObjectiveService; 41 import org.onosproject.net.flowobjective.FlowObjectiveService;
42 import org.onosproject.net.flowobjective.ForwardingObjective; 42 import org.onosproject.net.flowobjective.ForwardingObjective;
43 -import org.onosproject.openstackswitching.OpenstackNetwork; 43 +import org.onosproject.openstacknetworking.OpenstackNetwork;
44 -import org.onosproject.openstackswitching.OpenstackPort; 44 +import org.onosproject.openstacknetworking.OpenstackNetworkingService;
45 -import org.onosproject.openstackswitching.OpenstackPortInfo; 45 +import org.onosproject.openstacknetworking.OpenstackPort;
46 +import org.onosproject.openstacknetworking.OpenstackPortInfo;
46 import org.slf4j.Logger; 47 import org.slf4j.Logger;
47 import org.slf4j.LoggerFactory; 48 import org.slf4j.LoggerFactory;
48 49
...@@ -63,7 +64,6 @@ public class OpenstackSwitchingRulePopulator { ...@@ -63,7 +64,6 @@ public class OpenstackSwitchingRulePopulator {
63 private FlowObjectiveService flowObjectiveService; 64 private FlowObjectiveService flowObjectiveService;
64 private DriverService driverService; 65 private DriverService driverService;
65 private DeviceService deviceService; 66 private DeviceService deviceService;
66 - private OpenstackRestHandler restHandler;
67 private ApplicationId appId; 67 private ApplicationId appId;
68 68
69 private Collection<OpenstackNetwork> openstackNetworkList; 69 private Collection<OpenstackNetwork> openstackNetworkList;
...@@ -75,22 +75,20 @@ public class OpenstackSwitchingRulePopulator { ...@@ -75,22 +75,20 @@ public class OpenstackSwitchingRulePopulator {
75 * @param appId application id 75 * @param appId application id
76 * @param flowObjectiveService FlowObjectiveService reference 76 * @param flowObjectiveService FlowObjectiveService reference
77 * @param deviceService DeviceService reference 77 * @param deviceService DeviceService reference
78 - * @param restHandler OpenstackRestHandler reference
79 * @param driverService DriverService reference 78 * @param driverService DriverService reference
80 */ 79 */
81 public OpenstackSwitchingRulePopulator(ApplicationId appId, 80 public OpenstackSwitchingRulePopulator(ApplicationId appId,
82 FlowObjectiveService flowObjectiveService, 81 FlowObjectiveService flowObjectiveService,
83 DeviceService deviceService, 82 DeviceService deviceService,
84 - OpenstackRestHandler restHandler, 83 + OpenstackNetworkingService openstackService,
85 DriverService driverService) { 84 DriverService driverService) {
86 this.flowObjectiveService = flowObjectiveService; 85 this.flowObjectiveService = flowObjectiveService;
87 this.deviceService = deviceService; 86 this.deviceService = deviceService;
88 this.driverService = driverService; 87 this.driverService = driverService;
89 - this.restHandler = restHandler;
90 this.appId = appId; 88 this.appId = appId;
91 89
92 - openstackNetworkList = restHandler.getNetworks(); 90 + openstackNetworkList = openstackService.networks();
93 - openstackPortList = restHandler.getPorts(); 91 + openstackPortList = openstackService.ports();
94 } 92 }
95 93
96 94
......
...@@ -17,4 +17,4 @@ ...@@ -17,4 +17,4 @@
17 /** 17 /**
18 * OpenStack switch implementation. 18 * OpenStack switch implementation.
19 */ 19 */
20 -package org.onosproject.openstackswitching.impl; 20 +package org.onosproject.openstacknetworking.switching;
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016 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/xsd/maven-4.0.0.xsd">
20 + <modelVersion>4.0.0</modelVersion>
21 +
22 + <parent>
23 + <groupId>org.onosproject</groupId>
24 + <artifactId>onos-apps</artifactId>
25 + <version>1.5.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-app-openstacknetworking</artifactId>
30 + <packaging>pom</packaging>
31 +
32 + <modules>
33 + <module>app</module>
34 + <module>web</module>
35 + <module>api</module>
36 + <module>openstackswitching</module>
37 + <module>openstackrouting</module>
38 + </modules>
39 +
40 +
41 + <description>SONA Openstack Networking XXXX Application</description>
42 +
43 + <dependencies>
44 + </dependencies>
45 +</project>
1 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 +<!--
3 + ~ Copyright 2015-16 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 +<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
18 + <feature name="${project.artifactId}" version="${project.version}"
19 + description="${project.description}">
20 + <feature>onos-api</feature>
21 + <bundle>mvn:${project.groupId}/onos-app-openstacknetworking-api/${project.version}</bundle>
22 + <bundle>mvn:${project.groupId}/onos-app-openstacknetworking-web/${project.version}</bundle>
23 + <bundle>mvn:com.sun.jersey/jersey-client/1.19</bundle>
24 + </feature>
25 +</features>
...@@ -21,31 +21,28 @@ ...@@ -21,31 +21,28 @@
21 21
22 <parent> 22 <parent>
23 <groupId>org.onosproject</groupId> 23 <groupId>org.onosproject</groupId>
24 - <artifactId>onos-openstackswitching</artifactId> 24 + <artifactId>onos-app-openstacknetworking</artifactId>
25 <version>1.5.0-SNAPSHOT</version> 25 <version>1.5.0-SNAPSHOT</version>
26 <relativePath>../pom.xml</relativePath> 26 <relativePath>../pom.xml</relativePath>
27 </parent> 27 </parent>
28 28
29 - <artifactId>onos-app-openstackswitching</artifactId> 29 + <artifactId>onos-app-openstacknetworking-web</artifactId>
30 <packaging>bundle</packaging> 30 <packaging>bundle</packaging>
31 31
32 - <description>SONA Openstack Switching applications</description>
33 <properties> 32 <properties>
34 <web.context>/onos/openstackswitching</web.context> 33 <web.context>/onos/openstackswitching</web.context>
35 <api.version>1.0.0</api.version> 34 <api.version>1.0.0</api.version>
36 - <api.title>ONOS OpenStack Switching REST API</api.title> 35 + <api.title>ONOS Openstack Networking REST API</api.title>
37 <api.description> 36 <api.description>
38 - APIs for receiving Neutron information. 37 + APIs for interacting with Openstack Neutron Plugin.
39 </api.description> 38 </api.description>
40 - <api.package>org.onosproject.openstackswitching.web</api.package> 39 + <api.package>org.onosproject.openstacknetworking.web</api.package>
41 - <onos.app.origin>SKT, Inc.</onos.app.origin>
42 </properties> 40 </properties>
43 41
44 -
45 <dependencies> 42 <dependencies>
46 <dependency> 43 <dependency>
47 <groupId>org.onosproject</groupId> 44 <groupId>org.onosproject</groupId>
48 - <artifactId>onos-app-openstackswitching-api</artifactId> 45 + <artifactId>onos-app-openstacknetworking-api</artifactId>
49 <version>${project.version}</version> 46 <version>${project.version}</version>
50 </dependency> 47 </dependency>
51 <dependency> 48 <dependency>
......
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
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 -package org.onosproject.openstackswitching.web; 16 +package org.onosproject.openstacknetworking.web;
17 17
18 import com.fasterxml.jackson.databind.ObjectMapper; 18 import com.fasterxml.jackson.databind.ObjectMapper;
19 import com.fasterxml.jackson.databind.node.ObjectNode; 19 import com.fasterxml.jackson.databind.node.ObjectNode;
20 -import org.onosproject.openstackrouting.OpenstackRouter; 20 +import org.onosproject.openstacknetworking.OpenstackRouter;
21 -import org.onosproject.openstackrouting.OpenstackRouterInterface; 21 +import org.onosproject.openstacknetworking.OpenstackRouterInterface;
22 -import org.onosproject.openstackswitching.OpenstackSwitchingService; 22 +import org.onosproject.openstacknetworking.OpenstackRoutingService;
23 import org.onosproject.rest.AbstractWebResource; 23 import org.onosproject.rest.AbstractWebResource;
24 import org.slf4j.Logger; 24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory; 25 import org.slf4j.LoggerFactory;
...@@ -42,8 +42,7 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -42,8 +42,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
42 42
43 @Path("routers") 43 @Path("routers")
44 public class OpensatckRouterWebResource extends AbstractWebResource { 44 public class OpensatckRouterWebResource extends AbstractWebResource {
45 - protected static final Logger log = LoggerFactory 45 + private final Logger log = LoggerFactory.getLogger(getClass());
46 - .getLogger(OpenstackNetworkWebResource.class);
47 46
48 private static final OpenstackRouterInterfaceCodec ROUTER_INTERFACE_CODEC 47 private static final OpenstackRouterInterfaceCodec ROUTER_INTERFACE_CODEC
49 = new OpenstackRouterInterfaceCodec(); 48 = new OpenstackRouterInterfaceCodec();
...@@ -62,9 +61,9 @@ public class OpensatckRouterWebResource extends AbstractWebResource { ...@@ -62,9 +61,9 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
62 OpenstackRouter openstackRouter 61 OpenstackRouter openstackRouter
63 = ROUTER_CODEC.decode(routerNode, this); 62 = ROUTER_CODEC.decode(routerNode, this);
64 63
65 - OpenstackSwitchingService switchingService 64 + OpenstackRoutingService routingService
66 - = getService(OpenstackSwitchingService.class); 65 + = getService(OpenstackRoutingService.class);
67 - switchingService.createRouter(openstackRouter); 66 + routingService.createRouter(openstackRouter);
68 67
69 log.debug("REST API CREATE router is called {}", input.toString()); 68 log.debug("REST API CREATE router is called {}", input.toString());
70 return Response.status(Response.Status.OK).build(); 69 return Response.status(Response.Status.OK).build();
...@@ -80,14 +79,20 @@ public class OpensatckRouterWebResource extends AbstractWebResource { ...@@ -80,14 +79,20 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
80 @Path("{id}") 79 @Path("{id}")
81 @Consumes(MediaType.APPLICATION_JSON) 80 @Consumes(MediaType.APPLICATION_JSON)
82 @Produces(MediaType.APPLICATION_JSON) 81 @Produces(MediaType.APPLICATION_JSON)
83 - public Response updateRouter(@PathParam("id") String id) { 82 + public Response updateRouter(InputStream input) {
84 - checkNotNull(id); 83 + checkNotNull(input);
85 try { 84 try {
86 - OpenstackSwitchingService switchingService 85 + ObjectMapper mapper = new ObjectMapper();
87 - = getService(OpenstackSwitchingService.class); 86 + ObjectNode routerNode = (ObjectNode) mapper.readTree(input);
88 - switchingService.updateRouter(id);
89 87
90 - log.debug("REST API UPDATE router is called from router {}", id); 88 + OpenstackRouter openstackRouter
89 + = ROUTER_CODEC.decode(routerNode, this);
90 +
91 + OpenstackRoutingService routingService
92 + = getService(OpenstackRoutingService.class);
93 + routingService.updateRouter(openstackRouter);
94 +
95 + log.debug("REST API UPDATE router is called from router {}", input.toString());
91 return Response.status(Response.Status.OK).build(); 96 return Response.status(Response.Status.OK).build();
92 } catch (Exception e) { 97 } catch (Exception e) {
93 log.error("Updates Router failed because of exception {}", 98 log.error("Updates Router failed because of exception {}",
...@@ -110,9 +115,9 @@ public class OpensatckRouterWebResource extends AbstractWebResource { ...@@ -110,9 +115,9 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
110 OpenstackRouterInterface openstackRouterInterface 115 OpenstackRouterInterface openstackRouterInterface
111 = ROUTER_INTERFACE_CODEC.decode(routerIfNode, this); 116 = ROUTER_INTERFACE_CODEC.decode(routerIfNode, this);
112 117
113 - OpenstackSwitchingService switchingService 118 + OpenstackRoutingService routingService
114 - = getService(OpenstackSwitchingService.class); 119 + = getService(OpenstackRoutingService.class);
115 - switchingService.updateRouterInterface(openstackRouterInterface); 120 + routingService.updateRouterInterface(openstackRouterInterface);
116 121
117 log.debug("REST API AddRouterInterface is called from router {} portId: {}, subnetId: {}, tenantId: {}", 122 log.debug("REST API AddRouterInterface is called from router {} portId: {}, subnetId: {}, tenantId: {}",
118 openstackRouterInterface.id(), openstackRouterInterface.portId(), 123 openstackRouterInterface.id(), openstackRouterInterface.portId(),
...@@ -129,11 +134,12 @@ public class OpensatckRouterWebResource extends AbstractWebResource { ...@@ -129,11 +134,12 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
129 134
130 @DELETE 135 @DELETE
131 @Path("{id}") 136 @Path("{id}")
137 + @Produces(MediaType.APPLICATION_JSON)
132 public Response deleteRouter(@PathParam("id") String id) { 138 public Response deleteRouter(@PathParam("id") String id) {
133 checkNotNull(id); 139 checkNotNull(id);
134 - OpenstackSwitchingService switchingService = 140 + OpenstackRoutingService routingService
135 - getService(OpenstackSwitchingService.class); 141 + = getService(OpenstackRoutingService.class);
136 - switchingService.deleteRouter(id); 142 + routingService.deleteRouter(id);
137 143
138 log.debug("REST API DELETE routers is called {}", id); 144 log.debug("REST API DELETE routers is called {}", id);
139 return Response.status(Response.Status.OK).build(); 145 return Response.status(Response.Status.OK).build();
...@@ -153,9 +159,9 @@ public class OpensatckRouterWebResource extends AbstractWebResource { ...@@ -153,9 +159,9 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
153 OpenstackRouterInterface openstackRouterInterface 159 OpenstackRouterInterface openstackRouterInterface
154 = ROUTER_INTERFACE_CODEC.decode(routerIfNode, this); 160 = ROUTER_INTERFACE_CODEC.decode(routerIfNode, this);
155 161
156 - OpenstackSwitchingService switchingService 162 + OpenstackRoutingService routingService
157 - = getService(OpenstackSwitchingService.class); 163 + = getService(OpenstackRoutingService.class);
158 - switchingService.removeRouterInterface(openstackRouterInterface); 164 + routingService.removeRouterInterface(openstackRouterInterface);
159 165
160 log.debug("REST API RemoveRouterInterface is called from router {} portId: {}, subnetId: {}," + 166 log.debug("REST API RemoveRouterInterface is called from router {} portId: {}, subnetId: {}," +
161 "tenantId: {}", openstackRouterInterface.id(), openstackRouterInterface.portId(), 167 "tenantId: {}", openstackRouterInterface.id(), openstackRouterInterface.portId(),
......
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
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 -package org.onosproject.openstackswitching.web; 16 +package org.onosproject.openstacknetworking.web;
17 17
18 import com.fasterxml.jackson.databind.JsonNode; 18 import com.fasterxml.jackson.databind.JsonNode;
19 import com.fasterxml.jackson.databind.node.ObjectNode; 19 import com.fasterxml.jackson.databind.node.ObjectNode;
20 import org.onosproject.codec.CodecContext; 20 import org.onosproject.codec.CodecContext;
21 import org.onosproject.codec.JsonCodec; 21 import org.onosproject.codec.JsonCodec;
22 -import org.onosproject.openstackswitching.OpenstackNetwork; 22 +import org.onosproject.openstacknetworking.OpenstackNetwork;
23 import org.slf4j.Logger; 23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory; 24 import org.slf4j.LoggerFactory;
25 25
...@@ -29,8 +29,7 @@ import org.slf4j.LoggerFactory; ...@@ -29,8 +29,7 @@ import org.slf4j.LoggerFactory;
29 */ 29 */
30 public class OpenstackNetworkCodec extends JsonCodec<OpenstackNetwork> { 30 public class OpenstackNetworkCodec extends JsonCodec<OpenstackNetwork> {
31 31
32 - protected static final Logger log = LoggerFactory 32 + private final Logger log = LoggerFactory.getLogger(getClass());
33 - .getLogger(OpenstackNetworkCodec.class);
34 33
35 private static final String NETWORK = "network"; 34 private static final String NETWORK = "network";
36 private static final String NAME = "name"; 35 private static final String NAME = "name";
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching.web; 16 +package org.onosproject.openstacknetworking.web;
17 17
18 import org.onosproject.rest.AbstractWebResource; 18 import org.onosproject.rest.AbstractWebResource;
19 import org.slf4j.Logger; 19 import org.slf4j.Logger;
...@@ -35,8 +35,7 @@ import java.io.InputStream; ...@@ -35,8 +35,7 @@ import java.io.InputStream;
35 @Path("networks") 35 @Path("networks")
36 public class OpenstackNetworkWebResource extends AbstractWebResource { 36 public class OpenstackNetworkWebResource extends AbstractWebResource {
37 37
38 - protected static final Logger log = LoggerFactory 38 + private final Logger log = LoggerFactory.getLogger(getClass());
39 - .getLogger(OpenstackNetworkWebResource.class);
40 39
41 @POST 40 @POST
42 @Consumes(MediaType.APPLICATION_JSON) 41 @Consumes(MediaType.APPLICATION_JSON)
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching.impl; 16 +package org.onosproject.openstacknetworking.web;
17 17
18 import com.fasterxml.jackson.databind.ObjectMapper; 18 import com.fasterxml.jackson.databind.ObjectMapper;
19 import com.fasterxml.jackson.databind.node.ArrayNode; 19 import com.fasterxml.jackson.databind.node.ArrayNode;
...@@ -21,21 +21,32 @@ import com.fasterxml.jackson.databind.node.ObjectNode; ...@@ -21,21 +21,32 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
21 import com.google.common.collect.Lists; 21 import com.google.common.collect.Lists;
22 import com.sun.jersey.api.client.Client; 22 import com.sun.jersey.api.client.Client;
23 import com.sun.jersey.api.client.WebResource; 23 import com.sun.jersey.api.client.WebResource;
24 -import org.onosproject.openstackrouting.OpenstackRouter; 24 +import org.apache.felix.scr.annotations.Activate;
25 -import org.onosproject.openstackswitching.OpenstackNetwork; 25 +import org.apache.felix.scr.annotations.Component;
26 -import org.onosproject.openstackswitching.OpenstackPort; 26 +import org.apache.felix.scr.annotations.Deactivate;
27 -import org.onosproject.openstackswitching.OpenstackSubnet; 27 +import org.apache.felix.scr.annotations.Reference;
28 -import org.onosproject.openstackswitching.web.OpenstackNetworkCodec; 28 +import org.apache.felix.scr.annotations.ReferenceCardinality;
29 -import org.onosproject.openstackswitching.web.OpenstackPortCodec; 29 +import org.apache.felix.scr.annotations.Service;
30 -import org.onosproject.openstackswitching.web.OpenstackSecurityGroupCodec; 30 +import org.onosproject.core.ApplicationId;
31 -import org.onosproject.openstackswitching.web.OpenstackRouterCodec; 31 +import org.onosproject.core.CoreService;
32 -import org.onosproject.openstackswitching.web.OpenstackSubnetCodec; 32 +import org.onosproject.net.Port;
33 +import org.onosproject.net.driver.DriverService;
34 +import org.onosproject.openstacknetworking.OpenstackNetwork;
35 +import org.onosproject.openstacknetworking.OpenstackNetworkingService;
36 +import org.onosproject.openstacknetworking.OpenstackPort;
37 +import org.onosproject.openstacknetworking.OpenstackPortInfo;
38 +import org.onosproject.openstacknetworking.OpenstackRouter;
39 +import org.onosproject.openstacknetworking.OpenstackSecurityGroup;
40 +import org.onosproject.openstacknetworking.OpenstackSubnet;
41 +import org.onosproject.openstacknetworking.OpenstackSwitchingService;
33 import org.slf4j.Logger; 42 import org.slf4j.Logger;
34 import javax.ws.rs.core.MediaType; 43 import javax.ws.rs.core.MediaType;
35 import java.io.IOException; 44 import java.io.IOException;
36 import java.util.Collection; 45 import java.util.Collection;
37 import java.util.Collections; 46 import java.util.Collections;
38 import java.util.List; 47 import java.util.List;
48 +import java.util.Map;
49 +import java.util.stream.Collectors;
39 50
40 import static com.google.common.base.Preconditions.checkNotNull; 51 import static com.google.common.base.Preconditions.checkNotNull;
41 import static com.google.common.net.MediaType.JSON_UTF_8; 52 import static com.google.common.net.MediaType.JSON_UTF_8;
...@@ -45,7 +56,9 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -45,7 +56,9 @@ import static org.slf4j.LoggerFactory.getLogger;
45 * Handles REST Calls to Openstack Neutron. 56 * Handles REST Calls to Openstack Neutron.
46 * 57 *
47 */ 58 */
48 -public class OpenstackRestHandler { 59 +@Service
60 +@Component(immediate = true)
61 +public class OpenstackNetworkingManager implements OpenstackNetworkingService {
49 62
50 private static final String URI_NETWORKS = "networks"; 63 private static final String URI_NETWORKS = "networks";
51 private static final String URI_PORTS = "ports"; 64 private static final String URI_PORTS = "ports";
...@@ -70,16 +83,29 @@ public class OpenstackRestHandler { ...@@ -70,16 +83,29 @@ public class OpenstackRestHandler {
70 private String userName; 83 private String userName;
71 private String pass; 84 private String pass;
72 85
73 - /** 86 + private static final String PORT_NAME = "portName";
74 - * Creates OpenstackRestHandler instance. 87 +
75 - * 88 + private ApplicationId appId;
76 - * @param cfg OpenstackSwitchingConfig reference 89 +
77 - */ 90 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
78 - public OpenstackRestHandler(OpenstackSwitchingConfig cfg) { 91 + protected CoreService coreService;
79 - this.neutronUrl = checkNotNull(cfg.neutronServer()); 92 +
80 - this.keystoneUrl = checkNotNull(cfg.keystoneServer()); 93 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
81 - this.userName = checkNotNull(cfg.userName()); 94 + protected DriverService driverService;
82 - this.pass = checkNotNull(cfg.password()); 95 +
96 + protected OpenstackSwitchingService openstackSwitchingService;
97 +
98 + @Activate
99 + protected void activate() {
100 + appId = coreService
101 + .registerApplication("org.onosproject.openstacknetworking");
102 +
103 + log.info("started");
104 + }
105 +
106 + @Deactivate
107 + protected void deactivate() {
108 + log.info("stopped");
83 } 109 }
84 110
85 /** 111 /**
...@@ -249,4 +275,79 @@ public class OpenstackRestHandler { ...@@ -249,4 +275,79 @@ public class OpenstackRestHandler {
249 return true; 275 return true;
250 } 276 }
251 277
278 + @Override
279 + public Collection<OpenstackPort> ports(String networkId) {
280 + return getPorts().stream()
281 + .filter(port -> port.networkId().equals(networkId))
282 + .collect(Collectors.toList());
283 + }
284 +
285 + @Override
286 + public Collection<OpenstackPort> ports() {
287 + return getPorts();
288 + }
289 +
290 + @Override
291 + public OpenstackPort port(Port port) {
292 + String uuid = port.annotations().value(PORT_NAME).substring(3);
293 + return getPorts().stream()
294 + .filter(p -> p.id().startsWith(uuid))
295 + .findAny().orElse(null);
296 + }
297 +
298 + @Override
299 + public OpenstackPort port(String portId) {
300 + return getPorts().stream()
301 + .filter(p -> p.id().equals(portId))
302 + .findAny().orElse(null);
303 + }
304 +
305 + @Override
306 + public OpenstackNetwork network(String networkId) {
307 + return getNetworks().stream()
308 + .filter(n -> n.id().equals(networkId))
309 + .findAny().orElse(null);
310 + }
311 +
312 + @Override
313 + public Collection<OpenstackNetwork> networks() {
314 + return getNetworks();
315 + }
316 +
317 + @Override
318 + public OpenstackSubnet subnet(String subnetId) {
319 + return getSubnets().stream()
320 + .filter(subnet -> subnet.id().equals(subnetId))
321 + .findAny().orElse(null);
322 + }
323 +
324 + @Override
325 + public Collection<OpenstackSubnet> subnets() {
326 + return getSubnets();
327 + }
328 +
329 + @Override
330 + public Collection<OpenstackRouter> routers() {
331 + return getRouters();
332 + }
333 +
334 + @Override
335 + public OpenstackRouter router(String routerId) {
336 + return getRouters().stream()
337 + .filter(router -> router.id().equals(routerId))
338 + .findAny().orElse(null);
339 + }
340 +
341 + @Override
342 + public Map<String, OpenstackPortInfo> openstackPortInfo() {
343 + return openstackSwitchingService.openstackPortInfo();
344 + }
345 +
346 + @Override
347 + public void setConfigurations(String neutronUrl, String keystoneUrl, String userName, String pass) {
348 + this.neutronUrl = checkNotNull(neutronUrl);
349 + this.keystoneUrl = checkNotNull(keystoneUrl);
350 + this.userName = checkNotNull(userName);
351 + this.pass = checkNotNull(pass);
352 + }
252 } 353 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching.web; 16 +package org.onosproject.openstacknetworking.web;
17 17
18 import com.fasterxml.jackson.databind.JsonNode; 18 import com.fasterxml.jackson.databind.JsonNode;
19 import com.fasterxml.jackson.databind.node.ArrayNode; 19 import com.fasterxml.jackson.databind.node.ArrayNode;
...@@ -25,7 +25,7 @@ import org.onlab.packet.IpAddress; ...@@ -25,7 +25,7 @@ import org.onlab.packet.IpAddress;
25 import org.onlab.packet.MacAddress; 25 import org.onlab.packet.MacAddress;
26 import org.onosproject.codec.CodecContext; 26 import org.onosproject.codec.CodecContext;
27 import org.onosproject.codec.JsonCodec; 27 import org.onosproject.codec.JsonCodec;
28 -import org.onosproject.openstackswitching.OpenstackPort; 28 +import org.onosproject.openstacknetworking.OpenstackPort;
29 import org.slf4j.Logger; 29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory; 30 import org.slf4j.LoggerFactory;
31 31
...@@ -33,13 +33,14 @@ import java.util.Collection; ...@@ -33,13 +33,14 @@ import java.util.Collection;
33 import java.util.HashMap; 33 import java.util.HashMap;
34 import java.util.Map; 34 import java.util.Map;
35 35
36 +import static com.google.common.base.Preconditions.checkNotNull;
37 +
36 /** 38 /**
37 * Encodes and decodes the OpenstackPort. 39 * Encodes and decodes the OpenstackPort.
38 */ 40 */
39 public class OpenstackPortCodec extends JsonCodec<OpenstackPort> { 41 public class OpenstackPortCodec extends JsonCodec<OpenstackPort> {
40 42
41 - private static Logger log = LoggerFactory 43 + private final Logger log = LoggerFactory.getLogger(getClass());
42 - .getLogger(OpenstackPortCodec.class);
43 44
44 // JSON field names 45 // JSON field names
45 private static final String PORT = "port"; 46 private static final String PORT = "port";
...@@ -62,6 +63,7 @@ public class OpenstackPortCodec extends JsonCodec<OpenstackPort> { ...@@ -62,6 +63,7 @@ public class OpenstackPortCodec extends JsonCodec<OpenstackPort> {
62 @Override 63 @Override
63 public OpenstackPort decode(ObjectNode json, CodecContext context) { 64 public OpenstackPort decode(ObjectNode json, CodecContext context) {
64 65
66 + checkNotNull(json);
65 HashMap<String, Ip4Address> fixedIpMap = new HashMap<>(); 67 HashMap<String, Ip4Address> fixedIpMap = new HashMap<>();
66 JsonNode portInfo = json.get(PORT); 68 JsonNode portInfo = json.get(PORT);
67 if (portInfo == null) { 69 if (portInfo == null) {
......
...@@ -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 -package org.onosproject.openstackswitching.web; 16 +package org.onosproject.openstacknetworking.web;
17 17
18 import com.fasterxml.jackson.databind.ObjectMapper; 18 import com.fasterxml.jackson.databind.ObjectMapper;
19 import com.fasterxml.jackson.databind.node.ObjectNode; 19 import com.fasterxml.jackson.databind.node.ObjectNode;
20 -import org.onosproject.openstackswitching.OpenstackPort; 20 +import org.onosproject.openstacknetworking.OpenstackPort;
21 -import org.onosproject.openstackswitching.OpenstackSwitchingService; 21 +import org.onosproject.openstacknetworking.OpenstackSwitchingService;
22 import org.onosproject.rest.AbstractWebResource; 22 import org.onosproject.rest.AbstractWebResource;
23 import org.slf4j.Logger; 23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory; 24 import org.slf4j.LoggerFactory;
...@@ -40,8 +40,7 @@ import java.io.InputStream; ...@@ -40,8 +40,7 @@ import java.io.InputStream;
40 @Path("ports") 40 @Path("ports")
41 public class OpenstackPortWebResource extends AbstractWebResource { 41 public class OpenstackPortWebResource extends AbstractWebResource {
42 42
43 - protected static final Logger log = LoggerFactory 43 + private final Logger log = LoggerFactory.getLogger(getClass());
44 - .getLogger(OpenstackPortWebResource.class);
45 44
46 private static final OpenstackPortCodec PORT_CODEC = new OpenstackPortCodec(); 45 private static final OpenstackPortCodec PORT_CODEC = new OpenstackPortCodec();
47 46
...@@ -70,11 +69,12 @@ public class OpenstackPortWebResource extends AbstractWebResource { ...@@ -70,11 +69,12 @@ public class OpenstackPortWebResource extends AbstractWebResource {
70 } 69 }
71 70
72 @Path("{portUUID}") 71 @Path("{portUUID}")
72 + @Produces(MediaType.APPLICATION_JSON)
73 @DELETE 73 @DELETE
74 public Response deletePorts(@PathParam("portUUID") String id) { 74 public Response deletePorts(@PathParam("portUUID") String id) {
75 OpenstackSwitchingService switchingService = 75 OpenstackSwitchingService switchingService =
76 getService(OpenstackSwitchingService.class); 76 getService(OpenstackSwitchingService.class);
77 - switchingService.deletePort(id); 77 + switchingService.removePort(id);
78 return Response.status(Response.Status.OK).build(); 78 return Response.status(Response.Status.OK).build();
79 } 79 }
80 80
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching.web; 16 +package org.onosproject.openstacknetworking.web;
17 17
18 import com.fasterxml.jackson.databind.JsonNode; 18 import com.fasterxml.jackson.databind.JsonNode;
19 import com.fasterxml.jackson.databind.node.ArrayNode; 19 import com.fasterxml.jackson.databind.node.ArrayNode;
...@@ -22,8 +22,8 @@ import com.google.common.collect.Maps; ...@@ -22,8 +22,8 @@ import com.google.common.collect.Maps;
22 import org.onlab.packet.Ip4Address; 22 import org.onlab.packet.Ip4Address;
23 import org.onosproject.codec.CodecContext; 23 import org.onosproject.codec.CodecContext;
24 import org.onosproject.codec.JsonCodec; 24 import org.onosproject.codec.JsonCodec;
25 -import org.onosproject.openstackrouting.OpenstackExternalGateway; 25 +import org.onosproject.openstacknetworking.OpenstackExternalGateway;
26 -import org.onosproject.openstackrouting.OpenstackRouter; 26 +import org.onosproject.openstacknetworking.OpenstackRouter;
27 import org.slf4j.Logger; 27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory; 28 import org.slf4j.LoggerFactory;
29 import static com.google.common.base.Preconditions.checkNotNull; 29 import static com.google.common.base.Preconditions.checkNotNull;
...@@ -33,8 +33,7 @@ import java.util.Map; ...@@ -33,8 +33,7 @@ import java.util.Map;
33 * Implementation of the OpenstackRouter Codec. 33 * Implementation of the OpenstackRouter Codec.
34 */ 34 */
35 public class OpenstackRouterCodec extends JsonCodec<OpenstackRouter> { 35 public class OpenstackRouterCodec extends JsonCodec<OpenstackRouter> {
36 - protected static final Logger log = LoggerFactory 36 + private final Logger log = LoggerFactory.getLogger(getClass());
37 - .getLogger(OpenstackNetworkCodec.class);
38 37
39 private static final String ROUTER = "router"; 38 private static final String ROUTER = "router";
40 private static final String TENANT_ID = "tenant_id"; 39 private static final String TENANT_ID = "tenant_id";
...@@ -72,7 +71,7 @@ public class OpenstackRouterCodec extends JsonCodec<OpenstackRouter> { ...@@ -72,7 +71,7 @@ public class OpenstackRouterCodec extends JsonCodec<OpenstackRouter> {
72 String status = checkNotNull(routerInfo.path(STATUS).asText()); 71 String status = checkNotNull(routerInfo.path(STATUS).asText());
73 String adminStateUp = checkNotNull(routerInfo.path(ADMIN_STATE_UP).asText()); 72 String adminStateUp = checkNotNull(routerInfo.path(ADMIN_STATE_UP).asText());
74 73
75 - OpenstackExternalGateway.Builder osExtBuiler = OpenstackExternalGateway.builder(); 74 + OpenstackExternalGateway.Builder osExtBuiler = new OpenstackExternalGateway.Builder();
76 75
77 if (!routerInfo.path(EXTERNAL_GW_INFO).isMissingNode()) { 76 if (!routerInfo.path(EXTERNAL_GW_INFO).isMissingNode()) {
78 String externalGatewayNetId = checkNotNull(routerInfo.path(EXTERNAL_GW_INFO).path(NETWORK_ID).asText()); 77 String externalGatewayNetId = checkNotNull(routerInfo.path(EXTERNAL_GW_INFO).path(NETWORK_ID).asText());
......
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
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 -package org.onosproject.openstackswitching.web; 16 +package org.onosproject.openstacknetworking.web;
17 17
18 import com.fasterxml.jackson.databind.JsonNode; 18 import com.fasterxml.jackson.databind.JsonNode;
19 import com.fasterxml.jackson.databind.node.ObjectNode; 19 import com.fasterxml.jackson.databind.node.ObjectNode;
20 import org.onosproject.codec.CodecContext; 20 import org.onosproject.codec.CodecContext;
21 import org.onosproject.codec.JsonCodec; 21 import org.onosproject.codec.JsonCodec;
22 -import org.onosproject.openstackrouting.OpenstackRouterInterface; 22 +import org.onosproject.openstacknetworking.OpenstackRouterInterface;
23 import org.slf4j.Logger; 23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory; 24 import org.slf4j.LoggerFactory;
25 import static com.google.common.base.Preconditions.checkNotNull; 25 import static com.google.common.base.Preconditions.checkNotNull;
...@@ -27,8 +27,7 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -27,8 +27,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
27 * Implementation of the OpenstackRouterInterface Codec. 27 * Implementation of the OpenstackRouterInterface Codec.
28 */ 28 */
29 public class OpenstackRouterInterfaceCodec extends JsonCodec<OpenstackRouterInterface> { 29 public class OpenstackRouterInterfaceCodec extends JsonCodec<OpenstackRouterInterface> {
30 - protected static final Logger log = LoggerFactory 30 + private final Logger log = LoggerFactory.getLogger(getClass());
31 - .getLogger(OpenstackNetworkCodec.class);
32 31
33 private static final String ID = "id"; 32 private static final String ID = "id";
34 private static final String TENANT_ID = "tenant_id"; 33 private static final String TENANT_ID = "tenant_id";
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching.web; 16 +package org.onosproject.openstacknetworking.web;
17 17
18 import com.fasterxml.jackson.databind.JsonNode; 18 import com.fasterxml.jackson.databind.JsonNode;
19 import com.fasterxml.jackson.databind.node.ArrayNode; 19 import com.fasterxml.jackson.databind.node.ArrayNode;
...@@ -21,8 +21,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode; ...@@ -21,8 +21,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
21 import com.google.common.collect.Lists; 21 import com.google.common.collect.Lists;
22 import org.onosproject.codec.CodecContext; 22 import org.onosproject.codec.CodecContext;
23 import org.onosproject.codec.JsonCodec; 23 import org.onosproject.codec.JsonCodec;
24 -import org.onosproject.openstackswitching.impl.OpenstackSecurityGroup; 24 +import org.onosproject.openstacknetworking.OpenstackSecurityGroup;
25 -import org.onosproject.openstackswitching.impl.OpenstackSecurityGroupRule; 25 +import org.onosproject.openstacknetworking.OpenstackSecurityGroupRule;
26 import org.slf4j.Logger; 26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory; 27 import org.slf4j.LoggerFactory;
28 28
...@@ -33,8 +33,7 @@ import java.util.Collection; ...@@ -33,8 +33,7 @@ import java.util.Collection;
33 */ 33 */
34 public class OpenstackSecurityGroupCodec extends JsonCodec<OpenstackSecurityGroup> { 34 public class OpenstackSecurityGroupCodec extends JsonCodec<OpenstackSecurityGroup> {
35 35
36 - private static Logger log = LoggerFactory 36 + private final Logger log = LoggerFactory.getLogger(getClass());
37 - .getLogger(OpenstackSecurityGroupCodec.class);
38 37
39 private static final String SECURITY_GROUP = "security_group"; 38 private static final String SECURITY_GROUP = "security_group";
40 private static final String DESCRIPTION = "description"; 39 private static final String DESCRIPTION = "description";
...@@ -66,7 +65,7 @@ public class OpenstackSecurityGroupCodec extends JsonCodec<OpenstackSecurityGrou ...@@ -66,7 +65,7 @@ public class OpenstackSecurityGroupCodec extends JsonCodec<OpenstackSecurityGrou
66 Collection<OpenstackSecurityGroupRule> rules = Lists.newArrayList(); 65 Collection<OpenstackSecurityGroupRule> rules = Lists.newArrayList();
67 for (JsonNode ruleInfo: ruleInfoList) { 66 for (JsonNode ruleInfo: ruleInfoList) {
68 OpenstackSecurityGroupRule openstackSecurityGroupRule = 67 OpenstackSecurityGroupRule openstackSecurityGroupRule =
69 - OpenstackSecurityGroupRule.builder() 68 + new OpenstackSecurityGroupRule.Builder()
70 .direction(ruleInfo.path(DIRECTION).asText()) 69 .direction(ruleInfo.path(DIRECTION).asText())
71 .etherType(ruleInfo.path(EHTERTYPE).asText()) 70 .etherType(ruleInfo.path(EHTERTYPE).asText())
72 .id(ruleInfo.path(ID).asText()) 71 .id(ruleInfo.path(ID).asText())
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching.web; 16 +package org.onosproject.openstacknetworking.web;
17 17
18 import com.fasterxml.jackson.databind.JsonNode; 18 import com.fasterxml.jackson.databind.JsonNode;
19 19
...@@ -24,18 +24,19 @@ import com.google.common.collect.Lists; ...@@ -24,18 +24,19 @@ import com.google.common.collect.Lists;
24 import org.onlab.packet.Ip4Address; 24 import org.onlab.packet.Ip4Address;
25 import org.onosproject.codec.CodecContext; 25 import org.onosproject.codec.CodecContext;
26 import org.onosproject.codec.JsonCodec; 26 import org.onosproject.codec.JsonCodec;
27 -import org.onosproject.openstackswitching.OpenstackSubnet; 27 +import org.onosproject.openstacknetworking.OpenstackSubnet;
28 import org.slf4j.Logger; 28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory; 29 import org.slf4j.LoggerFactory;
30 30
31 import java.util.List; 31 import java.util.List;
32 32
33 +import static com.google.common.base.Preconditions.checkNotNull;
34 +
33 /** 35 /**
34 * Encodes and decodes the OpenstackSubnet. 36 * Encodes and decodes the OpenstackSubnet.
35 */ 37 */
36 public class OpenstackSubnetCodec extends JsonCodec<OpenstackSubnet> { 38 public class OpenstackSubnetCodec extends JsonCodec<OpenstackSubnet> {
37 - private static Logger log = LoggerFactory 39 + private final Logger log = LoggerFactory.getLogger(getClass());
38 - .getLogger(OpenstackSubnetCodec.class);
39 40
40 // JSON Field names 41 // JSON Field names
41 private static final String SUBNET = "subnet"; 42 private static final String SUBNET = "subnet";
...@@ -50,6 +51,7 @@ public class OpenstackSubnetCodec extends JsonCodec<OpenstackSubnet> { ...@@ -50,6 +51,7 @@ public class OpenstackSubnetCodec extends JsonCodec<OpenstackSubnet> {
50 51
51 @Override 52 @Override
52 public OpenstackSubnet decode(ObjectNode json, CodecContext context) { 53 public OpenstackSubnet decode(ObjectNode json, CodecContext context) {
54 + checkNotNull(json);
53 JsonNode subnetInfo = json.get(SUBNET); 55 JsonNode subnetInfo = json.get(SUBNET);
54 if (subnetInfo == null) { 56 if (subnetInfo == null) {
55 subnetInfo = json; 57 subnetInfo = json;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
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 -package org.onosproject.openstackswitching.web; 16 +package org.onosproject.openstacknetworking.web;
17 17
18 /** 18 /**
19 * Handles Rest API call from Neutron ML2 plugin. 19 * Handles Rest API call from Neutron ML2 plugin.
...@@ -47,21 +47,18 @@ public class OpenstackSubnetWebResource extends AbstractWebResource { ...@@ -47,21 +47,18 @@ public class OpenstackSubnetWebResource extends AbstractWebResource {
47 47
48 48
49 @PUT 49 @PUT
50 - @Path("{subnetUUID}") 50 + @Path("{subnetId}")
51 @Produces(MediaType.APPLICATION_JSON) 51 @Produces(MediaType.APPLICATION_JSON)
52 @Consumes(MediaType.APPLICATION_JSON) 52 @Consumes(MediaType.APPLICATION_JSON)
53 - public Response updateSubnet(@PathParam("id") String id, 53 + public Response updateSubnet(@PathParam("subnetId") String id,
54 final InputStream input) { 54 final InputStream input) {
55 return Response.status(Response.Status.OK).build(); 55 return Response.status(Response.Status.OK).build();
56 -
57 } 56 }
58 57
59 @DELETE 58 @DELETE
60 - @Path("{subnetUUID}") 59 + @Path("{subnetId}")
61 @Produces(MediaType.APPLICATION_JSON) 60 @Produces(MediaType.APPLICATION_JSON)
62 - @Consumes(MediaType.APPLICATION_JSON) 61 + public Response deleteSubnet(@PathParam("subnetId") String id) {
63 - public Response deleteSubnet(@PathParam("id") String id,
64 - final InputStream input) {
65 return Response.status(Response.Status.OK).build(); 62 return Response.status(Response.Status.OK).build();
66 } 63 }
67 64
......
...@@ -15,6 +15,6 @@ ...@@ -15,6 +15,6 @@
15 */ 15 */
16 16
17 /** 17 /**
18 - * OpenStack switch API. 18 + * OpenStack networking implementation.
19 */ 19 */
20 -package org.onosproject.openstackswitching; 20 +package org.onosproject.openstacknetworking.web;
......
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
30 <init-param> 30 <init-param>
31 <param-name>com.sun.jersey.config.property.classnames</param-name> 31 <param-name>com.sun.jersey.config.property.classnames</param-name>
32 <param-value> 32 <param-value>
33 - org.onosproject.openstackswitching.web.OpenstackPortWebResource, 33 + org.onosproject.openstacknetworking.web.OpenstackPortWebResource,
34 - org.onosproject.openstackswitching.web.OpenstackNetworkWebResource, 34 + org.onosproject.openstacknetworking.web.OpenstackNetworkWebResource,
35 - org.onosproject.openstackswitching.web.OpenstackSubnetWebResource, 35 + org.onosproject.openstacknetworking.web.OpenstackSubnetWebResource,
36 - org.onosproject.openstackswitching.web.OpensatckRouterWebResource 36 + org.onosproject.openstacknetworking.web.OpensatckRouterWebResource
37 </param-value> 37 </param-value>
38 </init-param> 38 </init-param>
39 <load-on-startup>1</load-on-startup> 39 <load-on-startup>1</load-on-startup>
......
...@@ -59,16 +59,15 @@ ...@@ -59,16 +59,15 @@
59 <module>igmp</module> 59 <module>igmp</module>
60 <module>pim</module> 60 <module>pim</module>
61 <module>mlb</module> 61 <module>mlb</module>
62 - <module>openstackswitching</module>
63 <module>pathpainter</module> 62 <module>pathpainter</module>
64 <module>drivermatrix</module> 63 <module>drivermatrix</module>
65 <module>cpman</module> 64 <module>cpman</module>
66 <module>events</module> 65 <module>events</module>
67 <module>vrouter</module> 66 <module>vrouter</module>
68 - <module>openstackrouting</module>
69 <module>cordmcast</module> 67 <module>cordmcast</module>
70 <module>vpls</module> 68 <module>vpls</module>
71 <module>openstacknode</module> 69 <module>openstacknode</module>
70 + <module>openstacknetworking</module>
72 </modules> 71 </modules>
73 72
74 <properties> 73 <properties>
......