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());
}
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());
}
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());
}
}
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);
}
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));
}
Aggregations