From 6775ec3cf258447c6276850ca898cd49c318a372 Mon Sep 17 00:00:00 2001 From: Nijin Ashok Date: Wed, 31 Oct 2018 19:04:00 +0530 Subject: [PATCH] Currently it's not possible to migrate the VMs if the automatic (#47612) migration is disabled. The PR adds new option to force migrate the VMs. This is required for hosted engine migration since automatic migration is disabled for HE VM by default. --- lib/ansible/modules/cloud/ovirt/ovirt_vm.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_vm.py b/lib/ansible/modules/cloud/ovirt/ovirt_vm.py index bd864b04a2..f77aa9375f 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_vm.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_vm.py @@ -576,6 +576,11 @@ options: - C(directory) - The name of the directory where the OVA has to be exported. - C(filename) - The name of the exported OVA file. version_added: "2.8" + force_migrate: + description: + - "If I(true), the VM will migrate even if it is defined as non-migratable." + version_added: "2.8" + type: bool notes: - If VM is in I(UNASSIGNED) or I(UNKNOWN) state before any operation, the module will fail. @@ -1374,7 +1379,7 @@ class VmsModule(BaseModule): current_vm_host = hosts_service.host_service(entity.host.id).get().name if vm_host != current_vm_host: if not self._module.check_mode: - vm_service.migrate(host=otypes.Host(name=vm_host)) + vm_service.migrate(host=otypes.Host(name=vm_host), force=self.param('force_migrate')) self._wait_for_UP(vm_service) self.changed = True @@ -2043,6 +2048,7 @@ def main(): exclusive=dict(type='bool'), export_domain=dict(default=None), export_ova=dict(type='dict'), + force_migrate=dict(type='bool'), ) module = AnsibleModule( argument_spec=argument_spec,