fixed multi_ok(multi) usage in vpc_exists function
This commit is contained in:
parent
64f98f855d
commit
cc240e3f2d
1 changed files with 6 additions and 5 deletions
|
@ -118,9 +118,9 @@ def boto_exception(err):
|
||||||
return error
|
return error
|
||||||
|
|
||||||
def vpc_exists(module, vpc, name, cidr_block, multi):
|
def vpc_exists(module, vpc, name, cidr_block, multi):
|
||||||
"""Returns True or False in regards to the existence of a VPC. When supplied
|
"""Returns None or a vpc object depending on the existence of a VPC. When supplied
|
||||||
with a CIDR, it will check for matching tags to determine if it is a match
|
with a CIDR, it will check for matching tags to determine if it is a match
|
||||||
otherwise it will assume the VPC does not exist and thus return false.
|
otherwise it will assume the VPC does not exist and thus return None.
|
||||||
"""
|
"""
|
||||||
matched_vpc = None
|
matched_vpc = None
|
||||||
|
|
||||||
|
@ -130,11 +130,12 @@ def vpc_exists(module, vpc, name, cidr_block, multi):
|
||||||
e_msg=boto_exception(e)
|
e_msg=boto_exception(e)
|
||||||
module.fail_json(msg=e_msg)
|
module.fail_json(msg=e_msg)
|
||||||
|
|
||||||
if len(matching_vpcs) == 1:
|
if multi:
|
||||||
|
return None
|
||||||
|
elif len(matching_vpcs) == 1:
|
||||||
matched_vpc = matching_vpcs[0]
|
matched_vpc = matching_vpcs[0]
|
||||||
elif len(matching_vpcs) > 1:
|
elif len(matching_vpcs) > 1:
|
||||||
if multi:
|
module.fail_json(msg='Currently there are %d VPCs that have the same name and '
|
||||||
module.fail_json(msg='Currently there are %d VPCs that have the same name and '
|
|
||||||
'CIDR block you specified. If you would like to create '
|
'CIDR block you specified. If you would like to create '
|
||||||
'the VPC anyway please pass True to the multi_ok param.' % len(matching_vpcs))
|
'the VPC anyway please pass True to the multi_ok param.' % len(matching_vpcs))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue