mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
refactor(instances): one way to reach a VM, its console and its devices
The .vv console file is built from the VM found by its UUID, with the console page's getters, instead of looking the VM up by name five times; a console without a listen address or password now gives 127.0.0.1 and an empty password instead of "None". Removed methods nothing calls: the by-name getters and power methods of wvmInstances, managed save, the vCPU mode getter (it read the wrong attribute), the old NIC editor and its bridge lookup. CD-ROM media and NIC hotplug use _definitions() like the other device edits, the disk editor takes the bus prefix from util.vol_dev_type, and an unreadable disk is logged, not printed.
This commit is contained in:
parent
0ea5f0ff18
commit
f1e83455e4
5 changed files with 31 additions and 201 deletions
|
|
@ -42,7 +42,7 @@ from logs.views import addlogmsg
|
|||
from webvirtcloud.middleware import error_text
|
||||
from vrtManager import util
|
||||
from vrtManager.create import wvmCreate
|
||||
from vrtManager.instance import USAGE_MAX_WINDOW, wvmInstances
|
||||
from vrtManager.instance import USAGE_MAX_WINDOW
|
||||
from vrtManager.interface import wvmInterface
|
||||
from vrtManager.storage import wvmStorage
|
||||
from vrtManager.util import randomPasswd
|
||||
|
|
@ -2046,15 +2046,6 @@ def getvvfile(request, pk):
|
|||
# The .vv file contains the VNC password: same rule as the console.
|
||||
if not utils.can_open_console(request.user, instance):
|
||||
raise PermissionDenied
|
||||
conn = wvmInstances(
|
||||
instance.compute.hostname,
|
||||
instance.compute.login,
|
||||
instance.compute.password,
|
||||
instance.compute.type,
|
||||
)
|
||||
|
||||
# The host's current name for this UUID; the stored name may be stale.
|
||||
name = instance.proxy.instance.name()
|
||||
msg = _("Send console.vv file")
|
||||
addlogmsg(request.user.username, instance.compute.name, instance.name, msg)
|
||||
response = HttpResponse(
|
||||
|
|
@ -2064,15 +2055,15 @@ def getvvfile(request, pk):
|
|||
reason=None,
|
||||
charset="utf-8",
|
||||
)
|
||||
response.writelines("[virt-viewer]\n")
|
||||
response.writelines("type=" + conn.graphics_type(name) + "\n")
|
||||
if conn.graphics_listen(name) == "0.0.0.0":
|
||||
response.writelines("host=" + conn.host + "\n")
|
||||
else:
|
||||
response.writelines("host=" + conn.graphics_listen(name) + "\n")
|
||||
response.writelines("port=" + conn.graphics_port(name) + "\n")
|
||||
response.writelines("title=" + conn.domain_name(name) + "\n")
|
||||
response.writelines("password=" + conn.graphics_passwd(name) + "\n")
|
||||
# the VM found by its UUID; the stored name may be stale
|
||||
with instance.proxy.cached_reads() as proxy:
|
||||
listen = proxy.get_console_listener_addr()
|
||||
response.writelines("[virt-viewer]\n")
|
||||
response.writelines(f"type={proxy.get_console_type()}\n")
|
||||
response.writelines(f"host={proxy.host if listen == '0.0.0.0' else listen}\n")
|
||||
response.writelines(f"port={proxy.get_console_port()}\n")
|
||||
response.writelines(f"title={proxy.instance.name()}\n")
|
||||
response.writelines(f"password={proxy.get_console_passwd() or ''}\n")
|
||||
response.writelines("enable-usbredir=1\n")
|
||||
response.writelines("disable-effects=all\n")
|
||||
response.writelines("secure-attention=ctrl+alt+ins\n")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue