Search in sources :

Example 26 with VirtualDevice

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

the class VirtualPortCreateCommand method doExecute.

@Override
protected void doExecute() {
    VirtualNetworkAdminService service = get(VirtualNetworkAdminService.class);
    DeviceService deviceService = get(DeviceService.class);
    VirtualDevice virtualDevice = getVirtualDevice(DeviceId.deviceId(deviceId));
    checkNotNull(virtualDevice, "The virtual device does not exist.");
    ConnectPoint realizedBy = null;
    if (physDeviceId != null && physPortNum != null) {
        checkNotNull(physPortNum, "The physical port does not specified.");
        realizedBy = new ConnectPoint(DeviceId.deviceId(physDeviceId), PortNumber.portNumber(physPortNum));
        checkNotNull(realizedBy, "The physical port does not exist.");
    }
    service.createVirtualPort(NetworkId.networkId(networkId), DeviceId.deviceId(deviceId), PortNumber.portNumber(portNum), realizedBy);
    print("Virtual port successfully created.");
}
Also used : DeviceService(org.onosproject.net.device.DeviceService) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) VirtualNetworkAdminService(org.onosproject.incubator.net.virtual.VirtualNetworkAdminService) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 27 with VirtualDevice

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

the class VirtualDeviceListCommand method getSortedVirtualDevices.

/**
 * Returns the list of virtual devices sorted using the device identifier.
 *
 * @return sorted virtual device list
 */
private List<VirtualDevice> getSortedVirtualDevices() {
    VirtualNetworkService service = get(VirtualNetworkService.class);
    List<VirtualDevice> virtualDevices = new ArrayList<>();
    virtualDevices.addAll(service.getVirtualDevices(NetworkId.networkId(networkId)));
    Collections.sort(virtualDevices, Comparators.VIRTUAL_DEVICE_COMPARATOR);
    return virtualDevices;
}
Also used : VirtualNetworkService(org.onosproject.incubator.net.virtual.VirtualNetworkService) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) ArrayList(java.util.ArrayList)

Example 28 with VirtualDevice

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

the class VirtualNetworkDeviceManagerTest method testGetPorts.

/**
 * Tests querying the ports of a device by device identifier.
 */
@Test
public void testGetPorts() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1);
    manager.createVirtualDevice(virtualNetwork.id(), DID2);
    DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);
    ConnectPoint cp = new ConnectPoint(virtualDevice.id(), PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice.id(), PortNumber.portNumber(1), cp);
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice.id(), PortNumber.portNumber(2), cp);
    // test the getPorts() method
    assertEquals("The port set size did not match.", 2, deviceService.getPorts(DID1).size());
    assertEquals("The port set size did not match.", 0, deviceService.getPorts(DID2).size());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) DeviceService(org.onosproject.net.device.DeviceService) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 29 with VirtualDevice

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

the class VirtualNetworkDeviceManagerTest method testGetDevices.

/**
 * Tests the getDevices(), getAvailableDevices(), getDeviceCount(), getDevice(), and isAvailable() methods.
 */
@Test
public void testGetDevices() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice device1 = manager.createVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice device2 = manager.createVirtualDevice(virtualNetwork.id(), DID2);
    DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);
    // test the getDevices() method
    Iterator<Device> it = deviceService.getDevices().iterator();
    assertEquals("The device set size did not match.", 2, Iterators.size(it));
    // test the getAvailableDevices() method
    Iterator<Device> it2 = deviceService.getAvailableDevices().iterator();
    assertEquals("The device set size did not match.", 2, Iterators.size(it2));
    // test the getDeviceCount() method
    assertEquals("The device set size did not match.", 2, deviceService.getDeviceCount());
    // test the getDevice() method
    assertEquals("The expect device did not match.", device1, deviceService.getDevice(DID1));
    assertNotEquals("The expect device should not have matched.", device1, deviceService.getDevice(DID2));
    // test the isAvailable() method
    assertTrue("The expect device availability did not match.", deviceService.isAvailable(DID1));
    assertFalse("The expect device availability did not match.", deviceService.isAvailable(DID3));
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Device(org.onosproject.net.Device) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) DeviceService(org.onosproject.net.device.DeviceService) Test(org.junit.Test)

Example 30 with VirtualDevice

use of org.onosproject.incubator.net.virtual.VirtualDevice 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)

Aggregations

VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)51 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)39 Test (org.junit.Test)29 ConnectPoint (org.onosproject.net.ConnectPoint)27 TopologyService (org.onosproject.net.topology.TopologyService)13 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)12 Topology (org.onosproject.net.topology.Topology)12 DefaultVirtualNetwork (org.onosproject.incubator.net.virtual.DefaultVirtualNetwork)11 VirtualPort (org.onosproject.incubator.net.virtual.VirtualPort)9 DisjointPath (org.onosproject.net.DisjointPath)9 VirtualNetworkService (org.onosproject.incubator.net.virtual.VirtualNetworkService)7 DeviceService (org.onosproject.net.device.DeviceService)7 HashSet (java.util.HashSet)6 DefaultVirtualDevice (org.onosproject.incubator.net.virtual.DefaultVirtualDevice)6 NetworkId (org.onosproject.incubator.net.virtual.NetworkId)6 DeviceId (org.onosproject.net.DeviceId)6 ArrayList (java.util.ArrayList)5 DefaultVirtualPort (org.onosproject.incubator.net.virtual.DefaultVirtualPort)5 VirtualHost (org.onosproject.incubator.net.virtual.VirtualHost)4 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)3