private void connectDevices() { NetconfProviderConfig cfg = cfgService.getConfig(appId, NetconfProviderConfig.class); if (cfg != null) { try { cfg.getDevicesAddresses() .stream() .forEach( addr -> { try { NetconfDeviceInfo netconf = new NetconfDeviceInfo(addr.name(), addr.password(), addr.ip(), addr.port()); controller.connectDevice(netconf); Device device = deviceService.getDevice(netconf.getDeviceId()); if (device.is(PortDiscovery.class)) { PortDiscovery portConfig = device.as(PortDiscovery.class); if (portConfig != null) { providerService.updatePorts(netconf.getDeviceId(), portConfig.getPorts()); } } else { log.warn("No portGetter behaviour for device {}", netconf.getDeviceId()); } } catch (IOException e) { throw new RuntimeException( new NetconfException( "Can't connect to NETCONF " + "device on " + addr.ip() + ":" + addr.port(), e)); } }); } catch (ConfigException e) { log.error("Cannot read config error " + e); } } }