From 22bf18ab11e337d6de0354ab93f4785c7cccbef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Luka=C5=A1=C3=ADk?= Date: Wed, 22 Mar 2017 10:58:11 +0100 Subject: [PATCH] Merge pull request #14155 from jelkosz/fail-migration-with-better-error Provide better error message when migrating to the same host (cherry picked from commit 976486006c16f51478718409200b818d509c7a14) https://bugzilla.redhat.com/show_bug.cgi?id=1436222 --- 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 0b94fa463a6..8ea2937d206 100644 --- a/app/models/vm_or_template/operations/relocation.rb +++ b/app/models/vm_or_template/operations/relocation.rb @@ -31,6 +31,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)