1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

improve exception handling (#23722)

make pep8
This commit is contained in:
Sloane Hertel 2017-04-20 16:40:37 -04:00 committed by Ryan Brown
parent 11c292bac2
commit 91644167c9
2 changed files with 18 additions and 16 deletions

View file

@ -126,6 +126,7 @@ def get_subnet_info(subnet):
return subnet_info
def subnet_exists(vpc_conn, subnet_id):
filters = {'subnet-id': subnet_id}
subnet = vpc_conn.get_all_subnets(filters=filters)
@ -149,6 +150,8 @@ def create_subnet(vpc_conn, vpc_id, cidr, az, check_mode):
except EC2ResponseError as e:
if e.error_code == "DryRunOperation":
subnet = None
elif e.error_code == "InvalidSubnet.Conflict":
raise AnsibleVPCSubnetCreationException("%s: the CIDR %s conflicts with another subnet with the VPC ID %s." % (e.error_code, cidr, vpc_id))
else:
raise AnsibleVPCSubnetCreationException(
'Unable to create subnet {0}, error: {1}'.format(cidr, e))

View file

@ -181,7 +181,6 @@ lib/ansible/modules/cloud/amazon/ec2_vpc_nat_gateway.py
lib/ansible/modules/cloud/amazon/ec2_vpc_net.py
lib/ansible/modules/cloud/amazon/ec2_vpc_net_facts.py
lib/ansible/modules/cloud/amazon/ec2_vpc_peer.py
lib/ansible/modules/cloud/amazon/ec2_vpc_subnet.py
lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py
lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py
lib/ansible/modules/cloud/amazon/ec2_win_password.py