From 02c605b4c9b6237cc552d6de03bcb90efabcc673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ne=C4=8Das?= Date: Tue, 23 Jul 2019 01:18:08 +0200 Subject: [PATCH] ovirt vm when creating Nonetypefix (#59377) * ovirt vm when creating Nonetypefix * update fix and add comment * add changelog * Update 59377-ovirt-vm-when-creating-fix.yml --- changelogs/fragments/59377-ovirt-vm-when-creating-fix.yml | 2 ++ lib/ansible/modules/cloud/ovirt/ovirt_vm.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/59377-ovirt-vm-when-creating-fix.yml diff --git a/changelogs/fragments/59377-ovirt-vm-when-creating-fix.yml b/changelogs/fragments/59377-ovirt-vm-when-creating-fix.yml new file mode 100644 index 00000000000..30d2553fbcc --- /dev/null +++ b/changelogs/fragments/59377-ovirt-vm-when-creating-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - ovirt_vm - fix for module failure on creation (https://github.com/ansible/ansible/issues/59385) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_vm.py b/lib/ansible/modules/cloud/ovirt/ovirt_vm.py index 8fcdbbc8562..cd8027431ae 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_vm.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_vm.py @@ -2288,6 +2288,8 @@ def main(): ) vm = vms_module.search_entity(list_params={'all_content': True}) + # Boolean variable to mark if vm existed before module was executed + vm_existed = True if vm else False control_state(vm, vms_service, module) if state in ('present', 'running', 'next_run'): if module.params['xen'] or module.params['kvm'] or module.params['vmware']: @@ -2372,7 +2374,8 @@ def main(): wait_condition=lambda vm: vm.status == otypes.VmStatus.UP, ) # Allow migrate vm when state present. - vms_module._migrate_vm(vm) + if vm_existed: + vms_module._migrate_vm(vm) ret['changed'] = vms_module.changed elif state == 'stopped': if module.params['xen'] or module.params['kvm'] or module.params['vmware']: