mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
cloudstack: fix wrong vpc found by name (#22603)
Fail fast if more than one VPC found with given identifier.
This commit is contained in:
@@ -260,9 +260,12 @@ class AnsibleCloudStackVpc(AnsibleCloudStack):
|
||||
if vpcs:
|
||||
vpc_name = self.module.params.get('name')
|
||||
for v in vpcs['vpc']:
|
||||
if vpc_name.lower() in [v['name'].lower(), v['id']]:
|
||||
self.vpc = v
|
||||
break
|
||||
if vpc_name in [v['name'], v['displaytext'], v['id']]:
|
||||
# Fail if the identifyer matches more than one VPC
|
||||
if self.vpc:
|
||||
self.module.fail_json(msg="More than one VPC found with the provided identifyer '%s'" % vpc_name)
|
||||
else:
|
||||
self.vpc = v
|
||||
return self.vpc
|
||||
|
||||
def restart_vpc(self):
|
||||
|
||||
Reference in New Issue
Block a user