Kyuhwi Choi
Committed by Ray Milkey

[ONOS-3689] Implement skeleton of Neutron L3 service plugin

  - Added event handlers (Floatingip_CUD(Create, Update, Delete), Router_CUD, and RouterInterface_CUD).
  - Added packet handlers about ICMP and pNAT.
  - Added the models of openstack router, router interface, external gateway and floatingIP.
  - Fixed pom.xml
  - Added external_fixed_IP information for PNAT and renamed SNAT to PNAT in OpenstackExternalGateway
  - Fixed java docs in OpenstackRoutingService.java

Change-Id: Ia694614cf8885d81a66fc4659db2fa0c5de5e950
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-openstackrouting</artifactId>
30 + <packaging>bundle</packaging>
31 +
32 + <description>SONA Openstack Routing Application</description>
33 +
34 + <properties>
35 + <onos.app.name>org.onosproject.openstackrouting</onos.app.name>
36 + <onos.app.category>default</onos.app.category>
37 + <onos.app.url>http://onosproject.org</onos.app.url>
38 + <onos.app.readme>SONA Openstack Routing Application</onos.app.readme>
39 + </properties>
40 +
41 + <dependencies>
42 + <dependency>
43 + <groupId>org.osgi</groupId>
44 + <artifactId>org.osgi.compendium</artifactId>
45 + </dependency>
46 + <dependency>
47 + <groupId>org.onosproject</groupId>
48 + <artifactId>onos-api</artifactId>
49 + </dependency>
50 + <dependency>
51 + <groupId>org.onosproject</groupId>
52 + <artifactId>onos-core-serializers</artifactId>
53 + <version>${project.version}</version>
54 + </dependency>
55 + <dependency>
56 + <groupId>org.onosproject</groupId>
57 + <artifactId>onos-ovsdb-api</artifactId>
58 + <version>${project.version}</version>
59 + </dependency>
60 + </dependencies>
61 +</project>
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.openstackrouting;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +
20 +import java.util.HashMap;
21 +
22 +/**
23 + * A configurable external gateway modes extension model in openstack router.
24 + */
25 +public final class OpenstackExternalGateway {
26 +
27 + private String networkId;
28 + private boolean enablePNAT;
29 + private HashMap<String, Ip4Address> externalFixedIps;
30 +
31 + private OpenstackExternalGateway(String networkId, boolean enablePNAT,
32 + HashMap externalFixedIps) {
33 + this.networkId = networkId;
34 + this.enablePNAT = enablePNAT;
35 + this.externalFixedIps = externalFixedIps;
36 + }
37 +
38 + /**
39 + * Returns network ID.
40 + *
41 + * @return Network ID
42 + */
43 + public String networkId() {
44 + return networkId;
45 + }
46 +
47 + /**
48 + * Returns the PNAT status for external gateway.
49 + *
50 + * @return PNAT status
51 + */
52 + public boolean isEnablePNAT() {
53 + return enablePNAT;
54 + }
55 +
56 + /**
57 + * An Openstack External Gateway Builder class.
58 + */
59 + public static final class Builder {
60 + private String networkId;
61 + private boolean enablePNAT;
62 + private HashMap<String, Ip4Address> externalFixedIPs;
63 +
64 + Builder() {
65 + externalFixedIPs = new HashMap<>();
66 + }
67 +
68 + /**
69 + * Sets network ID.
70 + *
71 + * @param networkId Network ID
72 + * @return Builder object
73 + */
74 + public Builder networkId(String networkId) {
75 + this.networkId = networkId;
76 + return this;
77 + }
78 +
79 + /**
80 + * Sets whether PNAT status is enabled or not.
81 + *
82 + * @param enablePNAT true if PNAT status is enabled, false otherwise
83 + * @return Builder object
84 + */
85 + public Builder enablePNAT(boolean enablePNAT) {
86 + this.enablePNAT = enablePNAT;
87 + return this;
88 + }
89 +
90 + /**
91 + * Sets external fixed IP address information.
92 + *
93 + * @param externalFixedIPs External fixed IP information
94 + * @return Builder object
95 + */
96 + public Builder externalFixedIPs(HashMap<String, Ip4Address> externalFixedIPs) {
97 + this.externalFixedIPs.putAll(externalFixedIPs);
98 + return this;
99 + }
100 +
101 + /**
102 + * Builds an OpenstackExternalGateway object.
103 + *
104 + * @return OpenstackExternalGateway object
105 + */
106 + public OpenstackExternalGateway build() {
107 + return new OpenstackExternalGateway(networkId, enablePNAT, externalFixedIPs);
108 + }
109 + }
110 +
111 +}
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.openstackrouting;
17 +
18 +import org.onlab.packet.Ip4Address;
19 +
20 +/**
21 + * An Openstack Neutron Floating IP Model.
22 + */
23 +public final class OpenstackFloatingIP {
24 +
25 + public enum FloatingIPStatus {
26 + UP,
27 + DOWN,
28 + ACTIVE,
29 + }
30 +
31 + private String tenantId;
32 + private String networkId;
33 + private Ip4Address fixedIpAddress;
34 + private String portId;
35 + private String routerId;
36 + private String id;
37 + private Ip4Address floatingIpAddress;
38 + private FloatingIPStatus status;
39 +
40 + private OpenstackFloatingIP(FloatingIPStatus status, String id, String tenantId,
41 + String networkId, Ip4Address fixedIpAddress, String portId,
42 + String routerId, Ip4Address floatingIpAddress) {
43 + this.status = status;
44 + this.id = id;
45 + this.tenantId = tenantId;
46 + this.networkId = networkId;
47 + this.fixedIpAddress = fixedIpAddress;
48 + this.portId = portId;
49 + this.routerId = routerId;
50 + this.floatingIpAddress = floatingIpAddress;
51 + }
52 +
53 + /**
54 + * Returns floating ip status.
55 + *
56 + * @return floating ip status
57 + */
58 + public FloatingIPStatus status() {
59 + return status;
60 + }
61 +
62 + /**
63 + * Returns floating ip`s ID.
64 + *
65 + * @return floating ip`s ID
66 + */
67 + public String id() {
68 + return id;
69 + }
70 +
71 + /**
72 + * Returns tenant ID.
73 + *
74 + * @return tenant ID
75 + */
76 + public String tenantId() {
77 + return tenantId;
78 + }
79 +
80 + /**
81 + * Returns network ID.
82 + *
83 + * @return network ID
84 + */
85 + public String networkId() {
86 + return networkId;
87 + }
88 +
89 + /**
90 + * Returns fixed IP Address.
91 + *
92 + * @return fixed IP Address
93 + */
94 + public Ip4Address fixedIpAddress() {
95 + return fixedIpAddress;
96 + }
97 +
98 + /**
99 + * Returns port ID.
100 + *
101 + * @return port ID
102 + */
103 + public String portId() {
104 + return portId;
105 + }
106 +
107 + /**
108 + * Returns router ID.
109 + *
110 + * @return router ID
111 + */
112 + public String routerId() {
113 + return routerId;
114 + }
115 +
116 + /**
117 + * Returns floating IP address.
118 + *
119 + * @return Floating IP address
120 + */
121 + public Ip4Address floatingIpAddress() {
122 + return floatingIpAddress;
123 + }
124 +
125 + /**
126 + * An Openstack Floating IP Builder class.
127 + */
128 + public static final class Builder {
129 + private String tenantId;
130 + private String networkId;
131 + private Ip4Address fixedIpAddress;
132 + private String portId;
133 + private String routerId;
134 + private String id;
135 + private Ip4Address floatingIpAddress;
136 + private FloatingIPStatus status;
137 +
138 + /**
139 + * Sets tenant ID.
140 + *
141 + * @param tenantId tenant ID
142 + * @return Builder object
143 + */
144 + public Builder tenantId(String tenantId) {
145 + this.tenantId = tenantId;
146 + return this;
147 + }
148 +
149 + /**
150 + * Sets floating IP status.
151 + *
152 + * @param status Floating IP status
153 + * @return Builder object
154 + */
155 + public Builder status(FloatingIPStatus status) {
156 + this.status = status;
157 + return this;
158 + }
159 +
160 + /**
161 + * Sets Floating IP`s ID.
162 + *
163 + * @param id Floating IP`s ID
164 + * @return Builder object
165 + */
166 + public Builder id(String id) {
167 + this.id = id;
168 + return this;
169 + }
170 +
171 + /**
172 + * Sets network ID.
173 + *
174 + * @param networkId Network ID
175 + * @return Builder object
176 + */
177 + public Builder networkId(String networkId) {
178 + this.networkId = networkId;
179 + return this;
180 + }
181 +
182 + /**
183 + * Sets fixed IP address.
184 + *
185 + * @param fixedIpAddress Fixed IP address
186 + * @return Builder object
187 + */
188 + public Builder fixedIpAddress(Ip4Address fixedIpAddress) {
189 + this.fixedIpAddress = fixedIpAddress;
190 + return this;
191 + }
192 +
193 + /**
194 + * Sets port ID.
195 + *
196 + * @param portId port ID
197 + * @return Builder object
198 + */
199 + public Builder portId(String portId) {
200 + this.portId = portId;
201 + return this;
202 + }
203 +
204 + /**
205 + * Sets router ID.
206 + *
207 + * @param routerId router ID
208 + * @return Builder object
209 + */
210 + public Builder routerId(String routerId) {
211 + this.routerId = routerId;
212 + return this;
213 + }
214 +
215 + /**
216 + * Sets floating IP address.
217 + *
218 + * @param floatingIpAddress Floating IP address
219 + * @return Builder object
220 + */
221 + public Builder floatingIpAddress(Ip4Address floatingIpAddress) {
222 + this.floatingIpAddress = floatingIpAddress;
223 + return this;
224 + }
225 +
226 + /**
227 + * Builds an OpenstackFloatingIP object.
228 + *
229 + * @return OpenstackFloatingIP object
230 + */
231 + public OpenstackFloatingIP build() {
232 + return new OpenstackFloatingIP(status, id, tenantId, networkId,
233 + fixedIpAddress, portId, routerId, floatingIpAddress);
234 +
235 + }
236 + }
237 +}
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.openstackrouting;
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.openstackrouting;
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 + OpenstackICMPHandler(PacketContext context) {
27 + this.context = context;
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.openstackrouting;
17 +
18 +import org.onosproject.net.packet.PacketContext;
19 +
20 +/**
21 + * Handle NAT packet processing for Managing Flow Rules In Openstack Nodes.
22 + */
23 +public class OpenstackPNATHandler implements Runnable {
24 +
25 + volatile PacketContext context;
26 + OpenstackPNATHandler(PacketContext context) {
27 + this.context = context;
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.openstackrouting;
17 +
18 +/**
19 + * An Openstack Neutron Router Model.
20 + */
21 +public final class OpenstackRouter {
22 +
23 + public enum RouterStatus {
24 + UP,
25 + DOWN,
26 + ACTIVE,
27 + }
28 +
29 + private String tenantId;
30 + private String id;
31 + private String name;
32 + private RouterStatus status;
33 + private boolean adminStateUp;
34 + private OpenstackExternalGateway gatewayExternalInfo;
35 +
36 + private OpenstackRouter(String id, String tenantId, String name, RouterStatus status,
37 + boolean adminStateUp, OpenstackExternalGateway gatewayExternalInfo) {
38 + this.id = id;
39 + this.tenantId = tenantId;
40 + this.name = name;
41 + this.status = status;
42 + this.adminStateUp = adminStateUp;
43 + this.gatewayExternalInfo = gatewayExternalInfo;
44 +
45 + }
46 +
47 + /**
48 + * Returns tenant ID.
49 + *
50 + * @return tenant ID
51 + */
52 + public String tenantId() {
53 + return tenantId;
54 + }
55 +
56 + /**
57 + * Returns router ID.
58 + *
59 + * @return router ID
60 + */
61 + public String id() {
62 + return id;
63 + }
64 +
65 + /**
66 + * Returns router name.
67 + *
68 + * @return router name
69 + */
70 + public String name() {
71 + return name;
72 + }
73 +
74 + /**
75 + * Returns router status.
76 + *
77 + * @return router stauts
78 + */
79 + public RouterStatus status() {
80 + return status;
81 + }
82 +
83 + /**
84 + * Returns whether admin state up or not.
85 + *
86 + * @return true if admin state up, false otherwise
87 + */
88 + public boolean adminStateUp() {
89 + return adminStateUp;
90 + }
91 +
92 + /**
93 + * Returns external gateway information.
94 + *
95 + * @return external gateway information
96 + */
97 + public OpenstackExternalGateway gatewayExternalInfo() {
98 + return gatewayExternalInfo;
99 + }
100 +
101 + /**
102 + * An Openstack Router Builder class.
103 + */
104 + public static final class Builder {
105 +
106 + private String tenantId;
107 + private String id;
108 + private String name;
109 + private RouterStatus status;
110 + private Boolean adminStateUp;
111 + private OpenstackExternalGateway gatewayExternalInfo;
112 +
113 + /**
114 + * Sets router ID.
115 + *
116 + * @param id router ID
117 + * @return Builder object
118 + */
119 + public Builder id(String id) {
120 + this.id = id;
121 + return this;
122 + }
123 +
124 + /**
125 + * Sets router name.
126 + *
127 + * @param name router name
128 + * @return Builder object
129 + */
130 + public Builder name(String name) {
131 + this.name = name;
132 + return this;
133 + }
134 +
135 + /**
136 + * Sets router status.
137 + *
138 + * @param status router status
139 + * @return Builder object
140 + */
141 + public Builder status(RouterStatus status) {
142 + this.status = status;
143 + return this;
144 + }
145 +
146 + /**
147 + * Sets tenant ID.
148 + *
149 + * @param tenantId Tenant ID
150 + * @return Builder object
151 + */
152 + public Builder tenantId(String tenantId) {
153 + this.tenantId = tenantId;
154 + return this;
155 + }
156 +
157 + /**
158 + * Sets whether admin state up or not.
159 + *
160 + * @param adminStateUp true if admin state is up, false otherwise
161 + * @return Builder object
162 + */
163 + public Builder adminStateUp(boolean adminStateUp) {
164 + this.adminStateUp = adminStateUp;
165 + return this;
166 + }
167 +
168 + /**
169 + * Sets external gateway information.
170 + *
171 + * @param gatewayExternalInfo external gateway information
172 + * @return Builder object
173 + */
174 + public Builder gatewayExternalInfo(OpenstackExternalGateway gatewayExternalInfo) {
175 + this.gatewayExternalInfo = gatewayExternalInfo;
176 + return this;
177 + }
178 +
179 + /**
180 + * Builds an OpenstackRouter object.
181 + *
182 + * @return OpenstasckRouter object
183 + */
184 + public OpenstackRouter build() {
185 + return new OpenstackRouter(id, tenantId, name, status,
186 + adminStateUp, gatewayExternalInfo);
187 + }
188 + }
189 +
190 +
191 +}
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.openstackrouting;
17 +
18 +/**
19 + * An Openstack Neutron Router Interface Model.
20 + */
21 +public final class OpenstackRouterInterface {
22 + private String id;
23 + private String tenantId;
24 + private String subnetId;
25 + private String portId;
26 +
27 + private OpenstackRouterInterface(String id, String tenantId,
28 + String subnetId, String portId) {
29 + this.id = id;
30 + this.tenantId = tenantId;
31 + this.subnetId = subnetId;
32 + this.portId = portId;
33 + }
34 +
35 + /**
36 + * Returns Router Interface ID.
37 + *
38 + * @return router interface ID
39 + */
40 + public String id() {
41 + return id;
42 + }
43 +
44 + /**
45 + * Returns tenant ID.
46 + *
47 + * @return tenant ID
48 + */
49 + public String tenantId() {
50 + return tenantId;
51 + }
52 +
53 + /**
54 + * Returns subnet ID.
55 + *
56 + * @return subnet ID
57 + */
58 + public String subnetId() {
59 + return subnetId;
60 + }
61 +
62 + /**
63 + * Returns port ID.
64 + *
65 + * @return port ID
66 + */
67 + public String portId() {
68 + return portId;
69 + }
70 +
71 + /**
72 + * An Openstack Router Interface Builder class.
73 + */
74 + public static final class Builder {
75 + private String id;
76 + private String tenantId;
77 + private String subnetId;
78 + private String portId;
79 +
80 + /**
81 + * Sets Router Interface ID.
82 + *
83 + * @param id router interface ID
84 + * @return Builder object
85 + */
86 + public Builder id(String id) {
87 + this.id = id;
88 + return this;
89 + }
90 +
91 + /**
92 + * Sets tenant ID.
93 + *
94 + * @param tenantId tenant ID
95 + * @return Builder object
96 + */
97 + public Builder tenantId(String tenantId) {
98 + this.tenantId = tenantId;
99 + return this;
100 + }
101 +
102 + /**
103 + * Sets subnet ID.
104 + *
105 + * @param subnetId subnet ID
106 + * @return Builder object
107 + */
108 + public Builder subnetId(String subnetId) {
109 + this.subnetId = subnetId;
110 + return this;
111 + }
112 +
113 + /**
114 + * Sets port ID.
115 + *
116 + * @param portId port ID
117 + * @return Builder object
118 + */
119 + public Builder portId(String portId) {
120 + this.portId = portId;
121 + return this;
122 + }
123 +
124 +
125 + /**
126 + * Builds an Openstack Router Interface object.
127 + *
128 + * @return OpenstackRouterInterface object
129 + */
130 + public OpenstackRouterInterface build() {
131 + return new OpenstackRouterInterface(id, tenantId, subnetId, portId);
132 + }
133 +
134 + }
135 +}
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.openstackrouting;
17 +
18 +import org.apache.felix.scr.annotations.Activate;
19 +import org.apache.felix.scr.annotations.Component;
20 +import org.apache.felix.scr.annotations.Deactivate;
21 +import org.apache.felix.scr.annotations.Reference;
22 +import org.apache.felix.scr.annotations.ReferenceCardinality;
23 +import org.apache.felix.scr.annotations.Service;
24 +import org.onlab.packet.Ethernet;
25 +import org.onlab.packet.IPv4;
26 +import org.onosproject.core.ApplicationId;
27 +import org.onosproject.core.CoreService;
28 +import org.onosproject.net.driver.DriverService;
29 +import org.onosproject.net.packet.InboundPacket;
30 +import org.onosproject.net.packet.PacketContext;
31 +import org.onosproject.net.packet.PacketProcessor;
32 +import org.onosproject.net.packet.PacketService;
33 +import org.slf4j.Logger;
34 +import org.slf4j.LoggerFactory;
35 +
36 +import java.util.concurrent.ExecutorService;
37 +import java.util.concurrent.Executors;
38 +
39 +import static org.onlab.util.Tools.groupedThreads;
40 +
41 +@Service
42 +@Component(immediate = true)
43 +/**
44 + * Populates flow rules about L3 functionality for VMs in Openstack.
45 + */
46 +public class OpenstackRoutingManager implements OpenstackRoutingService {
47 + private static Logger log = LoggerFactory
48 + .getLogger(OpenstackRoutingManager.class);
49 +
50 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
51 + protected CoreService coreService;
52 +
53 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
54 + protected PacketService packetService;
55 +
56 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
57 + protected DriverService driverService;
58 +
59 + private ApplicationId appId;
60 + private OpenstackICMPHandler icmpHandler;
61 + private OpenstackPNATHandler natHandler;
62 + private OpenstackFloatingIPHandler floatingIPHandler;
63 + private OpenstackRoutingRulePopulator openstackRoutingRulePopulator;
64 +
65 + private InternalPacketProcessor internalPacketProcessor = new InternalPacketProcessor();
66 + private ExecutorService l3EventExcutorService =
67 + Executors.newSingleThreadExecutor(groupedThreads("onos/openstackrouting", "L3-event"));
68 + private ExecutorService icmpEventExcutorService =
69 + Executors.newSingleThreadExecutor(groupedThreads("onos/openstackrouting", "icmp-event"));
70 +
71 + @Activate
72 + protected void activate() {
73 + appId = coreService.registerApplication("org.onosproject.openstackrouting");
74 + packetService.addProcessor(internalPacketProcessor, PacketProcessor.director(1));
75 +
76 + log.info("onos-openstackrouting started");
77 + }
78 +
79 + @Deactivate
80 + protected void deactivate() {
81 + packetService.removeProcessor(internalPacketProcessor);
82 + log.info("onos-openstackrouting stopped");
83 + }
84 +
85 +
86 + @Override
87 + public void createFloatingIP(OpenstackFloatingIP openstackFloatingIP) {
88 +
89 + }
90 +
91 + @Override
92 + public void updateFloatingIP(OpenstackFloatingIP openstackFloatingIP) {
93 +
94 + }
95 +
96 + @Override
97 + public void deleteFloatingIP(String id) {
98 +
99 + }
100 +
101 + @Override
102 + public void createRouter(OpenstackRouter openstackRouter) {
103 +
104 + }
105 +
106 + @Override
107 + public void updateRouter(OpenstackRouter openstackRouter) {
108 +
109 + }
110 +
111 + @Override
112 + public void deleteRouter(String id) {
113 +
114 + }
115 +
116 + @Override
117 + public void createRouterInterface(OpenstackRouterInterface openstackRouterInterface) {
118 +
119 + }
120 +
121 + @Override
122 + public void updateRouterInterface(OpenstackRouterInterface openstackRouterInterface) {
123 +
124 + }
125 +
126 + @Override
127 + public void deleteRouterInterface(String id) {
128 +
129 + }
130 +
131 + private class InternalPacketProcessor implements PacketProcessor {
132 +
133 + @Override
134 + public void process(PacketContext context) {
135 +
136 + if (context.isHandled()) {
137 + return;
138 + }
139 +
140 + InboundPacket pkt = context.inPacket();
141 + Ethernet ethernet = pkt.parsed();
142 +
143 + if (ethernet != null && ethernet.getEtherType() == Ethernet.TYPE_IPV4) {
144 + IPv4 iPacket = (IPv4) ethernet.getPayload();
145 + switch (iPacket.getProtocol()) {
146 + case IPv4.PROTOCOL_ICMP:
147 + icmpEventExcutorService.execute(new OpenstackICMPHandler(context));
148 + break;
149 + default:
150 + l3EventExcutorService.execute(new OpenstackPNATHandler(context));
151 + break;
152 + }
153 +
154 + }
155 +
156 +
157 + }
158 + }
159 +
160 +}
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.openstackrouting;
17 +
18 +/**
19 + * Populates Routing Flow Rules.
20 + */
21 +public class OpenstackRoutingRulePopulator {
22 +}
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.openstackrouting;
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 deleted 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 deleted by Openstack.
60 + *
61 + * @param id Deleted router`s ID
62 + */
63 + void deleteRouter(String id);
64 +
65 + /**
66 + * Stores the router information created by Openstack.
67 + *
68 + * @param openstackRouterInterface Floating IP information
69 + */
70 + void createRouterInterface(OpenstackRouterInterface openstackRouterInterface);
71 +
72 + /**
73 + * Updates flow rules corresponding to the router information updated by Openstack.
74 + *
75 + * @param openstackRouterInterface Router information
76 + */
77 + void updateRouterInterface(OpenstackRouterInterface openstackRouterInterface);
78 +
79 + /**
80 + * Removes flow rules corresponding to the router information deleted by Openstack.
81 + *
82 + * @param id Deleted router`s ID
83 + */
84 + void deleteRouterInterface(String id);
85 +
86 +
87 +}
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.openstackrouting;
...\ No newline at end of file ...\ No newline at end of file
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
65 <module>cpman</module> 65 <module>cpman</module>
66 <module>events</module> 66 <module>events</module>
67 <module>vrouter</module> 67 <module>vrouter</module>
68 + <module>openstackrouting</module>
68 </modules> 69 </modules>
69 70
70 <properties> 71 <properties>
......