Pradipta Banerjee has uploaded a new change for review.

Change subject: Add getOSName() method in deployUtil for OS detection
......................................................................

Add getOSName() method in deployUtil for OS detection

This patch improves the current detection of whether the running
host is RHEL6 based or Fedora by adding a new method getOSName()

Change-Id: Ifff9b08902cd234dfa03292136317d50e5e3d22b
Signed-off-by: Pradipta Kr. Banerjee <[email protected]>
---
M vds_bootstrap/vds_bootstrap.py
M vdsm_reg/deployUtil.py.in
2 files changed, 24 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/02/8002/1

diff --git a/vds_bootstrap/vds_bootstrap.py b/vds_bootstrap/vds_bootstrap.py
index 537953d..c6ae08e 100755
--- a/vds_bootstrap/vds_bootstrap.py
+++ b/vds_bootstrap/vds_bootstrap.py
@@ -66,11 +66,18 @@
                              (LOGDIR, "phase1", strftime("%Y%m%d%H%M%S")),
                     filemode='w')
 
-rhel6based = deployUtil.versionCompare(deployUtil.getOSVersion(), "6.0") >= 0
+#Detect RHEL6 or Fedora16 as min supported version
+rhel6based = False
+fedorabased = False
+if (deployUtil.getOSName().lower() == "redhat" and
+        deployUtil.versionCompare(deployUtil.getOSVersion(), "6.0")) >= 0:
+        rhel6based = True
 
-# TODO this is an infra-hackish heuristic for identifying Fedora
-# drop as soon as possible
-fedorabased = deployUtil.versionCompare(deployUtil.getOSVersion(), "16") >= 0
+if (deployUtil.getOSName().lower() == "fedora" and
+        deployUtil.versionCompare(deployUtil.getOSVersion(), "16")) >= 0:
+        fedorabased = True
+
+logging.debug("fedorabased=%d rhel6based=%d", fedorabased, rhel6based)
 
 if rhel6based:
     VDSM_NAME = "vdsm"
diff --git a/vdsm_reg/deployUtil.py.in b/vdsm_reg/deployUtil.py.in
index bbda70e..e410e32 100644
--- a/vdsm_reg/deployUtil.py.in
+++ b/vdsm_reg/deployUtil.py.in
@@ -451,6 +451,19 @@
     logging.debug("OS Release Ver = %s", osVer[1])
     return osVer[1]
 
+def getOSName():
+    """
+    Return the OS Name, Fedora, Redhat etc
+
+    Return "Unknown OS" on any failure.
+    """
+
+    # platform.linux_distribution returns a tuple (distname, version, id) or
+    # default as given in args in case of any failure
+    osName = platform.linux_distribution(distname='Unknown OS', version='')
+    logging.debug("OS Name = %s", osName[0])
+    return osName[0]
+
 def getKernelVR():
     """Return current kernel version and release."""
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifff9b08902cd234dfa03292136317d50e5e3d22b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Pradipta Banerjee <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to