mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
amazon: extract copies of boto_exception to module_utils.ec2 (#20403)
* amazon: extract boto_exception to ec2 module This function was copy/pasted throughout several Amazon modules. This causes a consistency problem, since some improvements to message formatting were applied to some modules but not others. Now all modules use the same, improved function. * Rebase and make requested changes * Rebase and make requested changes
This commit is contained in:
parent
587ab33415
commit
1d4ca0fd51
10 changed files with 36 additions and 92 deletions
|
@ -352,6 +352,21 @@ Ansible format, this function will convert the keys to snake_case.
|
|||
Converts a an Ansible list of filters to a boto3 friendly list of dicts. This is useful for any
|
||||
boto3 `_facts` modules.
|
||||
|
||||
### boto_exception
|
||||
|
||||
Pass an exception returned from boto or boto3, and this function will consistently get the message from the exception.
|
||||
|
||||
```
|
||||
import traceback
|
||||
from ansible.module_utils.ec2 import boto_exception
|
||||
try:
|
||||
...
|
||||
except boto.exception.BotoServerError as err:
|
||||
error_msg = boto_exception(err)
|
||||
module.fail_json(msg=error_msg, exception=traceback.format_exc())
|
||||
```
|
||||
|
||||
|
||||
#### boto3_tag_list_to_ansible_dict
|
||||
|
||||
Converts a boto3 tag list to an Ansible dict. Boto3 returns tags as a list of dicts containing keys
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue