use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class DeviceDiscoveryTest method deviceDescriptionTest.
@Test
public void deviceDescriptionTest() {
Ciena5162DeviceDescription targetUnderTest = new Ciena5162DeviceDescription();
Ciena5162DeviceDescription.TEMPLATE_MANAGER.setRequestDriver(mockRequestDriver);
targetUnderTest.setHandler(mockDriverHandlers.get(DeviceId.deviceId("netconf:1.2.3.4:830")));
DeviceDescription desc = targetUnderTest.discoverDeviceDetails();
assertEquals("Chassis ID", "1C1161EDB480", desc.chassisId().toString().toUpperCase());
assertEquals("Manufacturer", "Ciena", desc.manufacturer());
assertEquals("HW Version", "5162", desc.hwVersion());
assertEquals("Serial Number", "M9258605", desc.serialNumber());
assertEquals("SW Version", "saos-01-01-00-0025", desc.swVersion());
}
use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class DeviceDiscoveryTest method deviceDescriptionTest.
@Test
public void deviceDescriptionTest() {
Ciena5170DeviceDescription targetUnderTest = new Ciena5170DeviceDescription();
Ciena5170DeviceDescription.TEMPLATE_MANAGER.setRequestDriver(mockRequestDriver);
targetUnderTest.setHandler(mockDriverHandlers.get(DeviceId.deviceId("netconf:1.2.3.4:830")));
DeviceDescription desc = targetUnderTest.discoverDeviceDetails();
assertEquals("Chassis ID", "1C1161D18800", desc.chassisId().toString().toUpperCase());
assertEquals("Manufacturer", "Ciena", desc.manufacturer());
assertEquals("HW Version", "CN5170", desc.hwVersion());
assertEquals("Serial Number", "1C1161D18800", desc.serialNumber());
assertEquals("SW Version", "saos-01-01-00-0025", desc.swVersion());
}
use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class RestDeviceProvider method scheduleDevicePolling.
private ScheduledFuture scheduleDevicePolling() {
return deviceConnectionExecutor.scheduleWithFixedDelay(() -> {
try {
controller.getDevices().values().stream().forEach(restSBDevice -> {
DeviceId deviceId = restSBDevice.deviceId();
if (deviceService.getDevice(deviceId) != null) {
boolean connected = testDeviceConnection(restSBDevice);
restSBDevice.setActive(connected);
if (deviceService.isAvailable(deviceId) && (!connected)) {
providerService.deviceDisconnected(deviceId);
} else if (!deviceService.isAvailable(deviceId) && connected) {
DeviceDescription devDesc = getDesc(restSBDevice);
checkNotNull(devDesc, "deviceDescription cannot be null");
providerService.deviceConnected(deviceId, mergeAnn(deviceId, devDesc));
}
}
});
} catch (Exception e) {
log.error("Exception at schedule Device polling", e);
}
}, 1, pollFrequency, TimeUnit.SECONDS);
}
use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class RestDeviceProvider method deviceAdded.
private void deviceAdded(RestSBDevice restSBDev) {
checkNotNull(restSBDev, DEVICENULL);
Driver driver = getDriver(restSBDev);
// Check if the server is controlling a single or multiple devices
if (restSBDev.isProxy()) {
if (driver.hasBehaviour(DevicesDiscovery.class)) {
DevicesDiscovery devicesDiscovery = devicesDiscovery(restSBDev, driver);
Set<DeviceId> deviceIds = devicesDiscovery.deviceIds();
restSBDev.setActive(true);
deviceIds.forEach(deviceId -> {
controller.addProxiedDevice(deviceId, restSBDev);
DeviceDescription devDesc = devicesDiscovery.deviceDetails(deviceId);
checkNotNull(devDesc, "DeviceDescription cannot be null");
providerService.deviceConnected(deviceId, mergeAnn(restSBDev.deviceId(), devDesc));
if (driver.hasBehaviour(DeviceDescriptionDiscovery.class)) {
DriverHandler h = driverService.createHandler(deviceId);
DeviceDescriptionDiscovery devDisc = h.behaviour(DeviceDescriptionDiscovery.class);
providerService.updatePorts(deviceId, devDisc.discoverPortDetails());
}
checkAndUpdateDevice(deviceId);
});
} else {
log.warn("Device is proxy but driver does not have proxy discovery behaviour {}", restSBDev);
}
} else {
DeviceId deviceId = restSBDev.deviceId();
if (driver != null && driver.hasBehaviour(DevicesDiscovery.class)) {
restSBDev.setActive(true);
DevicesDiscovery devicesDiscovery = devicesDiscovery(restSBDev, driver);
DeviceDescription deviceDescription = devicesDiscovery.deviceDetails(deviceId);
checkNotNull(deviceDescription, "DeviceDescription cannot be null");
providerService.deviceConnected(deviceId, deviceDescription);
if (driver.hasBehaviour(DeviceDescriptionDiscovery.class)) {
DriverHandler h = driverService.createHandler(deviceId);
DeviceDescriptionDiscovery deviceDiscovery = h.behaviour(DeviceDescriptionDiscovery.class);
providerService.updatePorts(deviceId, deviceDiscovery.discoverPortDetails());
}
} else {
DeviceDescription deviceDescription = getDesc(restSBDev);
restSBDev.setActive(true);
providerService.deviceConnected(deviceId, deviceDescription);
}
checkAndUpdateDevice(deviceId);
}
}
use of org.onosproject.net.device.DeviceDescription in project onos by opennetworkinglab.
the class XmppDeviceProvider method connectDevice.
private void connectDevice(XmppDeviceId xmppDeviceId) {
DeviceId deviceId = DeviceId.deviceId(xmppDeviceId.id());
String ipAddress = controller.getDevice(xmppDeviceId).getIpAddress().getAddress().getHostAddress();
// Assumption: manufacturer is uniquely identified by domain part of JID
String manufacturer = xmppDeviceId.getJid().getDomain();
ChassisId cid = new ChassisId();
SparseAnnotations annotations = DefaultAnnotations.builder().set(AnnotationKeys.PROTOCOL, XMPP.toUpperCase()).set("IpAddress", ipAddress).build();
DeviceDescription deviceDescription = new DefaultDeviceDescription(deviceId.uri(), Device.Type.OTHER, manufacturer, HARDWARE_VERSION, SOFTWARE_VERSION, SERIAL_NUMBER, cid, true, annotations);
if (deviceService.getDevice(deviceId) == null) {
providerService.deviceConnected(deviceId, deviceDescription);
}
}
Aggregations