ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [8/8] ambari git commit: AMBARI-18465. Log results from shell commands run as user (aonishuk)
Date Mon, 26 Sep 2016 16:09:02 GMT
AMBARI-18465. Log results from shell commands run as user  (aonishuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8192601d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8192601d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8192601d

Branch: refs/heads/branch-feature-AMBARI-18456
Commit: 8192601dfa606e72084813969b7de5af39bd083d
Parents: 5a29d48
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Mon Sep 26 18:18:34 2016 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Mon Sep 26 18:18:34 2016 +0300

----------------------------------------------------------------------
 .../libraries/functions/get_user_call_output.py        | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8192601d/ambari-common/src/main/python/resource_management/libraries/functions/get_user_call_output.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/get_user_call_output.py
b/ambari-common/src/main/python/resource_management/libraries/functions/get_user_call_output.py
index 4b11614..e0723c6 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/get_user_call_output.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/get_user_call_output.py
@@ -21,6 +21,7 @@ Ambari Agent
 """
 
 import os
+import sys
 import tempfile
 from resource_management.core import shell
 from resource_management.core.logger import Logger
@@ -60,9 +61,17 @@ def get_user_call_output(command, user, quiet=False, is_checked_call=True,
**cal
       if is_checked_call:
         raise Fail(err_msg)
       else:
-        Logger.warning(err_msg)      
+        Logger.warning(err_msg)
+
+    result = code, files_output[0], files_output[1]
     
-    return code, files_output[0], files_output[1]
+    caller_filename = sys._getframe(1).f_code.co_filename
+    is_internal_call = shell.NOT_LOGGED_FOLDER in caller_filename
+    if quiet == False or (quiet == None and not is_internal_call):
+      log_msg = "{0} returned {1}".format(get_user_call_output.__name__, result)
+      Logger.info(log_msg)
+
+    return result
   finally:
     for f in out_files:
       f.close()


Mime
View raw message