Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Reuse PEM provider in netconf-testtool.
[controller.git]
/
opendaylight
/
netconf
/
netconf-testtool
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
netconf
/
test
/
tool
/
NetconfDeviceSimulator.java
diff --git
a/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/NetconfDeviceSimulator.java
b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/NetconfDeviceSimulator.java
index a45c374eae00ed456fae70ce4cd7c5c0a83ca89a..287ff2dca77a60a4a8f3cac0569c96fad233aac4 100644
(file)
--- a/
opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/NetconfDeviceSimulator.java
+++ b/
opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/NetconfDeviceSimulator.java
@@
-30,6
+30,7
@@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
+import java.net.BindException;
import java.net.Inet4Address;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.Inet4Address;
import java.net.InetSocketAddress;
import java.net.URI;
@@
-199,16
+200,19
@@
public class NetconfDeviceSimulator implements Closeable {
server = dispatcher.createLocalServer(tcpLocalAddress);
try {
final SshProxyServer sshServer = new SshProxyServer(minaTimerExecutor, nettyThreadgroup, nioExecutor);
server = dispatcher.createLocalServer(tcpLocalAddress);
try {
final SshProxyServer sshServer = new SshProxyServer(minaTimerExecutor, nettyThreadgroup, nioExecutor);
- sshServer.bind(getSshConfiguration(bindingAddress, tcpLocalAddress));
+ sshServer.bind(getSshConfiguration(bindingAddress, tcpLocalAddress
, keyPairProvider
));
sshWrappers.add(sshServer);
sshWrappers.add(sshServer);
- } catch (final Exception e) {
- LOG.warn("Cannot start simulated device on {},
skipping", address, e
);
+ } catch (final
Bind
Exception e) {
+ LOG.warn("Cannot start simulated device on {},
port already in use. Skipping.", address
);
// Close local server and continue
server.cancel(true);
if(server.isDone()) {
server.channel().close();
}
continue;
// Close local server and continue
server.cancel(true);
if(server.isDone()) {
server.channel().close();
}
continue;
+ } catch (final IOException e) {
+ LOG.warn("Cannot start simulated device on {} due to IOException.", address, e);
+ break;
} finally {
currentPort++;
}
} finally {
currentPort++;
}
@@
-255,7
+259,7
@@
public class NetconfDeviceSimulator implements Closeable {
return openDevices;
}
return openDevices;
}
- private SshProxyServerConfiguration getSshConfiguration(final InetSocketAddress bindingAddress, final LocalAddress tcpLocalAddress) throws IOException {
+ private SshProxyServerConfiguration getSshConfiguration(final InetSocketAddress bindingAddress, final LocalAddress tcpLocalAddress
, final PEMGeneratorHostKeyProvider keyPairProvider
) throws IOException {
return new SshProxyServerConfigurationBuilder()
.setBindingAddress(bindingAddress)
.setLocalAddress(tcpLocalAddress)
return new SshProxyServerConfigurationBuilder()
.setBindingAddress(bindingAddress)
.setLocalAddress(tcpLocalAddress)
@@
-265,7
+269,7
@@
public class NetconfDeviceSimulator implements Closeable {
return true;
}
})
return true;
}
})
- .setKeyPairProvider(
new PEMGeneratorHostKeyProvider(Files.createTempFile("prefix", "suffix").toAbsolutePath().toString())
)
+ .setKeyPairProvider(
keyPairProvider
)
.setIdleTimeout(Integer.MAX_VALUE)
.createSshProxyServerConfiguration();
}
.setIdleTimeout(Integer.MAX_VALUE)
.createSshProxyServerConfiguration();
}