You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by rl...@apache.org on 2017/04/07 09:17:50 UTC
incubator-hawq git commit: HAWQ-1425. Print error message if ssh
connect failed.
Repository: incubator-hawq
Updated Branches:
refs/heads/master 1bbd1e969 -> a48afb614
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/a48afb61
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/a48afb61
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/a48afb61
Branch: refs/heads/master
Commit: a48afb6144289276fe3978302f5ad3337489a254
Parents: 1bbd1e9
Author: rlei <rl...@pivotal.io>
Authored: Thu Apr 6 17:14:56 2017 +0800
Committer: rlei <rl...@pivotal.io>
Committed: Fri Apr 7 17:17:00 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/a48afb61/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