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
|
|
@ -52,17 +52,20 @@ class CanOpenConsoleTestCase(TestCase):
|
|||
|
||||
def test_owner_can_download_vv_file(self):
|
||||
self.client.force_login(self.owner)
|
||||
with patch("instances.views.wvmInstances") as mock_conn_cls, patch("instances.models.wvmInstance") as wvm:
|
||||
wvm.return_value.instance.name.return_value = "cons-vm"
|
||||
conn = mock_conn_cls.return_value
|
||||
conn.graphics_type.return_value = "vnc"
|
||||
conn.graphics_listen.return_value = "127.0.0.1"
|
||||
conn.graphics_port.return_value = "5900"
|
||||
conn.domain_name.return_value = "cons-vm"
|
||||
conn.graphics_passwd.return_value = "secret"
|
||||
with patch("instances.models.wvmInstance") as wvm:
|
||||
proxy = wvm.return_value.cached_reads.return_value.__enter__.return_value
|
||||
proxy.instance.name.return_value = "cons-vm"
|
||||
proxy.host = "192.0.2.7"
|
||||
proxy.get_console_type.return_value = "vnc"
|
||||
proxy.get_console_listener_addr.return_value = "0.0.0.0"
|
||||
proxy.get_console_port.return_value = "5900"
|
||||
proxy.get_console_passwd.return_value = "secret"
|
||||
res = self.client.get(reverse("instances:getvvfile", args=[self.instance.id]))
|
||||
self.assertEqual(res.status_code, 200)
|
||||
self.assertIn(b"[virt-viewer]", res.content)
|
||||
# the VM found by its UUID; a console on all addresses is reached through the host
|
||||
for line in (b"type=vnc", b"host=192.0.2.7", b"port=5900", b"title=cons-vm", b"password=secret"):
|
||||
self.assertIn(line + b"\n", res.content)
|
||||
|
||||
def test_owner_can_get_vdi_url(self):
|
||||
self.client.force_login(self.owner)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue