From ed25a625f0b678a8f1cbf0ed0b813230be4e1c75 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Wed, 13 May 2020 22:43:37 +0200 Subject: [PATCH] Sanity test fixups (#51) * Missing import * Tell the linter to ignore duplicat exceptions when using is_boto3_error_code * fix missing_variable (bad C&P) ci_complete --- plugins/modules/ec2_snapshot_info.py | 3 ++- plugins/modules/ec2_vol.py | 2 +- plugins/modules/ec2_vpc_net_info.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/modules/ec2_snapshot_info.py b/plugins/modules/ec2_snapshot_info.py index 156afe471d5..b89c3668b94 100644 --- a/plugins/modules/ec2_snapshot_info.py +++ b/plugins/modules/ec2_snapshot_info.py @@ -186,6 +186,7 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible_collections.amazon.aws.plugins.module_utils.aws.core import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.aws.core import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_tag_list_to_ansible_dict @@ -203,7 +204,7 @@ def list_ec2_snapshots(connection, module): if len(snapshot_ids) > 1: module.warn("Some of your snapshots may exist, but %s" % str(e)) snapshots = {'Snapshots': []} - except ClientError as e: + except ClientError as e: # pylint: disable=duplicate-except module.fail_json_aws(e, msg='Failed to describe snapshots') # Turn the boto3 result in to ansible_friendly_snaked_names diff --git a/plugins/modules/ec2_vol.py b/plugins/modules/ec2_vol.py index be467412b72..faad6182bd4 100644 --- a/plugins/modules/ec2_vol.py +++ b/plugins/modules/ec2_vol.py @@ -303,7 +303,7 @@ def delete_volume(module, ec2): except boto.exception.EC2ResponseError as ec2_error: if ec2_error.code == 'InvalidVolume.NotFound': module.exit_json(changed=False) - module.fail_json_aws(e) + module.fail_json_aws(ec2_error) def boto_supports_volume_encryption(): diff --git a/plugins/modules/ec2_vpc_net_info.py b/plugins/modules/ec2_vpc_net_info.py index f40f81e62b7..507f36db300 100644 --- a/plugins/modules/ec2_vpc_net_info.py +++ b/plugins/modules/ec2_vpc_net_info.py @@ -209,14 +209,14 @@ def describe_vpcs(connection, module): cl_enabled = connection.describe_vpc_classic_link(VpcIds=vpc_list) except is_boto3_error_code('UnsupportedOperation'): cl_enabled = {'Vpcs': [{'VpcId': vpc_id, 'ClassicLinkEnabled': False} for vpc_id in vpc_list]} - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: + except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: # pylint: disable=duplicate-except module.fail_json_aws(e, msg='Unable to describe if ClassicLink is enabled') try: cl_dns_support = connection.describe_vpc_classic_link_dns_support(VpcIds=vpc_list) except is_boto3_error_code('UnsupportedOperation'): cl_dns_support = {'Vpcs': [{'VpcId': vpc_id, 'ClassicLinkDnsSupported': False} for vpc_id in vpc_list]} - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: + except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: # pylint: disable=duplicate-except module.fail_json_aws(e, msg='Unable to describe if ClassicLinkDns is supported') # Loop through the results and add the other VPC attributes we gathered