Repository: ambari Updated Branches: refs/heads/branch-2.2 3e04c3943 -> 9e1739342
AMBARI-16154. RU/EU fails due to changes in script.py arguments (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9e173934 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9e173934 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9e173934 Branch: refs/heads/branch-2.2 Commit: 9e1739342a2111fc3dbc9f929c4ffb8524711609 Parents: 3e04c39 Author: Andrew Onishuk <[email protected]> Authored: Fri Apr 29 01:32:22 2016 +0300 Committer: Andrew Onishuk <[email protected]> Committed: Fri Apr 29 01:32:22 2016 +0300 ---------------------------------------------------------------------- .../ambari_agent/CustomServiceOrchestrator.py | 6 +++++- .../resource_management/libraries/script/script.py | 16 +++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9e173934/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py index fb5f78e..c77e094 100644 --- a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py +++ b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py @@ -189,7 +189,11 @@ class CustomServiceOrchestrator(): python_executor = self.get_py_executor(forced_command_name) for py_file, current_base_dir in filtered_py_file_list: log_info_on_failure = not command_name in self.DONT_DEBUG_FAILURES_FOR_COMMANDS - script_params = [command_name, json_path, current_base_dir, tmpstrucoutfile, logger_level, self.exec_tmp_dir, str(log_out_files)] + script_params = [command_name, json_path, current_base_dir, tmpstrucoutfile, logger_level, self.exec_tmp_dir] + + if log_out_files: + script_params.append("-o") + ret = python_executor.run_file(py_file, script_params, tmpoutfile, tmperrfile, timeout, tmpstrucoutfile, self.map_task_to_process, http://git-wip-us.apache.org/repos/asf/ambari/blob/9e173934/ambari-common/src/main/python/resource_management/libraries/script/script.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/libraries/script/script.py b/ambari-common/src/main/python/resource_management/libraries/script/script.py index 5c06d5e..8984b4f 100644 --- a/ambari-common/src/main/python/resource_management/libraries/script/script.py +++ b/ambari-common/src/main/python/resource_management/libraries/script/script.py @@ -28,6 +28,7 @@ import logging import platform import inspect import tarfile +from optparse import OptionParser from ambari_commons import OSCheck, OSConst from ambari_commons.constants import UPGRADE_TYPE_NON_ROLLING, UPGRADE_TYPE_ROLLING from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl @@ -58,7 +59,7 @@ if OSCheck.is_windows_family(): else: from resource_management.libraries.functions.tar_archive import archive_dir -USAGE = """Usage: {0} <COMMAND> <JSON_CONFIG> <BASEDIR> <STROUTPUT> <LOGGING_LEVEL> <TMP_DIR> <LOG_OUT_FILES> +USAGE = """Usage: {0} <COMMAND> <JSON_CONFIG> <BASEDIR> <STROUTPUT> <LOGGING_LEVEL> <TMP_DIR> <COMMAND> command type (INSTALL/CONFIGURE/START/STOP/SERVICE_CHECK...) <JSON_CONFIG> path to command json file. Ex: /var/lib/ambari-agent/data/command-2.json @@ -66,7 +67,6 @@ USAGE = """Usage: {0} <COMMAND> <JSON_CONFIG> <BASEDIR> <STROUTPUT> <LOGGING_LEV <STROUTPUT> path to file with structured command output (file will be created). Ex:/tmp/my.txt <LOGGING_LEVEL> log level for stdout. Ex:DEBUG,INFO <TMP_DIR> temporary directory for executable scripts. Ex: /var/lib/ambari-agent/tmp -<LOG_OUT_FILES> before start is done, should the service *.out files content be logged. Ex: false """ _PASSWORD_MAP = {"/configurations/cluster-env/hadoop.user.name":"/configurations/cluster-env/hadoop.user.password"} @@ -179,9 +179,16 @@ class Script(object): Sets up logging; Parses command parameters and executes method relevant to command type """ + parser = OptionParser() + parser.add_option("-o", "--out-files-logging", dest="log_out_files", action="store_true", + help="use this option to enable outputting *.out files of the service pre-start") + (self.options, args) = parser.parse_args() + + self.log_out_files = self.options.log_out_files + # parse arguments - if len(sys.argv) < 8: - print "Script expects at least 7 arguments" + if len(args) < 6: + print "Script expects at least 6 arguments" print USAGE.format(os.path.basename(sys.argv[0])) # print to stdout sys.exit(1) @@ -192,7 +199,6 @@ class Script(object): self.load_structured_out() self.logging_level = sys.argv[5] Script.tmp_dir = sys.argv[6] - self.log_out_files = sys.argv[7].lower() == "true" logging_level_str = logging._levelNames[self.logging_level] Logger.initialize_logger(__name__, logging_level=logging_level_str)
