Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 99F09200BB4 for ; Mon, 26 Sep 2016 18:08:57 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 98B10160ACA; Mon, 26 Sep 2016 16:08:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D4D05160AE8 for ; Mon, 26 Sep 2016 18:08:56 +0200 (CEST) Received: (qmail 56610 invoked by uid 500); 26 Sep 2016 16:08:55 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 56352 invoked by uid 99); 26 Sep 2016 16:08:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Sep 2016 16:08:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A07DCDFA44; Mon, 26 Sep 2016 16:08:55 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jonathanhurley@apache.org To: commits@ambari.apache.org Date: Mon, 26 Sep 2016 16:09:02 -0000 Message-Id: In-Reply-To: <27ff6f8fa4c84dafa84e184561761070@git.apache.org> References: <27ff6f8fa4c84dafa84e184561761070@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [8/8] ambari git commit: AMBARI-18465. Log results from shell commands run as user (aonishuk) archived-at: Mon, 26 Sep 2016 16:08:57 -0000 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 Authored: Mon Sep 26 18:18:34 2016 +0300 Committer: Andrew Onishuk 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()