- Set<String> latestCapabilities = null;
- while (System.nanoTime() < deadlineNanos) {
- attempt++;
- NetconfClientDispatcher netconfClientDispatcher = new NetconfClientDispatcher(configuration.eventLoopGroup,
- configuration.eventLoopGroup, additionalHeader, configuration.connectionAttemptTimeoutMs);
- NetconfClient netconfClient;
- try {
- netconfClient = new NetconfClient(this.toString(), configuration.netconfAddress, configuration.connectionAttemptDelayMs, netconfClientDispatcher);
- } catch (IllegalStateException e) {
- logger.debug("Netconf {} was not initialized or is not stable, attempt {}", configuration.netconfAddress, attempt, e);
- netconfClientDispatcher.close();
- Thread.sleep(configuration.connectionAttemptDelayMs);
- continue;
- }
- latestCapabilities = netconfClient.getCapabilities();
- if (Util.isSubset(netconfClient, expectedCaps)) {
- logger.debug("Hello from netconf stable with {} capabilities", latestCapabilities);
- logger.trace("Session id received from netconf server: {}", netconfClient.getClientSession());
- return netconfClient;
- }
- Set<String> allNotFound = computeNotFoundCapabilities(expectedCaps, latestCapabilities);
- logger.debug("Netconf server did not provide required capabilities. Attempt {}. " +
- "Expected but not found: {}, all expected {}, current {}",
- attempt, allNotFound, expectedCaps, latestCapabilities);
- Util.closeClientAndDispatcher(netconfClient);
- Thread.sleep(configuration.connectionAttemptDelayMs);
+ /**
+ * Get NetconfOperationService iif all required capabilities are present.
+ *
+ * @param expectedCapabilities that must be provided by configNetconfConnector
+ * @param idForReporting
+ * @return service if capabilities are present, otherwise absent value
+ */
+ private NetconfOperationService getOperationService(Set<String> expectedCapabilities, String idForReporting) throws NotEnoughCapabilitiesException {
+ NetconfOperationService serviceCandidate;
+ try {
+ serviceCandidate = configNetconfConnector.createService(idForReporting);
+ } catch(RuntimeException e) {
+ throw new NotEnoughCapabilitiesException("Netconf service not stable for " + idForReporting, e);