summaryrefslogtreecommitdiffstats
path: root/roles/openshift_facts/library
diff options
context:
space:
mode:
authorMichael Scherer <misc@redhat.com>2016-11-22 15:14:04 +0100
committerMichael Scherer <misc@redhat.com>2016-11-23 00:51:27 +0100
commitdadca6a277f9853e9b7f8d20249a8d4f33af2af0 (patch)
treea05d39cec69d5e031d88a8753bd6d0bf8bdebfed /roles/openshift_facts/library
parent4954982b72451f82bd40802b0bdf39379ad4bdf1 (diff)
downloadopenshift-dadca6a277f9853e9b7f8d20249a8d4f33af2af0.tar.gz
openshift-dadca6a277f9853e9b7f8d20249a8d4f33af2af0.tar.bz2
openshift-dadca6a277f9853e9b7f8d20249a8d4f33af2af0.tar.xz
openshift-dadca6a277f9853e9b7f8d20249a8d4f33af2af0.zip
Verify the presence of dbus python binding
While the proper fix is to have it installed by default, this commit will also permit to have a better error message in the case the module is not present (as running on python 3)
Diffstat (limited to 'roles/openshift_facts/library')
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index d797eb4d3..0d85dba4b 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -22,9 +22,14 @@ from distutils.util import strtobool
from distutils.version import LooseVersion
import struct
import socket
-from dbus import SystemBus, Interface
-from dbus.exceptions import DBusException
+HAVE_DBUS=False
+try:
+ from dbus import SystemBus, Interface
+ from dbus.exceptions import DBusException
+ HAVE_DBUS=True
+except ImportError:
+ pass
DOCUMENTATION = '''
---
@@ -2277,6 +2282,9 @@ def main():
add_file_common_args=True,
)
+ if not HAVE_DBUS:
+ module.fail_json(msg="This module requires dbus python bindings")
+
module.params['gather_subset'] = ['hardware', 'network', 'virtual', 'facter']
module.params['gather_timeout'] = 10
module.params['filter'] = '*'