cloudstack: ensure we select a template compatible with disksize (#21058)

When the user specify a root disk size, the template image must be
smaller than the specified root disk size.
pull/20423/head
Vincent Bernat 8 years ago committed by René Moser
parent 375846d764
commit d94f9bdd8d

@ -477,14 +477,20 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
if self.template:
return self._get_by_key(key, self.template)
rootdisksize = self.module.params.get('root_disk_size')
args['templatefilter'] = self.module.params.get('template_filter')
templates = self.cs.listTemplates(**args)
if templates:
for t in templates['template']:
if template in [ t['displaytext'], t['name'], t['id'] ]:
if rootdisksize and t['size'] > rootdisksize*1024**3:
continue
self.template = t
return self._get_by_key(key, self.template)
self.module.fail_json(msg="Template '%s' not found" % template)
more_info = ""
if rootdisksize:
more_info = " (with size <= %s)" % rootdisksize
self.module.fail_json(msg="Template '%s' not found%s" % (template, more_info))
elif iso:
if self.iso:

Loading…
Cancel
Save