mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 00:08:11 +00:00
Enforce console port for VNC
Ref https://github.com/GNS3/gns3-gui/issues/721
This commit is contained in:
parent
6e36687347
commit
504a4af4ab
@ -224,6 +224,10 @@ class BaseVM:
|
||||
|
||||
if console == self._console:
|
||||
return
|
||||
|
||||
if self._console_type == "vnc" and console < 5900:
|
||||
raise VMError("VNC console require a port superior or equal to 5900")
|
||||
|
||||
if self._console:
|
||||
self._manager.port_manager.release_tcp_port(self._console, self._project)
|
||||
self._console = self._manager.port_manager.reserve_tcp_port(console, self._project)
|
||||
|
@ -25,6 +25,7 @@ from tests.utils import asyncio_patch
|
||||
from unittest.mock import patch, MagicMock
|
||||
from gns3server.modules.vpcs.vpcs_vm import VPCSVM
|
||||
from gns3server.modules.vpcs.vpcs_error import VPCSError
|
||||
from gns3server.modules.vm_error import VMError
|
||||
from gns3server.modules.vpcs import VPCS
|
||||
|
||||
|
||||
@ -43,3 +44,16 @@ def vm(project, manager):
|
||||
def test_temporary_directory(project, manager):
|
||||
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
|
||||
assert isinstance(vm.temporary_directory, str)
|
||||
|
||||
|
||||
def test_console(project, manager):
|
||||
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
|
||||
vm.console = 2001
|
||||
assert vm.console == 2001
|
||||
|
||||
|
||||
def test_console_vnc_invalid(project, manager):
|
||||
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
|
||||
vm.console_type = "vnc"
|
||||
with pytest.raises(VMError):
|
||||
vm.console = 2002
|
||||
|
Loading…
Reference in New Issue
Block a user