Search in sources :

Example 41 with NetworkId

use of org.onosproject.incubator.net.virtual.NetworkId in project onos by opennetworkinglab.

the class VirtualNetworkWebResource method removeVirtualNetwork.

/**
 * Removes the virtual network with the specified network identifier.
 *
 * @param networkId network identifier
 * @return 204 NO CONTENT
 */
@DELETE
@Path("{networkId}")
public Response removeVirtualNetwork(@PathParam("networkId") long networkId) {
    NetworkId nid = NetworkId.networkId(networkId);
    vnetAdminService.removeVirtualNetwork(nid);
    return Response.noContent().build();
}
Also used : NetworkId(org.onosproject.incubator.net.virtual.NetworkId) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 42 with NetworkId

use of org.onosproject.incubator.net.virtual.NetworkId in project onos by opennetworkinglab.

the class VirtualNetworkWebResource method getVirtualPorts.

// VirtualPort
/**
 * Returns all virtual network ports in a virtual device in a virtual network.
 *
 * @param networkId network identifier
 * @param deviceId  virtual device identifier
 * @return 200 OK with set of virtual ports, 404 not found
 * @onos.rsModel VirtualPorts
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{networkId}/devices/{deviceId}/ports")
public Response getVirtualPorts(@PathParam("networkId") long networkId, @PathParam("deviceId") String deviceId) {
    NetworkId nid = NetworkId.networkId(networkId);
    Iterable<VirtualPort> vports = vnetService.getVirtualPorts(nid, DeviceId.deviceId(deviceId));
    return ok(encodeArray(VirtualPort.class, "ports", vports)).build();
}
Also used : VirtualPort(org.onosproject.incubator.net.virtual.VirtualPort) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 43 with NetworkId

use of org.onosproject.incubator.net.virtual.NetworkId in project onos by opennetworkinglab.

the class VirtualNetworkWebResource method getVirtualDevices.

// VirtualDevice
/**
 * Returns all virtual network devices in a virtual network.
 *
 * @param networkId network identifier
 * @return 200 OK with set of virtual devices, 404 not found
 * @onos.rsModel VirtualDevices
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{networkId}/devices")
public Response getVirtualDevices(@PathParam("networkId") long networkId) {
    NetworkId nid = NetworkId.networkId(networkId);
    Set<VirtualDevice> vdevs = vnetService.getVirtualDevices(nid);
    return ok(encodeArray(VirtualDevice.class, "devices", vdevs)).build();
}
Also used : VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 44 with NetworkId

use of org.onosproject.incubator.net.virtual.NetworkId in project onos by opennetworkinglab.

the class VirtualNetworkWebResource method removeVirtualPort.

/**
 * Removes the virtual network port from the virtual device in a virtual network.
 *
 * @param networkId network identifier
 * @param deviceId  virtual device identifier
 * @param portNum   virtual port number
 * @return 204 NO CONTENT
 */
@DELETE
@Path("{networkId}/devices/{deviceId}/ports/{portNum}")
public Response removeVirtualPort(@PathParam("networkId") long networkId, @PathParam("deviceId") String deviceId, @PathParam("portNum") long portNum) {
    NetworkId nid = NetworkId.networkId(networkId);
    vnetAdminService.removeVirtualPort(nid, DeviceId.deviceId(deviceId), PortNumber.portNumber(portNum));
    return Response.noContent().build();
}
Also used : NetworkId(org.onosproject.incubator.net.virtual.NetworkId) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 45 with NetworkId

use of org.onosproject.incubator.net.virtual.NetworkId in project onos by opennetworkinglab.

the class VirtualNetworkWebResource method getVirtualHosts.

/**
 * Returns all virtual network hosts in a virtual network.
 *
 * @param networkId network identifier
 * @return 200 OK with set of virtual network hosts
 * @onos.rsModel VirtualHosts
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{networkId}/hosts")
public Response getVirtualHosts(@PathParam("networkId") long networkId) {
    NetworkId nid = NetworkId.networkId(networkId);
    Set<VirtualHost> vhosts = vnetService.getVirtualHosts(nid);
    return ok(encodeArray(VirtualHost.class, "hosts", vhosts)).build();
}
Also used : VirtualHost(org.onosproject.incubator.net.virtual.VirtualHost) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

NetworkId (org.onosproject.incubator.net.virtual.NetworkId)50 DeviceId (org.onosproject.net.DeviceId)23 Test (org.junit.Test)21 WebTarget (javax.ws.rs.client.WebTarget)20 Matchers.containsString (org.hamcrest.Matchers.containsString)20 HostResourceTest (org.onosproject.rest.resources.HostResourceTest)20 LinksResourceTest (org.onosproject.rest.resources.LinksResourceTest)20 ResourceTest (org.onosproject.rest.resources.ResourceTest)20 Activate (org.osgi.service.component.annotations.Activate)11 Logger (org.slf4j.Logger)11 LoggerFactory.getLogger (org.slf4j.LoggerFactory.getLogger)11 Set (java.util.Set)10 Component (org.osgi.service.component.annotations.Component)10 Deactivate (org.osgi.service.component.annotations.Deactivate)10 HashSet (java.util.HashSet)9 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)9 ConnectPoint (org.onosproject.net.ConnectPoint)9 PortNumber (org.onosproject.net.PortNumber)9 Reference (org.osgi.service.component.annotations.Reference)9 ReferenceCardinality (org.osgi.service.component.annotations.ReferenceCardinality)9