Change in vdsm[master]: Using execCmd to run dmidecode command instead of using subp...

ybronhei at redhat.com ybronhei at redhat.com
Sun Jan 26 15:03:44 UTC 2014


Yaniv Bronhaim has uploaded a new change for review.

Change subject: Using execCmd to run dmidecode command instead of using subprocess.Popen
......................................................................

Using execCmd to run dmidecode command instead of using subprocess.Popen

This change is due to a bug while running 'vdsm-tool vdsm-id' as user
root which calls this function and fails on "require tty" for user root.

execCmd skip the sudo=True parameter while executing the command [1]

[1] http://gerrit.ovirt.org/#/c/23721/

Change-Id: I28f4aad240711a2ab4339c7551aa1d88913f735b
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1054759
Signed-off-by: Yaniv Bronhaim <ybronhei at redhat.com>
---
M lib/vdsm/utils.py
1 file changed, 5 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/22/23722/1

diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index a7e2320..001f660 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -689,21 +689,14 @@
         else:
             arch = platform.machine()
             if arch in ('x86_64', 'i686'):
-                p = subprocess.Popen([constants.EXT_SUDO,
-                                      constants.EXT_DMIDECODE, "-s",
-                                      "system-uuid"],
-                                     close_fds=True, stdin=subprocess.PIPE,
-                                     stdout=subprocess.PIPE,
-                                     stderr=subprocess.PIPE)
-                out, err = p.communicate()
-                out = '\n'.join(line for line in out.splitlines()
-                                if not line.startswith('#'))
-
-                if p.returncode == 0 and 'Not' not in out:
+                ret, out, err = execCmd([constants.EXT_DMIDECODE, "-s",
+                                         "system-uuid"],
+                                        sude=True)
+                if ret == 0 and 'Not' not in out:
                     #Avoid error string - 'Not Settable' or 'Not Present'
                     __hostUUID = out.strip()
                 else:
-                    logging.warning('Could not find host UUID.')
+                    logging.warning('Could not find host UUID: %s', err)
             elif arch in ('ppc', 'ppc64'):
                 #eg. output IBM,03061C14A
                 try:


-- 
To view, visit http://gerrit.ovirt.org/23722
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I28f4aad240711a2ab4339c7551aa1d88913f735b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei at redhat.com>


More information about the vdsm-patches mailing list