1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-25 23:55:24 +00:00

fix migrate logs to show source and destination hosts correctly

This commit is contained in:
catborise 2021-12-22 11:27:32 +03:00
parent e6f7588593
commit 13f332c9a5

View file

@ -342,15 +342,17 @@ def migrate(request, pk):
compress = request.POST.get("compress", False) compress = request.POST.get("compress", False)
postcopy = request.POST.get("postcopy", 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: 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: except libvirtError as err:
messages.error(request, err) messages.error(request, err)
msg = _("Instance is migrated to %(hostname)s") % {"hostname": new_compute.hostname} migration_method = "live" if live is True else "offline"
addlogmsg(request.user.username, instance.compute.hostname, instance.name, msg) 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")) return redirect(request.META.get("HTTP_REFERER"))