mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-09 01:44:03 -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
|
@ -131,15 +131,17 @@ import socket
|
|||
import struct
|
||||
import traceback
|
||||
|
||||
PUREOMAPI_IMP_ERR = None
|
||||
try:
|
||||
from pypureomapi import Omapi, OmapiMessage, OmapiError, OmapiErrorNotFound
|
||||
from pypureomapi import pack_ip, unpack_ip, pack_mac, unpack_mac
|
||||
from pypureomapi import OMAPI_OP_STATUS, OMAPI_OP_UPDATE
|
||||
pureomapi_found = True
|
||||
except ImportError:
|
||||
PUREOMAPI_IMP_ERR = traceback.format_exc()
|
||||
pureomapi_found = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils._text import to_bytes, to_native
|
||||
|
||||
|
||||
|
@ -290,7 +292,7 @@ def main():
|
|||
)
|
||||
|
||||
if not pureomapi_found:
|
||||
module.fail_json(msg="pypureomapi library is required by this module.")
|
||||
module.fail_json(msg=missing_required_lib('pypureomapi'), exception=PUREOMAPI_IMP_ERR)
|
||||
|
||||
if module.params['key'] is None or len(module.params["key"]) == 0:
|
||||
module.fail_json(msg="'key' parameter cannot be empty.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue