use of org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration in project netconf by opendaylight.
the class RemoteDeviceConnectorImpl method startRemoteDeviceConnection.
@Override
public void startRemoteDeviceConnection(final RemoteDeviceHandler<NetconfSessionPreferences> deviceHandler) {
final NetconfNode netconfNode = netconfTopologyDeviceSetup.getNode().augmentation(NetconfNode.class);
final NodeId nodeId = netconfTopologyDeviceSetup.getNode().getNodeId();
requireNonNull(netconfNode.getHost());
requireNonNull(netconfNode.getPort());
this.deviceCommunicatorDTO = createDeviceCommunicator(nodeId, netconfNode, deviceHandler);
final NetconfDeviceCommunicator deviceCommunicator = deviceCommunicatorDTO.getCommunicator();
final NetconfClientSessionListener netconfClientSessionListener = deviceCommunicatorDTO.getSessionListener();
final NetconfReconnectingClientConfiguration clientConfig = getClientConfig(netconfClientSessionListener, netconfNode);
final ListenableFuture<NetconfDeviceCapabilities> future = deviceCommunicator.initializeRemoteConnection(netconfTopologyDeviceSetup.getNetconfClientDispatcher(), clientConfig);
Futures.addCallback(future, new FutureCallback<NetconfDeviceCapabilities>() {
@Override
public void onSuccess(final NetconfDeviceCapabilities result) {
LOG.debug("{}: Connector started successfully", remoteDeviceId);
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("{}: Connector failed", remoteDeviceId, throwable);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration in project netconf by opendaylight.
the class NetconfTopologyImplTest method testGetClientConfig.
@Test
public void testGetClientConfig() {
final NetconfClientSessionListener sessionListener = mock(NetconfClientSessionListener.class);
final NetconfNodeBuilder nodeBuilder = new NetconfNodeBuilder().setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1")))).setPort(new PortNumber(Uint16.valueOf(9999))).setReconnectOnChangedSchema(true).setDefaultRequestTimeoutMillis(Uint32.valueOf(1000)).setBetweenAttemptsTimeoutMillis(Uint16.valueOf(100)).setKeepaliveDelay(Uint32.valueOf(1000)).setCredentials(new LoginPasswordBuilder().setUsername("testuser").setPassword("testpassword").build()).setMaxConnectionAttempts(Uint32.ZERO).setSleepFactor(new BigDecimal("1.5")).setConnectionTimeoutMillis(Uint32.valueOf(20000));
final NetconfReconnectingClientConfiguration configuration = spyTopology.getClientConfig(sessionListener, nodeBuilder.setTcpOnly(true).build());
assertEquals(NetconfClientConfiguration.NetconfClientProtocol.TCP, configuration.getProtocol());
assertNotNull(configuration.getAuthHandler());
assertNull(configuration.getSslHandlerFactory());
final NetconfReconnectingClientConfiguration configuration2 = spyTopology.getClientConfig(sessionListener, nodeBuilder.setTcpOnly(false).build());
assertEquals(NetconfClientConfiguration.NetconfClientProtocol.SSH, configuration2.getProtocol());
assertNotNull(configuration2.getAuthHandler());
assertNull(configuration2.getSslHandlerFactory());
final NetconfReconnectingClientConfiguration configuration3 = spyTopology.getClientConfig(sessionListener, nodeBuilder.setProtocol(new ProtocolBuilder().setName(Name.SSH).build()).build());
assertEquals(NetconfClientConfiguration.NetconfClientProtocol.SSH, configuration3.getProtocol());
assertNotNull(configuration3.getAuthHandler());
assertNull(configuration3.getSslHandlerFactory());
final NetconfReconnectingClientConfiguration configuration4 = spyTopology.getClientConfig(sessionListener, nodeBuilder.setProtocol(new ProtocolBuilder().setName(Name.TLS).build()).build());
assertEquals(NetconfClientConfiguration.NetconfClientProtocol.TLS, configuration4.getProtocol());
assertNull(configuration4.getAuthHandler());
assertNotNull(configuration4.getSslHandlerFactory());
}
Aggregations