Committed by
Gerrit Code Review
OpenstackRouting refactoring
- Replace OpenstackPortInfo with HostService - Replace OpenstackRoutingConfig with OpenstackNodeService (Remove OpenstackRoutingConfig) - Rebased with 10330 (existing_vm) - Added initialization process using OpenstackNodeListener Change-Id: If2ce8eb86d242a7180c9154e1a0f1668b266bf1c
Showing
17 changed files
with
58 additions
and
320 deletions
... | @@ -13,14 +13,15 @@ | ... | @@ -13,14 +13,15 @@ |
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.openstacknetworking.switching; | 16 | +package org.onosproject.openstacknetworking; |
17 | 17 | ||
18 | import org.onlab.packet.Ip4Address; | 18 | import org.onlab.packet.Ip4Address; |
19 | import org.onlab.packet.Ip4Prefix; | 19 | import org.onlab.packet.Ip4Prefix; |
20 | import org.onlab.packet.IpPrefix; | 20 | import org.onlab.packet.IpPrefix; |
21 | +import org.onlab.packet.MacAddress; | ||
21 | 22 | ||
22 | /** | 23 | /** |
23 | - * Provides constants used in OpenStack node services. | 24 | + * Provides constants used in OpenStackSwitching. |
24 | */ | 25 | */ |
25 | public final class Constants { | 26 | public final class Constants { |
26 | 27 | ||
... | @@ -33,9 +34,11 @@ public final class Constants { | ... | @@ -33,9 +34,11 @@ public final class Constants { |
33 | public static final String PORTNAME_PREFIX_ROUTER = "qr-"; | 34 | public static final String PORTNAME_PREFIX_ROUTER = "qr-"; |
34 | public static final String PORTNAME_PREFIX_TUNNEL = "vxlan"; | 35 | public static final String PORTNAME_PREFIX_TUNNEL = "vxlan"; |
35 | 36 | ||
36 | - // TODO remove this | 37 | + public static final MacAddress GATEWAY_MAC = MacAddress.valueOf("1f:1f:1f:1f:1f:1f"); |
37 | - public static final String ROUTER_INTERFACE = "network:router_interface"; | 38 | + |
38 | - public static final String DEVICE_OWNER_GATEWAY = "network:router_gateway"; | 39 | + // TODO: Please change these valuses following the way vrouter is implemented |
40 | + public static final MacAddress GW_EXT_INT_MAC = MacAddress.valueOf("56:e6:30:a6:8c:e5"); | ||
41 | + public static final MacAddress PHY_ROUTER_MAC = MacAddress.valueOf("00:00:00:00:01:01"); | ||
39 | 42 | ||
40 | public static final Ip4Address DNS_SERVER_IP = Ip4Address.valueOf("8.8.8.8"); | 43 | public static final Ip4Address DNS_SERVER_IP = Ip4Address.valueOf("8.8.8.8"); |
41 | public static final IpPrefix IP_PREFIX_ANY = Ip4Prefix.valueOf("0.0.0.0/0"); | 44 | public static final IpPrefix IP_PREFIX_ANY = Ip4Prefix.valueOf("0.0.0.0/0"); |
... | @@ -51,4 +54,5 @@ public final class Constants { | ... | @@ -51,4 +54,5 @@ public final class Constants { |
51 | public static final int SWITCHING_RULE_PRIORITY = 30000; | 54 | public static final int SWITCHING_RULE_PRIORITY = 30000; |
52 | public static final int TUNNELTAG_RULE_PRIORITY = 30000; | 55 | public static final int TUNNELTAG_RULE_PRIORITY = 30000; |
53 | public static final int ACL_RULE_PRIORITY = 30000; | 56 | public static final int ACL_RULE_PRIORITY = 30000; |
57 | + | ||
54 | } | 58 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | -/* | ||
2 | - * Copyright 2016-present 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 | -import org.onlab.packet.MacAddress; | ||
20 | -import org.onosproject.net.DeviceId; | ||
21 | - | ||
22 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
23 | - | ||
24 | -/** | ||
25 | - * Contains OpenstackPort Information. | ||
26 | - */ | ||
27 | -// TODO remove this | ||
28 | -public final class OpenstackPortInfo { | ||
29 | - private final Ip4Address hostIp; | ||
30 | - private final MacAddress hostMac; | ||
31 | - private final DeviceId deviceId; | ||
32 | - private final long vni; | ||
33 | - private final Ip4Address gatewayIP; | ||
34 | - private final String networkId; | ||
35 | - | ||
36 | - /** | ||
37 | - * Returns OpenstackPortInfo reference. | ||
38 | - * | ||
39 | - * @param hostIp host IP address | ||
40 | - * @param hostMac host MAC address | ||
41 | - * @param deviceId device ID | ||
42 | - * @param vni tunnel ID | ||
43 | - * @param gatewayIP gateway IP address | ||
44 | - * @param networkId network identifier | ||
45 | - */ | ||
46 | - public OpenstackPortInfo(Ip4Address hostIp, MacAddress hostMac, DeviceId deviceId, long vni, | ||
47 | - Ip4Address gatewayIP, String networkId) { | ||
48 | - this.hostIp = hostIp; | ||
49 | - this.hostMac = hostMac; | ||
50 | - this.deviceId = deviceId; | ||
51 | - this.vni = vni; | ||
52 | - this.gatewayIP = gatewayIP; | ||
53 | - this.networkId = networkId; | ||
54 | - } | ||
55 | - | ||
56 | - /** | ||
57 | - * Returns IP address of the port. | ||
58 | - * | ||
59 | - * @return IP address | ||
60 | - */ | ||
61 | - public Ip4Address ip() { | ||
62 | - return hostIp; | ||
63 | - } | ||
64 | - | ||
65 | - /** | ||
66 | - * Returns MAC address of the port. | ||
67 | - * | ||
68 | - * @return MAC address | ||
69 | - */ | ||
70 | - public MacAddress mac() { | ||
71 | - return hostMac; | ||
72 | - } | ||
73 | - | ||
74 | - /** | ||
75 | - * Returns device ID. | ||
76 | - * | ||
77 | - * @return device ID | ||
78 | - */ | ||
79 | - public DeviceId deviceId() { | ||
80 | - return deviceId; | ||
81 | - } | ||
82 | - | ||
83 | - /** | ||
84 | - * Returns tunnel ID. | ||
85 | - * | ||
86 | - * @return tunnel ID | ||
87 | - */ | ||
88 | - public long vni() { | ||
89 | - return vni; | ||
90 | - } | ||
91 | - | ||
92 | - /** | ||
93 | - * Returns gateway IP address. | ||
94 | - * | ||
95 | - * @return gateway IP address | ||
96 | - */ | ||
97 | - public Ip4Address gatewayIP() { | ||
98 | - return gatewayIP; | ||
99 | - } | ||
100 | - | ||
101 | - /** | ||
102 | - * Returns network ID. | ||
103 | - * | ||
104 | - * @return network ID | ||
105 | - */ | ||
106 | - public String networkId() { | ||
107 | - return networkId; | ||
108 | - } | ||
109 | - | ||
110 | - /** | ||
111 | - * Returns the builder of the OpenstackPortInfo. | ||
112 | - * | ||
113 | - * @return OpenstackPortInfo builder reference | ||
114 | - */ | ||
115 | - public static OpenstackPortInfo.Builder builder() { | ||
116 | - return new Builder(); | ||
117 | - } | ||
118 | - | ||
119 | - /** | ||
120 | - * Represents the OpenstackPortInfo Builder. | ||
121 | - * | ||
122 | - */ | ||
123 | - public static final class Builder { | ||
124 | - private Ip4Address hostIp; | ||
125 | - private MacAddress hostMac; | ||
126 | - private DeviceId deviceId; | ||
127 | - private long vni; | ||
128 | - private Ip4Address gatewayIP; | ||
129 | - private String networkId; | ||
130 | - | ||
131 | - /** | ||
132 | - * Sets the IP address of the port. | ||
133 | - * | ||
134 | - * @param gatewayIP gateway IP | ||
135 | - * @return Builder reference | ||
136 | - */ | ||
137 | - public Builder setGatewayIP(Ip4Address gatewayIP) { | ||
138 | - this.gatewayIP = checkNotNull(gatewayIP, "gatewayIP cannot be null"); | ||
139 | - return this; | ||
140 | - } | ||
141 | - | ||
142 | - /** | ||
143 | - * Sets the network ID. | ||
144 | - * | ||
145 | - * @param networkId network id | ||
146 | - * @return Builder reference | ||
147 | - */ | ||
148 | - public Builder setNetworkId(String networkId) { | ||
149 | - this.networkId = checkNotNull(networkId, "networkId cannot be null"); | ||
150 | - return this; | ||
151 | - } | ||
152 | - | ||
153 | - /** | ||
154 | - * Sets the host IP address of the port. | ||
155 | - * | ||
156 | - * @param hostIp host IP address | ||
157 | - * @return Builder reference | ||
158 | - */ | ||
159 | - public Builder setHostIp(Ip4Address hostIp) { | ||
160 | - this.hostIp = checkNotNull(hostIp, "hostIp cannot be null"); | ||
161 | - return this; | ||
162 | - } | ||
163 | - | ||
164 | - /** | ||
165 | - * Sets the host MAC address of the port. | ||
166 | - * | ||
167 | - * @param hostMac host MAC address | ||
168 | - * @return Builder reference | ||
169 | - */ | ||
170 | - public Builder setHostMac(MacAddress hostMac) { | ||
171 | - this.hostMac = checkNotNull(hostMac, "hostMac cannot be bull"); | ||
172 | - return this; | ||
173 | - } | ||
174 | - | ||
175 | - /** | ||
176 | - * Sets the device ID. | ||
177 | - * | ||
178 | - * @param deviceId device ID | ||
179 | - * @return Builder reference | ||
180 | - */ | ||
181 | - public Builder setDeviceId(DeviceId deviceId) { | ||
182 | - this.deviceId = checkNotNull(deviceId, "deviceId cannot be null"); | ||
183 | - return this; | ||
184 | - } | ||
185 | - | ||
186 | - /** | ||
187 | - * Sets the tunnel ID. | ||
188 | - * | ||
189 | - * @param vni tunnel ID | ||
190 | - * @return Builder reference | ||
191 | - */ | ||
192 | - public Builder setVni(long vni) { | ||
193 | - this.vni = checkNotNull(vni, "vni cannot be null"); | ||
194 | - return this; | ||
195 | - } | ||
196 | - | ||
197 | - /** | ||
198 | - * Builds the OpenstackPortInfo reference. | ||
199 | - * | ||
200 | - * @return OpenstackPortInfo reference | ||
201 | - */ | ||
202 | - public OpenstackPortInfo build() { | ||
203 | - return new OpenstackPortInfo(hostIp, hostMac, deviceId, vni, gatewayIP, networkId); | ||
204 | - } | ||
205 | - } | ||
206 | -} |
... | @@ -85,8 +85,8 @@ public interface OpenstackRoutingService { | ... | @@ -85,8 +85,8 @@ public interface OpenstackRoutingService { |
85 | * | 85 | * |
86 | * @param portId Deleted vm | 86 | * @param portId Deleted vm |
87 | * @param portInfo stored information about deleted vm | 87 | * @param portInfo stored information about deleted vm |
88 | - */ | ||
89 | void checkDisassociatedFloatingIp(String portId, OpenstackPortInfo portInfo); | 88 | void checkDisassociatedFloatingIp(String portId, OpenstackPortInfo portInfo); |
89 | + */ | ||
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Returns network id for routerInterface. | 92 | * Returns network id for routerInterface. | ... | ... |
1 | -/* | ||
2 | - * Copyright 2016-present 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 | -// TODO remove this | ||
24 | -public interface OpenstackSwitchingService { | ||
25 | - | ||
26 | - /** | ||
27 | - * Retruns OpenstackPortInfo map. | ||
28 | - * | ||
29 | - * @return OpenstackPortInfo map | ||
30 | - */ | ||
31 | - // TODO remove this | ||
32 | - Map<String, OpenstackPortInfo> openstackPortInfo(); | ||
33 | -} |
... | @@ -68,6 +68,11 @@ | ... | @@ -68,6 +68,11 @@ |
68 | <artifactId>onos-scalablegateway</artifactId> | 68 | <artifactId>onos-scalablegateway</artifactId> |
69 | <version>${project.version}</version> | 69 | <version>${project.version}</version> |
70 | </dependency> | 70 | </dependency> |
71 | + <dependency> | ||
72 | + <groupId>org.onosproject</groupId> | ||
73 | + <artifactId>onos-app-openstacknode</artifactId> | ||
74 | + <version>${project.version}</version> | ||
75 | + </dependency> | ||
71 | </dependencies> | 76 | </dependencies> |
72 | </project> | 77 | </project> |
73 | 78 | ... | ... |
... | @@ -15,34 +15,39 @@ | ... | @@ -15,34 +15,39 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.openstacknetworking.routing; | 16 | package org.onosproject.openstacknetworking.routing; |
17 | 17 | ||
18 | +import org.onosproject.net.Host; | ||
18 | import org.onosproject.openstackinterface.OpenstackFloatingIP; | 19 | import org.onosproject.openstackinterface.OpenstackFloatingIP; |
19 | -import org.onosproject.openstacknetworking.OpenstackPortInfo; | ||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * Handle FloatingIP Event for Managing Flow Rules In Openstack Nodes. | 22 | * Handle FloatingIP Event for Managing Flow Rules In Openstack Nodes. |
23 | */ | 23 | */ |
24 | public class OpenstackFloatingIPHandler implements Runnable { | 24 | public class OpenstackFloatingIPHandler implements Runnable { |
25 | 25 | ||
26 | + public enum Action { | ||
27 | + ASSOCIATE, | ||
28 | + DISSASSOCIATE | ||
29 | + } | ||
30 | + | ||
26 | private final OpenstackFloatingIP floatingIP; | 31 | private final OpenstackFloatingIP floatingIP; |
27 | private final OpenstackRoutingRulePopulator rulePopulator; | 32 | private final OpenstackRoutingRulePopulator rulePopulator; |
28 | - private boolean associate; | 33 | + private final Host host; |
29 | - private final OpenstackPortInfo portInfo; | 34 | + private final Action action; |
35 | + | ||
30 | 36 | ||
31 | OpenstackFloatingIPHandler(OpenstackRoutingRulePopulator rulePopulator, | 37 | OpenstackFloatingIPHandler(OpenstackRoutingRulePopulator rulePopulator, |
32 | - OpenstackFloatingIP openstackFloatingIP, boolean associate, OpenstackPortInfo portInfo) { | 38 | + OpenstackFloatingIP openstackFloatingIP, Action action, Host host) { |
33 | this.floatingIP = openstackFloatingIP; | 39 | this.floatingIP = openstackFloatingIP; |
34 | this.rulePopulator = rulePopulator; | 40 | this.rulePopulator = rulePopulator; |
35 | - this.associate = associate; | 41 | + this.action = action; |
36 | - this.portInfo = portInfo; | 42 | + this.host = host; |
37 | } | 43 | } |
38 | 44 | ||
39 | @Override | 45 | @Override |
40 | public void run() { | 46 | public void run() { |
41 | - if (associate) { | 47 | + if (action == Action.ASSOCIATE) { |
42 | rulePopulator.populateFloatingIpRules(floatingIP); | 48 | rulePopulator.populateFloatingIpRules(floatingIP); |
43 | } else { | 49 | } else { |
44 | - rulePopulator.removeFloatingIpRules(floatingIP, portInfo); | 50 | + rulePopulator.removeFloatingIpRules(floatingIP, host); |
45 | } | 51 | } |
46 | - | ||
47 | } | 52 | } |
48 | } | 53 | } | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -32,7 +32,6 @@ import org.onosproject.net.packet.PacketService; | ... | @@ -32,7 +32,6 @@ import org.onosproject.net.packet.PacketService; |
32 | import org.onosproject.openstackinterface.OpenstackInterfaceService; | 32 | import org.onosproject.openstackinterface.OpenstackInterfaceService; |
33 | import org.onosproject.openstackinterface.OpenstackPort; | 33 | import org.onosproject.openstackinterface.OpenstackPort; |
34 | import org.onosproject.openstackinterface.OpenstackRouter; | 34 | import org.onosproject.openstackinterface.OpenstackRouter; |
35 | -import org.onosproject.openstacknetworking.OpenstackNetworkingConfig; | ||
36 | import org.onosproject.scalablegateway.api.GatewayNode; | 35 | import org.onosproject.scalablegateway.api.GatewayNode; |
37 | import org.onosproject.scalablegateway.api.ScalableGatewayService; | 36 | import org.onosproject.scalablegateway.api.ScalableGatewayService; |
38 | import org.slf4j.Logger; | 37 | import org.slf4j.Logger; |
... | @@ -52,25 +51,21 @@ public class OpenstackPnatHandler implements Runnable { | ... | @@ -52,25 +51,21 @@ public class OpenstackPnatHandler implements Runnable { |
52 | volatile PacketContext context; | 51 | volatile PacketContext context; |
53 | private final Logger log = LoggerFactory.getLogger(getClass()); | 52 | private final Logger log = LoggerFactory.getLogger(getClass()); |
54 | 53 | ||
55 | - protected PacketService packetService; | ||
56 | - | ||
57 | private final OpenstackRoutingRulePopulator rulePopulator; | 54 | private final OpenstackRoutingRulePopulator rulePopulator; |
58 | private final int portNum; | 55 | private final int portNum; |
59 | private final OpenstackPort openstackPort; | 56 | private final OpenstackPort openstackPort; |
60 | private final Port port; | 57 | private final Port port; |
61 | - private OpenstackNetworkingConfig config; | ||
62 | 58 | ||
63 | private static final String DEVICE_OWNER_ROUTER_INTERFACE = "network:router_interface"; | 59 | private static final String DEVICE_OWNER_ROUTER_INTERFACE = "network:router_interface"; |
64 | private static final String EXTERNAL_PORT_NULL = "There is no external port in this deviceId []"; | 60 | private static final String EXTERNAL_PORT_NULL = "There is no external port in this deviceId []"; |
65 | 61 | ||
66 | OpenstackPnatHandler(OpenstackRoutingRulePopulator rulePopulator, PacketContext context, | 62 | OpenstackPnatHandler(OpenstackRoutingRulePopulator rulePopulator, PacketContext context, |
67 | - int portNum, OpenstackPort openstackPort, Port port, OpenstackNetworkingConfig config) { | 63 | + int portNum, OpenstackPort openstackPort, Port port) { |
68 | this.rulePopulator = checkNotNull(rulePopulator); | 64 | this.rulePopulator = checkNotNull(rulePopulator); |
69 | this.context = checkNotNull(context); | 65 | this.context = checkNotNull(context); |
70 | this.portNum = checkNotNull(portNum); | 66 | this.portNum = checkNotNull(portNum); |
71 | this.openstackPort = checkNotNull(openstackPort); | 67 | this.openstackPort = checkNotNull(openstackPort); |
72 | this.port = checkNotNull(port); | 68 | this.port = checkNotNull(port); |
73 | - this.config = checkNotNull(config); | ||
74 | } | 69 | } |
75 | 70 | ||
76 | @Override | 71 | @Override |
... | @@ -149,6 +144,7 @@ public class OpenstackPnatHandler implements Runnable { | ... | @@ -149,6 +144,7 @@ public class OpenstackPnatHandler implements Runnable { |
149 | iPacket.resetChecksum(); | 144 | iPacket.resetChecksum(); |
150 | iPacket.setParent(ethernet); | 145 | iPacket.setParent(ethernet); |
151 | ethernet.setPayload(iPacket); | 146 | ethernet.setPayload(iPacket); |
147 | + | ||
152 | ScalableGatewayService gatewayService = getService(ScalableGatewayService.class); | 148 | ScalableGatewayService gatewayService = getService(ScalableGatewayService.class); |
153 | GatewayNode gatewayNode = gatewayService.getGatewayNode(deviceId); | 149 | GatewayNode gatewayNode = gatewayService.getGatewayNode(deviceId); |
154 | if (gatewayNode.getGatewayExternalInterfaceNames().size() == 0) { | 150 | if (gatewayNode.getGatewayExternalInterfaceNames().size() == 0) { |
... | @@ -159,7 +155,6 @@ public class OpenstackPnatHandler implements Runnable { | ... | @@ -159,7 +155,6 @@ public class OpenstackPnatHandler implements Runnable { |
159 | 155 | ||
160 | ethernet.resetChecksum(); | 156 | ethernet.resetChecksum(); |
161 | 157 | ||
162 | - | ||
163 | packetService.emit(new DefaultOutboundPacket(deviceId, treatment.build(), | 158 | packetService.emit(new DefaultOutboundPacket(deviceId, treatment.build(), |
164 | ByteBuffer.wrap(ethernet.serialize()))); | 159 | ByteBuffer.wrap(ethernet.serialize()))); |
165 | } | 160 | } | ... | ... |
... | @@ -34,8 +34,9 @@ import org.onosproject.net.packet.PacketPriority; | ... | @@ -34,8 +34,9 @@ import org.onosproject.net.packet.PacketPriority; |
34 | import org.onosproject.net.packet.PacketService; | 34 | import org.onosproject.net.packet.PacketService; |
35 | import org.onosproject.openstackinterface.OpenstackInterfaceService; | 35 | import org.onosproject.openstackinterface.OpenstackInterfaceService; |
36 | import org.onosproject.openstackinterface.OpenstackPort; | 36 | import org.onosproject.openstackinterface.OpenstackPort; |
37 | -import org.onosproject.openstacknetworking.OpenstackNetworkingConfig; | ||
38 | import org.onosproject.scalablegateway.api.ScalableGatewayService; | 37 | import org.onosproject.scalablegateway.api.ScalableGatewayService; |
38 | +import org.onosproject.openstacknetworking.Constants; | ||
39 | +import org.onosproject.openstacknode.OpenstackNodeService; | ||
39 | import org.slf4j.Logger; | 40 | import org.slf4j.Logger; |
40 | 41 | ||
41 | import java.nio.ByteBuffer; | 42 | import java.nio.ByteBuffer; |
... | @@ -53,23 +54,24 @@ public class OpenstackRoutingArpHandler { | ... | @@ -53,23 +54,24 @@ public class OpenstackRoutingArpHandler { |
53 | 54 | ||
54 | private final PacketService packetService; | 55 | private final PacketService packetService; |
55 | private final OpenstackInterfaceService openstackService; | 56 | private final OpenstackInterfaceService openstackService; |
56 | - private final OpenstackNetworkingConfig config; | ||
57 | private final ScalableGatewayService gatewayService; | 57 | private final ScalableGatewayService gatewayService; |
58 | + private final OpenstackNodeService nodeService; | ||
58 | private static final String NETWORK_ROUTER_GATEWAY = "network:router_gateway"; | 59 | private static final String NETWORK_ROUTER_GATEWAY = "network:router_gateway"; |
59 | private static final String NETWORK_FLOATING_IP = "network:floatingip"; | 60 | private static final String NETWORK_FLOATING_IP = "network:floatingip"; |
60 | 61 | ||
61 | /** | 62 | /** |
62 | * Default constructor. | 63 | * Default constructor. |
63 | - * @param packetService packet service | 64 | + * |
65 | + * @param packetService packet service | ||
64 | * @param openstackService openstackInterface service | 66 | * @param openstackService openstackInterface service |
65 | - * @param config openstackRoutingConfig | 67 | + * @param gatewayService gateway service |
66 | - * @param gatewayService | 68 | + * @param nodeService openstackNodeService |
67 | */ | 69 | */ |
68 | OpenstackRoutingArpHandler(PacketService packetService, OpenstackInterfaceService openstackService, | 70 | OpenstackRoutingArpHandler(PacketService packetService, OpenstackInterfaceService openstackService, |
69 | - OpenstackNetworkingConfig config, ScalableGatewayService gatewayService) { | 71 | + OpenstackNodeService nodeService, ScalableGatewayService gatewayService) { |
70 | this.packetService = packetService; | 72 | this.packetService = packetService; |
71 | this.openstackService = checkNotNull(openstackService); | 73 | this.openstackService = checkNotNull(openstackService); |
72 | - this.config = checkNotNull(config); | 74 | + this.nodeService = nodeService; |
73 | this.gatewayService = gatewayService; | 75 | this.gatewayService = gatewayService; |
74 | } | 76 | } |
75 | 77 | ||
... | @@ -118,7 +120,8 @@ public class OpenstackRoutingArpHandler { | ... | @@ -118,7 +120,8 @@ public class OpenstackRoutingArpHandler { |
118 | if (getTargetMacForTargetIp(targetIp.getIp4Address()) == MacAddress.NONE) { | 120 | if (getTargetMacForTargetIp(targetIp.getIp4Address()) == MacAddress.NONE) { |
119 | return; | 121 | return; |
120 | } | 122 | } |
121 | - MacAddress targetMac = MacAddress.valueOf(config.gatewayExternalInterfaceMac()); | 123 | + // FIXME: Set the correct gateway |
124 | + MacAddress targetMac = Constants.GW_EXT_INT_MAC; | ||
122 | 125 | ||
123 | Ethernet ethReply = ARP.buildArpReply(targetIp.getIp4Address(), | 126 | Ethernet ethReply = ARP.buildArpReply(targetIp.getIp4Address(), |
124 | targetMac, ethernet); | 127 | targetMac, ethernet); | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
... | @@ -26,6 +26,7 @@ import org.onosproject.net.Host; | ... | @@ -26,6 +26,7 @@ import org.onosproject.net.Host; |
26 | import org.onosproject.net.host.HostEvent; | 26 | import org.onosproject.net.host.HostEvent; |
27 | import org.onosproject.net.host.HostListener; | 27 | import org.onosproject.net.host.HostListener; |
28 | import org.onosproject.net.host.HostService; | 28 | import org.onosproject.net.host.HostService; |
29 | +import org.onosproject.openstacknetworking.Constants; | ||
29 | import org.slf4j.Logger; | 30 | import org.slf4j.Logger; |
30 | 31 | ||
31 | import java.util.Objects; | 32 | import java.util.Objects; |
... | @@ -36,7 +37,7 @@ import java.util.stream.Collectors; | ... | @@ -36,7 +37,7 @@ import java.util.stream.Collectors; |
36 | 37 | ||
37 | import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; | 38 | import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; |
38 | import static org.onlab.util.Tools.groupedThreads; | 39 | import static org.onlab.util.Tools.groupedThreads; |
39 | -import static org.onosproject.openstacknetworking.switching.Constants.*; | 40 | +import static org.onosproject.openstacknetworking.Constants.*; |
40 | import static org.slf4j.LoggerFactory.getLogger; | 41 | import static org.slf4j.LoggerFactory.getLogger; |
41 | 42 | ||
42 | /** | 43 | /** | ... | ... |
... | @@ -48,7 +48,7 @@ import java.util.Dictionary; | ... | @@ -48,7 +48,7 @@ import java.util.Dictionary; |
48 | import java.util.Set; | 48 | import java.util.Set; |
49 | 49 | ||
50 | import static com.google.common.base.Preconditions.checkNotNull; | 50 | import static com.google.common.base.Preconditions.checkNotNull; |
51 | -import static org.onosproject.openstacknetworking.switching.Constants.*; | 51 | +import static org.onosproject.openstacknetworking.Constants.*; |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Handles ARP packet from VMs. | 54 | * Handles ARP packet from VMs. | ... | ... |
... | @@ -50,7 +50,7 @@ import java.util.Optional; | ... | @@ -50,7 +50,7 @@ import java.util.Optional; |
50 | import java.util.Set; | 50 | import java.util.Set; |
51 | import java.util.stream.Collectors; | 51 | import java.util.stream.Collectors; |
52 | 52 | ||
53 | -import static org.onosproject.openstacknetworking.switching.Constants.*; | 53 | +import static org.onosproject.openstacknetworking.Constants.*; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Populates flows rules for Security Groups of VMs. | 56 | * Populates flows rules for Security Groups of VMs. | ... | ... |
... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
16 | package org.onosproject.openstacknetworking.switching; | 16 | package org.onosproject.openstacknetworking.switching; |
17 | 17 | ||
18 | import com.google.common.base.Strings; | 18 | import com.google.common.base.Strings; |
19 | -import com.google.common.collect.Maps; | ||
20 | import com.google.common.collect.Sets; | 19 | import com.google.common.collect.Sets; |
21 | import org.apache.felix.scr.annotations.Activate; | 20 | import org.apache.felix.scr.annotations.Activate; |
22 | import org.apache.felix.scr.annotations.Component; | 21 | import org.apache.felix.scr.annotations.Component; |
... | @@ -27,7 +26,6 @@ import org.apache.felix.scr.annotations.Service; | ... | @@ -27,7 +26,6 @@ import org.apache.felix.scr.annotations.Service; |
27 | import org.onlab.packet.Ip4Address; | 26 | import org.onlab.packet.Ip4Address; |
28 | import org.onlab.packet.IpPrefix; | 27 | import org.onlab.packet.IpPrefix; |
29 | import org.onlab.packet.VlanId; | 28 | import org.onlab.packet.VlanId; |
30 | -import org.onlab.util.Tools; | ||
31 | import org.onosproject.core.CoreService; | 29 | import org.onosproject.core.CoreService; |
32 | import org.onosproject.dhcp.DhcpService; | 30 | import org.onosproject.dhcp.DhcpService; |
33 | import org.onosproject.dhcp.IpAssignment; | 31 | import org.onosproject.dhcp.IpAssignment; |
... | @@ -54,8 +52,6 @@ import org.onosproject.openstackinterface.OpenstackInterfaceService; | ... | @@ -54,8 +52,6 @@ import org.onosproject.openstackinterface.OpenstackInterfaceService; |
54 | import org.onosproject.openstackinterface.OpenstackNetwork; | 52 | import org.onosproject.openstackinterface.OpenstackNetwork; |
55 | import org.onosproject.openstackinterface.OpenstackPort; | 53 | import org.onosproject.openstackinterface.OpenstackPort; |
56 | import org.onosproject.openstackinterface.OpenstackSubnet; | 54 | import org.onosproject.openstackinterface.OpenstackSubnet; |
57 | -import org.onosproject.openstacknetworking.OpenstackPortInfo; | ||
58 | -import org.onosproject.openstacknetworking.OpenstackSwitchingService; | ||
59 | import org.onosproject.openstacknode.OpenstackNode; | 55 | import org.onosproject.openstacknode.OpenstackNode; |
60 | import org.onosproject.openstacknode.OpenstackNodeEvent; | 56 | import org.onosproject.openstacknode.OpenstackNodeEvent; |
61 | import org.onosproject.openstacknode.OpenstackNodeListener; | 57 | import org.onosproject.openstacknode.OpenstackNodeListener; |
... | @@ -64,7 +60,6 @@ import org.slf4j.Logger; | ... | @@ -64,7 +60,6 @@ import org.slf4j.Logger; |
64 | import org.slf4j.LoggerFactory; | 60 | import org.slf4j.LoggerFactory; |
65 | 61 | ||
66 | import java.util.Date; | 62 | import java.util.Date; |
67 | -import java.util.Map; | ||
68 | import java.util.concurrent.ExecutorService; | 63 | import java.util.concurrent.ExecutorService; |
69 | import java.util.concurrent.Executors; | 64 | import java.util.concurrent.Executors; |
70 | 65 | ||
... | @@ -74,7 +69,7 @@ import static org.onosproject.dhcp.IpAssignment.AssignmentStatus.Option_RangeNot | ... | @@ -74,7 +69,7 @@ import static org.onosproject.dhcp.IpAssignment.AssignmentStatus.Option_RangeNot |
74 | import static com.google.common.base.Preconditions.checkArgument; | 69 | import static com.google.common.base.Preconditions.checkArgument; |
75 | import static com.google.common.base.Preconditions.checkNotNull; | 70 | import static com.google.common.base.Preconditions.checkNotNull; |
76 | import static org.onosproject.net.AnnotationKeys.PORT_NAME; | 71 | import static org.onosproject.net.AnnotationKeys.PORT_NAME; |
77 | -import static org.onosproject.openstacknetworking.switching.Constants.*; | 72 | +import static org.onosproject.openstacknetworking.Constants.*; |
78 | 73 | ||
79 | @Service | 74 | @Service |
80 | @Component(immediate = true) | 75 | @Component(immediate = true) |
... | @@ -82,7 +77,7 @@ import static org.onosproject.openstacknetworking.switching.Constants.*; | ... | @@ -82,7 +77,7 @@ import static org.onosproject.openstacknetworking.switching.Constants.*; |
82 | * Populates forwarding rules for VMs created by Openstack. | 77 | * Populates forwarding rules for VMs created by Openstack. |
83 | */ | 78 | */ |
84 | public final class OpenstackSwitchingManager extends AbstractProvider | 79 | public final class OpenstackSwitchingManager extends AbstractProvider |
85 | - implements OpenstackSwitchingService, HostProvider { | 80 | + implements HostProvider { |
86 | 81 | ||
87 | private final Logger log = LoggerFactory.getLogger(getClass()); | 82 | private final Logger log = LoggerFactory.getLogger(getClass()); |
88 | 83 | ||
... | @@ -153,41 +148,6 @@ public final class OpenstackSwitchingManager extends AbstractProvider | ... | @@ -153,41 +148,6 @@ public final class OpenstackSwitchingManager extends AbstractProvider |
153 | // no probe is required | 148 | // no probe is required |
154 | } | 149 | } |
155 | 150 | ||
156 | - @Override | ||
157 | - // TODO remove this and openstackPortInfo | ||
158 | - public Map<String, OpenstackPortInfo> openstackPortInfo() { | ||
159 | - Map<String, OpenstackPortInfo> portInfoMap = Maps.newHashMap(); | ||
160 | - | ||
161 | - Tools.stream(hostService.getHosts()).filter(this::isValidHost).forEach(host -> { | ||
162 | - Port port = deviceService.getPort( | ||
163 | - host.location().deviceId(), | ||
164 | - host.location().port()); | ||
165 | - | ||
166 | - OpenstackPortInfo portInfo = OpenstackPortInfo.builder() | ||
167 | - .setDeviceId(host.location().deviceId()) | ||
168 | - .setHostMac(host.mac()) | ||
169 | - .setNetworkId(host.annotations().value(NETWORK_ID)) | ||
170 | - .setGatewayIP(Ip4Address.valueOf(host.annotations().value(GATEWAY_IP))) | ||
171 | - .setVni(Long.valueOf(host.annotations().value(VXLAN_ID))) | ||
172 | - .setHostIp(host.ipAddresses().stream().findFirst().get().getIp4Address()) | ||
173 | - .build(); | ||
174 | - | ||
175 | - portInfoMap.put(port.annotations().value(PORT_NAME), portInfo); | ||
176 | - }); | ||
177 | - | ||
178 | - return portInfoMap; | ||
179 | - } | ||
180 | - | ||
181 | - // TODO remove this and openstackPortInfo | ||
182 | - private boolean isValidHost(Host host) { | ||
183 | - return !host.ipAddresses().isEmpty() && | ||
184 | - host.annotations().value(VXLAN_ID) != null && | ||
185 | - host.annotations().value(NETWORK_ID) != null && | ||
186 | - host.annotations().value(TENANT_ID) != null && | ||
187 | - host.annotations().value(GATEWAY_IP) != null && | ||
188 | - host.annotations().value(PORT_ID) != null; | ||
189 | - } | ||
190 | - | ||
191 | private void processPortAdded(Port port) { | 151 | private void processPortAdded(Port port) { |
192 | // TODO check the node state is COMPLETE | 152 | // TODO check the node state is COMPLETE |
193 | OpenstackPort osPort = openstackService.port(port); | 153 | OpenstackPort osPort = openstackService.port(port); | ... | ... |
... | @@ -47,7 +47,7 @@ import java.util.Objects; | ... | @@ -47,7 +47,7 @@ import java.util.Objects; |
47 | import java.util.Optional; | 47 | import java.util.Optional; |
48 | 48 | ||
49 | import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST; | 49 | import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST; |
50 | -import static org.onosproject.openstacknetworking.switching.Constants.*; | 50 | +import static org.onosproject.openstacknetworking.Constants.*; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Populates switching flow rules. | 53 | * Populates switching flow rules. | ... | ... |
... | @@ -50,6 +50,7 @@ import org.onosproject.scalablegateway.api.GatewayNodeConfig; | ... | @@ -50,6 +50,7 @@ import org.onosproject.scalablegateway.api.GatewayNodeConfig; |
50 | import org.onosproject.scalablegateway.api.ScalableGatewayService; | 50 | import org.onosproject.scalablegateway.api.ScalableGatewayService; |
51 | 51 | ||
52 | import java.util.List; | 52 | import java.util.List; |
53 | +import java.util.Optional; | ||
53 | 54 | ||
54 | import org.onosproject.store.serializers.KryoNamespaces; | 55 | import org.onosproject.store.serializers.KryoNamespaces; |
55 | import org.onosproject.store.service.ConsistentMap; | 56 | import org.onosproject.store.service.ConsistentMap; |
... | @@ -128,7 +129,6 @@ public class ScalableGatewayManager implements ScalableGatewayService { | ... | @@ -128,7 +129,6 @@ public class ScalableGatewayManager implements ScalableGatewayService { |
128 | deviceService.addListener(internalDeviceListener); | 129 | deviceService.addListener(internalDeviceListener); |
129 | 130 | ||
130 | selectGroupHandler = new SelectGroupHandler(groupService, deviceService, driverService, appId); | 131 | selectGroupHandler = new SelectGroupHandler(groupService, deviceService, driverService, appId); |
131 | - readConfiguration(); | ||
132 | 132 | ||
133 | gatewayNodeMap = storageService.<DeviceId, GatewayNode>consistentMapBuilder() | 133 | gatewayNodeMap = storageService.<DeviceId, GatewayNode>consistentMapBuilder() |
134 | .withSerializer(Serializer.using(GATEWAYNODE_SERIALIZER.build())) | 134 | .withSerializer(Serializer.using(GATEWAYNODE_SERIALIZER.build())) |
... | @@ -165,13 +165,17 @@ public class ScalableGatewayManager implements ScalableGatewayService { | ... | @@ -165,13 +165,17 @@ public class ScalableGatewayManager implements ScalableGatewayService { |
165 | } | 165 | } |
166 | 166 | ||
167 | private PortNumber findPortNumFromPortName(DeviceId gatewayDeviceId, String name) { | 167 | private PortNumber findPortNumFromPortName(DeviceId gatewayDeviceId, String name) { |
168 | - Port port = deviceService.getPorts(gatewayDeviceId) | 168 | + Optional<Port> port = deviceService.getPorts(gatewayDeviceId) |
169 | .stream() | 169 | .stream() |
170 | .filter(p -> p.annotations().value(PORT_NAME).equals(name)) | 170 | .filter(p -> p.annotations().value(PORT_NAME).equals(name)) |
171 | - .iterator() | 171 | + .findFirst(); |
172 | - .next(); | ||
173 | - return checkNotNull(port, PORT_CAN_NOT_BE_NULL).number(); | ||
174 | 172 | ||
173 | + if (!port.isPresent()) { | ||
174 | + log.error("Cannot find port {} in gateway device {}", name, gatewayDeviceId); | ||
175 | + return null; | ||
176 | + } | ||
177 | + | ||
178 | + return port.get().number(); | ||
175 | } | 179 | } |
176 | 180 | ||
177 | @Override | 181 | @Override | ... | ... |
-
Please register or login to post a comment