Search in sources :

Example 1 with NeutronSubnet

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();
}
Also used : NeutronSubnet(org.openstack4j.openstack.networking.domain.NeutronSubnet) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 2 with NeutronSubnet

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();
}
Also used : NeutronSubnet(org.openstack4j.openstack.networking.domain.NeutronSubnet) UriBuilder(javax.ws.rs.core.UriBuilder) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

Consumes (javax.ws.rs.Consumes)2 Produces (javax.ws.rs.Produces)2 NeutronSubnet (org.openstack4j.openstack.networking.domain.NeutronSubnet)2 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 UriBuilder (javax.ws.rs.core.UriBuilder)1