From 67309fc8a7a4edd4996490b64f51ce37f0ed2327 Mon Sep 17 00:00:00 2001
From: Dan Kenigsberg <danken@redhat.com>
Date: Tue, 19 Jun 2012 00:33:22 +0300
Subject: [PATCH 03/17] deployUtil.yumSearchVersion: compare versions sanely
Change-Id: I0aa40c3395ca012a21f148f20125b54e3ba16d8a
Signed-off-by: Dan Kenigsberg <danken@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/5469
Reviewed-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Tested-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Reviewed-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/5544
Tested-by: Federico Simoncelli <fsimonce@redhat.com>
Reviewed-by: Federico Simoncelli <fsimonce@redhat.com>
---
vds_bootstrap/vds_bootstrap.py | 6 +++---
vdsm_reg/deployUtil.py.in | 31 +++++++------------------------
2 files changed, 10 insertions(+), 27 deletions(-)
diff --git a/vds_bootstrap/vds_bootstrap.py b/vds_bootstrap/vds_bootstrap.py
index 12e127e..9801459 100755
--- a/vds_bootstrap/vds_bootstrap.py
+++ b/vds_bootstrap/vds_bootstrap.py
@@ -80,13 +80,13 @@ fedorabased = deployUtil.versionCompare(deployUtil.getOSVersion(), "16") >= 0
if rhel6based:
VDSM_NAME = "vdsm"
- VDSM_MIN_VER = VDSM_NAME + "-4.9"
+ VDSM_MIN_VER = "4.9"
KERNEL_VER = "2.6.32-.*.el6"
KERNEL_MIN_VER = 150
MINIMAL_SUPPORTED_PLATFORM = "6.0"
else:
VDSM_NAME = "vdsm22"
- VDSM_MIN_VER = VDSM_NAME + "-4.5"
+ VDSM_MIN_VER = "4.5"
KERNEL_VER = "2.6.18-.*.el5"
KERNEL_MIN_VER = 159
MINIMAL_SUPPORTED_PLATFORM = "5.5"
@@ -250,7 +250,7 @@ class Deploy:
rc = True
try:
- rc = deployUtil.yumSearchVersion(VDSM_NAME, VDSM_MIN_VER, True)
+ rc = deployUtil.yumSearchVersion(VDSM_NAME, VDSM_MIN_VER)
except:
rc = False
logging.error("checkMajorVersion: Error searching for VDSM version!",
diff --git a/vdsm_reg/deployUtil.py.in b/vdsm_reg/deployUtil.py.in
index 1adf1a5..1474196 100644
--- a/vdsm_reg/deployUtil.py.in
+++ b/vdsm_reg/deployUtil.py.in
@@ -1039,32 +1039,15 @@ def yumListPackages(pkgName):
my.preconf.debuglevel = 0 # Remove yum noise
return my.pkgSack.searchNevra(name=pkgName)
-def yumSearchVersion(pkgName, ver, startWith=True):
- """
- Returns True is package exists in yum's db with the given version.
- Note: yum internal code has verEQ and verGT. We should use it ASAP.
- """
- fReturn = False
+def yumSearchVersion(pkgName, ver):
+ "Return True if package exists in yum's db with the given version or higer"
+ import rpmUtils.miscutils
- pkgs = yumListPackages(pkgName)
- if pkgs:
- for item in pkgs:
- if startWith:
- if str(item).startswith(ver):
- fReturn = True
- logging.debug("yumSearchVersion: pkg " + str(item) + " starts with: " + ver)
- else:
- logging.debug("yumSearchVersion: pkg " + str(item) + " does not start with: " + ver)
- else:
- if str(item) == ver:
- fReturn = True
- logging.debug("yumSearchVersion: pkg " + str(item) + " matches: " + ver)
- else:
- logging.debug("yumSearchVersion: pkg " + str(item) + " does not match: " + ver)
+ for pkg in yumListPackages(pkgName):
+ if rpmUtils.miscutils.compareVerOnly(pkg.ver, ver) >= 0:
+ return True
else:
- logging.debug("yumSearchVersion: package " + str(pkgName) + " not found!")
-
- return fReturn
+ return False
#############################################################################################################
# Host PKI functions.
--
1.7.1