use of org.onosproject.net.device.DefaultDeviceDescription in project onos by opennetworkinglab.
the class LispDeviceProvider method connectDevice.
/**
* Adds a LISP router into device store.
*/
private void connectDevice(LispRouterId routerId) {
DeviceId deviceId = getDeviceId(routerId.id().toString());
Preconditions.checkNotNull(deviceId, IS_NULL_MSG);
// formulate LISP router object
ChassisId cid = new ChassisId();
String ipAddress = routerId.id().toString();
SparseAnnotations annotations = DefaultAnnotations.builder().set(IPADDRESS, ipAddress).set(AnnotationKeys.PROTOCOL, SCHEME_NAME.toUpperCase()).build();
DeviceDescription deviceDescription = new DefaultDeviceDescription(deviceId.uri(), Device.Type.ROUTER, MANUFACTURER, HARDWARE_VERSION, SOFTWARE_VERSION, SERIAL_NUMBER, cid, false, annotations);
if (deviceService.getDevice(deviceId) == null) {
providerService.deviceConnected(deviceId, deviceDescription);
}
checkAndUpdateDevice(deviceId, deviceDescription);
}
use of org.onosproject.net.device.DefaultDeviceDescription in project onos by opennetworkinglab.
the class DeviceManagerTest method connectDevice.
private void connectDevice(DeviceId deviceId, String swVersion) {
DeviceDescription description = new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, HW, swVersion, SN, CID);
providerService.deviceConnected(deviceId, description);
assertNotNull("device should be found", service.getDevice(DID1));
}
use of org.onosproject.net.device.DefaultDeviceDescription in project onos by opennetworkinglab.
the class CienaWaveserverAiDeviceDescription method discoverDeviceDetails.
@Override
public DeviceDescription discoverDeviceDetails() {
log.debug("Adding description for Waveserver Ai device");
NetconfSession session = getNetconfSession();
Device device = getDevice(handler().data().deviceId());
try {
XPath xp = XPathFactory.newInstance().newXPath();
Node node = TEMPLATE_MANAGER.doRequest(session, "discoverDeviceDetails");
String chassisId = xp.evaluate("waveserver-chassis/mac-addresses/chassis/base/text()", node);
chassisId = chassisId.replace(":", "");
SparseAnnotations annotationDevice = DefaultAnnotations.builder().set("name", xp.evaluate("waveserver-system/host-name/current-host-name/text()", node)).build();
return new DefaultDeviceDescription(device.id().uri(), Device.Type.OTN, "Ciena", "WaverserverAi", xp.evaluate("waveserver-software/status/active-version/text()", node), xp.evaluate("waveserver-chassis/identification/serial-number/text()", node), new ChassisId(Long.valueOf(chassisId, 16)), (SparseAnnotations) annotationDevice);
} catch (NetconfException | XPathExpressionException e) {
log.error("Unable to retrieve device information for device {}, {}", device.chassisId(), e);
}
return new DefaultDeviceDescription(device.id().uri(), Device.Type.OTN, "Ciena", "WaverserverAi", "unknown", "unknown", device.chassisId());
}
use of org.onosproject.net.device.DefaultDeviceDescription in project onos by opennetworkinglab.
the class CienaWaveserverAiDeviceDescriptionTest method testDiscoverDeviceDetails.
@Test
public void testDiscoverDeviceDetails() {
XPath xp = XPathFactory.newInstance().newXPath();
SparseAnnotations expectAnnotation = DefaultAnnotations.builder().set("hostname", "hostnameWaveServer").build();
DefaultDeviceDescription expectResult = new DefaultDeviceDescription(mockDeviceId.uri(), Device.Type.OTN, "Ciena", "WaverserverAi", "waveserver-1.1.0.302", "M000", new ChassisId(0L), expectAnnotation);
try {
Node node = doRequest("/response/discoverDeviceDetails.xml", "/rpc-reply/data");
SparseAnnotations annotationDevice = DefaultAnnotations.builder().set("hostname", xp.evaluate("waveserver-system/host-name/current-host-name/text()", node)).build();
DefaultDeviceDescription result = new DefaultDeviceDescription(mockDeviceId.uri(), Device.Type.OTN, "Ciena", "WaverserverAi", xp.evaluate("waveserver-software/status/active-version/text()", node), xp.evaluate("waveserver-chassis/identification/serial-number/text()", node), new ChassisId(0L), annotationDevice);
assertEquals(expectResult, result);
} catch (XPathExpressionException e) {
e.printStackTrace();
}
}
use of org.onosproject.net.device.DefaultDeviceDescription in project onos by opennetworkinglab.
the class CiscoIosDeviceDescription method discoverDeviceDetails.
@Override
public DeviceDescription discoverDeviceDetails() {
NetconfController controller = checkNotNull(handler().get(NetconfController.class));
NetconfSession session = controller.getDevicesMap().get(handler().data().deviceId()).getSession();
try {
version = session.get(showVersionRequestBuilder());
} catch (NetconfException e) {
throw new IllegalStateException(new NetconfException("Failed to retrieve version info.", e));
}
String[] details = TextBlockParserCisco.parseCiscoIosDeviceDetails(version);
DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
DeviceId deviceId = handler().data().deviceId();
Device device = deviceService.getDevice(deviceId);
return new DefaultDeviceDescription(device.id().uri(), Device.Type.SWITCH, details[0], details[1], details[2], details[3], device.chassisId());
}
Aggregations