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