Search in sources :

Example 6 with OpenstackVtapNetwork

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();
}
Also used : OpenstackVtapNetwork(org.onosproject.openstackvtap.api.OpenstackVtapNetwork) Consumes(javax.ws.rs.Consumes) INDENT_OUTPUT(com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT) PUT(javax.ws.rs.PUT)

Example 7 with OpenstackVtapNetwork

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;
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) OpenstackVtapNetwork(org.onosproject.openstackvtap.api.OpenstackVtapNetwork) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 8 with OpenstackVtapNetwork

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));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultOpenstackVtapNetwork(org.onosproject.openstackvtap.impl.DefaultOpenstackVtapNetwork) OpenstackVtapNetwork(org.onosproject.openstackvtap.api.OpenstackVtapNetwork) Test(org.junit.Test)

Aggregations

OpenstackVtapNetwork (org.onosproject.openstackvtap.api.OpenstackVtapNetwork)8 Consumes (javax.ws.rs.Consumes)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Test (org.junit.Test)2 INDENT_OUTPUT (com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Dictionary (java.util.Dictionary)1 List (java.util.List)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Executors.newSingleThreadScheduledExecutor (java.util.concurrent.Executors.newSingleThreadScheduledExecutor)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Collectors (java.util.stream.Collectors)1 StreamSupport (java.util.stream.StreamSupport)1 GET (javax.ws.rs.GET)1