Search in sources :

Example 11 with TenantId

use of org.onosproject.net.TenantId in project onos by opennetworkinglab.

the class VirtualNetworkWebResource method createVirtualNetwork.

/**
 * Creates a virtual network from the JSON input stream.
 *
 * @param stream tenant identifier JSON stream
 * @return status of the request - CREATED if the JSON is correct,
 * BAD_REQUEST if the JSON is invalid
 * @onos.rsModel TenantId
 */
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createVirtualNetwork(InputStream stream) {
    try {
        final TenantId tid = TenantId.tenantId(getFromJsonStream(stream, "id").asText());
        VirtualNetwork newVnet = vnetAdminService.createVirtualNetwork(tid);
        UriBuilder locationBuilder = uriInfo.getBaseUriBuilder().path("vnets").path(newVnet.id().toString());
        return Response.created(locationBuilder.build()).build();
    } catch (IOException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) TenantId(org.onosproject.net.TenantId) IOException(java.io.IOException) UriBuilder(javax.ws.rs.core.UriBuilder) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 12 with TenantId

use of org.onosproject.net.TenantId in project onos by opennetworkinglab.

the class VirtualNetworkWebResource method getVirtualNetworkById.

/**
 * Returns the virtual networks with the specified tenant identifier.
 *
 * @param tenantId tenant identifier
 * @return 200 OK with a virtual network, 404 not found
 * @onos.rsModel VirtualNetworks
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{tenantId}")
public Response getVirtualNetworkById(@PathParam("tenantId") String tenantId) {
    final TenantId existingTid = TenantWebResource.getExistingTenantId(vnetAdminService, TenantId.tenantId(tenantId));
    Set<VirtualNetwork> vnets = vnetService.getVirtualNetworks(existingTid);
    return ok(encodeArray(VirtualNetwork.class, "vnets", vnets)).build();
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) TenantId(org.onosproject.net.TenantId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 13 with TenantId

use of org.onosproject.net.TenantId in project onos by opennetworkinglab.

the class VirtualNetworkManagerTest method testGetTenantIdForRegisteredVirtualNetwork.

/**
 * Test method {@code getTenantId()} for registered virtual network.
 */
@Test
public void testGetTenantIdForRegisteredVirtualNetwork() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology(tenantIdValue1);
    TenantId tenantId = manager.getTenantId(virtualNetwork.id());
    assertThat(tenantId.toString(), is(tenantIdValue1));
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) TenantId(org.onosproject.net.TenantId) Test(org.junit.Test)

Aggregations

TenantId (org.onosproject.net.TenantId)13 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)7 VirtualNetworkAdminService (org.onosproject.incubator.net.virtual.VirtualNetworkAdminService)4 ArrayList (java.util.ArrayList)3 Produces (javax.ws.rs.Produces)3 DefaultVirtualNetwork (org.onosproject.incubator.net.virtual.DefaultVirtualNetwork)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 UriBuilder (javax.ws.rs.core.UriBuilder)2 StringsCompleter (org.apache.karaf.shell.support.completers.StringsCompleter)2 NetworkId (org.onosproject.incubator.net.virtual.NetworkId)2 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)2 VirtualNetworkService (org.onosproject.incubator.net.virtual.VirtualNetworkService)2 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 Test (org.junit.Test)1 DefaultVirtualDevice (org.onosproject.incubator.net.virtual.DefaultVirtualDevice)1