mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
feat(instances): choose VNC or the serial console on the VM page
Settings > Console gets a Console type field. Serial removes the VM's graphics device (adding a pty console when there is none); VNC adds the graphics device new VMs get, on localhost, and then applies the form's VNC fields, so an administrator can open it to all interfaces for a TCP compute. Serial is offered only while SERIAL_CONSOLE_ENABLED is on.
This commit is contained in:
parent
d37aa42392
commit
0f9bbd3e86
6 changed files with 53 additions and 3 deletions
|
|
@ -2,7 +2,7 @@ from unittest.mock import patch
|
|||
|
||||
from computes.models import Compute
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase, override_settings
|
||||
from django.urls import reverse
|
||||
from instances.models import Instance
|
||||
|
||||
|
|
@ -25,3 +25,18 @@ class UpdateConsoleTestCase(TestCase):
|
|||
proxy = self.post({"listen_on": "127.0.0.1", "password": "", "keymap": "de"})
|
||||
proxy.set_console_keymap.assert_called_once_with("de")
|
||||
proxy.set_console_listener_addr.assert_called_once_with("127.0.0.1")
|
||||
|
||||
@override_settings(SERIAL_CONSOLE_ENABLED=True)
|
||||
def test_a_new_console_type_and_its_vnc_settings(self):
|
||||
data = {"listen_on": "0.0.0.0", "keymap": "de"}
|
||||
for old, new, vnc_settings in (("vnc", "pty", False), ("pty", "vnc", True)):
|
||||
with self.subTest(new), patch("instances.models.wvmInstance") as wvm:
|
||||
wvm.return_value.get_console_type.return_value = old
|
||||
self.client.post(reverse("instances:update_console", args=[self.instance.id]), dict(data, console_type=new))
|
||||
wvm.return_value.set_console_type.assert_called_once_with(new)
|
||||
self.assertEqual(wvm.return_value.set_console_listener_addr.called, vnc_settings)
|
||||
|
||||
@override_settings(SERIAL_CONSOLE_ENABLED=False)
|
||||
def test_serial_is_not_offered_while_the_serial_console_is_off(self):
|
||||
proxy = self.post({"console_type": "pty", "listen_on": "127.0.0.1", "keymap": "de"})
|
||||
proxy.set_console_type.assert_not_called()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue