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 { ...@@ -233,10 +233,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
233 @Override 233 @Override
234 public void updateRouter(OpenstackRouter openstackRouter) { 234 public void updateRouter(OpenstackRouter openstackRouter) {
235 if (openstackRouter.gatewayExternalInfo().externalFixedIps().size() > 0) { 235 if (openstackRouter.gatewayExternalInfo().externalFixedIps().size() > 0) {
236 - Ip4Address externalIp = openstackRouter.gatewayExternalInfo().externalFixedIps() 236 + checkExternalConnection(openstackRouter, getOpenstackRouterInterface(openstackRouter));
237 - .values().stream().findFirst().orElse(null);
238 - OpenstackRouter router = getRouterfromExternalIp(externalIp);
239 - checkExternalConnection(router, getOpenstackRouterInterface(router));
240 } else { 237 } else {
241 unsetExternalConnection(); 238 unsetExternalConnection();
242 } 239 }
......
...@@ -81,18 +81,25 @@ public class OpensatckRouterWebResource extends AbstractWebResource { ...@@ -81,18 +81,25 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
81 @Path("{id}") 81 @Path("{id}")
82 @Consumes(MediaType.APPLICATION_JSON) 82 @Consumes(MediaType.APPLICATION_JSON)
83 @Produces(MediaType.APPLICATION_JSON) 83 @Produces(MediaType.APPLICATION_JSON)
84 - public Response updateRouter(InputStream input) { 84 + public Response updateRouter(@PathParam("id") String id, InputStream input) {
85 checkNotNull(input); 85 checkNotNull(input);
86 try { 86 try {
87 ObjectMapper mapper = new ObjectMapper(); 87 ObjectMapper mapper = new ObjectMapper();
88 ObjectNode routerNode = (ObjectNode) mapper.readTree(input); 88 ObjectNode routerNode = (ObjectNode) mapper.readTree(input);
89 89
90 - OpenstackRouter openstackRouter 90 + OpenstackRouter or = ROUTER_CODEC.decode(routerNode, this);
91 - = ROUTER_CODEC.decode(routerNode, this); 91 +
92 + OpenstackRouter.Builder osBuilder = new OpenstackRouter.Builder()
93 + .tenantId(or.tenantId())
94 + .id(id)
95 + .name(or.name())
96 + .status(OpenstackRouter.RouterStatus.ACTIVE)
97 + .adminStateUp(Boolean.valueOf(or.adminStateUp()))
98 + .gatewayExternalInfo(or.gatewayExternalInfo());
92 99
93 OpenstackRoutingService routingService 100 OpenstackRoutingService routingService
94 = getService(OpenstackRoutingService.class); 101 = getService(OpenstackRoutingService.class);
95 - routingService.updateRouter(openstackRouter); 102 + routingService.updateRouter(osBuilder.build());
96 103
97 log.debug("REST API UPDATE router is called from router {}", input.toString()); 104 log.debug("REST API UPDATE router is called from router {}", input.toString());
98 return Response.status(Response.Status.OK).build(); 105 return Response.status(Response.Status.OK).build();
...@@ -108,7 +115,7 @@ public class OpensatckRouterWebResource extends AbstractWebResource { ...@@ -108,7 +115,7 @@ public class OpensatckRouterWebResource extends AbstractWebResource {
108 @Path("{id}/add_router_interface") 115 @Path("{id}/add_router_interface")
109 @Consumes(MediaType.APPLICATION_JSON) 116 @Consumes(MediaType.APPLICATION_JSON)
110 @Produces(MediaType.APPLICATION_JSON) 117 @Produces(MediaType.APPLICATION_JSON)
111 - public Response addRouterInterface(InputStream input) { 118 + public Response addRouterInterface(@PathParam("id") String id, InputStream input) {
112 checkNotNull(input); 119 checkNotNull(input);
113 try { 120 try {
114 ObjectMapper mapper = new ObjectMapper(); 121 ObjectMapper mapper = new ObjectMapper();
......