Change in vdsm[master]: Remove usage of dmidecode for getting system uuid

bpradip at in.ibm.com bpradip at in.ibm.com
Tue Oct 16 01:40:00 UTC 2012


Pradipta Banerjee has uploaded a new change for review.

Change subject: Remove usage of dmidecode for getting system uuid
......................................................................

Remove usage of dmidecode for getting system uuid

The system uuid for x86 systems is available in /sys file system
This patchset removes the usage of dmidecode for retreiving system
uuid and instead uses the /sys file system to get the uuid

Change-Id: I2c06abc3ba00795fc9906ac67af61ef5d8513d3b
Signed-off-by: Pradipta Kr. Banerjee <bpradip at in.ibm.com>
---
M configure.ac
M vdsm.spec.in
M vdsm/constants.py.in
M vdsm/sudoers.vdsm.in
M vdsm/utils.py
M vdsm_reg/deployUtil.py.in
6 files changed, 4 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/96/8596/1

diff --git a/configure.ac b/configure.ac
index 450f714..bdc3a78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -134,7 +134,6 @@
 AC_PATH_PROG([CHOWN_PATH], [chown], [/bin/chown])
 AC_PATH_PROG([CP_PATH], [cp], [/bin/cp])
 AC_PATH_PROG([DD_PATH], [dd], [/bin/dd])
-AC_PATH_PROG([DMIDECODE_PATH], [dmidecode], [/usr/sbin/dmidecode])
 AC_PATH_PROG([DMSETUP_PATH], [dmsetup], [/sbin/dmsetup])
 AC_PATH_PROG([ECHO_PATH], [echo], [/bin/echo])
 AC_PATH_PROG([FSCK_PATH], [fsck], [/sbin/fsck])
diff --git a/vdsm.spec.in b/vdsm.spec.in
index a838ef3..c56ba39 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -68,10 +68,6 @@
 Requires: nfs-utils
 Requires: lvm2 >= 2.02.95
 
-%ifarch x86_64
-Requires: dmidecode
-%endif
-
 %if 0%{?rhel}
 Requires: python
 # Update the qemu-kvm requires when block_stream will be included
diff --git a/vdsm/constants.py.in b/vdsm/constants.py.in
index a91096f..ab045d0 100644
--- a/vdsm/constants.py.in
+++ b/vdsm/constants.py.in
@@ -88,7 +88,6 @@
 
 EXT_DD = '@DD_PATH@'
 EXT_DELNETWORK = '@VDSMDIR@/delNetwork'
-EXT_DMIDECODE = '@DMIDECODE_PATH@'
 EXT_DMSETUP = '@DMSETUP_PATH@'
 
 EXT_EDITNETWORK = '@VDSMDIR@/editNetwork'
diff --git a/vdsm/sudoers.vdsm.in b/vdsm/sudoers.vdsm.in
index ab99e8e..867d595 100644
--- a/vdsm/sudoers.vdsm.in
+++ b/vdsm/sudoers.vdsm.in
@@ -3,7 +3,6 @@
     @VDSMDIR@/delNetwork, \
     @VDSMDIR@/editNetwork, \
     @VDSMDIR@/vdsm-store-net-config, \
-    @DMIDECODE_PATH@, \
     @VDSMDIR@/mk_sysprep_floppy, \
     @SERVICE_PATH@ ksmtuned *, \
     @SERVICE_PATH@ ksm *, \
diff --git a/vdsm/utils.py b/vdsm/utils.py
index 0dbb342..9a0640f 100644
--- a/vdsm/utils.py
+++ b/vdsm/utils.py
@@ -31,7 +31,6 @@
 import os, time
 import logging
 import errno
-import subprocess
 import pwd
 import fcntl
 import functools
@@ -701,17 +700,8 @@
             with open(constants.P_VDSM_NODE_ID) as f:
                 __hostUUID = f.readline().replace("\n", "")
         else:
-            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:
-                #Avoid error string - 'Not Settable' or 'Not Present'
-                __hostUUID = out.strip()
+            if os.path.exists('/sys/devices/virtual/dmi/id/product_uuid'):
+                __hostUUID = file('/sys/devices/virtual/dmi/id/product_uuid').readline().strip()
             else:
                 logging.warning('Could not find host UUID.')
 
diff --git a/vdsm_reg/deployUtil.py.in b/vdsm_reg/deployUtil.py.in
index cd41028..34f8379 100644
--- a/vdsm_reg/deployUtil.py.in
+++ b/vdsm_reg/deployUtil.py.in
@@ -61,7 +61,6 @@
 # Executables
 EX_CAT = '@CAT_PATH@'
 EX_CHKCONFIG = '@CHKCONFIG_PATH@'
-EX_DMIDECODE = '@DMIDECODE_PATH@'
 EX_ECHO = '@ECHO_PATH@'
 EX_GRUBBY = '@GRUBBY_PATH@'
 EX_HWCLOCK = '@HWCLOCK_PATH@'
@@ -331,13 +330,8 @@
     """
     arch = platform.machine()
     if arch == 'x86_64':
-        out, err, ret = _logExec([EX_DMIDECODE, "-s", "system-uuid"])
-        out = '\n'.join( line for line in out.splitlines()
-                         if not line.startswith('#') )
-
-        # Avoid error string- 'Not Settable' or 'Not Present'
-        if ret == 0 and "Not" not in out:
-            return out.replace ("\n", "")
+        if os.path.exists('/sys/devices/virtual/dmi/id/product_uuid'):
+            return file('/sys/devices/virtual/dmi/id/product_uuid').readline().strip()
     elif arch == "ppc64":
         if os.path.exists('/proc/device-tree/system-id'):
             #eg. output IBM,03061C14A


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2c06abc3ba00795fc9906ac67af61ef5d8513d3b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Pradipta Banerjee <bpradip at in.ibm.com>


More information about the vdsm-patches mailing list