Repository: ambari Updated Branches: refs/heads/branch-2.2 70c7432b8 -> 750e4e45d
AMBARI-15020: HAWQ service check fails when PXF is present due to cmd syntax error (bhuvnesh2703 via jaoki) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/750e4e45 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/750e4e45 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/750e4e45 Branch: refs/heads/branch-2.2 Commit: 750e4e45d6ea5bf4e73129475c1f3d67f10cf662 Parents: 70c7432 Author: Jun Aoki <ja...@apache.org> Authored: Wed Feb 17 11:13:31 2016 -0800 Committer: Jun Aoki <ja...@apache.org> Committed: Wed Feb 17 11:13:31 2016 -0800 ---------------------------------------------------------------------- .../common-services/HAWQ/2.0.0/package/scripts/utils.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/750e4e45/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/utils.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/utils.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/utils.py index a8036d8..dc6c203 100644 --- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/utils.py +++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/utils.py @@ -79,12 +79,8 @@ def exec_ssh_cmd(hostname, cmd): """ Runs the command on the remote host as gpadmin user """ - import params # Only gpadmin should be allowed to run command via ssh, thus not exposing user as a parameter - if params.hostname != hostname: - cmd = "su - {0} -c 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null {1} \"{2} \" '".format(hawq_constants.hawq_user, hostname, cmd) - else: - cmd = "su - {0} -c \"{1}\"".format(hawq_constants.hawq_user, cmd) + cmd = "su - {0} -c \"ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null {1} \\\"{2} \\\" \"".format(hawq_constants.hawq_user, hostname, cmd) Logger.info("Command executed: {0}".format(cmd)) process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) (stdout, stderr) = process.communicate() @@ -97,9 +93,9 @@ def exec_psql_cmd(command, host, port, db="template1", tuples_only=True): """ src_cmd = "export PGPORT={0} && source {1}".format(port, hawq_constants.hawq_greenplum_path_file) if tuples_only: - cmd = src_cmd + " && psql -d {0} -c \\\"{1};\\\"".format(db, command) + cmd = src_cmd + " && psql -d {0} -c \\\\\\\"{1};\\\\\\\"".format(db, command) else: - cmd = src_cmd + " && psql -t -d {0} -c \\\"{1};\\\"".format(db, command) + cmd = src_cmd + " && psql -t -d {0} -c \\\\\\\"{1};\\\\\\\"".format(db, command) retcode, out, err = exec_ssh_cmd(host, cmd) if retcode: Logger.error("SQL command executed failed: {0}\nReturncode: {1}\nStdout: {2}\nStderr: {3}".format(cmd, retcode, out, err))