Committed by
Gerrit Code Review
[ONOS-3804] [ONOS-3805] Initial L3 flowrules setup for Compute/Gateway nodes and…
… PNAT Handler for OpenstackRouting - Performs app refactoring (openstackrouting and openstackswitching) - Implements L3 REST call corresponding openstackRouter and openstackRouterInterface. - Implements initail L3 rules population to compute/gateway node. - Implements PNAT rules population corresponding packet-in event. - Fixs comments and javadocs. - Rebases on master. Change-Id: I5ad68810f50dc977737d30c43150c892b978b7cb
Showing
19 changed files
with
158 additions
and
1138 deletions
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.openstacknetworking; | 16 | package org.onosproject.openstacknetworking; |
17 | 17 | ||
18 | +import com.google.common.collect.ImmutableMap; | ||
18 | import com.google.common.collect.Maps; | 19 | import com.google.common.collect.Maps; |
19 | import org.onlab.packet.Ip4Address; | 20 | import org.onlab.packet.Ip4Address; |
20 | import java.util.Map; | 21 | import java.util.Map; |
... | @@ -60,7 +61,7 @@ public final class OpenstackExternalGateway { | ... | @@ -60,7 +61,7 @@ public final class OpenstackExternalGateway { |
60 | * @return External fixed IP informations | 61 | * @return External fixed IP informations |
61 | */ | 62 | */ |
62 | public Map<String, Ip4Address> externalFixedIps() { | 63 | public Map<String, Ip4Address> externalFixedIps() { |
63 | - return externalFixedIps; | 64 | + return ImmutableMap.copyOf(externalFixedIps); |
64 | } | 65 | } |
65 | 66 | ||
66 | @Override | 67 | @Override |
... | @@ -137,7 +138,7 @@ public final class OpenstackExternalGateway { | ... | @@ -137,7 +138,7 @@ public final class OpenstackExternalGateway { |
137 | * @return OpenstackExternalGateway object | 138 | * @return OpenstackExternalGateway object |
138 | */ | 139 | */ |
139 | public OpenstackExternalGateway build() { | 140 | public OpenstackExternalGateway build() { |
140 | - return new OpenstackExternalGateway(networkId, enablePnat, externalFixedIps); | 141 | + return new OpenstackExternalGateway(networkId, enablePnat, ImmutableMap.copyOf(externalFixedIps)); |
141 | } | 142 | } |
142 | } | 143 | } |
143 | 144 | ... | ... |
... | @@ -19,12 +19,14 @@ import org.onlab.packet.Ip4Address; | ... | @@ -19,12 +19,14 @@ import org.onlab.packet.Ip4Address; |
19 | 19 | ||
20 | import java.util.Objects; | 20 | import java.util.Objects; |
21 | 21 | ||
22 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
23 | + | ||
22 | /** | 24 | /** |
23 | * An Openstack Neutron Floating IP Model. | 25 | * An Openstack Neutron Floating IP Model. |
24 | */ | 26 | */ |
25 | public final class OpenstackFloatingIP { | 27 | public final class OpenstackFloatingIP { |
26 | 28 | ||
27 | - public enum FloatingIPStatus { | 29 | + public enum FloatingIpStatus { |
28 | UP, | 30 | UP, |
29 | DOWN, | 31 | DOWN, |
30 | ACTIVE, | 32 | ACTIVE, |
... | @@ -33,13 +35,13 @@ public final class OpenstackFloatingIP { | ... | @@ -33,13 +35,13 @@ public final class OpenstackFloatingIP { |
33 | private final String tenantId; | 35 | private final String tenantId; |
34 | private final String networkId; | 36 | private final String networkId; |
35 | private final Ip4Address fixedIpAddress; | 37 | private final Ip4Address fixedIpAddress; |
36 | - private final String portId; | 38 | + private String portId; |
37 | - private final String routerId; | 39 | + private String routerId; |
38 | private final String id; | 40 | private final String id; |
39 | private final Ip4Address floatingIpAddress; | 41 | private final Ip4Address floatingIpAddress; |
40 | - private final FloatingIPStatus status; | 42 | + private final FloatingIpStatus status; |
41 | 43 | ||
42 | - private OpenstackFloatingIP(FloatingIPStatus status, String id, String tenantId, | 44 | + private OpenstackFloatingIP(FloatingIpStatus status, String id, String tenantId, |
43 | String networkId, Ip4Address fixedIpAddress, String portId, | 45 | String networkId, Ip4Address fixedIpAddress, String portId, |
44 | String routerId, Ip4Address floatingIpAddress) { | 46 | String routerId, Ip4Address floatingIpAddress) { |
45 | this.status = status; | 47 | this.status = status; |
... | @@ -57,7 +59,7 @@ public final class OpenstackFloatingIP { | ... | @@ -57,7 +59,7 @@ public final class OpenstackFloatingIP { |
57 | * | 59 | * |
58 | * @return floating IP status | 60 | * @return floating IP status |
59 | */ | 61 | */ |
60 | - public FloatingIPStatus status() { | 62 | + public FloatingIpStatus status() { |
61 | return status; | 63 | return status; |
62 | } | 64 | } |
63 | 65 | ||
... | @@ -107,6 +109,15 @@ public final class OpenstackFloatingIP { | ... | @@ -107,6 +109,15 @@ public final class OpenstackFloatingIP { |
107 | } | 109 | } |
108 | 110 | ||
109 | /** | 111 | /** |
112 | + * Updates port ID. | ||
113 | + * | ||
114 | + * @param portId Updated port ID | ||
115 | + */ | ||
116 | + public void updatePortId(String portId) { | ||
117 | + this.portId = portId; | ||
118 | + } | ||
119 | + | ||
120 | + /** | ||
110 | * Returns router ID. | 121 | * Returns router ID. |
111 | * | 122 | * |
112 | * @return router ID | 123 | * @return router ID |
... | @@ -116,6 +127,15 @@ public final class OpenstackFloatingIP { | ... | @@ -116,6 +127,15 @@ public final class OpenstackFloatingIP { |
116 | } | 127 | } |
117 | 128 | ||
118 | /** | 129 | /** |
130 | + * Updates router ID. | ||
131 | + * | ||
132 | + * @param routerId Updated router ID | ||
133 | + */ | ||
134 | + public void updateRouterId(String routerId) { | ||
135 | + this.routerId = routerId; | ||
136 | + } | ||
137 | + | ||
138 | + /** | ||
119 | * Returns floating IP address. | 139 | * Returns floating IP address. |
120 | * | 140 | * |
121 | * @return Floating IP address | 141 | * @return Floating IP address |
... | @@ -162,7 +182,7 @@ public final class OpenstackFloatingIP { | ... | @@ -162,7 +182,7 @@ public final class OpenstackFloatingIP { |
162 | private String routerId; | 182 | private String routerId; |
163 | private String id; | 183 | private String id; |
164 | private Ip4Address floatingIpAddress; | 184 | private Ip4Address floatingIpAddress; |
165 | - private FloatingIPStatus status; | 185 | + private FloatingIpStatus status; |
166 | 186 | ||
167 | /** | 187 | /** |
168 | * Sets tenant ID. | 188 | * Sets tenant ID. |
... | @@ -181,7 +201,7 @@ public final class OpenstackFloatingIP { | ... | @@ -181,7 +201,7 @@ public final class OpenstackFloatingIP { |
181 | * @param status Floating IP status | 201 | * @param status Floating IP status |
182 | * @return Builder object | 202 | * @return Builder object |
183 | */ | 203 | */ |
184 | - public Builder status(FloatingIPStatus status) { | 204 | + public Builder status(FloatingIpStatus status) { |
185 | this.status = status; | 205 | this.status = status; |
186 | return this; | 206 | return this; |
187 | } | 207 | } |
... | @@ -258,8 +278,9 @@ public final class OpenstackFloatingIP { | ... | @@ -258,8 +278,9 @@ public final class OpenstackFloatingIP { |
258 | * @return OpenstackFloatingIP object | 278 | * @return OpenstackFloatingIP object |
259 | */ | 279 | */ |
260 | public OpenstackFloatingIP build() { | 280 | public OpenstackFloatingIP build() { |
261 | - return new OpenstackFloatingIP(status, id, tenantId, networkId, | 281 | + return new OpenstackFloatingIP(checkNotNull(status), checkNotNull(id), checkNotNull(tenantId), |
262 | - fixedIpAddress, portId, routerId, floatingIpAddress); | 282 | + checkNotNull(networkId), fixedIpAddress, portId, |
283 | + routerId, checkNotNull(floatingIpAddress)); | ||
263 | 284 | ||
264 | } | 285 | } |
265 | } | 286 | } | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | package org.onosproject.openstacknetworking; | 16 | package org.onosproject.openstacknetworking; |
17 | 17 | ||
18 | import java.util.Objects; | 18 | import java.util.Objects; |
19 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
19 | 20 | ||
20 | /** | 21 | /** |
21 | * An Openstack Neutron Router Model. | 22 | * An Openstack Neutron Router Model. |
... | @@ -31,9 +32,9 @@ public final class OpenstackRouter { | ... | @@ -31,9 +32,9 @@ public final class OpenstackRouter { |
31 | private final String tenantId; | 32 | private final String tenantId; |
32 | private final String id; | 33 | private final String id; |
33 | private final String name; | 34 | private final String name; |
34 | - private final RouterStatus status; | 35 | + private RouterStatus status; |
35 | - private final boolean adminStateUp; | 36 | + private boolean adminStateUp; |
36 | - private final OpenstackExternalGateway gatewayExternalInfo; | 37 | + private OpenstackExternalGateway gatewayExternalInfo; |
37 | 38 | ||
38 | private OpenstackRouter(String id, String tenantId, String name, RouterStatus status, | 39 | private OpenstackRouter(String id, String tenantId, String name, RouterStatus status, |
39 | boolean adminStateUp, OpenstackExternalGateway gatewayExternalInfo) { | 40 | boolean adminStateUp, OpenstackExternalGateway gatewayExternalInfo) { |
... | @@ -209,8 +210,8 @@ public final class OpenstackRouter { | ... | @@ -209,8 +210,8 @@ public final class OpenstackRouter { |
209 | * @return OpenstasckRouter object | 210 | * @return OpenstasckRouter object |
210 | */ | 211 | */ |
211 | public OpenstackRouter build() { | 212 | public OpenstackRouter build() { |
212 | - return new OpenstackRouter(id, tenantId, name, status, | 213 | + return new OpenstackRouter(checkNotNull(id), checkNotNull(tenantId), name, checkNotNull(status), |
213 | - adminStateUp, gatewayExternalInfo); | 214 | + checkNotNull(adminStateUp), gatewayExternalInfo); |
214 | } | 215 | } |
215 | } | 216 | } |
216 | 217 | ... | ... |
... | @@ -99,12 +99,12 @@ public final class OpenstackRouterInterface { | ... | @@ -99,12 +99,12 @@ public final class OpenstackRouterInterface { |
99 | * An Openstack Router Interface Builder class. | 99 | * An Openstack Router Interface Builder class. |
100 | */ | 100 | */ |
101 | public static final class Builder { | 101 | public static final class Builder { |
102 | - private String id; | 102 | + private String id; |
103 | - private String tenantId; | 103 | + private String tenantId; |
104 | - private String subnetId; | 104 | + private String subnetId; |
105 | - private String portId; | 105 | + private String portId; |
106 | 106 | ||
107 | - /** | 107 | + /** |
108 | * Sets Router Interface ID. | 108 | * Sets Router Interface ID. |
109 | * | 109 | * |
110 | * @param id router interface ID | 110 | * @param id router interface ID |
... | @@ -148,14 +148,14 @@ public final class OpenstackRouterInterface { | ... | @@ -148,14 +148,14 @@ public final class OpenstackRouterInterface { |
148 | return this; | 148 | return this; |
149 | } | 149 | } |
150 | 150 | ||
151 | - | ||
152 | /** | 151 | /** |
153 | * Builds an Openstack Router Interface object. | 152 | * Builds an Openstack Router Interface object. |
154 | * | 153 | * |
155 | * @return OpenstackRouterInterface object | 154 | * @return OpenstackRouterInterface object |
156 | */ | 155 | */ |
157 | public OpenstackRouterInterface build() { | 156 | public OpenstackRouterInterface build() { |
158 | - return new OpenstackRouterInterface(id, tenantId, subnetId, portId); | 157 | + return new OpenstackRouterInterface(checkNotNull(id), checkNotNull(tenantId), |
158 | + checkNotNull(subnetId), checkNotNull(portId)); | ||
159 | } | 159 | } |
160 | 160 | ||
161 | } | 161 | } | ... | ... |
... | @@ -17,24 +17,29 @@ package org.onosproject.openstacknetworking.routing; | ... | @@ -17,24 +17,29 @@ package org.onosproject.openstacknetworking.routing; |
17 | 17 | ||
18 | import org.onlab.packet.Ethernet; | 18 | import org.onlab.packet.Ethernet; |
19 | import org.onlab.packet.IPv4; | 19 | import org.onlab.packet.IPv4; |
20 | +import org.onlab.packet.Ip4Address; | ||
20 | import org.onlab.packet.MacAddress; | 21 | import org.onlab.packet.MacAddress; |
21 | import org.onlab.packet.TCP; | 22 | import org.onlab.packet.TCP; |
22 | import org.onlab.packet.UDP; | 23 | import org.onlab.packet.UDP; |
23 | import org.onosproject.net.DeviceId; | 24 | import org.onosproject.net.DeviceId; |
24 | -import org.onosproject.net.PortNumber; | 25 | +import org.onosproject.net.Port; |
25 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 26 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
26 | import org.onosproject.net.flow.TrafficTreatment; | 27 | import org.onosproject.net.flow.TrafficTreatment; |
27 | import org.onosproject.net.packet.DefaultOutboundPacket; | 28 | import org.onosproject.net.packet.DefaultOutboundPacket; |
28 | import org.onosproject.net.packet.InboundPacket; | 29 | import org.onosproject.net.packet.InboundPacket; |
29 | import org.onosproject.net.packet.PacketContext; | 30 | import org.onosproject.net.packet.PacketContext; |
30 | import org.onosproject.net.packet.PacketService; | 31 | import org.onosproject.net.packet.PacketService; |
32 | +import org.onosproject.openstacknetworking.OpenstackNetwork; | ||
33 | +import org.onosproject.openstacknetworking.OpenstackNetworkingService; | ||
31 | import org.onosproject.openstacknetworking.OpenstackPort; | 34 | import org.onosproject.openstacknetworking.OpenstackPort; |
35 | +import org.onosproject.openstacknetworking.OpenstackRouter; | ||
32 | import org.slf4j.Logger; | 36 | import org.slf4j.Logger; |
33 | import org.slf4j.LoggerFactory; | 37 | import org.slf4j.LoggerFactory; |
34 | 38 | ||
35 | import java.nio.ByteBuffer; | 39 | import java.nio.ByteBuffer; |
36 | 40 | ||
37 | import static com.google.common.base.Preconditions.checkNotNull; | 41 | import static com.google.common.base.Preconditions.checkNotNull; |
42 | +import static org.onlab.osgi.DefaultServiceDirectory.getService; | ||
38 | 43 | ||
39 | 44 | ||
40 | /** | 45 | /** |
... | @@ -50,13 +55,20 @@ public class OpenstackPnatHandler implements Runnable { | ... | @@ -50,13 +55,20 @@ public class OpenstackPnatHandler implements Runnable { |
50 | private final OpenstackRoutingRulePopulator rulePopulator; | 55 | private final OpenstackRoutingRulePopulator rulePopulator; |
51 | private final int portNum; | 56 | private final int portNum; |
52 | private final OpenstackPort openstackPort; | 57 | private final OpenstackPort openstackPort; |
58 | + private final Port port; | ||
59 | + | ||
60 | + private static final String DEVICE_OWNER_ROUTER_INTERFACE = "network:router_interface"; | ||
61 | + // TODO: This will be replaced to get the information from openstacknetworkingservice. | ||
62 | + private static final MacAddress GATEWAYMAC = MacAddress.valueOf("1f:1f:1f:1f:1f:1f"); | ||
63 | + private static final MacAddress EXTERNAL_INTERFACE_MAC = MacAddress.valueOf("00:00:00:00:00:11"); | ||
53 | 64 | ||
54 | OpenstackPnatHandler(OpenstackRoutingRulePopulator rulePopulator, PacketContext context, | 65 | OpenstackPnatHandler(OpenstackRoutingRulePopulator rulePopulator, PacketContext context, |
55 | - int portNum, OpenstackPort openstackPort) { | 66 | + int portNum, OpenstackPort openstackPort, Port port) { |
56 | this.rulePopulator = checkNotNull(rulePopulator); | 67 | this.rulePopulator = checkNotNull(rulePopulator); |
57 | this.context = checkNotNull(context); | 68 | this.context = checkNotNull(context); |
58 | this.portNum = checkNotNull(portNum); | 69 | this.portNum = checkNotNull(portNum); |
59 | this.openstackPort = checkNotNull(openstackPort); | 70 | this.openstackPort = checkNotNull(openstackPort); |
71 | + this.port = checkNotNull(port); | ||
60 | } | 72 | } |
61 | 73 | ||
62 | @Override | 74 | @Override |
... | @@ -70,14 +82,41 @@ public class OpenstackPnatHandler implements Runnable { | ... | @@ -70,14 +82,41 @@ public class OpenstackPnatHandler implements Runnable { |
70 | return; | 82 | return; |
71 | } | 83 | } |
72 | 84 | ||
73 | - packetOut(inboundPacket, portNum); | 85 | + OpenstackRouter router = getOpenstackRouter(openstackPort); |
74 | 86 | ||
75 | rulePopulator.populatePnatFlowRules(inboundPacket, openstackPort, portNum, | 87 | rulePopulator.populatePnatFlowRules(inboundPacket, openstackPort, portNum, |
76 | - getExternalInterfaceMacAddress(), getExternalRouterMacAddress()); | 88 | + getExternalIp(router), getExternalInterfaceMacAddress(), getExternalRouterMacAddress()); |
89 | + | ||
90 | + packetOut((Ethernet) ethernet.clone(), inboundPacket.receivedFrom().deviceId(), portNum, router); | ||
77 | } | 91 | } |
78 | 92 | ||
79 | - private void packetOut(InboundPacket inboundPacket, int portNum) { | 93 | + private OpenstackRouter getOpenstackRouter(OpenstackPort openstackPort) { |
80 | - Ethernet ethernet = checkNotNull(inboundPacket.parsed()); | 94 | + OpenstackNetworkingService networkingService = getService(OpenstackNetworkingService.class); |
95 | + OpenstackNetwork network = networkingService.network(openstackPort.networkId()); | ||
96 | + | ||
97 | + OpenstackPort port = networkingService.ports() | ||
98 | + .stream() | ||
99 | + .filter(p -> p.deviceOwner().equals(DEVICE_OWNER_ROUTER_INTERFACE)) | ||
100 | + .filter(p -> checkSameSubnet(p, openstackPort)) | ||
101 | + .findAny() | ||
102 | + .orElse(null); | ||
103 | + | ||
104 | + return checkNotNull(networkingService.router(port.deviceId())); | ||
105 | + } | ||
106 | + | ||
107 | + private boolean checkSameSubnet(OpenstackPort p, OpenstackPort openstackPort) { | ||
108 | + String key1 = checkNotNull(p.fixedIps().keySet().stream().findFirst().orElse(null)).toString(); | ||
109 | + String key2 = checkNotNull(openstackPort.fixedIps().keySet().stream().findFirst().orElse(null)).toString(); | ||
110 | + return key1.equals(key2) ? true : false; | ||
111 | + } | ||
112 | + | ||
113 | + private Ip4Address getExternalIp(OpenstackRouter router) { | ||
114 | + return router.gatewayExternalInfo().externalFixedIps().values().stream().findAny().orElse(null); | ||
115 | + } | ||
116 | + | ||
117 | + private void packetOut(Ethernet ethernet, DeviceId deviceId, int portNum, OpenstackRouter router) { | ||
118 | + PacketService packetService = getService(PacketService.class); | ||
119 | + | ||
81 | IPv4 iPacket = (IPv4) ethernet.getPayload(); | 120 | IPv4 iPacket = (IPv4) ethernet.getPayload(); |
82 | 121 | ||
83 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); | 122 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); |
... | @@ -98,31 +137,27 @@ public class OpenstackPnatHandler implements Runnable { | ... | @@ -98,31 +137,27 @@ public class OpenstackPnatHandler implements Runnable { |
98 | iPacket.setPayload(udpPacket); | 137 | iPacket.setPayload(udpPacket); |
99 | break; | 138 | break; |
100 | default: | 139 | default: |
101 | - break; | 140 | + log.error("Temporally, this method can process UDP and TCP protocol."); |
141 | + return; | ||
102 | } | 142 | } |
103 | 143 | ||
144 | + iPacket.setSourceAddress(getExternalIp(router).toString()); | ||
104 | iPacket.resetChecksum(); | 145 | iPacket.resetChecksum(); |
105 | - iPacket.setPayload(ethernet); | 146 | + iPacket.setParent(ethernet); |
106 | ethernet.setSourceMACAddress(getExternalInterfaceMacAddress()) | 147 | ethernet.setSourceMACAddress(getExternalInterfaceMacAddress()) |
107 | .setDestinationMACAddress(getExternalRouterMacAddress()); | 148 | .setDestinationMACAddress(getExternalRouterMacAddress()); |
108 | ethernet.resetChecksum(); | 149 | ethernet.resetChecksum(); |
109 | 150 | ||
110 | - treatment.setOutput(getExternalPort(inboundPacket.receivedFrom().deviceId())); | 151 | + treatment.setOutput(port.number()); |
111 | 152 | ||
112 | - packetService.emit(new DefaultOutboundPacket(inboundPacket.receivedFrom().deviceId(), | 153 | + packetService.emit(new DefaultOutboundPacket(deviceId, treatment.build(), |
113 | - treatment.build(), ByteBuffer.wrap(ethernet.serialize()))); | 154 | + ByteBuffer.wrap(ethernet.serialize()))); |
114 | } | 155 | } |
115 | 156 | ||
116 | - private PortNumber getExternalPort(DeviceId deviceId) { | ||
117 | - // TODO | ||
118 | - return null; | ||
119 | - } | ||
120 | private MacAddress getExternalInterfaceMacAddress() { | 157 | private MacAddress getExternalInterfaceMacAddress() { |
121 | - // TODO | 158 | + return EXTERNAL_INTERFACE_MAC; |
122 | - return null; | ||
123 | } | 159 | } |
124 | private MacAddress getExternalRouterMacAddress() { | 160 | private MacAddress getExternalRouterMacAddress() { |
125 | - // TODO | 161 | + return GATEWAYMAC; |
126 | - return null; | ||
127 | } | 162 | } |
128 | } | 163 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -29,6 +29,8 @@ import org.onlab.packet.Ip4Address; | ... | @@ -29,6 +29,8 @@ import org.onlab.packet.Ip4Address; |
29 | import org.onlab.packet.MacAddress; | 29 | import org.onlab.packet.MacAddress; |
30 | import org.onosproject.core.ApplicationId; | 30 | import org.onosproject.core.ApplicationId; |
31 | import org.onosproject.core.CoreService; | 31 | import org.onosproject.core.CoreService; |
32 | +import org.onosproject.net.DeviceId; | ||
33 | +import org.onosproject.net.Port; | ||
32 | import org.onosproject.net.device.DeviceService; | 34 | import org.onosproject.net.device.DeviceService; |
33 | import org.onosproject.net.driver.DriverService; | 35 | import org.onosproject.net.driver.DriverService; |
34 | import org.onosproject.net.flowobjective.FlowObjectiveService; | 36 | import org.onosproject.net.flowobjective.FlowObjectiveService; |
... | @@ -55,14 +57,14 @@ import java.util.stream.Collectors; | ... | @@ -55,14 +57,14 @@ import java.util.stream.Collectors; |
55 | import static com.google.common.base.Preconditions.checkNotNull; | 57 | import static com.google.common.base.Preconditions.checkNotNull; |
56 | import static org.onlab.util.Tools.groupedThreads; | 58 | import static org.onlab.util.Tools.groupedThreads; |
57 | 59 | ||
58 | -@Service | ||
59 | @Component(immediate = true) | 60 | @Component(immediate = true) |
61 | +@Service | ||
60 | /** | 62 | /** |
61 | * Populates flow rules about L3 functionality for VMs in Openstack. | 63 | * Populates flow rules about L3 functionality for VMs in Openstack. |
62 | */ | 64 | */ |
63 | public class OpenstackRoutingManager implements OpenstackRoutingService { | 65 | public class OpenstackRoutingManager implements OpenstackRoutingService { |
64 | - private final Logger log = LoggerFactory | 66 | + |
65 | - .getLogger(getClass()); | 67 | + private final Logger log = LoggerFactory.getLogger(getClass()); |
66 | 68 | ||
67 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 69 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
68 | protected CoreService coreService; | 70 | protected CoreService coreService; |
... | @@ -86,6 +88,12 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { | ... | @@ -86,6 +88,12 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { |
86 | private Map<String, OpenstackRouterInterface> routerInterfaceMap = Maps.newHashMap(); | 88 | private Map<String, OpenstackRouterInterface> routerInterfaceMap = Maps.newHashMap(); |
87 | private Map<Integer, String> portNumMap = initPortNumMap(); | 89 | private Map<Integer, String> portNumMap = initPortNumMap(); |
88 | private static final String APP_ID = "org.onosproject.openstackrouting"; | 90 | private static final String APP_ID = "org.onosproject.openstackrouting"; |
91 | + private static final String PORT_NAME = "portName"; | ||
92 | + private static final String DEVICE_OWNER_ROUTER_INTERFACE = "network:router_interface"; | ||
93 | + | ||
94 | + // TODO: This will be replaced to get the information from openstackswitchingservice. | ||
95 | + private static final String EXTERNAL_INTERFACE_NAME = "veth0"; | ||
96 | + | ||
89 | private Map<Integer, String> initPortNumMap() { | 97 | private Map<Integer, String> initPortNumMap() { |
90 | Map<Integer, String> map = Maps.newHashMap(); | 98 | Map<Integer, String> map = Maps.newHashMap(); |
91 | for (int i = 1024; i < 65535; i++) { | 99 | for (int i = 1024; i < 65535; i++) { |
... | @@ -104,7 +112,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { | ... | @@ -104,7 +112,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { |
104 | protected void activate() { | 112 | protected void activate() { |
105 | appId = coreService.registerApplication(APP_ID); | 113 | appId = coreService.registerApplication(APP_ID); |
106 | packetService.addProcessor(internalPacketProcessor, PacketProcessor.director(1)); | 114 | packetService.addProcessor(internalPacketProcessor, PacketProcessor.director(1)); |
107 | - | 115 | + reloadInitL3Rules(); |
108 | log.info("onos-openstackrouting started"); | 116 | log.info("onos-openstackrouting started"); |
109 | } | 117 | } |
110 | 118 | ||
... | @@ -150,7 +158,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { | ... | @@ -150,7 +158,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { |
150 | routerInterfaceMap.putIfAbsent(routerInterface.portId(), routerInterface); | 158 | routerInterfaceMap.putIfAbsent(routerInterface.portId(), routerInterface); |
151 | List<OpenstackRouterInterface> routerInterfaces = Lists.newArrayList(); | 159 | List<OpenstackRouterInterface> routerInterfaces = Lists.newArrayList(); |
152 | routerInterfaces.add(routerInterface); | 160 | routerInterfaces.add(routerInterface); |
153 | - checkExternalConnection(getOpenstackRouter(routerInterface.tenantId()), routerInterfaces); | 161 | + checkExternalConnection(getOpenstackRouter(routerInterface.portId()), routerInterfaces); |
154 | } | 162 | } |
155 | 163 | ||
156 | @Override | 164 | @Override |
... | @@ -160,6 +168,27 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { | ... | @@ -160,6 +168,27 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { |
160 | rulePopulator.removeExternalRules(routerInterface); | 168 | rulePopulator.removeExternalRules(routerInterface); |
161 | routerInterfaceMap.remove(routerInterface.portId()); | 169 | routerInterfaceMap.remove(routerInterface.portId()); |
162 | } | 170 | } |
171 | + | ||
172 | + private void reloadInitL3Rules() { | ||
173 | + openstackService.ports() | ||
174 | + .stream() | ||
175 | + .filter(p -> p.deviceOwner().equals(DEVICE_OWNER_ROUTER_INTERFACE)) | ||
176 | + .forEach(p -> { | ||
177 | + OpenstackRouterInterface routerInterface = portToRouterInterface(p); | ||
178 | + updateRouterInterface(routerInterface); | ||
179 | + }); | ||
180 | + } | ||
181 | + | ||
182 | + private OpenstackRouterInterface portToRouterInterface(OpenstackPort p) { | ||
183 | + OpenstackRouterInterface.Builder osBuilder = new OpenstackRouterInterface.Builder() | ||
184 | + .id(checkNotNull(p.id())) | ||
185 | + .tenantId(checkNotNull(openstackService.network(p.networkId()).tenantId())) | ||
186 | + .subnetId(checkNotNull(p.fixedIps().keySet().stream().findFirst().orElse(null)).toString()) | ||
187 | + .portId(checkNotNull(p.deviceId())); | ||
188 | + | ||
189 | + return osBuilder.build(); | ||
190 | + } | ||
191 | + | ||
163 | private class InternalPacketProcessor implements PacketProcessor { | 192 | private class InternalPacketProcessor implements PacketProcessor { |
164 | 193 | ||
165 | @Override | 194 | @Override |
... | @@ -183,10 +212,15 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { | ... | @@ -183,10 +212,15 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { |
183 | break; | 212 | break; |
184 | default: | 213 | default: |
185 | int portNum = getPortNum(ethernet.getSourceMAC(), iPacket.getDestinationAddress()); | 214 | int portNum = getPortNum(ethernet.getSourceMAC(), iPacket.getDestinationAddress()); |
215 | + Port port = getExternalPort(pkt.receivedFrom().deviceId(), EXTERNAL_INTERFACE_NAME); | ||
216 | + if (port == null) { | ||
217 | + log.warn("There`s no external interface"); | ||
218 | + break; | ||
219 | + } | ||
186 | OpenstackPort openstackPort = getOpenstackPort(ethernet.getSourceMAC(), | 220 | OpenstackPort openstackPort = getOpenstackPort(ethernet.getSourceMAC(), |
187 | Ip4Address.valueOf(iPacket.getSourceAddress())); | 221 | Ip4Address.valueOf(iPacket.getSourceAddress())); |
188 | l3EventExecutorService.execute(new OpenstackPnatHandler(rulePopulator, context, | 222 | l3EventExecutorService.execute(new OpenstackPnatHandler(rulePopulator, context, |
189 | - portNum, openstackPort)); | 223 | + portNum, openstackPort, port)); |
190 | break; | 224 | break; |
191 | } | 225 | } |
192 | 226 | ||
... | @@ -201,24 +235,30 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { | ... | @@ -201,24 +235,30 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { |
201 | } | 235 | } |
202 | } | 236 | } |
203 | 237 | ||
238 | + private Port getExternalPort(DeviceId deviceId, String interfaceName) { | ||
239 | + return deviceService.getPorts(deviceId) | ||
240 | + .stream() | ||
241 | + .filter(p -> p.annotations().value(PORT_NAME).equals(interfaceName)) | ||
242 | + .findAny() | ||
243 | + .orElse(null); | ||
244 | + } | ||
245 | + | ||
204 | private void checkExternalConnection(OpenstackRouter router, | 246 | private void checkExternalConnection(OpenstackRouter router, |
205 | Collection<OpenstackRouterInterface> routerInterfaces) { | 247 | Collection<OpenstackRouterInterface> routerInterfaces) { |
206 | checkNotNull(router, "Router can not be null"); | 248 | checkNotNull(router, "Router can not be null"); |
207 | - checkNotNull(routerInterfaces, "RouterInterfaces can not be null"); | 249 | + checkNotNull(routerInterfaces, "routerInterfaces can not be null"); |
208 | Ip4Address externalIp = router.gatewayExternalInfo().externalFixedIps() | 250 | Ip4Address externalIp = router.gatewayExternalInfo().externalFixedIps() |
209 | .values().stream().findFirst().orElse(null); | 251 | .values().stream().findFirst().orElse(null); |
210 | if ((externalIp == null) || (!router.gatewayExternalInfo().isEnablePnat())) { | 252 | if ((externalIp == null) || (!router.gatewayExternalInfo().isEnablePnat())) { |
211 | - log.debug("Failed to set pnat configuration"); | 253 | + log.debug("Not satisfied to set pnat configuration"); |
212 | return; | 254 | return; |
213 | } | 255 | } |
214 | - routerInterfaces.forEach(routerInterface -> { | 256 | + routerInterfaces.forEach(routerInterface -> initiateL3Rule(router, routerInterface)); |
215 | - initiateL3Rule(router, routerInterface); | ||
216 | - }); | ||
217 | } | 257 | } |
218 | 258 | ||
219 | private void initiateL3Rule(OpenstackRouter router, OpenstackRouterInterface routerInterface) { | 259 | private void initiateL3Rule(OpenstackRouter router, OpenstackRouterInterface routerInterface) { |
220 | long vni = Long.parseLong(openstackService.network(openstackService | 260 | long vni = Long.parseLong(openstackService.network(openstackService |
221 | - .port(routerInterface.portId()).networkId()).segmentId()); | 261 | + .port(routerInterface.id()).networkId()).segmentId()); |
222 | OpenstackRoutingRulePopulator rulePopulator = new OpenstackRoutingRulePopulator(appId, | 262 | OpenstackRoutingRulePopulator rulePopulator = new OpenstackRoutingRulePopulator(appId, |
223 | openstackService, flowObjectiveService, deviceService, driverService); | 263 | openstackService, flowObjectiveService, deviceService, driverService); |
224 | rulePopulator.populateExternalRules(vni, router, routerInterface); | 264 | rulePopulator.populateExternalRules(vni, router, routerInterface); |
... | @@ -229,15 +269,15 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { | ... | @@ -229,15 +269,15 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { |
229 | .collect(Collectors.toList()); | 269 | .collect(Collectors.toList()); |
230 | } | 270 | } |
231 | 271 | ||
232 | - private OpenstackRouter getOpenstackRouter(String tenantId) { | 272 | + private OpenstackRouter getOpenstackRouter(String id) { |
233 | return openstackService.routers().stream().filter(r -> | 273 | return openstackService.routers().stream().filter(r -> |
234 | - r.tenantId().equals(tenantId)).findFirst().orElse(null); | 274 | + r.id().equals(id)).findAny().orElse(null); |
235 | } | 275 | } |
236 | 276 | ||
237 | private OpenstackPort getOpenstackPort(MacAddress sourceMac, Ip4Address ip4Address) { | 277 | private OpenstackPort getOpenstackPort(MacAddress sourceMac, Ip4Address ip4Address) { |
238 | - OpenstackPort openstackPort = openstackService.ports("").stream() | 278 | + OpenstackPort openstackPort = openstackService.ports().stream() |
239 | .filter(p -> p.macAddress().equals(sourceMac)).findFirst().orElse(null); | 279 | .filter(p -> p.macAddress().equals(sourceMac)).findFirst().orElse(null); |
240 | - return openstackPort.fixedIps().values().stream().findFirst().orElse(null) | 280 | + return checkNotNull(openstackPort.fixedIps().values().stream().findFirst().orElse(null)) |
241 | .equals(ip4Address) ? openstackPort : null; | 281 | .equals(ip4Address) ? openstackPort : null; |
242 | } | 282 | } |
243 | 283 | ... | ... |
This diff is collapsed. Click to expand it.
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 com.google.common.collect.ImmutableMap; | ||
19 | -import org.onlab.packet.Ip4Address; | ||
20 | - | ||
21 | -import java.util.HashMap; | ||
22 | -import java.util.Map; | ||
23 | - | ||
24 | -/** | ||
25 | - * A configurable external gateway modes extension model in openstack router. | ||
26 | - */ | ||
27 | -public final class OpenstackExternalGateway { | ||
28 | - | ||
29 | - private String networkId; | ||
30 | - private boolean enablePnat; | ||
31 | - private Map<String, Ip4Address> externalFixedIps; | ||
32 | - | ||
33 | - private OpenstackExternalGateway(String networkId, boolean enablePnat, | ||
34 | - Map<String, Ip4Address> externalFixedIps) { | ||
35 | - this.networkId = networkId; | ||
36 | - this.enablePnat = enablePnat; | ||
37 | - this.externalFixedIps = externalFixedIps; | ||
38 | - } | ||
39 | - | ||
40 | - public static OpenstackExternalGateway.Builder builder() { | ||
41 | - return new Builder(); | ||
42 | - } | ||
43 | - /** | ||
44 | - * Returns network ID. | ||
45 | - * | ||
46 | - * @return Network ID | ||
47 | - */ | ||
48 | - public String networkId() { | ||
49 | - return networkId; | ||
50 | - } | ||
51 | - | ||
52 | - /** | ||
53 | - * Returns the PNAT status for external gateway. | ||
54 | - * | ||
55 | - * @return PNAT status | ||
56 | - */ | ||
57 | - public boolean isEnablePnat() { | ||
58 | - return enablePnat; | ||
59 | - } | ||
60 | - | ||
61 | - public Map<String, Ip4Address> externalFixedIps() { | ||
62 | - return ImmutableMap.copyOf(externalFixedIps); | ||
63 | - } | ||
64 | - | ||
65 | - /** | ||
66 | - * An Openstack External Gateway Builder class. | ||
67 | - */ | ||
68 | - public static final class Builder { | ||
69 | - private String networkId; | ||
70 | - private boolean enablePnat; | ||
71 | - private Map<String, Ip4Address> externalFixedIps; | ||
72 | - | ||
73 | - Builder() { | ||
74 | - externalFixedIps = new HashMap<>(); | ||
75 | - } | ||
76 | - | ||
77 | - /** | ||
78 | - * Sets network ID. | ||
79 | - * | ||
80 | - * @param networkId Network ID | ||
81 | - * @return Builder object | ||
82 | - */ | ||
83 | - public Builder networkId(String networkId) { | ||
84 | - this.networkId = networkId; | ||
85 | - return this; | ||
86 | - } | ||
87 | - | ||
88 | - /** | ||
89 | - * Sets whether PNAT status is enabled or not. | ||
90 | - * | ||
91 | - * @param enablePnat true if PNAT status is enabled, false otherwise | ||
92 | - * @return Builder object | ||
93 | - */ | ||
94 | - public Builder enablePnat(boolean enablePnat) { | ||
95 | - this.enablePnat = enablePnat; | ||
96 | - return this; | ||
97 | - } | ||
98 | - | ||
99 | - /** | ||
100 | - * Sets external fixed IP address information. | ||
101 | - * | ||
102 | - * @param externalFixedIps External fixed IP information | ||
103 | - * @return Builder object | ||
104 | - */ | ||
105 | - | ||
106 | - public Builder externalFixedIps(Map<String, Ip4Address> externalFixedIps) { | ||
107 | - this.externalFixedIps.putAll(externalFixedIps); | ||
108 | - return this; | ||
109 | - } | ||
110 | - | ||
111 | - /** | ||
112 | - * Builds an OpenstackExternalGateway object. | ||
113 | - * | ||
114 | - * @return OpenstackExternalGateway object | ||
115 | - */ | ||
116 | - public OpenstackExternalGateway build() { | ||
117 | - return new OpenstackExternalGateway(networkId, enablePnat, externalFixedIps); | ||
118 | - } | ||
119 | - } | ||
120 | - | ||
121 | -} |
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 | -} | ||
... | \ 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.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 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/OpenstackRouter.java
deleted
100644 → 0
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 | - public static OpenstackRouter.Builder builder() { | ||
48 | - return new Builder(); | ||
49 | - } | ||
50 | - | ||
51 | - /** | ||
52 | - * Returns tenant ID. | ||
53 | - * | ||
54 | - * @return tenant ID | ||
55 | - */ | ||
56 | - public String tenantId() { | ||
57 | - return tenantId; | ||
58 | - } | ||
59 | - | ||
60 | - /** | ||
61 | - * Returns router ID. | ||
62 | - * | ||
63 | - * @return router ID | ||
64 | - */ | ||
65 | - public String id() { | ||
66 | - return id; | ||
67 | - } | ||
68 | - | ||
69 | - /** | ||
70 | - * Returns router name. | ||
71 | - * | ||
72 | - * @return router name | ||
73 | - */ | ||
74 | - public String name() { | ||
75 | - return name; | ||
76 | - } | ||
77 | - | ||
78 | - /** | ||
79 | - * Returns router status. | ||
80 | - * | ||
81 | - * @return router stauts | ||
82 | - */ | ||
83 | - public RouterStatus status() { | ||
84 | - return status; | ||
85 | - } | ||
86 | - | ||
87 | - /** | ||
88 | - * Returns whether admin state up or not. | ||
89 | - * | ||
90 | - * @return true if admin state up, false otherwise | ||
91 | - */ | ||
92 | - public boolean adminStateUp() { | ||
93 | - return adminStateUp; | ||
94 | - } | ||
95 | - | ||
96 | - /** | ||
97 | - * Returns external gateway information. | ||
98 | - * | ||
99 | - * @return external gateway information | ||
100 | - */ | ||
101 | - public OpenstackExternalGateway gatewayExternalInfo() { | ||
102 | - return gatewayExternalInfo; | ||
103 | - } | ||
104 | - | ||
105 | - /** | ||
106 | - * An Openstack Router Builder class. | ||
107 | - */ | ||
108 | - public static final class Builder { | ||
109 | - | ||
110 | - private String tenantId; | ||
111 | - private String id; | ||
112 | - private String name; | ||
113 | - private RouterStatus status; | ||
114 | - private Boolean adminStateUp; | ||
115 | - private OpenstackExternalGateway gatewayExternalInfo; | ||
116 | - | ||
117 | - /** | ||
118 | - * Sets router ID. | ||
119 | - * | ||
120 | - * @param id router ID | ||
121 | - * @return Builder object | ||
122 | - */ | ||
123 | - public Builder id(String id) { | ||
124 | - this.id = id; | ||
125 | - return this; | ||
126 | - } | ||
127 | - | ||
128 | - /** | ||
129 | - * Sets router name. | ||
130 | - * | ||
131 | - * @param name router name | ||
132 | - * @return Builder object | ||
133 | - */ | ||
134 | - public Builder name(String name) { | ||
135 | - this.name = name; | ||
136 | - return this; | ||
137 | - } | ||
138 | - | ||
139 | - /** | ||
140 | - * Sets router status. | ||
141 | - * | ||
142 | - * @param status router status | ||
143 | - * @return Builder object | ||
144 | - */ | ||
145 | - public Builder status(RouterStatus status) { | ||
146 | - this.status = status; | ||
147 | - return this; | ||
148 | - } | ||
149 | - | ||
150 | - /** | ||
151 | - * Sets tenant ID. | ||
152 | - * | ||
153 | - * @param tenantId Tenant ID | ||
154 | - * @return Builder object | ||
155 | - */ | ||
156 | - public Builder tenantId(String tenantId) { | ||
157 | - this.tenantId = tenantId; | ||
158 | - return this; | ||
159 | - } | ||
160 | - | ||
161 | - /** | ||
162 | - * Sets whether admin state up or not. | ||
163 | - * | ||
164 | - * @param adminStateUp true if admin state is up, false otherwise | ||
165 | - * @return Builder object | ||
166 | - */ | ||
167 | - public Builder adminStateUp(boolean adminStateUp) { | ||
168 | - this.adminStateUp = adminStateUp; | ||
169 | - return this; | ||
170 | - } | ||
171 | - | ||
172 | - /** | ||
173 | - * Sets external gateway information. | ||
174 | - * | ||
175 | - * @param gatewayExternalInfo external gateway information | ||
176 | - * @return Builder object | ||
177 | - */ | ||
178 | - public Builder gatewayExternalInfo(OpenstackExternalGateway gatewayExternalInfo) { | ||
179 | - this.gatewayExternalInfo = gatewayExternalInfo; | ||
180 | - return this; | ||
181 | - } | ||
182 | - | ||
183 | - /** | ||
184 | - * Builds an OpenstackRouter object. | ||
185 | - * | ||
186 | - * @return OpenstasckRouter object | ||
187 | - */ | ||
188 | - public OpenstackRouter build() { | ||
189 | - return new OpenstackRouter(id, tenantId, name, status, | ||
190 | - adminStateUp, gatewayExternalInfo); | ||
191 | - } | ||
192 | - } | ||
193 | - | ||
194 | - | ||
195 | -} |
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 removeRouterInterface(OpenstackRouterInterface openstackRouterInterface) { | ||
128 | - | ||
129 | - } | ||
130 | - private class InternalPacketProcessor implements PacketProcessor { | ||
131 | - | ||
132 | - @Override | ||
133 | - public void process(PacketContext context) { | ||
134 | - | ||
135 | - if (context.isHandled()) { | ||
136 | - return; | ||
137 | - } | ||
138 | - | ||
139 | - InboundPacket pkt = context.inPacket(); | ||
140 | - Ethernet ethernet = pkt.parsed(); | ||
141 | - | ||
142 | - if (ethernet != null && ethernet.getEtherType() == Ethernet.TYPE_IPV4) { | ||
143 | - IPv4 iPacket = (IPv4) ethernet.getPayload(); | ||
144 | - switch (iPacket.getProtocol()) { | ||
145 | - case IPv4.PROTOCOL_ICMP: | ||
146 | - icmpEventExcutorService.execute(new OpenstackIcmpHandler(context)); | ||
147 | - break; | ||
148 | - default: | ||
149 | - l3EventExcutorService.execute(new OpenstackPnatHandler(context)); | ||
150 | - break; | ||
151 | - } | ||
152 | - | ||
153 | - } | ||
154 | - | ||
155 | - | ||
156 | - } | ||
157 | - } | ||
158 | - | ||
159 | -} |
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 removed by Openstack. | ||
81 | - * | ||
82 | - * @param openstackRouterInterface Router information | ||
83 | - */ | ||
84 | - void removeRouterInterface(OpenstackRouterInterface openstackRouterInterface); | ||
85 | - | ||
86 | - | ||
87 | -} |
apps/openstackrouting/src/main/java/org/onosproject/openstackrouting/package-info.java
deleted
100644 → 0
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 |
... | @@ -39,7 +39,7 @@ | ... | @@ -39,7 +39,7 @@ |
39 | <dependencies> | 39 | <dependencies> |
40 | <dependency> | 40 | <dependency> |
41 | <groupId>org.onosproject</groupId> | 41 | <groupId>org.onosproject</groupId> |
42 | - <artifactId>onos-app-openstackrouting</artifactId> | 42 | + <artifactId>onos-app-openstackrouting-api</artifactId> |
43 | <version>${project.version}</version> | 43 | <version>${project.version}</version> |
44 | </dependency> | 44 | </dependency> |
45 | </dependencies> | 45 | </dependencies> | ... | ... |
-
Please register or login to post a comment