You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2016/04/28 13:18:24 UTC

ambari git commit: AMBARI-16154. RU/EU fails due to changes in script.py arguments (aonishuk)

Repository: ambari
Updated Branches:
  refs/heads/trunk 79489a8f3 -> 97b44238e


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/97b44238
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/97b44238
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/97b44238

Branch: refs/heads/trunk
Commit: 97b44238e58b10fbfdabae988e11a7c051aad8a3
Parents: 79489a8
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Thu Apr 28 14:17:25 2016 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Thu Apr 28 14:17:25 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/97b44238/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 ecf0f1f..fcea23f 100644
--- a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
+++ b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
@@ -193,7 +193,11 @@ class CustomServiceOrchestrator():
       
       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/97b44238/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 9206887..f578fc4 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
 import resource_management
 from ambari_commons import OSCheck, OSConst
 from ambari_commons.constants import UPGRADE_TYPE_NON_ROLLING, UPGRADE_TYPE_ROLLING
@@ -63,7 +64,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
@@ -71,7 +72,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"}
@@ -198,9 +198,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)
      
@@ -211,7 +218,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)