Skip to content

Commit

Permalink
Provide better error message when migrating to the same host
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Tomas Jelinek committed Mar 21, 2017
1 parent ab5f789 commit f4bc176
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/vm_or_template/operations/relocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f4bc176

Please sign in to comment.