use of org.onosproject.openstackvtap.api.OpenstackVtapNetwork in project onos by opennetworkinglab.
the class OpenstackVtapNetworkWebResource method updateNetwork.
/**
* Updates openstack vtap network from the JSON input stream.
*
* @param input openstack vtap network JSON input stream
* @return 200 OK on updating success
* 400 BAD_REQUEST if the JSON is malformed
* 404 NOT_FOUND if openstack vtap network is not exists
* @onos.rsModel OpenstackVtapNetwork
*/
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public Response updateNetwork(InputStream input) {
log.info(MESSAGE_NETWORK, UPDATE);
OpenstackVtapNetwork vtapNetwork = readNetworkConfiguration(input);
if (vtapNetwork == null) {
return Response.status(Response.Status.BAD_REQUEST).build();
}
if (vtapService.updateVtapNetwork(vtapNetwork) == null) {
log.warn(ERROR_NOTFOUND, vtapNetwork);
return Response.status(Response.Status.NOT_FOUND).build();
}
return Response.ok().build();
}
use of org.onosproject.openstackvtap.api.OpenstackVtapNetwork in project onos by opennetworkinglab.
the class OpenstackVtapNetworkWebResource method readNetworkConfiguration.
private OpenstackVtapNetwork readNetworkConfiguration(InputStream input) {
try {
JsonNode jsonTree = readTreeFromStream(mapper().enable(INDENT_OUTPUT), input);
ObjectNode vtap = (ObjectNode) jsonTree.get(NETWORK);
return codec(OpenstackVtapNetwork.class).decode(vtap, this);
} catch (Exception e) {
log.error(e.toString());
return null;
}
}
use of org.onosproject.openstackvtap.api.OpenstackVtapNetwork in project onos by opennetworkinglab.
the class OpenstackVtapNetworkCodecTest method testEncode.
/**
* Tests the openstack vtap network encoding.
*/
@Test
public void testEncode() {
OpenstackVtapNetwork vtapNetwork = DefaultOpenstackVtapNetwork.builder().mode(MODE).networkId(VNI).serverIp(IpAddress.valueOf(SERVER_IP_ADDRESS)).build();
ObjectNode nodeJson = vtapNetworkCodec.encode(vtapNetwork, context);
assertThat(nodeJson, matchesVtapNetwork(vtapNetwork));
}
Aggregations