improve exception handling (#23722)

make pep8
pull/23839/head
Sloane Hertel 8 years ago committed by Ryan Brown
parent 11c292bac2
commit 91644167c9

@ -126,6 +126,7 @@ def get_subnet_info(subnet):
return subnet_info return subnet_info
def subnet_exists(vpc_conn, subnet_id): def subnet_exists(vpc_conn, subnet_id):
filters = {'subnet-id': subnet_id} filters = {'subnet-id': subnet_id}
subnet = vpc_conn.get_all_subnets(filters=filters) 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: except EC2ResponseError as e:
if e.error_code == "DryRunOperation": if e.error_code == "DryRunOperation":
subnet = None 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: else:
raise AnsibleVPCSubnetCreationException( raise AnsibleVPCSubnetCreationException(
'Unable to create subnet {0}, error: {1}'.format(cidr, e)) 'Unable to create subnet {0}, error: {1}'.format(cidr, e))

@ -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.py
lib/ansible/modules/cloud/amazon/ec2_vpc_net_facts.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_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.py
lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py
lib/ansible/modules/cloud/amazon/ec2_win_password.py lib/ansible/modules/cloud/amazon/ec2_win_password.py

Loading…
Cancel
Save