ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject [1/3] ambari git commit: AMBARI-13627. Security can not be enabled on cluster with MOTD for "su" (aonishuk)
Date Thu, 29 Oct 2015 11:46:09 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 2c9647a60 -> c1cda7f03
  refs/heads/branch-2.1.2 4c1787a6b -> 51ac4130a
  refs/heads/trunk db399a13f -> 0388379b7


AMBARI-13627. Security can not be enabled on cluster with MOTD for "su" (aonishuk)


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

Branch: refs/heads/trunk
Commit: 0388379b7d1032ee2314d6bce31b6de2d791b44a
Parents: db399a1
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Thu Oct 29 13:45:56 2015 +0200
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Thu Oct 29 13:45:56 2015 +0200

----------------------------------------------------------------------
 .../libraries/functions/get_user_call_output.py    |  6 +++---
 .../STORM/0.9.1.2.1/package/scripts/service.py     |  3 ++-
 .../stacks/2.1/STORM/test_storm_drpc_server.py     |  9 +++++----
 .../python/stacks/2.1/STORM/test_storm_nimbus.py   | 10 +++++-----
 .../2.1/STORM/test_storm_rest_api_service.py       |  9 +++++----
 .../stacks/2.1/STORM/test_storm_supervisor.py      | 17 +++++++++--------
 .../stacks/2.1/STORM/test_storm_supervisor_prod.py |  9 +++++----
 .../stacks/2.1/STORM/test_storm_ui_server.py       | 12 +++++++-----
 8 files changed, 41 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0388379b/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 b254372..732cc7f 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
@@ -24,7 +24,7 @@ import os
 import tempfile
 from resource_management.core import shell
 
-def get_user_call_output(command, user, is_checked_call=True, **call_kwargs):
+def get_user_call_output(command, user, quiet=False, is_checked_call=True, **call_kwargs):
   """
   This function eliminates only output of command inside the su, ignoring the su ouput itself.
   This is useful since some users have motd messages setup by default on su -l. 
@@ -46,11 +46,11 @@ def get_user_call_output(command, user, is_checked_call=True, **call_kwargs):
     command_string += " 2>" + out_files[1].name
     
     func = shell.checked_call if is_checked_call else shell.call
-    func_result = func(shell.as_user(command_string, user), **call_kwargs)
+    func_result = func(shell.as_user(command_string, user), quiet=quiet, **call_kwargs)
     
     files_output = []
     for f in out_files:
-      files_output.append(f.read())
+      files_output.append(f.read().strip('\n'))
     
     return func_result[0], files_output[0], files_output[1]
   finally:

http://git-wip-us.apache.org/repos/asf/ambari/blob/0388379b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py
b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py
index fcd3da5..3210d8a 100644
--- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py
+++ b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py
@@ -22,6 +22,7 @@ from resource_management.core.resources import Execute
 from resource_management.core.resources import File
 from resource_management.core.shell import as_user
 from resource_management.libraries.functions.format import format
+from resource_management.libraries.functions import get_user_call_output
 import time
 
 
@@ -75,7 +76,7 @@ def service(name, action = 'start'):
 
   elif action == "stop":
     process_dont_exist = format("! ({no_op_test})")
-    pid = '`' + as_user(format("cat {pid_file}"), user=params.storm_user) + '`'
+    pid = get_user_call_output.get_user_call_output(format("cat {pid_file}"), user=params.storm_user)[1]
 
     Execute(format("{sudo} kill {pid}"),
       not_if = process_dont_exist)

http://git-wip-us.apache.org/repos/asf/ambari/blob/0388379b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_drpc_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_drpc_server.py b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_drpc_server.py
index 7eb3f50..5211a02 100644
--- a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_drpc_server.py
+++ b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_drpc_server.py
@@ -24,6 +24,7 @@ from stacks.utils.RMFTestCase import *
 import resource_management.core.source
 from test_storm_base import TestStormBase
 
+@patch("resource_management.libraries.functions.get_user_call_output.get_user_call_output",
new=MagicMock(return_value=(0, '123', '')))
 class TestStormDrpcServer(TestStormBase):
 
   def test_configure_default(self):
@@ -73,10 +74,10 @@ class TestStormDrpcServer(TestStormBase):
                        hdp_stack_version = self.STACK_VERSION,
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/drpc.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/drpc.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/drpc.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/drpc.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/drpc.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/drpc.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/drpc.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/drpc.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )
@@ -130,10 +131,10 @@ class TestStormDrpcServer(TestStormBase):
                        hdp_stack_version = self.STACK_VERSION,
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/drpc.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/drpc.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/drpc.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/drpc.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/drpc.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/drpc.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/drpc.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/drpc.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/0388379b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py
index 39c7ee3..323f3ef 100644
--- a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py
+++ b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_nimbus.py
@@ -24,7 +24,7 @@ from stacks.utils.RMFTestCase import *
 import resource_management.core.source
 from test_storm_base import TestStormBase
 
-
+@patch("resource_management.libraries.functions.get_user_call_output.get_user_call_output",
new=MagicMock(return_value=(0, '123', '')))
 class TestStormNimbus(TestStormBase):
 
   def test_configure_default(self):
@@ -72,10 +72,10 @@ class TestStormNimbus(TestStormBase):
                        hdp_stack_version = self.STACK_VERSION,
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/nimbus.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/nimbus.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/nimbus.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/nimbus.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/nimbus.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/nimbus.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/nimbus.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/nimbus.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )
@@ -129,10 +129,10 @@ class TestStormNimbus(TestStormBase):
                        hdp_stack_version = self.STACK_VERSION,
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/nimbus.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/nimbus.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/nimbus.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/nimbus.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/nimbus.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/nimbus.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/nimbus.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/nimbus.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/0388379b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_rest_api_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_rest_api_service.py
b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_rest_api_service.py
index 127e63d..0419b3c 100644
--- a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_rest_api_service.py
+++ b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_rest_api_service.py
@@ -24,6 +24,7 @@ from stacks.utils.RMFTestCase import *
 import  resource_management.core.source
 from test_storm_base import TestStormBase
 
+@patch("resource_management.libraries.functions.get_user_call_output.get_user_call_output",
new=MagicMock(return_value=(0, '123', '')))
 class TestStormRestApi(TestStormBase):
 
   def test_configure_default(self):
@@ -72,10 +73,10 @@ class TestStormRestApi(TestStormBase):
                        hdp_stack_version = self.STACK_VERSION,
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/restapi.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/restapi.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/restapi.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/restapi.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/restapi.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/restapi.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/restapi.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/restapi.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )
@@ -129,10 +130,10 @@ class TestStormRestApi(TestStormBase):
                        hdp_stack_version = self.STACK_VERSION,
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/restapi.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/restapi.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/restapi.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/restapi.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/restapi.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/restapi.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/restapi.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/restapi.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/0388379b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor.py b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor.py
index ef1c91e..742556e 100644
--- a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor.py
+++ b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor.py
@@ -24,6 +24,7 @@ from stacks.utils.RMFTestCase import *
 import  resource_management.core.source
 from test_storm_base import TestStormBase
 
+@patch("resource_management.libraries.functions.get_user_call_output.get_user_call_output",
new=MagicMock(return_value=(0, '123', '')))
 class TestStormSupervisor(TestStormBase):
 
   def test_configure_default(self):
@@ -84,20 +85,20 @@ class TestStormSupervisor(TestStormBase):
                        hdp_stack_version = self.STACK_VERSION,
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/supervisor.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/supervisor.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/supervisor.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/supervisor.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/supervisor.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/supervisor.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/supervisor.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/supervisor.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )
     self.assertResourceCalled('File', '/var/run/storm/supervisor.pid',
         action = ['delete'],
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/logviewer.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/logviewer.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/logviewer.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/logviewer.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/logviewer.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/logviewer.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/logviewer.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/logviewer.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )
@@ -164,20 +165,20 @@ class TestStormSupervisor(TestStormBase):
                        hdp_stack_version = self.STACK_VERSION,
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/supervisor.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/supervisor.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/supervisor.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/supervisor.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/supervisor.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/supervisor.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/supervisor.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/supervisor.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )
     self.assertResourceCalled('File', '/var/run/storm/supervisor.pid',
         action = ['delete'],
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/logviewer.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/logviewer.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/logviewer.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/logviewer.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/logviewer.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/logviewer.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/logviewer.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/logviewer.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/0388379b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor_prod.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor_prod.py
b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor_prod.py
index cd06e5b..631a9ed 100644
--- a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor_prod.py
+++ b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_supervisor_prod.py
@@ -24,6 +24,7 @@ from stacks.utils.RMFTestCase import *
 import resource_management.core.source
 from test_storm_base import TestStormBase
 
+@patch("resource_management.libraries.functions.get_user_call_output.get_user_call_output",
new=MagicMock(return_value=(0, '123', '')))
 class TestStormSupervisor(TestStormBase):
 
   def test_configure_default(self):
@@ -77,10 +78,10 @@ class TestStormSupervisor(TestStormBase):
     self.assertResourceCalled('Execute', 'supervisorctl stop storm-supervisor',
                               wait_for_finish = False,
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/logviewer.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/logviewer.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/logviewer.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/logviewer.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/logviewer.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/logviewer.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/logviewer.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/logviewer.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )
@@ -142,10 +143,10 @@ class TestStormSupervisor(TestStormBase):
                               wait_for_finish = False,
     )
 
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/logviewer.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/logviewer.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/logviewer.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/logviewer.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/logviewer.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/logviewer.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/logviewer.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/logviewer.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/0388379b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_ui_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_ui_server.py b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_ui_server.py
index 78e8202..b16104b 100644
--- a/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_ui_server.py
+++ b/ambari-server/src/test/python/stacks/2.1/STORM/test_storm_ui_server.py
@@ -23,6 +23,8 @@ from mock.mock import MagicMock, call, patch
 from stacks.utils.RMFTestCase import *
 import resource_management.core.source
 from test_storm_base import TestStormBase
+
+@patch("resource_management.libraries.functions.get_user_call_output.get_user_call_output",
new=MagicMock(return_value=(0, '123', '')))
 class TestStormUiServer(TestStormBase):
 
   def test_configure_default(self):
@@ -61,7 +63,7 @@ class TestStormUiServer(TestStormBase):
         try_sleep = 10,
     )
     self.assertNoMoreResources()
-
+  
   def test_stop_default(self):
     self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/ui_server.py",
                        classname = "UiServer",
@@ -70,10 +72,10 @@ class TestStormUiServer(TestStormBase):
                        hdp_stack_version = self.STACK_VERSION,
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/ui.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/ui.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/ui.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/ui.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/ui.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/ui.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/ui.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/ui.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )
@@ -127,10 +129,10 @@ class TestStormUiServer(TestStormBase):
                        hdp_stack_version = self.STACK_VERSION,
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su storm -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/ui.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
         not_if = "! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/ui.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/ui.pid`
>/dev/null 2>&1')",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su storm
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/storm/ui.pid'`",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
         not_if = "sleep 2; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/ui.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/ui.pid`
>/dev/null 2>&1') || sleep 20; ! (ambari-sudo.sh su storm -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]ls
/var/run/storm/ui.pid >/dev/null 2>&1 && ps -p `cat /var/run/storm/ui.pid`
>/dev/null 2>&1')",
         ignore_failures = True,
     )


Mime
View raw message