use of org.openstack4j.openstack.networking.domain.NeutronNetwork in project onos by opennetworkinglab.
the class OpenstackNetworkWebResource method createNetwork.
/**
* Creates a network from the JSON input stream.
*
* @param input network JSON input stream
* @return 201 CREATED if the JSON is correct, 400 BAD_REQUEST if the JSON
* is invalid or duplicated network already exists
* @throws IOException exception
* @onos.rsModel NeutronNetwork
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createNetwork(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, NETWORKS, inputStr);
}
final NeutronNetwork net = (NeutronNetwork) jsonToModelEntity(inputStr, NeutronNetwork.class);
adminService.createNetwork(net);
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder().path(NETWORKS).path(net.getId());
return created(locationBuilder.build()).build();
}
use of org.openstack4j.openstack.networking.domain.NeutronNetwork in project onos by opennetworkinglab.
the class OpenstackNetworkWebResource method updateNetwork.
/**
* Updates the network with the specified identifier.
*
* @param id network identifier
* @param input network JSON input stream
* @return 200 OK with the updated network, 400 BAD_REQUEST if the requested
* network does not exist
* @throws IOException exception
* @onos.rsModel NeutronNetwork
*/
@PUT
@Path("{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateNetwork(@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, NETWORKS, id, inputStr);
}
final NeutronNetwork net = (NeutronNetwork) jsonToModelEntity(inputStr, NeutronNetwork.class);
adminService.updateNetwork(net);
return status(Response.Status.OK).build();
}
Aggregations