summaryrefslogtreecommitdiffstats
path: root/roles/openshift_health_checker
diff options
context:
space:
mode:
authorJakub Hadvig <jhadvig@redhat.com>2017-09-05 11:03:03 +0200
committerJakub Hadvig <jhadvig@redhat.com>2017-09-05 16:11:03 +0200
commitbc79e5c3093c23ba16f79421ff53ed0c7a22a14a (patch)
tree4b79ce39c3bdb5eb95145c17d2ad3f0765265236 /roles/openshift_health_checker
parent91a2cac8f5a5ae438b034e3712525480ce749fa6 (diff)
downloadopenshift-bc79e5c3093c23ba16f79421ff53ed0c7a22a14a.tar.gz
openshift-bc79e5c3093c23ba16f79421ff53ed0c7a22a14a.tar.bz2
openshift-bc79e5c3093c23ba16f79421ff53ed0c7a22a14a.tar.xz
openshift-bc79e5c3093c23ba16f79421ff53ed0c7a22a14a.zip
Import dnf only if importing yum fails
Diffstat (limited to 'roles/openshift_health_checker')
-rw-r--r--roles/openshift_health_checker/library/aos_version.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/roles/openshift_health_checker/library/aos_version.py b/roles/openshift_health_checker/library/aos_version.py
index c8769b511..34d8f71e7 100644
--- a/roles/openshift_health_checker/library/aos_version.py
+++ b/roles/openshift_health_checker/library/aos_version.py
@@ -32,11 +32,14 @@ try:
PKG_MGR = "yum"
except ImportError as err:
YUM_IMPORT_EXCEPTION = err
-try:
- import dnf # pylint: disable=import-error
- PKG_MGR = "dnf"
-except ImportError as err:
- DNF_IMPORT_EXCEPTION = err
+
+# Import and use dnf only if yum is missing
+if YUM_IMPORT_EXCEPTION:
+ try:
+ import dnf # pylint: disable=import-error
+ PKG_MGR = "dnf"
+ except ImportError as err:
+ DNF_IMPORT_EXCEPTION = err
class AosVersionException(Exception):
@@ -127,8 +130,11 @@ def _retrieve_available_packages(expected_pkgs):
dquery = dbase.sack.query()
aquery = dquery.available()
+ iquery = dquery.installed()
- pkgs = list(aquery.filter(name=expected_pkgs))
+ available_pkgs = list(aquery.filter(name=expected_pkgs))
+ installed_pkgs = list(iquery.filter(name=expected_pkgs))
+ pkgs = available_pkgs + installed_pkgs
if not pkgs:
# pkgs list is empty, raise because no expected packages found