Search in sources :

Example 26 with DeviceDescription

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

the class DeviceDiscoveryTest method deviceDescriptionTest.

@Test
public void deviceDescriptionTest() {
    Ciena5162DeviceDescription targetUnderTest = new Ciena5162DeviceDescription();
    Ciena5162DeviceDescription.TEMPLATE_MANAGER.setRequestDriver(mockRequestDriver);
    targetUnderTest.setHandler(mockDriverHandlers.get(DeviceId.deviceId("netconf:1.2.3.4:830")));
    DeviceDescription desc = targetUnderTest.discoverDeviceDetails();
    assertEquals("Chassis ID", "1C1161EDB480", desc.chassisId().toString().toUpperCase());
    assertEquals("Manufacturer", "Ciena", desc.manufacturer());
    assertEquals("HW Version", "5162", desc.hwVersion());
    assertEquals("Serial Number", "M9258605", desc.serialNumber());
    assertEquals("SW Version", "saos-01-01-00-0025", desc.swVersion());
}
Also used : DeviceDescription(org.onosproject.net.device.DeviceDescription) Test(org.junit.Test)

Example 27 with DeviceDescription

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

the class DeviceDiscoveryTest method deviceDescriptionTest.

@Test
public void deviceDescriptionTest() {
    Ciena5170DeviceDescription targetUnderTest = new Ciena5170DeviceDescription();
    Ciena5170DeviceDescription.TEMPLATE_MANAGER.setRequestDriver(mockRequestDriver);
    targetUnderTest.setHandler(mockDriverHandlers.get(DeviceId.deviceId("netconf:1.2.3.4:830")));
    DeviceDescription desc = targetUnderTest.discoverDeviceDetails();
    assertEquals("Chassis ID", "1C1161D18800", desc.chassisId().toString().toUpperCase());
    assertEquals("Manufacturer", "Ciena", desc.manufacturer());
    assertEquals("HW Version", "CN5170", desc.hwVersion());
    assertEquals("Serial Number", "1C1161D18800", desc.serialNumber());
    assertEquals("SW Version", "saos-01-01-00-0025", desc.swVersion());
}
Also used : DeviceDescription(org.onosproject.net.device.DeviceDescription) Test(org.junit.Test)

Example 28 with DeviceDescription

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

the class RestDeviceProvider method scheduleDevicePolling.

private ScheduledFuture scheduleDevicePolling() {
    return deviceConnectionExecutor.scheduleWithFixedDelay(() -> {
        try {
            controller.getDevices().values().stream().forEach(restSBDevice -> {
                DeviceId deviceId = restSBDevice.deviceId();
                if (deviceService.getDevice(deviceId) != null) {
                    boolean connected = testDeviceConnection(restSBDevice);
                    restSBDevice.setActive(connected);
                    if (deviceService.isAvailable(deviceId) && (!connected)) {
                        providerService.deviceDisconnected(deviceId);
                    } else if (!deviceService.isAvailable(deviceId) && connected) {
                        DeviceDescription devDesc = getDesc(restSBDevice);
                        checkNotNull(devDesc, "deviceDescription cannot be null");
                        providerService.deviceConnected(deviceId, mergeAnn(deviceId, devDesc));
                    }
                }
            });
        } catch (Exception e) {
            log.error("Exception at schedule Device polling", e);
        }
    }, 1, pollFrequency, TimeUnit.SECONDS);
}
Also used : DeviceDescription(org.onosproject.net.device.DeviceDescription) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceId(org.onosproject.net.DeviceId) TimeoutException(java.util.concurrent.TimeoutException) ProcessingException(javax.ws.rs.ProcessingException) ExecutionException(java.util.concurrent.ExecutionException)

Example 29 with DeviceDescription

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

the class RestDeviceProvider method deviceAdded.

private void deviceAdded(RestSBDevice restSBDev) {
    checkNotNull(restSBDev, DEVICENULL);
    Driver driver = getDriver(restSBDev);
    // Check if the server is controlling a single or multiple devices
    if (restSBDev.isProxy()) {
        if (driver.hasBehaviour(DevicesDiscovery.class)) {
            DevicesDiscovery devicesDiscovery = devicesDiscovery(restSBDev, driver);
            Set<DeviceId> deviceIds = devicesDiscovery.deviceIds();
            restSBDev.setActive(true);
            deviceIds.forEach(deviceId -> {
                controller.addProxiedDevice(deviceId, restSBDev);
                DeviceDescription devDesc = devicesDiscovery.deviceDetails(deviceId);
                checkNotNull(devDesc, "DeviceDescription cannot be null");
                providerService.deviceConnected(deviceId, mergeAnn(restSBDev.deviceId(), devDesc));
                if (driver.hasBehaviour(DeviceDescriptionDiscovery.class)) {
                    DriverHandler h = driverService.createHandler(deviceId);
                    DeviceDescriptionDiscovery devDisc = h.behaviour(DeviceDescriptionDiscovery.class);
                    providerService.updatePorts(deviceId, devDisc.discoverPortDetails());
                }
                checkAndUpdateDevice(deviceId);
            });
        } else {
            log.warn("Device is proxy but driver does not have proxy discovery behaviour {}", restSBDev);
        }
    } else {
        DeviceId deviceId = restSBDev.deviceId();
        if (driver != null && driver.hasBehaviour(DevicesDiscovery.class)) {
            restSBDev.setActive(true);
            DevicesDiscovery devicesDiscovery = devicesDiscovery(restSBDev, driver);
            DeviceDescription deviceDescription = devicesDiscovery.deviceDetails(deviceId);
            checkNotNull(deviceDescription, "DeviceDescription cannot be null");
            providerService.deviceConnected(deviceId, deviceDescription);
            if (driver.hasBehaviour(DeviceDescriptionDiscovery.class)) {
                DriverHandler h = driverService.createHandler(deviceId);
                DeviceDescriptionDiscovery deviceDiscovery = h.behaviour(DeviceDescriptionDiscovery.class);
                providerService.updatePorts(deviceId, deviceDiscovery.discoverPortDetails());
            }
        } else {
            DeviceDescription deviceDescription = getDesc(restSBDev);
            restSBDev.setActive(true);
            providerService.deviceConnected(deviceId, deviceDescription);
        }
        checkAndUpdateDevice(deviceId);
    }
}
Also used : DeviceDescription(org.onosproject.net.device.DeviceDescription) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescriptionDiscovery(org.onosproject.net.device.DeviceDescriptionDiscovery) DeviceId(org.onosproject.net.DeviceId) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) DriverHandler(org.onosproject.net.driver.DriverHandler) Driver(org.onosproject.net.driver.Driver) DevicesDiscovery(org.onosproject.net.behaviour.DevicesDiscovery)

Example 30 with DeviceDescription

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

the class XmppDeviceProvider method connectDevice.

private void connectDevice(XmppDeviceId xmppDeviceId) {
    DeviceId deviceId = DeviceId.deviceId(xmppDeviceId.id());
    String ipAddress = controller.getDevice(xmppDeviceId).getIpAddress().getAddress().getHostAddress();
    // Assumption: manufacturer is uniquely identified by domain part of JID
    String manufacturer = xmppDeviceId.getJid().getDomain();
    ChassisId cid = new ChassisId();
    SparseAnnotations annotations = DefaultAnnotations.builder().set(AnnotationKeys.PROTOCOL, XMPP.toUpperCase()).set("IpAddress", ipAddress).build();
    DeviceDescription deviceDescription = new DefaultDeviceDescription(deviceId.uri(), Device.Type.OTHER, manufacturer, HARDWARE_VERSION, SOFTWARE_VERSION, SERIAL_NUMBER, cid, true, annotations);
    if (deviceService.getDevice(deviceId) == null) {
        providerService.deviceConnected(deviceId, deviceDescription);
    }
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescription(org.onosproject.net.device.DeviceDescription) ChassisId(org.onlab.packet.ChassisId) XmppDeviceId(org.onosproject.xmpp.core.XmppDeviceId) DeviceId(org.onosproject.net.DeviceId) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription)

Aggregations

DeviceDescription (org.onosproject.net.device.DeviceDescription)44 DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)32 ChassisId (org.onlab.packet.ChassisId)14 DeviceId (org.onosproject.net.DeviceId)14 Test (org.junit.Test)11 ProviderId (org.onosproject.net.provider.ProviderId)10 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)9 DeviceEvent (org.onosproject.net.device.DeviceEvent)8 SparseAnnotations (org.onosproject.net.SparseAnnotations)6 DeviceDescriptionDiscovery (org.onosproject.net.device.DeviceDescriptionDiscovery)6 Device (org.onosproject.net.Device)5 PortDescription (org.onosproject.net.device.PortDescription)5 IOException (java.io.IOException)4 ExecutionException (java.util.concurrent.ExecutionException)4 BiFunction (java.util.function.BiFunction)4 Function (java.util.function.Function)4 NodeId (org.onosproject.cluster.NodeId)4 NetconfException (org.onosproject.netconf.NetconfException)4 Arrays (java.util.Arrays)3 HashMap (java.util.HashMap)3