|
|
|
@ -219,16 +219,28 @@ class AnsibleCloudStackVpc(AnsibleCloudStack):
|
|
|
|
|
|
|
|
|
|
def get_vpc_offering(self, key=None):
|
|
|
|
|
vpc_offering = self.module.params.get('vpc_offering')
|
|
|
|
|
args = {}
|
|
|
|
|
args = {
|
|
|
|
|
'state': 'Enabled',
|
|
|
|
|
}
|
|
|
|
|
if vpc_offering:
|
|
|
|
|
args['name'] = vpc_offering
|
|
|
|
|
fail_msg = "VPC offering not found or not enabled: %s" % vpc_offering
|
|
|
|
|
else:
|
|
|
|
|
args['isdefault'] = True
|
|
|
|
|
fail_msg = "No enabled default VPC offering found"
|
|
|
|
|
|
|
|
|
|
vpc_offerings = self.query_api('listVPCOfferings', **args)
|
|
|
|
|
if vpc_offerings:
|
|
|
|
|
return self._get_by_key(key, vpc_offerings['vpcoffering'][0])
|
|
|
|
|
self.module.fail_json(msg="VPC offering not found: %s" % vpc_offering)
|
|
|
|
|
# The API name argument filter also matches substrings, we have to
|
|
|
|
|
# iterate over the results to get an exact match
|
|
|
|
|
for vo in vpc_offerings['vpcoffering']:
|
|
|
|
|
if 'name' in args:
|
|
|
|
|
if args['name'] == vo['name']:
|
|
|
|
|
return self._get_by_key(key, vo)
|
|
|
|
|
# Return the first offering found, if not queried for the name
|
|
|
|
|
else:
|
|
|
|
|
return self._get_by_key(key, vo)
|
|
|
|
|
self.module.fail_json(msg=fail_msg)
|
|
|
|
|
|
|
|
|
|
def get_vpc(self):
|
|
|
|
|
if self.vpc:
|
|
|
|
|