mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 08:26:03 +00:00
fix(console): Reconnect after a migration opens the console on the VM's new compute
A console page's link names the compute the VM ran on. After a migration moved the VM, the page's Reconnect asked for it there and got "User does not have permission to access console or host/instance not exist". The console page now sends the user to the VM's new compute when that is the only VM with the UUID the user may open; others still get the same 403. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
1488baea7a
commit
450ffbba30
2 changed files with 27 additions and 1 deletions
|
|
@ -8,7 +8,7 @@ from pathlib import Path
|
|||
from appsettings.settings import app_settings
|
||||
from console import tokens
|
||||
from django.conf import settings
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import redirect, render
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from instances.models import Instance
|
||||
from instances.utils import can_open_console
|
||||
|
|
@ -42,6 +42,12 @@ def console(request, compute_id, uuid):
|
|||
"""The console page of the VM with this UUID on this compute. A console
|
||||
that cannot open gets a page that says why, and no console client."""
|
||||
instance = Instance.objects.filter(compute_id=compute_id, uuid=uuid).first()
|
||||
if instance is None:
|
||||
# migrated since the page was opened: a reconnect finds the VM on its
|
||||
# new compute, when it is the only one with that UUID the user may open
|
||||
moved = [vm for vm in Instance.objects.filter(uuid=uuid) if can_open_console(request.user, vm)]
|
||||
if len(moved) == 1:
|
||||
return redirect("console", moved[0].compute_id, uuid)
|
||||
# Same answer for "no such VM" and "not allowed", so the response
|
||||
# does not reveal whether a VM exists.
|
||||
if instance is None or not can_open_console(request.user, instance):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue