mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Do not import xenapi without checking, so we can avoid (#1953)
backtrace
This commit is contained in:
committed by
Matt Clay
parent
6967a32ce4
commit
1702937ab3
@@ -28,7 +28,13 @@ author:
|
||||
'''
|
||||
|
||||
import platform
|
||||
import XenAPI
|
||||
|
||||
HAVE_XENAPI = False
|
||||
try:
|
||||
import XenAPI
|
||||
HAVE_XENAPI = True
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
EXAMPLES = '''
|
||||
- name: Gather facts from xenserver
|
||||
@@ -158,6 +164,9 @@ def get_srs(session):
|
||||
def main():
|
||||
module = AnsibleModule({})
|
||||
|
||||
if not HAVE_XENAPI:
|
||||
module.fail_json(changed=False, msg="python xen api required for this module")
|
||||
|
||||
obj = XenServerFacts()
|
||||
try:
|
||||
session = get_xenapi_session()
|
||||
|
||||
Reference in New Issue
Block a user