1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-25 00:08:11 +00:00

Merge pull request #2231 from GNS3/fix/3452

Fix Docker + VNC issues
This commit is contained in:
Jeremy Grossmann 2023-06-02 20:24:55 +09:30 committed by GitHub
commit aae7bf9865
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 37 deletions

View File

@ -85,7 +85,6 @@ class DockerVM(BaseNode):
self._ethernet_adapters = []
self._temporary_directory = None
self._telnet_servers = []
self._xvfb_process = None
self._vnc_process = None
self._vncconfig_process = None
self._console_resolution = console_resolution
@ -585,8 +584,8 @@ class DockerVM(BaseNode):
self._display = self._get_free_display_port()
tigervnc_path = shutil.which("Xtigervnc") or shutil.which("Xvnc")
if not (tigervnc_path or shutil.which("Xvfb") and shutil.which("x11vnc")):
raise DockerError("Please install TigerVNC (recommended) or Xvfb + x11vnc before using VNC support")
if not tigervnc_path:
raise DockerError("Please install TigerVNC server before using VNC support")
if tigervnc_path:
with open(os.path.join(self.working_dir, "vnc.log"), "w") as fd:
@ -600,29 +599,6 @@ class DockerVM(BaseNode):
"-SecurityTypes", "None",
":{}".format(self._display),
stdout=fd, stderr=subprocess.STDOUT)
else:
if restart is False:
self._xvfb_process = await asyncio.create_subprocess_exec("Xvfb",
"-nolisten", "tcp",
"-extension", "MIT-SHM",
":{}".format(self._display),
"-screen", "0",
self._console_resolution + "x16")
# We pass a port for TCPV6 due to a crash in X11VNC if not here: https://github.com/GNS3/gns3-server/issues/569
with open(os.path.join(self.working_dir, "vnc.log"), "w") as fd:
self._vnc_process = await asyncio.create_subprocess_exec("x11vnc",
"-forever",
"-nopw",
"-shared",
"-noshm",
"-geometry", self._console_resolution,
"-display", "WAIT:{}".format(self._display),
"-rfbport", str(self.console),
"-rfbportv6", str(self.console),
"-noncache",
"-listen", self._manager.port_manager.console_host,
stdout=fd, stderr=subprocess.STDOUT)
async def _start_vnc(self):
"""
@ -631,8 +607,8 @@ class DockerVM(BaseNode):
self._display = self._get_free_display_port()
tigervnc_path = shutil.which("Xtigervnc") or shutil.which("Xvnc")
if not (tigervnc_path or shutil.which("Xvfb") and shutil.which("x11vnc")):
raise DockerError("Please install TigerVNC server (recommended) or Xvfb + x11vnc before using VNC support")
if not tigervnc_path:
raise DockerError("Please install TigerVNC server before using VNC support")
await self._start_vnc_process()
x11_socket = os.path.join("/tmp/.X11-unix/", "X{}".format(self._display))
try:
@ -875,12 +851,6 @@ class DockerVM(BaseNode):
await self._vnc_process.wait()
except ProcessLookupError:
pass
if self._xvfb_process:
try:
self._xvfb_process.terminate()
await self._xvfb_process.wait()
except ProcessLookupError:
pass
if self._display:
display = "/tmp/.X11-unix/X{}".format(self._display)

View File

@ -1115,8 +1115,7 @@ async def test_close(vm, port_manager):
async def test_close_vnc(vm):
vm._console_type = "vnc"
vm._x11vnc_process = MagicMock()
vm._xvfb_process = MagicMock()
vm._vnc_process = MagicMock()
with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"):
with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query:
@ -1124,7 +1123,7 @@ async def test_close_vnc(vm):
mock_query.assert_called_with("DELETE", "containers/e90e34656842", params={"force": 1, "v": 1})
assert vm._closed is True
assert vm._xvfb_process.terminate.called
assert vm._vnc_process.terminate.called
async def test_get_namespace(vm):