execute_ssh_command ignore_err=1 fix on login fail

When execute_ssh_command is called with ignore_err=1 and the login
fails (e.g. 'Authentication failed for user 'root'.'), it does not
ignore the error as it should.

Added a try/except block to handle this scenario.

Change-Id: Id65c49b43f32faaac86ee076718058e5aae6087b
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/gen_robot_ssh.py b/lib/gen_robot_ssh.py
index 5af114c..a9db810 100755
--- a/lib/gen_robot_ssh.py
+++ b/lib/gen_robot_ssh.py
@@ -221,6 +221,7 @@
 
     global sshlib
 
+    max_exec_cmd_attempts = 2
     # Look for existing SSH connection.
     # Prepare a search connection dictionary.
     search_connection_args = open_connection_args.copy()
@@ -240,9 +241,15 @@
     else:
         gp.lprint_timen("Connecting to " + open_connection_args['host'] + ".")
         cix = sshlib.open_connection(**open_connection_args)
-        login_ssh(login_args)
+        try:
+            login_ssh(login_args)
+        except Exception as login_exception:
+            except_type, except_value, except_traceback = sys.exc_info()
+            rc = 1
+            stderr = str(except_value)
+            stdout = ""
+            max_exec_cmd_attempts = 0
 
-    max_exec_cmd_attempts = 2
     for exec_cmd_attempt_num in range(1, max_exec_cmd_attempts + 1):
         gp.lprint_var(exec_cmd_attempt_num)
         try: