Skip to content

Commit

Permalink
Big Black PR (ansible-collections#1784)
Browse files Browse the repository at this point in the history
* Black prep

* Black

* changelog

* Fix pylint unused-import in tests

* Split SSM connection plugin changes

* disable glue tests - bucket's missing

* Disable s3_logging and s3_sync tests

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@2c4575c
  • Loading branch information
tremble authored and mandar242 committed Oct 23, 2024
1 parent 2630549 commit 77faa7f
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions plugins/modules/ec2_transit_gateway_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,10 @@


class AnsibleEc2TgwInfo(object):

def __init__(self, module, results):
self._module = module
self._results = results
self._connection = self._module.client('ec2')
self._connection = self._module.client("ec2")
self._check_mode = self._module.check_mode

@AWSRetry.exponential_backoff()
Expand All @@ -193,26 +192,27 @@ def describe_transit_gateways(self):
connection : boto3 client connection object
"""
# collect parameters
filters = ansible_dict_to_boto3_filter_list(self._module.params['filters'])
transit_gateway_ids = self._module.params['transit_gateway_ids']
filters = ansible_dict_to_boto3_filter_list(self._module.params["filters"])
transit_gateway_ids = self._module.params["transit_gateway_ids"]

# init empty list for return vars
transit_gateway_info = list()

# Get the basic transit gateway info
try:
response = self._connection.describe_transit_gateways(
TransitGatewayIds=transit_gateway_ids, Filters=filters)
except is_boto3_error_code('InvalidTransitGatewayID.NotFound'):
self._results['transit_gateways'] = []
TransitGatewayIds=transit_gateway_ids, Filters=filters
)
except is_boto3_error_code("InvalidTransitGatewayID.NotFound"):
self._results["transit_gateways"] = []
return

for transit_gateway in response['TransitGateways']:
transit_gateway_info.append(camel_dict_to_snake_dict(transit_gateway, ignore_list=['Tags']))
for transit_gateway in response["TransitGateways"]:
transit_gateway_info.append(camel_dict_to_snake_dict(transit_gateway, ignore_list=["Tags"]))
# convert tag list to ansible dict
transit_gateway_info[-1]['tags'] = boto3_tag_list_to_ansible_dict(transit_gateway.get('Tags', []))
transit_gateway_info[-1]["tags"] = boto3_tag_list_to_ansible_dict(transit_gateway.get("Tags", []))

self._results['transit_gateways'] = transit_gateway_info
self._results["transit_gateways"] = transit_gateway_info
return


Expand All @@ -223,8 +223,8 @@ def setup_module_object():
"""

argument_spec = dict(
transit_gateway_ids=dict(type='list', default=[], elements='str', aliases=['transit_gateway_id']),
filters=dict(type='dict', default={})
transit_gateway_ids=dict(type="list", default=[], elements="str", aliases=["transit_gateway_id"]),
filters=dict(type="dict", default={}),
)

module = AnsibleAWSModule(
Expand All @@ -236,12 +236,9 @@ def setup_module_object():


def main():

module = setup_module_object()

results = dict(
changed=False
)
results = dict(changed=False)

tgwf_manager = AnsibleEc2TgwInfo(module=module, results=results)
try:
Expand All @@ -252,5 +249,5 @@ def main():
module.exit_json(**results)


if __name__ == '__main__':
if __name__ == "__main__":
main()

0 comments on commit 77faa7f

Please sign in to comment.