From f4bc1765501cd26dffd37331609eee6ca6ebb75f Mon Sep 17 00:00:00 2001 From: Tomas Jelinek Date: Fri, 3 Mar 2017 04:24:03 -0500 Subject: [PATCH] Provide better error message when migrating to the same host In case the VM is migrated to the same host it is already running on, a misleading error message is shown in the Requests: "There are no hosts to use. Check that the cluster contains at least one host in Up state" Fixed by failing the migration with the better message: "Error: The VM 'vm name' can not be migrated to the same host it is already running on." The host is not filtered out from the "Migrate Virtual Machine" screen since this screen can be used to migrate more VMs at once and what is a good host for one VM is not for the other. --- app/models/vm_or_template/operations/relocation.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/vm_or_template/operations/relocation.rb b/app/models/vm_or_template/operations/relocation.rb index 1d19cdb4120..16c8304e5ec 100644 --- a/app/models/vm_or_template/operations/relocation.rb +++ b/app/models/vm_or_template/operations/relocation.rb @@ -47,6 +47,10 @@ def raw_migrate(host, pool = nil, priority = "defaultPriority", state = nil) end end + if host_id == host.id + raise _("The VM '#{name}' can not be migrated to the same host it is already running on.") + end + host_mor = host.ems_ref_obj pool_mor = pool.ems_ref_obj run_command_via_parent(:vm_migrate, :host => host_mor, :pool => pool_mor, :priority => priority, :state => state)