Committed by
Gerrit Code Review
Fixed to add the subNetCidr of flow when deleted.
Change-Id: I2eb10b3222e63c1f53a4bb52d35bebc2de81a992
Showing
2 changed files
with
11 additions
and
6 deletions
... | @@ -137,7 +137,11 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst | ... | @@ -137,7 +137,11 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst |
137 | openstackService.ports().stream() | 137 | openstackService.ports().stream() |
138 | .filter(osPort -> osPort.deviceOwner().equals(DEVICE_OWNER_ROUTER_INTERFACE) && | 138 | .filter(osPort -> osPort.deviceOwner().equals(DEVICE_OWNER_ROUTER_INTERFACE) && |
139 | osPort.deviceId().equals(osRouter.id())) | 139 | osPort.deviceId().equals(osRouter.id())) |
140 | - .forEach(osPort -> unsetExternalConnection(osRouter, osPort.networkId())); | 140 | + .forEach(osPort -> { |
141 | + String subnetId = osPort.fixedIps().keySet().stream().findFirst().get(); | ||
142 | + OpenstackSubnet osSubNet = openstackService.subnet(subnetId); | ||
143 | + unsetExternalConnection(osRouter, osPort.networkId(), osSubNet.cidr()); | ||
144 | + }); | ||
141 | 145 | ||
142 | log.info("Disconnected external gateway from router {}", | 146 | log.info("Disconnected external gateway from router {}", |
143 | osRouter.name()); | 147 | osRouter.name()); |
... | @@ -184,7 +188,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst | ... | @@ -184,7 +188,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst |
184 | unsetRoutes(osRouter, osSubnet); | 188 | unsetRoutes(osRouter, osSubnet); |
185 | 189 | ||
186 | if (osRouter.gatewayExternalInfo().externalFixedIps().size() > 0) { | 190 | if (osRouter.gatewayExternalInfo().externalFixedIps().size() > 0) { |
187 | - unsetExternalConnection(osRouter, osNet.id()); | 191 | + unsetExternalConnection(osRouter, osNet.id(), osSubnet.cidr()); |
188 | } | 192 | } |
189 | log.info("Disconnected {} from router {}", osSubnet.cidr(), osRouter.name()); | 193 | log.info("Disconnected {} from router {}", osSubnet.cidr(), osRouter.name()); |
190 | } | 194 | } |
... | @@ -250,7 +254,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst | ... | @@ -250,7 +254,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst |
250 | populateExternalRules(osNet, osSubNet); | 254 | populateExternalRules(osNet, osSubNet); |
251 | } | 255 | } |
252 | 256 | ||
253 | - private void unsetExternalConnection(OpenstackRouter osRouter, String osNetId) { | 257 | + private void unsetExternalConnection(OpenstackRouter osRouter, String osNetId, String subNetCidr) { |
254 | if (!osRouter.gatewayExternalInfo().isEnablePnat()) { | 258 | if (!osRouter.gatewayExternalInfo().isEnablePnat()) { |
255 | log.debug("Source NAT is disabled"); | 259 | log.debug("Source NAT is disabled"); |
256 | return; | 260 | return; |
... | @@ -258,7 +262,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst | ... | @@ -258,7 +262,7 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst |
258 | 262 | ||
259 | // FIXME router interface is subnet specific, not network | 263 | // FIXME router interface is subnet specific, not network |
260 | OpenstackNetwork osNet = openstackService.network(osNetId); | 264 | OpenstackNetwork osNet = openstackService.network(osNetId); |
261 | - removeExternalRules(osNet); | 265 | + removeExternalRules(osNet, subNetCidr); |
262 | } | 266 | } |
263 | 267 | ||
264 | private void setRoutes(OpenstackRouter osRouter, Optional<Host> host) { | 268 | private void setRoutes(OpenstackRouter osRouter, Optional<Host> host) { |
... | @@ -324,10 +328,11 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst | ... | @@ -324,10 +328,11 @@ public class OpenstackRoutingManager extends AbstractVmHandler implements Openst |
324 | populateGatewayToController(Long.valueOf(osNet.segmentId()), osSubNet.cidr()); | 328 | populateGatewayToController(Long.valueOf(osNet.segmentId()), osSubNet.cidr()); |
325 | } | 329 | } |
326 | 330 | ||
327 | - private void removeExternalRules(OpenstackNetwork osNet) { | 331 | + private void removeExternalRules(OpenstackNetwork osNet, String subNetCidr) { |
328 | TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder(); | 332 | TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder(); |
329 | sBuilder.matchEthType(Ethernet.TYPE_IPV4) | 333 | sBuilder.matchEthType(Ethernet.TYPE_IPV4) |
330 | .matchTunnelId(Long.valueOf(osNet.segmentId())) | 334 | .matchTunnelId(Long.valueOf(osNet.segmentId())) |
335 | + .matchIPSrc(IpPrefix.valueOf(subNetCidr)) | ||
331 | .matchEthDst(Constants.DEFAULT_GATEWAY_MAC); | 336 | .matchEthDst(Constants.DEFAULT_GATEWAY_MAC); |
332 | 337 | ||
333 | nodeService.completeNodes().forEach(node -> { | 338 | nodeService.completeNodes().forEach(node -> { | ... | ... |
... | @@ -57,7 +57,7 @@ public class OpenstackPortWebResource extends AbstractWebResource { | ... | @@ -57,7 +57,7 @@ public class OpenstackPortWebResource extends AbstractWebResource { |
57 | 57 | ||
58 | @Path("{portUUID}") | 58 | @Path("{portUUID}") |
59 | @DELETE | 59 | @DELETE |
60 | - @Produces(MediaType.APPLICATION_JSON) | 60 | + @Consumes(MediaType.APPLICATION_JSON) |
61 | public Response deletePorts(@PathParam("portUUID") String id) { | 61 | public Response deletePorts(@PathParam("portUUID") String id) { |
62 | return Response.noContent().build(); | 62 | return Response.noContent().build(); |
63 | } | 63 | } | ... | ... |
-
Please register or login to post a comment