Dax Kelson created AMBARI-2984:
----------------------------------

             Summary: RPM has direct query mode, bootstrap.py should use it 
instead of needless pipe to grep
                 Key: AMBARI-2984
                 URL: https://issues.apache.org/jira/browse/AMBARI-2984
             Project: Ambari
          Issue Type: Improvement
            Reporter: Dax Kelson
            Priority: Minor


Here is my patch

From: Dax Kelson <[email protected]>
Date: Wed, 21 Aug 2013 17:59:15 -0600
Subject: [PATCH] Improved RPM query for sudo

No need to run "rpm -qa | grep sudo" when
"rpm -q sudo" works much faster and efficiently.

$ time rpm -qa | grep sudo
sudo-1.8.6p3-7.el6.x86_64

real    0m0.537s
user    0m0.323s
sys     0m0.161s

$ time rpm -q sudo
sudo-1.8.6p3-7.el6.x86_64

real    0m0.010s
user    0m0.009s
sys     0m0.000s
---
 ambari-server/src/main/python/bootstrap.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ambari-server/src/main/python/bootstrap.py 
b/ambari-server/src/main/python/bootstrap.py
index f83739b..b4bcdd2 100755
--- a/ambari-server/src/main/python/bootstrap.py
+++ b/ambari-server/src/main/python/bootstrap.py
@@ -549,7 +549,7 @@ class BootStrap:
   def checkSudoPackage(self):
     try:
       """ Checking 'sudo' package on remote hosts """
-      command = "rpm -qa | grep sudo"
+      command = "rpm -q sudo"
       pssh = PSSH(self.successive_hostlist, self.user, self.sshkeyFile, 
self.bootdir,\
                   errorMessage="Error: Sudo command is not available. Please 
install the sudo command.",\
                   command=command)
-- 
1.8.3.1


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to