HAWQ-1425. Print error message if ssh connect failed.
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 @@
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 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_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