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);
}
}
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();
}
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));
}
Aggregations