Change in vdsm[master]: Modify getOSVersion to use python 'platform' module

bpradip at in.ibm.com bpradip at in.ibm.com
Tue Sep 11 16:03:50 UTC 2012


Pradipta Banerjee has uploaded a new change for review.

Change subject: Modify getOSVersion to use python 'platform' module
......................................................................

Modify getOSVersion to use python 'platform' module

Modify getOSVersion function to use the python 'platform'
module instead of custom file parsing logic

Change-Id: Ia58284ce75dc6d09f0302181ea35ed3817dd861d
Signed-off-by: Pradipta Kr. Banerjee <bpradip at in.ibm.com>
---
M vdsm_reg/deployUtil.py.in
1 file changed, 6 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/30/7930/1

diff --git a/vdsm_reg/deployUtil.py.in b/vdsm_reg/deployUtil.py.in
index 55433eb..e181a4b 100644
--- a/vdsm_reg/deployUtil.py.in
+++ b/vdsm_reg/deployUtil.py.in
@@ -38,7 +38,7 @@
 import glob
 import imp
 from optparse import OptionParser
-from itertools import dropwhile, islice
+import platform
 
 try:
     from ovirtnode import ovirtfunctions
@@ -445,14 +445,13 @@
     Return "Unknown OS" on any failure.
     """
 
-    s = ''
+    osVer = ''
     try:
-        s = file('/etc/redhat-release', 'r').read()
-
-        return islice(dropwhile(lambda x: x != 'release', s.split()),
-                      1, 2).next()
+        osVer = platform.linux_distribution()
+        logging.debug("OS Release Ver = %s", osVer[1])
+        return osVer[1]
     except:
-        logging.error('failed to parse os release from `%s`.', s, exc_info=True)
+        logging.error('failed to get OS release')
         return "Unknown OS"
 
 def getKernelVR():


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia58284ce75dc6d09f0302181ea35ed3817dd861d
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