+
+ public NetconfClientConfiguration getClientConfig(final NetconfDevice device) {
+ InetSocketAddress socketAddress = getSocketAddress();
+ ReconnectStrategy strategy = getReconnectStrategy();
+ long clientConnectionTimeoutMillis = getConnectionTimeoutMillis();
+
+ return NetconfClientConfigurationBuilder.create()
+ .withAddress(socketAddress)
+ .withConnectionTimeoutMillis(clientConnectionTimeoutMillis)
+ .withReconnectStrategy(strategy)
+ .withSessionListener(new NetconfDeviceListener(device))
+ .withAuthHandler(new LoginPassword(getUsername(),getPassword()))
+ .withProtocol(getTcpOnly() ?
+ NetconfClientConfiguration.NetconfClientProtocol.TCP :
+ NetconfClientConfiguration.NetconfClientProtocol.SSH)
+ .build();
+ }
+
+ private ReconnectStrategy getReconnectStrategy() {
+ Long connectionAttempts;
+ if (getMaxConnectionAttempts() != null && getMaxConnectionAttempts() > 0) {
+ connectionAttempts = getMaxConnectionAttempts();
+ } else {
+ logger.trace("Setting {} on {} to infinity", maxConnectionAttemptsJmxAttribute, this);
+ connectionAttempts = null;
+ }
+ double sleepFactor = 1.0;
+ int minSleep = 1000;
+ Long maxSleep = null;
+ Long deadline = null;
+
+ return new TimedReconnectStrategy(GlobalEventExecutor.INSTANCE, getBetweenAttemptsTimeoutMillis(),
+ minSleep, sleepFactor, maxSleep, connectionAttempts, deadline);
+ }
+
+ private InetSocketAddress getSocketAddress() {
+ /*
+ * Uncomment after Switch to IP Address
+ if(getAddress().getIpv4Address() != null) {
+ addressValue = getAddress().getIpv4Address().getValue();
+ } else {
+ addressValue = getAddress().getIpv6Address().getValue();
+ }
+ */
+ InetAddress inetAddress = InetAddresses.forString(getAddress());
+ return new InetSocketAddress(inetAddress, getPort().intValue());
+ }