Merge "Fix allowable Unix ports range 1024 - 65535"
authorEd Warnicke <eaw@cisco.com>
Tue, 2 Dec 2014 16:20:59 +0000 (16:20 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 2 Dec 2014 16:20:59 +0000 (16:20 +0000)
opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/Main.java
opendaylight/netconf/netconf-testtool/src/main/java/org/opendaylight/controller/netconf/test/tool/NetconfDeviceSimulator.java

index e36d58591e2ad8a1b2f757ca475ec7f41aa392ae..e441c709ccabcdcc9a9659a0ca96add3c21a27f1 100644 (file)
@@ -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<Integer> 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<File> generated = configGenerator.generate(params.ssh, params.generateConfigBatchSize, params.generateConfigsTimeout, params.generateConfigsAddress);
index adcdea6073860b5f6b660faa356baf9cf7455df4..a45c374eae00ed456fae70ce4cd7c5c0a83ca89a 100644 (file)
@@ -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);
         }