Browse Source

Merge pull request #2842 from mscherer/check_dbus_module

Verify the presence of dbus python binding
Scott Dodson 8 years ago
parent
commit
b93494b916
1 changed files with 10 additions and 2 deletions
  1. 10 2
      roles/openshift_facts/library/openshift_facts.py

+ 10 - 2
roles/openshift_facts/library/openshift_facts.py

@@ -22,9 +22,14 @@ from distutils.util import strtobool
 from distutils.version import LooseVersion
 from distutils.version import LooseVersion
 import struct
 import struct
 import socket
 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 = '''
 DOCUMENTATION = '''
 ---
 ---
@@ -2293,6 +2298,9 @@ def main():
         add_file_common_args=True,
         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_subset'] = ['hardware', 'network', 'virtual', 'facter']
     module.params['gather_timeout'] = 10
     module.params['gather_timeout'] = 10
     module.params['filter'] = '*'
     module.params['filter'] = '*'