Final round of moving modules to new import error msg (#51852)

* Final round of moving modules to new import error msg

* readd URL to jenkins install guide

* fix unit tests
This commit is contained in:
Jordan Borean 2019-02-08 10:07:01 +10:00 committed by GitHub
parent ffbc9d99de
commit a39c4ad464
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 292 additions and 150 deletions

View file

@ -151,14 +151,17 @@ state:
'''
import os
import traceback
IPADDRESS_IMP_ERR = None
try:
from ipaddress import ip_network
HAS_IPADDRESS = True
except ImportError:
IPADDRESS_IMP_ERR = traceback.format_exc()
HAS_IPADDRESS = False
from ansible.module_utils.basic import AnsibleModule, env_fallback
from ansible.module_utils.basic import AnsibleModule, env_fallback, missing_required_lib
from ansible.module_utils.cloudscale import AnsibleCloudscaleBase, cloudscale_argument_spec
@ -249,7 +252,7 @@ def main():
)
if not HAS_IPADDRESS:
module.fail_json(msg='Could not import the python library ipaddress required by this module')
module.fail_json(msg=missing_required_lib('ipaddress'), exception=IPADDRESS_IMP_ERR)
target_state = module.params['state']
target_server = module.params['server']