mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 06:10:22 -07:00
Remove deprecated get_exception API
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
caefe31125
commit
6bd0fbb63c
42 changed files with 284 additions and 409 deletions
|
@ -134,7 +134,6 @@ build_errors:
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.aos.aos import get_aos_session, check_aos_version, find_collection_item
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
|
||||
|
||||
def create_blueprint(module, aos, name):
|
||||
|
@ -149,8 +148,7 @@ def create_blueprint(module, aos, name):
|
|||
blueprint = aos.Blueprints[name]
|
||||
blueprint.create(template_id, reference_arch=margs['reference_arch'])
|
||||
|
||||
except:
|
||||
exc = get_exception()
|
||||
except Exception as exc:
|
||||
msg = "Unable to create blueprint: %s" % exc.message
|
||||
if 'UNPROCESSABLE ENTITY' in exc.message:
|
||||
msg += ' (likely missing dependencies)'
|
||||
|
@ -170,8 +168,7 @@ def ensure_absent(module, aos, blueprint):
|
|||
if not module.check_mode:
|
||||
try:
|
||||
blueprint.delete()
|
||||
except:
|
||||
exc = get_exception()
|
||||
except Exception as exc:
|
||||
module.fail_json(msg='Unable to delete blueprint, %s' % exc.message)
|
||||
|
||||
module.exit_json(changed=True,
|
||||
|
@ -294,5 +291,6 @@ def main():
|
|||
|
||||
aos_blueprint(module)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -163,7 +163,7 @@ import json
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.aos.aos import get_aos_session, find_collection_item, check_aos_version
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
try:
|
||||
import yaml
|
||||
|
@ -238,10 +238,9 @@ def blueprint_param_present(module, aos, blueprint, param, param_value):
|
|||
if not module.check_mode:
|
||||
try:
|
||||
param.value = param_value
|
||||
except:
|
||||
exc = get_exception()
|
||||
module.fail_json(msg='unable to write to param %s: %r' %
|
||||
(margs['name'], exc))
|
||||
except Exception as exc:
|
||||
module.fail_json(msg='unable to write to param %s: %s' %
|
||||
(margs['name'], to_native(exc)))
|
||||
|
||||
module.exit_json(changed=True,
|
||||
blueprint=blueprint.name,
|
||||
|
@ -265,9 +264,8 @@ def blueprint_param_absent(module, aos, blueprint, param, param_value):
|
|||
if not module.check_mode:
|
||||
try:
|
||||
param.value = {}
|
||||
except:
|
||||
exc = get_exception()
|
||||
module.fail_json(msg='Unable to write to param %s: %r' % (margs['name'], exc))
|
||||
except Exception as exc:
|
||||
module.fail_json(msg='Unable to write to param %s: %s' % (margs['name'], to_native(exc)))
|
||||
|
||||
module.exit_json(changed=True,
|
||||
blueprint=blueprint.name,
|
||||
|
|
|
@ -84,8 +84,8 @@ EXAMPLES = '''
|
|||
|
||||
import json
|
||||
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.network.aos.aos import get_aos_session, find_collection_item, do_load_resource, check_aos_version, content_to_dict
|
||||
|
||||
|
||||
|
@ -103,9 +103,8 @@ def ensure_present(module, aos, blueprint, virtnet):
|
|||
if not module.check_mode:
|
||||
try:
|
||||
virtnet.create(module.params['content'])
|
||||
except:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="unable to create virtual-network : %r" % e)
|
||||
except Exception as e:
|
||||
module.fail_json(msg="unable to create virtual-network : %s" % to_native(e))
|
||||
|
||||
module.exit_json(changed=True,
|
||||
blueprint=blueprint.name,
|
||||
|
@ -120,9 +119,8 @@ def ensure_absent(module, aos, blueprint, virtnet):
|
|||
if not module.check_mode:
|
||||
try:
|
||||
virtnet.delete()
|
||||
except:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="unable to delete virtual-network %s : %r" % (virtnet.name, e))
|
||||
except Exception as e:
|
||||
module.fail_json(msg="unable to delete virtual-network %s : %s" % (virtnet.name, to_native(e)))
|
||||
|
||||
module.exit_json(changed=True,
|
||||
blueprint=blueprint.name)
|
||||
|
@ -214,5 +212,6 @@ def main():
|
|||
|
||||
blueprint_virtnet(module)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue