From 13f332c9a5097ef25a6680497b68494ecd104ac0 Mon Sep 17 00:00:00 2001 From: catborise Date: Wed, 22 Dec 2021 11:27:32 +0300 Subject: [PATCH] fix migrate logs to show source and destination hosts correctly --- instances/views.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/instances/views.py b/instances/views.py index e766bee..aed5b28 100644 --- a/instances/views.py +++ b/instances/views.py @@ -342,15 +342,17 @@ def migrate(request, pk): compress = request.POST.get("compress", False) postcopy = request.POST.get("postcopy", False) - new_compute = Compute.objects.get(id=compute_id) + current_host = instance.compute.hostname + target_host = Compute.objects.get(id=compute_id) try: - utils.migrate_instance(new_compute, instance, request.user, live, unsafe, xml_del, offline) + utils.migrate_instance(target_host, instance, request.user, live, unsafe, xml_del, offline) except libvirtError as err: messages.error(request, err) - msg = _("Instance is migrated to %(hostname)s") % {"hostname": new_compute.hostname} - addlogmsg(request.user.username, instance.compute.hostname, instance.name, msg) + migration_method = "live" if live is True else "offline" + msg = _("Instance is migrated(%(method)s) to %(hostname)s") % {"hostname": target_host.hostname, "method": migration_method} + addlogmsg(request.user.username, current_host, instance.name, msg) return redirect(request.META.get("HTTP_REFERER"))