use of org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader in project netconf by opendaylight.
the class AdditionalHeaderParserTest method testParsing2.
@Test
public void testParsing2() throws Exception {
String message = "[tomas;10.0.0.0/10000;tcp;1000;1000;;/home/tomas;;]";
NetconfHelloMessageAdditionalHeader header = NetconfHelloMessageAdditionalHeader.fromString(message);
assertEquals("tomas", header.getUserName());
assertEquals("10.0.0.0", header.getAddress());
assertEquals("tcp", header.getTransport());
}
use of org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader 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();
}
use of org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader in project netconf by opendaylight.
the class RemoteNetconfCommand method start.
@Override
public void start(final ChannelSession channel, final Environment env) {
final ServerSession session = channel.getServerSession();
final SocketAddress remoteAddress = session.getIoSession().getRemoteAddress();
final String hostName;
final String port;
if (remoteAddress instanceof InetSocketAddress) {
hostName = ((InetSocketAddress) remoteAddress).getAddress().getHostAddress();
port = Integer.toString(((InetSocketAddress) remoteAddress).getPort());
} else {
hostName = "";
port = "";
}
netconfHelloMessageAdditionalHeader = new NetconfHelloMessageAdditionalHeader(session.getUsername(), hostName, port, "ssh", "client");
LOG.trace("Establishing internal connection to netconf server for client: {}", getClientAddress());
final Bootstrap clientBootstrap = new Bootstrap();
clientBootstrap.group(clientEventGroup).channel(LocalChannel.class);
clientBootstrap.handler(new ChannelInitializer<LocalChannel>() {
@Override
public void initChannel(final LocalChannel ch) {
ch.pipeline().addLast(new SshProxyClientHandler(in, out, netconfHelloMessageAdditionalHeader, callback));
}
});
clientChannelFuture = clientBootstrap.connect(localAddress);
clientChannelFuture.addListener(future -> {
if (future.isSuccess()) {
clientChannel = clientChannelFuture.channel();
} else {
LOG.warn("Unable to establish internal connection to netconf server for client: {}", getClientAddress());
requireNonNull(callback, "Exit callback must be set").onExit(1, "Unable to establish internal connection to netconf server for client: " + getClientAddress());
}
});
}
Aggregations