Skip to content

Commit

Permalink
Fix Filters case, add request call
Browse files Browse the repository at this point in the history
  • Loading branch information
mandar242 committed Aug 31, 2021
1 parent 6634233 commit 3ba662a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions plugins/modules/ec2_spot_instance_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

RETURN = '''
'''

import q
import time
import datetime

Expand All @@ -31,10 +33,17 @@

def describe_spot_instance_requests(connection, module):

changed = True

if module.check_mode:
module.exit_json(changed=changed)

params = {}

if module.params.get('filters'):
params['Filters'] = module.params.get('filters')
filters_dit = module.params.get('filters')
camel_filters = snake_dict_to_camel_dict(filters_dit, capitalize_first=True)
params['Filters'] = camel_filters
if module.params.get('dry_run'):
params['DryRun'] = module.params.get('dry_run')
if module.params.get('spot_instance_request_ids'):
Expand All @@ -44,7 +53,14 @@ def describe_spot_instance_requests(connection, module):
if module.params.get('max_results'):
params['MaxResults'] = module.params.get('max_results')

pass
try:
describe_spot_instance_requests_response = (connection.describe_spot_instance_requests(**params))
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg='Failed to describe sport instance requests')

describe_spot_instance_requests_response['Tags'] = boto3_tag_list_to_ansible_dict(describe_spot_instance_requests_response.get('Tags', []))
describe_spot_requests = camel_dict_to_snake_dict(describe_spot_instance_requests_response, ignore_list=['Tags'])
module.exit_json(describe_spot_requests=describe_spot_requests, changed=changed)

def main():

Expand Down

0 comments on commit 3ba662a

Please sign in to comment.