sangho
Committed by Gerrit Code Review

[ONOS-4280] Allow to add a subnet to external network after the external network is used in routers

Change-Id: Idc41e64c21b9b36422bba67b48027c8a7f337a70
......@@ -233,10 +233,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
@Override
public void updateRouter(OpenstackRouter openstackRouter) {
if (openstackRouter.gatewayExternalInfo().externalFixedIps().size() > 0) {
Ip4Address externalIp = openstackRouter.gatewayExternalInfo().externalFixedIps()
.values().stream().findFirst().orElse(null);
OpenstackRouter router = getRouterfromExternalIp(externalIp);
checkExternalConnection(router, getOpenstackRouterInterface(router));
checkExternalConnection(openstackRouter, getOpenstackRouterInterface(openstackRouter));
} else {
unsetExternalConnection();
}
......
......@@ -81,18 +81,25 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
@Path("{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateRouter(InputStream input) {
public Response updateRouter(@PathParam("id") String id, InputStream input) {
checkNotNull(input);
try {
ObjectMapper mapper = new ObjectMapper();
ObjectNode routerNode = (ObjectNode) mapper.readTree(input);
OpenstackRouter openstackRouter
= ROUTER_CODEC.decode(routerNode, this);
OpenstackRouter or = ROUTER_CODEC.decode(routerNode, this);
OpenstackRouter.Builder osBuilder = new OpenstackRouter.Builder()
.tenantId(or.tenantId())
.id(id)
.name(or.name())
.status(OpenstackRouter.RouterStatus.ACTIVE)
.adminStateUp(Boolean.valueOf(or.adminStateUp()))
.gatewayExternalInfo(or.gatewayExternalInfo());
OpenstackRoutingService routingService
= getService(OpenstackRoutingService.class);
routingService.updateRouter(openstackRouter);
routingService.updateRouter(osBuilder.build());
log.debug("REST API UPDATE router is called from router {}", input.toString());
return Response.status(Response.Status.OK).build();
......@@ -108,7 +115,7 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
@Path("{id}/add_router_interface")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response addRouterInterface(InputStream input) {
public Response addRouterInterface(@PathParam("id") String id, InputStream input) {
checkNotNull(input);
try {
ObjectMapper mapper = new ObjectMapper();
......