Search in sources :

Example 1 with NeverReconnectStrategy

use of org.opendaylight.netconf.nettyutil.NeverReconnectStrategy 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();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) NeverReconnectStrategy(org.opendaylight.netconf.nettyutil.NeverReconnectStrategy) NetconfClientConfigurationBuilder(org.opendaylight.netconf.client.conf.NetconfClientConfigurationBuilder)

Example 2 with NeverReconnectStrategy

use of org.opendaylight.netconf.nettyutil.NeverReconnectStrategy 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();
}
Also used : NetconfHelloMessageAdditionalHeader(org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader) LoginPasswordHandler(org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswordHandler) NeverReconnectStrategy(org.opendaylight.netconf.nettyutil.NeverReconnectStrategy) NetconfClientConfigurationBuilder(org.opendaylight.netconf.client.conf.NetconfClientConfigurationBuilder)

Aggregations

NetconfClientConfigurationBuilder (org.opendaylight.netconf.client.conf.NetconfClientConfigurationBuilder)2 NeverReconnectStrategy (org.opendaylight.netconf.nettyutil.NeverReconnectStrategy)2 InetSocketAddress (java.net.InetSocketAddress)1 NetconfHelloMessageAdditionalHeader (org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader)1 LoginPasswordHandler (org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswordHandler)1