From 480adb443670715f74a7276dc381d5f5a06064e9 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Thu, 27 Nov 2014 14:38:07 -0500 Subject: [PATCH 1/1] Fix allowable Unix ports range 1024 - 65535 The well known ports / system ports are actually only in the range between 0 - 1023. The port 1024 should be usable. Also now handles the max allowable port of 65535. Change-Id: I5ec944abfe40156467ac53b9f5731a0aa6776596 Signed-off-by: Thanh Ha --- .../org/opendaylight/controller/netconf/test/tool/Main.java | 6 +++++- .../netconf/test/tool/NetconfDeviceSimulator.java | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/Main.java b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/Main.java index e36d58591e..e441c709cc 100644 --- a/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/Main.java +++ b/opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/Main.java @@ -147,7 +147,7 @@ public final class Main { void validate() { checkArgument(deviceCount > 0, "Device count has to be > 0"); - checkArgument(startingPort > 1024, "Starting port has to be > 1024"); + checkArgument(startingPort > 1023, "Starting port has to be > 1023"); if(schemasDir != null) { checkArgument(schemasDir.exists(), "Schemas dir has to exist"); @@ -167,6 +167,10 @@ public final class Main { final NetconfDeviceSimulator netconfDeviceSimulator = new NetconfDeviceSimulator(); try { final List openDevices = netconfDeviceSimulator.start(params); + if (openDevices.size() == 0) { + LOG.error("Failed to start any simulated devices, exiting..."); + System.exit(1); + } if(params.distroFolder != null) { final ConfigGenerator configGenerator = new ConfigGenerator(params.distroFolder, openDevices); final List generated = configGenerator.generate(params.ssh, params.generateConfigBatchSize, params.generateConfigsTimeout, params.generateConfigsAddress); 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 adcdea6073..a45c374eae 100644 --- 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 @@ -185,6 +185,10 @@ public class NetconfDeviceSimulator implements Closeable { final PEMGeneratorHostKeyProvider keyPairProvider = getPemGeneratorHostKeyProvider(); for (int i = 0; i < params.deviceCount; i++) { + if (currentPort > 65535) { + LOG.warn("Port cannot be greater than 65535, stopping further attempts."); + break; + } final InetSocketAddress address = getAddress(currentPort); final ChannelFuture server; @@ -242,6 +246,8 @@ public class NetconfDeviceSimulator implements Closeable { if(openDevices.size() == params.deviceCount) { LOG.info("All simulated devices started successfully from port {} to {}", params.startingPort, currentPort - 1); + } else if (openDevices.size() == 0) { + LOG.warn("No simulated devices started."); } else { LOG.warn("Not all simulated devices started successfully. Started devices ar on ports {}", openDevices); } -- 2.36.6