Search in sources :

Example 96 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class VirtualPortBindCommand method doExecute.

@Override
protected void doExecute() {
    VirtualNetworkAdminService service = get(VirtualNetworkAdminService.class);
    DeviceService deviceService = get(DeviceService.class);
    VirtualPort vPort = getVirtualPort(PortNumber.portNumber(portNum));
    checkNotNull(vPort, "The virtual Port does not exist");
    ConnectPoint realizedBy = new ConnectPoint(DeviceId.deviceId(physDeviceId), PortNumber.portNumber(physPortNum));
    service.bindVirtualPort(NetworkId.networkId(networkId), DeviceId.deviceId(deviceId), PortNumber.portNumber(portNum), realizedBy);
    print("Virtual port is successfully bound.");
}
Also used : VirtualPort(org.onosproject.incubator.net.virtual.VirtualPort) DeviceService(org.onosproject.net.device.DeviceService) VirtualNetworkAdminService(org.onosproject.incubator.net.virtual.VirtualNetworkAdminService) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 97 with DeviceService

use of org.onosproject.net.device.DeviceService 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 98 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class VirtualNetworkDeviceManagerTest method testGetDeviceByNullType.

/**
 * Tests querying for a device using a null device type.
 */
@Test(expected = NullPointerException.class)
public void testGetDeviceByNullType() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);
    // test the getDevices() method with null type value.
    deviceService.getDevices(null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DeviceService(org.onosproject.net.device.DeviceService) Test(org.junit.Test)

Example 99 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class VirtualNetworkDeviceManagerTest method testGetPortsDeltaStatisticsByNullId.

/**
 * Tests querying the port delta statistics of a device by null device identifier.
 */
@Test(expected = NullPointerException.class)
public void testGetPortsDeltaStatisticsByNullId() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);
    // test the getPortDeltaStatistics() method using a null device identifier
    deviceService.getPortDeltaStatistics(null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DeviceService(org.onosproject.net.device.DeviceService) Test(org.junit.Test)

Example 100 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class VirtualNetworkDeviceManagerTest method testGetRole.

/**
 * Tests querying the role of a device by device identifier.
 */
@Test
public void testGetRole() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);
    // test the getRole() method
    assertEquals("The expect device role did not match.", MastershipRole.MASTER, deviceService.getRole(DID1));
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DeviceService(org.onosproject.net.device.DeviceService) Test(org.junit.Test)

Aggregations

DeviceService (org.onosproject.net.device.DeviceService)187 Device (org.onosproject.net.Device)75 DeviceId (org.onosproject.net.DeviceId)73 Port (org.onosproject.net.Port)59 ConnectPoint (org.onosproject.net.ConnectPoint)42 PortNumber (org.onosproject.net.PortNumber)40 List (java.util.List)30 Collectors (java.util.stream.Collectors)24 Set (java.util.Set)23 AbstractHandlerBehaviour (org.onosproject.net.driver.AbstractHandlerBehaviour)19 Logger (org.slf4j.Logger)19 ArrayList (java.util.ArrayList)18 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)17 Optional (java.util.Optional)17 Test (org.junit.Test)16 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 Collections (java.util.Collections)15 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)15 DriverHandler (org.onosproject.net.driver.DriverHandler)15 Collection (java.util.Collection)14