mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 14:40:19 -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
|
@ -236,7 +236,7 @@ RETURN = '''
|
|||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import get_exception
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
try:
|
||||
import pan.xapi
|
||||
|
@ -479,9 +479,8 @@ def main():
|
|||
try:
|
||||
if commit:
|
||||
match.delete()
|
||||
except PanXapiError:
|
||||
exc = get_exception()
|
||||
module.fail_json(msg=exc.message)
|
||||
except PanXapiError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
|
||||
module.exit_json(changed=True, msg='Rule \'%s\' successfully deleted' % rule_name)
|
||||
else:
|
||||
|
@ -525,9 +524,8 @@ def main():
|
|||
changed = add_rule(rulebase, new_rule)
|
||||
if changed and commit:
|
||||
device.commit(sync=True)
|
||||
except PanXapiError:
|
||||
exc = get_exception()
|
||||
module.fail_json(msg=exc.message)
|
||||
except PanXapiError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.exit_json(changed=changed, msg='Rule \'%s\' successfully added' % rule_name)
|
||||
elif operation == 'update':
|
||||
# Search for the rule. Update if found.
|
||||
|
@ -563,9 +561,8 @@ def main():
|
|||
changed = update_rule(rulebase, new_rule)
|
||||
if changed and commit:
|
||||
device.commit(sync=True)
|
||||
except PanXapiError:
|
||||
exc = get_exception()
|
||||
module.fail_json(msg=exc.message)
|
||||
except PanXapiError as exc:
|
||||
module.fail_json(msg=to_native(exc))
|
||||
module.exit_json(changed=changed, msg='Rule \'%s\' successfully updated' % rule_name)
|
||||
else:
|
||||
module.fail_json(msg='Rule \'%s\' does not exist. Use operation: \'add\' to add it.' % rule_name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue