/** * Discovers the device details using the device discovery behaviour of * the supplied driver handler context for interacting with a specific * device. * * @param handler driver handler context */ protected void discoverDevice(DriverHandler handler) { DeviceId deviceId = handler.data().deviceId(); DeviceDescriptionDiscovery discovery = handler.behaviour(DeviceDescriptionDiscovery.class); DeviceDescription description = discovery.discoverDeviceDetails(); if (description != null) { providerService.deviceConnected(deviceId, description); } else { log.info("No other description given for device {}", deviceId); } providerService.updatePorts(deviceId, discovery.discoverPortDetails()); } // TODO: inspect NETCONF, SNMP, RESTSB device providers for additional common patterns
private void updatePortsAndStats(DeviceId did) { Device device = deviceService.getDevice(did); if (device.is(DeviceDescriptionDiscovery.class)) { DeviceDescriptionDiscovery discovery = device.as(DeviceDescriptionDiscovery.class); List<PortDescription> portDescriptions = discovery.discoverPortDetails(); if (portDescriptions != null) { providerService.updatePorts(did, portDescriptions); } } else { log.warn("No DeviceDescriptionDiscovery behavior for device {}", did); } try { Collection<PortStatistics> portStats = getPortStatistics(controller.getAgent(did), deviceService.getPorts(did)); providerService.updatePortStatistics(did, portStats); } catch (Bmv2RuntimeException e) { log.warn("Unable to get port statistics for {}: {}", did, e.explain()); } }
private DeviceDescription getDeviceDescription(DeviceId did) { Device device = deviceService.getDevice(did); DeviceDescriptionDiscovery discovery = null; if (device == null) { // Device not yet in the core. Manually get a driver. Driver driver = driverService.getDriver(MANUFACTURER, HW_VERSION, SW_VERSION); if (driver.hasBehaviour(DeviceDescriptionDiscovery.class)) { discovery = driver.createBehaviour(new DefaultDriverHandler(new DefaultDriverData(driver, did)), DeviceDescriptionDiscovery.class); } } else if (device.is(DeviceDescriptionDiscovery.class)) { discovery = device.as(DeviceDescriptionDiscovery.class); } if (discovery == null) { log.warn("No DeviceDescriptionDiscovery behavior for device {}", did); return null; } else { return discovery.discoverDeviceDetails(); } }
discovery.get().discoverDeviceDetails()); providerService.updatePorts(did, discovery.get().discoverPortDetails()); } else {
if (d.is(DeviceDescriptionDiscovery.class)) { DeviceDescriptionDiscovery descriptionDiscovery = d.as(DeviceDescriptionDiscovery.class); DeviceDescription description = descriptionDiscovery.discoverDeviceDetails(); deviceStore.createOrUpdateDevice( new ProviderId("snmp", "org.onosproject.provider.device"), did, description); providerService.updatePorts(did, descriptionDiscovery.discoverPortDetails()); } else { log.warn("No populate description and ports behaviour for device {}", did);