Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E365B17FE5 for ; Tue, 17 Mar 2015 16:41:13 +0000 (UTC) Received: (qmail 1001 invoked by uid 500); 17 Mar 2015 16:41:13 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 973 invoked by uid 500); 17 Mar 2015 16:41:13 -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 964 invoked by uid 99); 17 Mar 2015 16:41:13 -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; Tue, 17 Mar 2015 16:41:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7CBC4E17F2; Tue, 17 Mar 2015 16:41:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aonishuk@apache.org To: commits@ambari.apache.org Message-Id: <66aeed48c2384af0b7ed73f6d4ef9bc0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-10109. Improve logging of RMF (aonishuk) Date: Tue, 17 Mar 2015 16:41:13 +0000 (UTC) Repository: ambari Updated Branches: refs/heads/trunk 1db1692ee -> c34b47410 AMBARI-10109. Improve logging of RMF (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c34b4741 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c34b4741 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c34b4741 Branch: refs/heads/trunk Commit: c34b474108be07ea5db8fd56b04af96fb3dc06d1 Parents: 1db1692 Author: Andrew Onishuk Authored: Tue Mar 17 18:41:05 2015 +0200 Committer: Andrew Onishuk Committed: Tue Mar 17 18:41:05 2015 +0200 ---------------------------------------------------------------------- .../resource_management/TestDirectoryResource.py | 6 +++--- .../TestExecuteHadoopResource.py | 2 +- .../python/resource_management/TestFileResource.py | 4 ++-- .../python/resource_management/TestLinkResource.py | 4 ++-- .../TestMonitorWebserverResource.py | 16 ++++++++-------- .../test/python/resource_management/TestScript.py | 4 ++-- .../main/python/resource_management/core/base.py | 2 +- .../main/python/resource_management/core/shell.py | 8 +++++++- .../libraries/functions/version_select_util.py | 2 +- 9 files changed, 27 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c34b4741/ambari-agent/src/test/python/resource_management/TestDirectoryResource.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/test/python/resource_management/TestDirectoryResource.py b/ambari-agent/src/test/python/resource_management/TestDirectoryResource.py index f42de93..7667a2d 100644 --- a/ambari-agent/src/test/python/resource_management/TestDirectoryResource.py +++ b/ambari-agent/src/test/python/resource_management/TestDirectoryResource.py @@ -111,7 +111,7 @@ class TestDirectoryResource(TestCase): ) self.fail("Must fail because parent directory /a/b/c doesn't exist") except Fail as e: - self.assertEqual('Applying u"Directory[\'/a/b/c/d\']" failed, parent directory /a/b/c doesn\'t exist', + self.assertEqual('Applying Directory[\'/a/b/c/d\'] failed, parent directory /a/b/c doesn\'t exist', str(e)) @patch.object(sudo, "path_exists") @@ -130,7 +130,7 @@ class TestDirectoryResource(TestCase): ) self.fail("Must fail because file /a/b/c/d already exists") except Fail as e: - self.assertEqual('Applying u"Directory[\'/a/b/c/d\']" failed, file /a/b/c/d already exists', + self.assertEqual('Applying Directory[\'/a/b/c/d\'] failed, file /a/b/c/d already exists', str(e)) @patch.object(sudo, "rmtree") @@ -170,5 +170,5 @@ class TestDirectoryResource(TestCase): ) self.fail("Must fail because /a/b/c/d is not a directory") except Fail as e: - self.assertEqual('Applying u"Directory[\'/a/b/c/d\']" failed, /a/b/c/d is not a directory', + self.assertEqual('Applying Directory[\'/a/b/c/d\'] failed, /a/b/c/d is not a directory', str(e)) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/c34b4741/ambari-agent/src/test/python/resource_management/TestExecuteHadoopResource.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/test/python/resource_management/TestExecuteHadoopResource.py b/ambari-agent/src/test/python/resource_management/TestExecuteHadoopResource.py index a368e5d..6bb9d0f 100644 --- a/ambari-agent/src/test/python/resource_management/TestExecuteHadoopResource.py +++ b/ambari-agent/src/test/python/resource_management/TestExecuteHadoopResource.py @@ -176,7 +176,7 @@ class TestExecuteHadoopResource(TestCase): ) self.assertEqual(execute_mock.call_count, 2) self.assertEqual(str(execute_mock.call_args_list[0][0][0]), - 'u"Execute[\'path -kt keytab principal\']"') + 'Execute[\'path -kt keytab principal\']') self.assertEqual(execute_mock.call_args_list[0][0][0].command, 'path -kt keytab principal') self.assertEqual(execute_mock.call_args_list[0][0][0].arguments, http://git-wip-us.apache.org/repos/asf/ambari/blob/c34b4741/ambari-agent/src/test/python/resource_management/TestFileResource.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/test/python/resource_management/TestFileResource.py b/ambari-agent/src/test/python/resource_management/TestFileResource.py index f60fc12..703651c 100644 --- a/ambari-agent/src/test/python/resource_management/TestFileResource.py +++ b/ambari-agent/src/test/python/resource_management/TestFileResource.py @@ -48,7 +48,7 @@ class TestFileResource(TestCase): self.fail("Must fail when directory with name 'path' exist") except Fail as e: - self.assertEqual('Applying u"File[\'/existent_directory\']" failed, directory with name /existent_directory exists', + self.assertEqual('Applying File[\'/existent_directory\'] failed, directory with name /existent_directory exists', str(e)) self.assertFalse(dirname_mock.called) @@ -72,7 +72,7 @@ class TestFileResource(TestCase): self.fail('Must fail on non existent parent directory') except Fail as e: self.assertEqual( - 'Applying u"File[\'/non_existent_directory/file\']" failed, parent directory /non_existent_directory doesn\'t exist', + 'Applying File[\'/non_existent_directory/file\'] failed, parent directory /non_existent_directory doesn\'t exist', str(e)) self.assertTrue(dirname_mock.called) http://git-wip-us.apache.org/repos/asf/ambari/blob/c34b4741/ambari-agent/src/test/python/resource_management/TestLinkResource.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/test/python/resource_management/TestLinkResource.py b/ambari-agent/src/test/python/resource_management/TestLinkResource.py index 2d5194c..88a20a5 100644 --- a/ambari-agent/src/test/python/resource_management/TestLinkResource.py +++ b/ambari-agent/src/test/python/resource_management/TestLinkResource.py @@ -110,7 +110,7 @@ class TestLinkResource(TestCase): ) self.fail("Must fail when target directory do doenst exist") except Fail as e: - self.assertEqual('Failed to apply u"Link[\'/some_path\']", linking to nonexistent location /a/b/link_to_path', + self.assertEqual('Failed to apply Link[\'/some_path\'], linking to nonexistent location /a/b/link_to_path', str(e)) @patch.object(sudo, "path_isdir") @@ -130,7 +130,7 @@ class TestLinkResource(TestCase): ) self.fail("Must fail when hardlinking to directory") except Fail as e: - self.assertEqual('Failed to apply u"Link[\'/some_path\']", cannot create hard link to a directory (/a/b/link_to_path)', + self.assertEqual('Failed to apply Link[\'/some_path\'], cannot create hard link to a directory (/a/b/link_to_path)', str(e)) @patch.object(sudo, "unlink") http://git-wip-us.apache.org/repos/asf/ambari/blob/c34b4741/ambari-agent/src/test/python/resource_management/TestMonitorWebserverResource.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/test/python/resource_management/TestMonitorWebserverResource.py b/ambari-agent/src/test/python/resource_management/TestMonitorWebserverResource.py index 2125e72..2e4b473 100644 --- a/ambari-agent/src/test/python/resource_management/TestMonitorWebserverResource.py +++ b/ambari-agent/src/test/python/resource_management/TestMonitorWebserverResource.py @@ -31,11 +31,11 @@ class TestMonitorWebserverResource(TestCase): with Environment(test_mode=True) as env: MonitorWebserverProvider(MonitorWebserver("start")).action_start() defined_resources = env.resource_list - expected_resources = '[u"MonitorWebserver[\'start\']", u"Execute[\'grep -E \'KeepAlive (On|Off)\' ' \ + expected_resources = '[MonitorWebserver[\'start\'], Execute[\'grep -E \'KeepAlive (On|Off)\' ' \ '/etc/httpd/conf/httpd.conf && ambari-sudo.sh [RMF_ENV_PLACEHOLDER] -H -E sed -i ' \ '\'s/KeepAlive Off/KeepAlive On/\' /etc/httpd/conf/httpd.conf || echo \'KeepAlive On\' ' \ - '| ambari-sudo.sh [RMF_ENV_PLACEHOLDER] -H -E tee --append /etc/httpd/conf/httpd.conf > /dev/null\']"' \ - ', u"Execute[\'(\'/etc/init.d/httpd\', \'start\')\']"]' + '| ambari-sudo.sh [RMF_ENV_PLACEHOLDER] -H -E tee --append /etc/httpd/conf/httpd.conf > /dev/null\']' \ + ', Execute[\'(\'/etc/init.d/httpd\', \'start\')\']]' self.assertEqual(str(defined_resources), expected_resources) @patch.object(System, "os_family", new='suse') @@ -43,11 +43,11 @@ class TestMonitorWebserverResource(TestCase): with Environment(test_mode=True) as env: MonitorWebserverProvider(MonitorWebserver("start")).action_start() defined_resources = env.resource_list - expected_resources = '[u"MonitorWebserver[\'start\']", u"Execute[\'grep -E \'KeepAlive (On|Off)\' ' \ + expected_resources = '[MonitorWebserver[\'start\'], Execute[\'grep -E \'KeepAlive (On|Off)\' ' \ '/etc/apache2/httpd.conf && ambari-sudo.sh [RMF_ENV_PLACEHOLDER] -H -E sed -i ' \ '\'s/KeepAlive Off/KeepAlive On/\' /etc/apache2/httpd.conf || echo \'KeepAlive On\' ' \ - '| ambari-sudo.sh [RMF_ENV_PLACEHOLDER] -H -E tee --append /etc/apache2/httpd.conf > /dev/null\']",' \ - ' u"Execute[\'(\'/etc/init.d/apache2\', \'start\')\']"]' + '| ambari-sudo.sh [RMF_ENV_PLACEHOLDER] -H -E tee --append /etc/apache2/httpd.conf > /dev/null\'],' \ + ' Execute[\'(\'/etc/init.d/apache2\', \'start\')\']]' self.assertEqual(str(defined_resources), expected_resources) @patch.object(System, "os_family", new='redhat') @@ -55,7 +55,7 @@ class TestMonitorWebserverResource(TestCase): with Environment(test_mode=True) as env: MonitorWebserverProvider(MonitorWebserver("stop")).action_stop() defined_resources = env.resource_list - expected_resources = '[u"MonitorWebserver[\'stop\']", u"Execute[\'(\'/etc/init.d/httpd\', \'stop\')\']"]' + expected_resources = '[MonitorWebserver[\'stop\'], Execute[\'(\'/etc/init.d/httpd\', \'stop\')\']]' self.assertEqual(str(defined_resources), expected_resources) @patch.object(System, "os_family", new='suse') @@ -63,5 +63,5 @@ class TestMonitorWebserverResource(TestCase): with Environment(test_mode=True) as env: MonitorWebserverProvider(MonitorWebserver("stop")).action_stop() defined_resources = env.resource_list - expected_resources = '[u"MonitorWebserver[\'stop\']", u"Execute[\'(\'/etc/init.d/apache2\', \'stop\')\']"]' + expected_resources = '[MonitorWebserver[\'stop\'], Execute[\'(\'/etc/init.d/apache2\', \'stop\')\']]' self.assertEqual(str(defined_resources), expected_resources) http://git-wip-us.apache.org/repos/asf/ambari/blob/c34b4741/ambari-agent/src/test/python/resource_management/TestScript.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/test/python/resource_management/TestScript.py b/ambari-agent/src/test/python/resource_management/TestScript.py index da9aa0e..5f21c7a 100644 --- a/ambari-agent/src/test/python/resource_management/TestScript.py +++ b/ambari-agent/src/test/python/resource_management/TestScript.py @@ -89,7 +89,7 @@ class TestScript(TestCase): Script.config = dummy_config script.install_packages("env") resource_dump = pprint.pformat(env.resource_list) - self.assertEqual(resource_dump, '[u"Package[\'hbase\']", u"Package[\'yet-another-package\']"]') + self.assertEqual(resource_dump, '[Package[\'hbase\'], Package[\'yet-another-package\']]') @patch("__builtin__.open") def test_structured_out(self, open_mock): @@ -130,7 +130,7 @@ class TestScript(TestCase): Script.config = good_config script.set_version() resource_dump = pprint.pformat(env.resource_list) - self.assertEquals(resource_dump, '[u"Execute[\'(\'/usr/bin/hdp-select\', \'set\', \'kafka-broker\', \'2.2.0.0-2041\')\']"]') + self.assertEquals(resource_dump, '[Execute[\'(\'/usr/bin/hdp-select\', \'set\', \'kafka-broker\', \'2.2.0.0-2041\')\']]') # Component does not provide mapping get_stack_to_component_mock.return_value = {} http://git-wip-us.apache.org/repos/asf/ambari/blob/c34b4741/ambari-common/src/main/python/resource_management/core/base.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/core/base.py b/ambari-common/src/main/python/resource_management/core/base.py index cc5f111..67634cd 100644 --- a/ambari-common/src/main/python/resource_management/core/base.py +++ b/ambari-common/src/main/python/resource_management/core/base.py @@ -151,7 +151,7 @@ class Resource(object): pass def __repr__(self): - return repr(unicode(self)) + return unicode(self) def __unicode__(self): return u"%s['%s']" % (self.__class__.__name__, self.name) http://git-wip-us.apache.org/repos/asf/ambari/blob/c34b4741/ambari-common/src/main/python/resource_management/core/shell.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/core/shell.py b/ambari-common/src/main/python/resource_management/core/shell.py index cfa87f6..4fcb04b 100644 --- a/ambari-common/src/main/python/resource_management/core/shell.py +++ b/ambari-common/src/main/python/resource_management/core/shell.py @@ -66,7 +66,13 @@ def log_function_call(function): ('logoutput' in kwargs and kwargs['logoutput']==None and Logger.logger.isEnabledFor(logging.DEBUG)) or \ (not 'logoutput' in kwargs and not is_internal_call and Logger.logger.isEnabledFor(logging.DEBUG)) - return function(command, **kwargs) + result = function(command, **kwargs) + + if quiet == False or (quiet == None and not is_internal_call): + log_msg = "{0} returned {1}".format(function.__name__, result) + Logger.info(log_msg) + + return result return inner http://git-wip-us.apache.org/repos/asf/ambari/blob/c34b4741/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py b/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py index 138b97f..d1649df 100644 --- a/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py +++ b/ambari-common/src/main/python/resource_management/libraries/functions/version_select_util.py @@ -57,7 +57,7 @@ def get_component_version(stack_name, component_name): if code != 0 or out is None: raise Exception("Code is nonzero or output is empty") - Logger.info("Command: %s\nOutput: %s" % (get_hdp_comp_version_cmd, str(out))) + Logger.debug("Command: %s\nOutput: %s" % (get_hdp_comp_version_cmd, str(out))) matches = re.findall(r"([\d\.]+\-\d+)", out) version = matches[0] if matches and len(matches) > 0 else None except Exception, e: