use of org.opendaylight.netconf.client.conf.NetconfClientConfigurationBuilder in project netconf by opendaylight.
the class TestingNetconfClient method getClientConfig.
private static NetconfClientConfiguration getClientConfig(final String host, final int port, final boolean ssh, final Optional<? extends AuthenticationHandler> maybeAuthHandler) throws UnknownHostException {
InetSocketAddress netconfAddress = new InetSocketAddress(InetAddress.getByName(host), port);
final NetconfClientConfigurationBuilder b = NetconfClientConfigurationBuilder.create();
b.withAddress(netconfAddress);
b.withSessionListener(new SimpleNetconfClientSessionListener());
b.withReconnectStrategy(new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, NetconfClientConfigurationBuilder.DEFAULT_CONNECTION_TIMEOUT_MILLIS));
if (ssh) {
b.withProtocol(NetconfClientProtocol.SSH);
b.withAuthHandler(maybeAuthHandler.get());
} else {
b.withProtocol(NetconfClientProtocol.TCP);
}
return b.build();
}
use of org.opendaylight.netconf.client.conf.NetconfClientConfigurationBuilder in project netconf by opendaylight.
the class StressClientCallable method getNetconfClientConfiguration.
private static NetconfClientConfiguration getNetconfClientConfiguration(final Parameters params, final NetconfDeviceCommunicator sessionListener) {
final NetconfClientConfigurationBuilder netconfClientConfigurationBuilder = NetconfClientConfigurationBuilder.create();
netconfClientConfigurationBuilder.withSessionListener(sessionListener);
netconfClientConfigurationBuilder.withAddress(params.getInetAddress());
if (params.tcpHeader != null) {
final String header = params.tcpHeader.replaceAll("\"", "").trim() + "\n";
netconfClientConfigurationBuilder.withAdditionalHeader(new NetconfHelloMessageAdditionalHeader(null, null, null, null, null) {
@Override
public String toFormattedString() {
LOG.debug("Sending TCP header {}", header);
return header;
}
});
}
netconfClientConfigurationBuilder.withProtocol(params.ssh ? NetconfClientConfiguration.NetconfClientProtocol.SSH : NetconfClientConfiguration.NetconfClientProtocol.TCP);
netconfClientConfigurationBuilder.withAuthHandler(new LoginPasswordHandler(params.username, params.password));
netconfClientConfigurationBuilder.withConnectionTimeoutMillis(20000L);
netconfClientConfigurationBuilder.withReconnectStrategy(new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000));
return netconfClientConfigurationBuilder.build();
}
Aggregations