Search in sources :

Example 21 with DefaultDeviceDescription

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

the class Ciena5170DeviceDescription method discoverDeviceDetails.

@Override
public DeviceDescription discoverDeviceDetails() {
    DeviceId deviceId = handler().data().deviceId();
    NetconfController controller = checkNotNull(handler().get(NetconfController.class));
    NetconfSession session = controller.getDevicesMap().get(handler().data().deviceId()).getSession();
    try {
        Node systemInfo = TEMPLATE_MANAGER.doRequest(session, "systemInfo");
        Node chassisMac = TEMPLATE_MANAGER.doRequest(session, "chassis-mac");
        Node softwareVersion = TEMPLATE_MANAGER.doRequest(session, "softwareVersion");
        XPath xp = XPathFactory.newInstance().newXPath();
        String mac = xp.evaluate("lldp-global-operational/chassis-id/text()", chassisMac).toUpperCase();
        return new DefaultDeviceDescription(deviceId.uri(), Device.Type.SWITCH, "Ciena", xp.evaluate("components/component/name/text()", systemInfo), xp.evaluate("software-state/running-package/package-version/text()", softwareVersion), mac, new ChassisId(Long.valueOf(mac, 16)));
    } catch (XPathExpressionException | NetconfException ne) {
        log.error("failed to query system info from device {} : {}", handler().data().deviceId(), ne.getMessage(), ne);
    }
    return new DefaultDeviceDescription(deviceId.uri(), Device.Type.SWITCH, "Ciena", "5170", "Unknown", "Unknown", new ChassisId());
}
Also used : NetconfSession(org.onosproject.netconf.NetconfSession) XPath(javax.xml.xpath.XPath) ChassisId(org.onlab.packet.ChassisId) NetconfException(org.onosproject.netconf.NetconfException) DeviceId(org.onosproject.net.DeviceId) XPathExpressionException(javax.xml.xpath.XPathExpressionException) Node(org.w3c.dom.Node) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) NetconfController(org.onosproject.netconf.NetconfController)

Example 22 with DefaultDeviceDescription

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

the class Ciena5162DeviceDescription method discoverDeviceDetails.

@Override
public DeviceDescription discoverDeviceDetails() {
    DeviceId deviceId = handler().data().deviceId();
    NetconfController controller = checkNotNull(handler().get(NetconfController.class));
    NetconfSession session = controller.getDevicesMap().get(handler().data().deviceId()).getSession();
    try {
        Node systemInfo = TEMPLATE_MANAGER.doRequest(session, "systemInfo");
        Node softwareVersion = TEMPLATE_MANAGER.doRequest(session, "softwareVersion");
        XPath xp = XPathFactory.newInstance().newXPath();
        String mac = xp.evaluate("components/component/properties/property/state/value/text()", systemInfo).toUpperCase();
        return new DefaultDeviceDescription(deviceId.uri(), Device.Type.SWITCH, xp.evaluate("components/component/state/mfg-name/text()", systemInfo), xp.evaluate("components/component/state/name/text()", systemInfo), xp.evaluate("software-state/running-package/package-version/text()", softwareVersion), xp.evaluate("components/component/state/serial-no/text()", systemInfo), new ChassisId(Long.valueOf(mac, 16)));
    } catch (XPathExpressionException | NetconfException ne) {
        log.error("failed to query system info from device {}", handler().data().deviceId(), ne);
    }
    return new DefaultDeviceDescription(deviceId.uri(), Device.Type.SWITCH, "Ciena", "5162", "Unknown", "Unknown", new ChassisId());
}
Also used : NetconfSession(org.onosproject.netconf.NetconfSession) XPath(javax.xml.xpath.XPath) ChassisId(org.onlab.packet.ChassisId) NetconfException(org.onosproject.netconf.NetconfException) DeviceId(org.onosproject.net.DeviceId) XPathExpressionException(javax.xml.xpath.XPathExpressionException) Node(org.w3c.dom.Node) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) NetconfController(org.onosproject.netconf.NetconfController)

Example 23 with DefaultDeviceDescription

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

the class CienaWaveserverDeviceDescription method discoverDeviceDetails.

@Override
public DeviceDescription discoverDeviceDetails() {
    log.debug("getting device description");
    DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
    DeviceId deviceId = handler().data().deviceId();
    Device device = deviceService.getDevice(deviceId);
    if (device == null) {
        return new DefaultDeviceDescription(deviceId.uri(), Device.Type.OTN, "Ciena", "WaveServer", "Unknown", "Unknown", new ChassisId());
    } else {
        return new DefaultDeviceDescription(device.id().uri(), Device.Type.OTN, device.manufacturer(), device.hwVersion(), device.swVersion(), device.serialNumber(), device.chassisId());
    }
}
Also used : ChassisId(org.onlab.packet.ChassisId) DeviceId(org.onosproject.net.DeviceId) Device(org.onosproject.net.Device) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceService(org.onosproject.net.device.DeviceService)

Example 24 with DefaultDeviceDescription

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

the class JuniperUtils method parseJuniperDescription.

/**
 * Parses device configuration and returns the device description.
 *
 * @param deviceId    the id of the device
 * @param sysInfoCfg  system configuration
 * @param chassisMacAddresses chassis MAC addresses response. Its format depends on JUNOS version of device.
 * @return device description
 */
public static DeviceDescription parseJuniperDescription(DeviceId deviceId, HierarchicalConfiguration sysInfoCfg, String chassisMacAddresses) {
    HierarchicalConfiguration info = sysInfoCfg.configurationAt(SYS_INFO);
    String hw = info.getString(HW_MODEL) == null ? UNKNOWN : info.getString(HW_MODEL);
    String sw = UNKNOWN;
    if (info.getString(OS_NAME) != null || info.getString(OS_VER) != null) {
        sw = info.getString(OS_NAME) + " " + info.getString(OS_VER);
    }
    String serial = info.getString(SER_NUM) == null ? UNKNOWN : info.getString(SER_NUM);
    return new DefaultDeviceDescription(deviceId.uri(), ROUTER, JUNIPER, hw, sw, serial, extractChassisId(chassisMacAddresses), DefaultAnnotations.EMPTY);
}
Also used : DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) XmlConfigParser.loadXmlString(org.onosproject.drivers.utilities.XmlConfigParser.loadXmlString) HierarchicalConfiguration(org.apache.commons.configuration.HierarchicalConfiguration)

Example 25 with DefaultDeviceDescription

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

the class ZteDeviceDiscoveryImpl method discoverDeviceDetails.

@Override
public DeviceDescription discoverDeviceDetails() {
    DeviceId deviceId = handler().data().deviceId();
    log.info("Discovering ZTE device {}", deviceId);
    NetconfController controller = handler().get(NetconfController.class);
    NetconfSession session = controller.getDevicesMap().get(deviceId).getSession();
    String hwVersion = "ZTE hw";
    String swVersion = "ZTE sw";
    String serialNumber = "000000000000";
    try {
        String reply = session.requestSync(buildDeviceInfoRequest());
        XMLConfiguration cfg = (XMLConfiguration) XmlConfigParser.loadXmlString(getDataOfRpcReply(reply));
        hwVersion = cfg.getString("components.component.state.hardware-version");
        swVersion = cfg.getString("components.component.state.software-version");
        serialNumber = cfg.getString("components.component.state.serial-no");
    } catch (NetconfException e) {
        log.error("ZTE device discovery error.", e);
    }
    return new DefaultDeviceDescription(deviceId.uri(), Device.Type.OTN, "ZTE", hwVersion, swVersion, serialNumber, new ChassisId(1));
}
Also used : NetconfSession(org.onosproject.netconf.NetconfSession) XMLConfiguration(org.apache.commons.configuration.XMLConfiguration) ChassisId(org.onlab.packet.ChassisId) NetconfException(org.onosproject.netconf.NetconfException) DeviceId(org.onosproject.net.DeviceId) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) NetconfController(org.onosproject.netconf.NetconfController)

Aggregations

DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)52 ChassisId (org.onlab.packet.ChassisId)33 DeviceDescription (org.onosproject.net.device.DeviceDescription)26 DeviceId (org.onosproject.net.DeviceId)24 Device (org.onosproject.net.Device)20 SparseAnnotations (org.onosproject.net.SparseAnnotations)14 DeviceService (org.onosproject.net.device.DeviceService)11 NetconfException (org.onosproject.netconf.NetconfException)11 NetconfSession (org.onosproject.netconf.NetconfSession)11 Test (org.junit.Test)9 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)8 XMLConfiguration (org.apache.commons.configuration.XMLConfiguration)6 DeviceDescriptionDiscovery (org.onosproject.net.device.DeviceDescriptionDiscovery)6 DeviceEvent (org.onosproject.net.device.DeviceEvent)6 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)5 NetconfDevice (org.onosproject.netconf.NetconfDevice)5 List (java.util.List)4 BiFunction (java.util.function.BiFunction)4 Function (java.util.function.Function)4 XPath (javax.xml.xpath.XPath)4