discovery.get().discoverDeviceDetails()); providerService.updatePorts(did, discovery.get().discoverPortDetails());
/** * 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 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(); } }
if (d.is(DeviceDescriptionDiscovery.class)) { DeviceDescriptionDiscovery descriptionDiscovery = d.as(DeviceDescriptionDiscovery.class); DeviceDescription description = descriptionDiscovery.discoverDeviceDetails(); deviceStore.createOrUpdateDevice( new ProviderId("snmp", "org.onosproject.provider.device"),