use of org.openstack4j.openstack.networking.domain.NeutronRouter in project onos by opennetworkinglab.
the class OpenstackRouterWebResource method updateRouter.
/**
* Updates the router with the specified identifier.
*
* @param id router identifier
* @param input router JSON input stream
* @return 200 OK with the updated router, 400 BAD_REQUEST if the requested
* router does not exist
* @throws IOException exception
* @onos.rsModel NeutronRouter
*/
@PUT
@Path("{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateRouter(@PathParam("id") String id, InputStream input) throws IOException {
log.trace(String.format(MESSAGE_ROUTER, "UPDATE " + id));
String inputStr = IOUtils.toString(input, REST_UTF8);
if (!haService.isActive() && !DEFAULT_ACTIVE_IP_ADDRESS.equals(haService.getActiveIp())) {
return syncPut(haService, ROUTERS, id, inputStr);
}
final NeutronRouter osRouter = (NeutronRouter) jsonToModelEntity(inputStr, NeutronRouter.class);
osRouter.setId(id);
adminService.updateRouter(osRouter);
return status(Response.Status.OK).build();
}
use of org.openstack4j.openstack.networking.domain.NeutronRouter in project onos by opennetworkinglab.
the class OpenstackRouterWebResource method createRouter.
/**
* Creates a router from the JSON input stream.
*
* @param input router JSON input stream
* @return 201 CREATED if the JSON is correct, 400 BAD_REQUEST if the JSON
* is invalid or duplicated router already exists
* @throws IOException exception
* @onos.rsModel NeutronRouter
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createRouter(InputStream input) throws IOException {
log.trace(String.format(MESSAGE_ROUTER, "CREATE"));
String inputStr = IOUtils.toString(input, REST_UTF8);
if (!haService.isActive() && !DEFAULT_ACTIVE_IP_ADDRESS.equals(haService.getActiveIp())) {
return syncPost(haService, ROUTERS, inputStr);
}
final NeutronRouter osRouter = (NeutronRouter) jsonToModelEntity(inputStr, NeutronRouter.class);
adminService.createRouter(osRouter);
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder().path(ROUTERS).path(osRouter.getId());
return created(locationBuilder.build()).build();
}
Aggregations