Search in sources :

Example 11 with DeviceDescription

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

the class GossipDeviceStore method handleDeviceEvent.

private void handleDeviceEvent(InternalDeviceEvent event) {
    ProviderId providerId = event.providerId();
    DeviceId deviceId = event.deviceId();
    Timestamped<DeviceDescription> deviceDescription = event.deviceDescription();
    try {
        notifyDelegateIfNotNull(createOrUpdateDeviceInternal(providerId, deviceId, deviceDescription));
    } catch (Exception e) {
        log.warn("Exception thrown handling device update", e);
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) DeviceDescription(org.onosproject.net.device.DeviceDescription) DeviceId(org.onosproject.net.DeviceId) IOException(java.io.IOException)

Example 12 with DeviceDescription

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

the class DeviceDescriptions method putDeviceDesc.

/**
 * Puts DeviceDescription, merging annotations as necessary.
 *
 * @param newDesc new DeviceDescription
 */
public void putDeviceDesc(Timestamped<DeviceDescription> newDesc) {
    Timestamped<DeviceDescription> oldOne = deviceDesc;
    Timestamped<DeviceDescription> newOne = newDesc;
    if (oldOne != null) {
        SparseAnnotations merged = union(oldOne.value().annotations(), newDesc.value().annotations());
        newOne = new Timestamped<>(new DefaultDeviceDescription(newDesc.value(), merged), newDesc.timestamp());
    }
    deviceDesc = newOne;
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescription(org.onosproject.net.device.DeviceDescription) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription)

Example 13 with DeviceDescription

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

the class GeneralDeviceProvider method getDeviceDescription.

private DeviceDescription getDeviceDescription(DeviceId deviceId, boolean defaultAvailable) {
    // Get one from driver or forge.
    final DeviceDescriptionDiscovery deviceDiscovery = getBehaviour(deviceId, DeviceDescriptionDiscovery.class);
    if (deviceDiscovery == null) {
        return forgeDeviceDescription(deviceId, defaultAvailable);
    }
    final DeviceDescription d = deviceDiscovery.discoverDeviceDetails();
    if (d == null) {
        return forgeDeviceDescription(deviceId, defaultAvailable);
    }
    // Enforce defaultAvailable flag over the one obtained from driver.
    return new DefaultDeviceDescription(d, defaultAvailable, d.annotations());
}
Also used : DeviceDescription(org.onosproject.net.device.DeviceDescription) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescriptionDiscovery(org.onosproject.net.device.DeviceDescriptionDiscovery) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription)

Example 14 with DeviceDescription

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

the class OpenRoadmDeviceDescription method discoverDeviceDetails.

/**
 * Returns a DeviceDescription with Device info.
 *
 * @return DeviceDescription or null
 */
@Override
public DeviceDescription discoverDeviceDetails() {
    boolean defaultAvailable = true;
    NetconfDevice ncDevice = getNetconfDevice();
    if (ncDevice == null) {
        log.error("ONOS Error: Device reachable, deviceID {} is not in Map", did());
        return null;
    }
    DefaultAnnotations.Builder annotationsBuilder = DefaultAnnotations.builder();
    // Some defaults
    String vendor = "UNKNOWN";
    String hwVersion = "2.2.0";
    String swVersion = "2.2.0";
    String serialNumber = "0x0000";
    String chassisId = "0";
    String nodeType = "rdm";
    // Get the session, if null, at least we can use the defaults.
    NetconfSession session = getNetconfSession(did());
    if (session != null) {
        try {
            String reply = session.rpc(getDeviceDetailsBuilder()).get();
            XMLConfiguration xconf = (XMLConfiguration) XmlConfigParser.loadXmlString(reply);
            String nodeId = xconf.getString("data.org-openroadm-device.info.node-id", "");
            if (nodeId.equals("")) {
                log.error("[OPENROADM] {} org-openroadm-device node-id undefined, returning", did());
                return null;
            }
            annotationsBuilder.set(AnnotationKeys.OPENROADM_NODEID, nodeId);
            nodeType = xconf.getString("data.org-openroadm-device.info.node-type", "");
            if (nodeType.equals("")) {
                log.error("[OPENROADM] {} empty node-type", did());
                return null;
            }
            vendor = xconf.getString("data.org-openroadm-device.info.vendor", vendor);
            hwVersion = xconf.getString("data.org-openroadm-device.info.model", hwVersion);
            swVersion = xconf.getString("data.org-openroadm-device.info.softwareVersion", swVersion);
            serialNumber = xconf.getString("data.org-openroadm-device.info.serial-id", serialNumber);
            chassisId = xconf.getString("data.org-openroadm-device.info.node-number", chassisId);
            // GEOLOCATION
            String longitudeStr = xconf.getString("data.org-openroadm-device.info.geoLocation.longitude");
            String latitudeStr = xconf.getString("data.org-openroadm-device.info.geoLocation.latitude");
            if (longitudeStr != null && latitudeStr != null) {
                annotationsBuilder.set(org.onosproject.net.AnnotationKeys.LONGITUDE, longitudeStr).set(org.onosproject.net.AnnotationKeys.LATITUDE, latitudeStr);
            }
        } catch (NetconfException | InterruptedException | ExecutionException e) {
            log.error("[OPENROADM] {} exception", did());
            return null;
        }
    } else {
        log.debug("[OPENROADM] - No  session {}", did());
    }
    log.debug("[OPENROADM] {} - VENDOR {} HWVERSION {} SWVERSION {} SERIAL {} CHASSIS {}", did(), vendor, hwVersion, swVersion, serialNumber, chassisId);
    ChassisId cid = new ChassisId(Long.valueOf(chassisId, 10));
    /*
         * OpenROADM defines multiple devices (node types). This driver has been tested with
         * ROADMS, (node type, "rdm"). Other devices can also be discovered, and this code is here
         * for future developments - untested - it is likely that the XML documents
         * are model specific.
         */
    org.onosproject.net.Device.Type type;
    if (nodeType.equals("rdm")) {
        type = org.onosproject.net.Device.Type.ROADM;
    } else if (nodeType.equals("ila")) {
        type = org.onosproject.net.Device.Type.OPTICAL_AMPLIFIER;
    } else if (nodeType.equals("xpdr")) {
        type = org.onosproject.net.Device.Type.TERMINAL_DEVICE;
    } else if (nodeType.equals("extplug")) {
        type = org.onosproject.net.Device.Type.OTHER;
    } else {
        log.error("[OPENROADM] {} unsupported node-type", did());
        return null;
    }
    DeviceDescription desc = new DefaultDeviceDescription(did().uri(), type, vendor, hwVersion, swVersion, serialNumber, cid, defaultAvailable, annotationsBuilder.build());
    return desc;
}
Also used : NetconfSession(org.onosproject.netconf.NetconfSession) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescription(org.onosproject.net.device.DeviceDescription) ChassisId(org.onlab.packet.ChassisId) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) NetconfDevice(org.onosproject.netconf.NetconfDevice) XMLConfiguration(org.apache.commons.configuration.XMLConfiguration) NetconfException(org.onosproject.netconf.NetconfException) NetconfDevice(org.onosproject.netconf.NetconfDevice) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) ExecutionException(java.util.concurrent.ExecutionException)

Example 15 with DeviceDescription

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

the class Tl1DeviceProvider method connectDevice.

// Register a device in the core and in the TL1 controller.
private void connectDevice(Tl1Device device) {
    try {
        // Add device to TL1 controller
        DeviceId deviceId = DeviceId.deviceId(new URI(Tl1DeviceConfig.TL1, device.ip() + ":" + device.port(), null));
        if (controller.addDevice(deviceId, device)) {
            SparseAnnotations ann = DefaultAnnotations.builder().set(AnnotationKeys.PROTOCOL, Tl1DeviceConfig.TL1.toUpperCase()).build();
            // Register device in the core with default parameters and mark it as unavailable
            DeviceDescription dd = new DefaultDeviceDescription(deviceId.uri(), Device.Type.SWITCH, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), false, ann);
            providerService.deviceConnected(deviceId, dd);
        }
    } catch (URISyntaxException e) {
        log.error("Skipping device {}", device, e);
    }
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescription(org.onosproject.net.device.DeviceDescription) ChassisId(org.onlab.packet.ChassisId) DeviceId(org.onosproject.net.DeviceId) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

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