cloudstack: fix cs_instance hypervisor must be omitted if set on template/iso

Fix related to issue reported in PR GH-646
reviewable/pr18780/r1
Rene Moser 9 years ago
parent 60b5ae35b3
commit b1e6d6ba52

@ -70,8 +70,8 @@ options:
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.
- Relevant when using C(state=present) and option C(ISO) is used. - Relevant when using C(state=present), but only considered if not set on ISO/template.
- If not set, first found hypervisor will be used. - If not set or found on ISO/template, first found hypervisor will be used.
required: false required: false
default: null default: null
choices: [ 'KVM', 'VMware', 'BareMetal', 'XenServer', 'LXC', 'HyperV', 'UCS', 'OVM' ] choices: [ 'KVM', 'VMware', 'BareMetal', 'XenServer', 'LXC', 'HyperV', 'UCS', 'OVM' ]
@ -520,7 +520,6 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
args['projectid'] = self.get_project('id') args['projectid'] = self.get_project('id')
args['diskofferingid'] = self.get_disk_offering_id() args['diskofferingid'] = self.get_disk_offering_id()
args['networkids'] = self.get_network_ids() args['networkids'] = self.get_network_ids()
args['hypervisor'] = self.get_hypervisor()
args['userdata'] = self.get_user_data() args['userdata'] = self.get_user_data()
args['keyboard'] = self.module.params.get('keyboard') args['keyboard'] = self.module.params.get('keyboard')
args['ipaddress'] = self.module.params.get('ip_address') args['ipaddress'] = self.module.params.get('ip_address')
@ -532,6 +531,10 @@ class AnsibleCloudStackInstance(AnsibleCloudStack):
args['securitygroupnames'] = ','.join(self.module.params.get('security_groups')) args['securitygroupnames'] = ','.join(self.module.params.get('security_groups'))
args['affinitygroupnames'] = ','.join(self.module.params.get('affinity_groups')) args['affinitygroupnames'] = ','.join(self.module.params.get('affinity_groups'))
template_iso = self.get_template_or_iso()
if 'hypervisor' not in template_iso:
args['hypervisor'] = self.get_hypervisor()
instance = None instance = None
if not self.module.check_mode: if not self.module.check_mode:
instance = self.cs.deployVirtualMachine(**args) instance = self.cs.deployVirtualMachine(**args)

Loading…
Cancel
Save