mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Use common functions for handling import errors (#51851)
* Use common functions for handling import errors * use refactored version of gitlab modules
This commit is contained in:
parent
28dcfa985f
commit
c1e51ef486
39 changed files with 233 additions and 93 deletions
|
@ -120,15 +120,18 @@ hw_uuid:
|
|||
'''
|
||||
|
||||
import re
|
||||
import traceback
|
||||
import warnings
|
||||
|
||||
HPILO_IMP_ERR = None
|
||||
try:
|
||||
import hpilo
|
||||
HAS_HPILO = True
|
||||
except ImportError:
|
||||
HPILO_IMP_ERR = traceback.format_exc()
|
||||
HAS_HPILO = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
|
||||
|
||||
# Suppress warnings from hpilo
|
||||
|
@ -161,7 +164,7 @@ def main():
|
|||
)
|
||||
|
||||
if not HAS_HPILO:
|
||||
module.fail_json(msg='The hpilo python module is required')
|
||||
module.fail_json(msg=missing_required_lib('python-hpilo'), exception=HPILO_IMP_ERR)
|
||||
|
||||
host = module.params['host']
|
||||
login = module.params['login']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue