use of org.onlab.packet.ChassisId 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.onlab.packet.ChassisId 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.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class JuniperUtils method extractChassisId.
/**
* Parses the chassisMacAddresses argument to find the private-base-address and maps it to a chassis id.
* @param chassisMacAddresses XML response
* @return the corresponding chassisId, or null if supplied chassisMacAddresses could not be parsed.
*/
private static ChassisId extractChassisId(final String chassisMacAddresses) {
ChassisId result = null;
// Old JUNOS versions used CLI-style text for chassisMacAddresses, whereas recent versions provide a
// chassis-mac-addresses XML.
Matcher matcher = ADD_PATTERN_JUNOS15_1.matcher(chassisMacAddresses);
if (matcher.lookingAt()) {
result = new ChassisId(MacAddress.valueOf(matcher.group(1)).toLong());
} else {
String pba = loadXmlString(chassisMacAddresses).configurationAt("chassis-mac-addresses").configurationAt("mac-address-information").getString("private-base-address");
if (StringUtils.isNotBlank(pba)) {
result = new ChassisId(MacAddress.valueOf(pba).toLong());
}
}
return result;
}
use of org.onlab.packet.ChassisId 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));
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class HostLocationProviderTest method removeHostByDevicePortDown.
@Test
public void removeHostByDevicePortDown() {
provider.modified(CTX_FOR_REMOVE);
testProcessor.process(new TestArpPacketContext(DEV1));
testProcessor.process(new TestArpPacketContext(DEV4));
Device device = new DefaultDevice(ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
deviceService.listener.event(new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
assertEquals("incorrect remove count", 1, providerService.locationRemoveCount);
device = new DefaultDevice(ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
deviceService.listener.event(new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
assertEquals("incorrect remove count", 2, providerService.locationRemoveCount);
}
Aggregations