cloudstack: cs_instance: fix template not found (#2005)

Let users decide which filter should be used to find the template.
pull/18777/head
René Moser 9 years ago committed by Matt Clay
parent b5e4edd9f9
commit d7e8dd22df

@ -88,6 +88,15 @@ options:
- Mutually exclusive with C(template) option. - Mutually exclusive with C(template) option.
required: false required: false
default: null default: null
template_filter:
description:
- Name of the filter used to search for the template or iso.
- Used for params C(iso) or C(template) on C(state=present).
required: false
default: 'executable'
choices: [ 'featured', 'self', 'selfexecutable', 'sharedexecutable', 'executable', 'community' ]
aliases: [ 'iso_filter' ]
version_added: '2.1'
hypervisor: hypervisor:
description: description:
- Name the hypervisor to be used for creating the new instance. - Name the hypervisor to be used for creating the new instance.
@ -451,7 +460,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
if self.template: if self.template:
return self._get_by_key(key, self.template) return self._get_by_key(key, self.template)
args['templatefilter'] = 'executable' args['templatefilter'] = self.module.params.get('template_filter')
templates = self.cs.listTemplates(**args) templates = self.cs.listTemplates(**args)
if templates: if templates:
for t in templates['template']: for t in templates['template']:
@ -463,7 +472,7 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
elif iso: elif iso:
if self.iso: if self.iso:
return self._get_by_key(key, self.iso) return self._get_by_key(key, self.iso)
args['isofilter'] = 'executable' args['isofilter'] = self.module.params.get('template_filter')
isos = self.cs.listIsos(**args) isos = self.cs.listIsos(**args)
if isos: if isos:
for i in isos['iso']: for i in isos['iso']:
@ -918,6 +927,7 @@ def main():
memory = dict(default=None, type='int'), memory = dict(default=None, type='int'),
template = dict(default=None), template = dict(default=None),
iso = dict(default=None), iso = dict(default=None),
template_filter = dict(default="executable", aliases=['iso_filter'], choices=['featured', 'self', 'selfexecutable', 'sharedexecutable', 'executable', 'community']),
networks = dict(type='list', aliases=[ 'network' ], default=None), networks = dict(type='list', aliases=[ 'network' ], default=None),
ip_to_networks = dict(type='list', aliases=['ip_to_network'], default=None), ip_to_networks = dict(type='list', aliases=['ip_to_network'], default=None),
ip_address = dict(defaul=None), ip_address = dict(defaul=None),

Loading…
Cancel
Save