Repository: ambari Updated Branches: refs/heads/trunk da1701de9 -> c2e9b465d
AMBARI-17937:Ambari install/init should create a new gpadmin database (lavjain) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c2e9b465 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c2e9b465 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c2e9b465 Branch: refs/heads/trunk Commit: c2e9b465df3b3c175baf9048784f38dd486a14a6 Parents: da1701d Author: ljainpivotalio <[email protected]> Authored: Wed Aug 3 13:54:39 2016 -0700 Committer: ljainpivotalio <[email protected]> Committed: Wed Aug 3 13:54:39 2016 -0700 ---------------------------------------------------------------------- .../HAWQ/2.0.0/package/scripts/common.py | 14 ++++++++------ .../HAWQ/2.0.0/package/scripts/utils.py | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c2e9b465/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py index 8c43555..298513c 100644 --- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py +++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py @@ -31,7 +31,6 @@ import xml.etree.ElementTree as ET import utils import hawq_constants import custom_params -import hawqstatus def setup_user(): """ @@ -291,15 +290,18 @@ def start_component(component_name, port, data_dir): mode=0755) params.HdfsResource(None, action="execute") + options_str = "{0} -a -v".format(component_name) if os.path.exists(os.path.join(data_dir, hawq_constants.postmaster_opts_filename)): - return utils.exec_hawq_operation(hawq_constants.START, - "{0} -a -v".format(component_name), + return utils.exec_hawq_operation(hawq_constants.START, options_str, not_if=utils.generate_hawq_process_status_cmd(component_name, port)) - options_str = "{0} -a -v".format(component_name) + # Initialize HAWQ if component_name == hawq_constants.MASTER: - options_str+=" --ignore-bad-hosts" - utils.exec_hawq_operation(hawq_constants.INIT, options_str) + utils.exec_hawq_operation(hawq_constants.INIT, options_str + " --ignore-bad-hosts") + utils.exec_psql_cmd('create database {0};'.format(hawq_constants.hawq_user), + params.hawqmaster_host, params.hawq_master_address_port, ignore_error=True) + else: + utils.exec_hawq_operation(hawq_constants.INIT, options_str) def stop_component(component_name, mode): """ http://git-wip-us.apache.org/repos/asf/ambari/blob/c2e9b465/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 55a5982..95c3dcc 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 @@ -88,7 +88,7 @@ def exec_ssh_cmd(hostname, cmd): return process.returncode, stdout, stderr -def exec_psql_cmd(command, host, port, db=hawq_constants.POSTGRES, tuples_only=True): +def exec_psql_cmd(command, host, port, db=hawq_constants.POSTGRES, tuples_only=True, ignore_error=False): """ Sets up execution environment and runs the HAWQ queries """ @@ -100,7 +100,8 @@ def exec_psql_cmd(command, host, port, db=hawq_constants.POSTGRES, tuples_only=T 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)) - raise Fail("SQL command executed failed.") + if not ignore_error: + raise Fail("SQL command executed failed.") Logger.info("Output:\n{0}".format(out)) return retcode, out, err
