Repository: incubator-hawq
Updated Branches:
  refs/heads/2.2.0.0-incubating 18e928c91 -> 32e01c76b


HAWQ-1425. Print error message if ssh connect failed.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/32e01c76
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/32e01c76
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/32e01c76

Branch: refs/heads/2.2.0.0-incubating
Commit: 32e01c76b54782d0367204737d412cdf5b6146ff
Parents: 18e928c
Author: rlei <r...@pivotal.io>
Authored: Thu Apr 6 17:14:56 2017 +0800
Committer: rlei <r...@pivotal.io>
Committed: Fri Apr 7 18:16:10 2017 +0800

----------------------------------------------------------------------
 tools/bin/hawqpylib/hawqlib.py | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/32e01c76/tools/bin/hawqpylib/hawqlib.py
----------------------------------------------------------------------
diff --git a/tools/bin/hawqpylib/hawqlib.py b/tools/bin/hawqpylib/hawqlib.py
index 08a8caf..6914118 100755
--- a/tools/bin/hawqpylib/hawqlib.py
+++ b/tools/bin/hawqpylib/hawqlib.py
@@ -203,6 +203,13 @@ def check_hostname_equal(remote_host, user = ""):
     cmd = "hostname"
     result_local, local_hostname, stderr_remote  = local_ssh_output(cmd)
     result_remote, remote_hostname, stderr_remote = remote_ssh_output(cmd, 
remote_host, user)
+    if result_remote != 0:
+        print "Execute command '%s' failed with return code %d on %s." % (cmd, 
result_remote, remote_host)
+        print "Either ssh connection fails or command exits with error. 
Details:"
+        print stderr_remote
+        print "For ssh connection issue, please make sure passwordless ssh is 
enabled or check remote host."
+        sys.exit(result_remote)
+
     if local_hostname.strip() == remote_hostname.strip():
         return True
     else:
@@ -265,9 +272,9 @@ def local_ssh_output(cmd):
 def remote_ssh(cmd, host, user):
 
     if user == "":
-        remote_cmd_str = "ssh -o 'StrictHostKeyChecking no' %s \"%s\"" % 
(host, cmd)
+        remote_cmd_str = "ssh -o StrictHostKeyChecking=no %s \"%s\"" % (host, 
cmd)
     else:
-        remote_cmd_str = "ssh -o 'StrictHostKeyChecking no' %s@%s \"%s\"" % 
(user, host, cmd)
+        remote_cmd_str = "ssh -o StrictHostKeyChecking=no %s@%s \"%s\"" % 
(user, host, cmd)
     try:
         result = subprocess.Popen(remote_cmd_str, shell=True).wait()
     except subprocess.CalledProcessError:
@@ -280,14 +287,14 @@ def remote_ssh(cmd, host, user):
 def remote_ssh_output(cmd, host, user):
 
     if user == "":
-        remote_cmd_str = "ssh -o 'StrictHostKeyChecking no' %s \"%s\"" % 
(host, cmd)
+        remote_cmd_str = "ssh -o StrictHostKeyChecking=no %s \"%s\"" % (host, 
cmd)
     else:
-        remote_cmd_str = "ssh -o 'StrictHostKeyChecking no' %s@%s \"%s\"" % 
(user, host, cmd)
+        remote_cmd_str = "ssh -o StrictHostKeyChecking=no %s@%s \"%s\"" % 
(user, host, cmd)
 
     try:
         result = subprocess.Popen(remote_cmd_str, shell=True, stdout = 
subprocess.PIPE, stderr = subprocess.PIPE)
         stdout,stderr = result.communicate()
-    except subprocess.CalledProcessError:
+    except:
         print "Execute shell command on %s failed" % host
         pass
 

Reply via email to