Server support for VNC console resolution

Ref https://github.com/GNS3/gns3-gui/issues/1165
This commit is contained in:
Julien Duponchelle committed 2016-04-07 13:29:11 +02:00
1 parent ad6fb664a2
commit 977ccabf98
5 files changed
+40 -8

No files matched your search

@@ -73,6 +73,7 @@ class DockerHandler:
adapters=request.json.get("adapters"),
console=request.json.get("console"),
console_type=request.json.get("console_type"),
console_resolution=request.json.get("console_resolution", "1024x768"),
aux=request.json.get("aux")
)
for name, value in request.json.items():
@@ -277,6 +278,8 @@ class DockerHandler:
vm = docker_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
vm.name = request.json.get("name", vm.name)
vm.console = request.json.get("console", vm.console)
vm.aux = request.json.get("aux", vm.aux)
vm.console_resolution = request.json.get("console_resolution", vm.console_resolution)
vm.start_command = request.json.get("start_command", vm.start_command)
vm.environment = request.json.get("environment", vm.environment)
vm.adapters = request.json.get("adapters", vm.adapters)
+14 -3
View File
@@ -53,11 +53,13 @@ class DockerVM(BaseVM):
:param console: TCP console port
:param console_type: Console type
:param aux: TCP aux console port
:param console_resolution: Resolution of the VNC display
"""
def __init__(self, name, vm_id, project, manager, image,
console=None, aux=None, start_command=None,
adapters=None, environment=None, console_type="telnet"):
adapters=None, environment=None, console_type="telnet",
console_resolution="1024x768"):
super().__init__(name, vm_id, project, manager, console=console, aux=aux, allocate_aux=True, console_type=console_type)
self._image = image
@@ -69,6 +71,7 @@ class DockerVM(BaseVM):
self._temporary_directory = None
self._telnet_servers = []
self._x11vnc_process = None
self._console_resolution = console_resolution
if adapters is None:
self.adapters = 1
@@ -91,6 +94,7 @@ class DockerVM(BaseVM):
"adapters": self.adapters,
"console": self.console,
"console_type": self.console_type,
"console_resolution": self.console_resolution,
"aux": self.aux,
"start_command": self.start_command,
"environment": self.environment,
@@ -121,6 +125,14 @@ class DockerVM(BaseVM):
else:
self._start_command = command
@property
def console_resolution(self):
return self._console_resolution
@console_resolution.setter
def console_resolution(self, resolution):
self._console_resolution = resolution
@property
def environment(self):
return self._environment
@@ -343,8 +355,7 @@ class DockerVM(BaseVM):
self._display = self._get_free_display_port()
if shutil.which("Xvfb") is None or shutil.which("x11vnc") is None:
raise DockerError("Please install Xvfb and x11vnc before using the VNC support")
screen_resolution = "1024x768"
self._xvfb_process = yield from asyncio.create_subprocess_exec("Xvfb", "-nolisten", "tcp", ":{}".format(self._display), "-screen", "0", screen_resolution + "x16")
self._xvfb_process = yield from asyncio.create_subprocess_exec("Xvfb", "-nolisten", "tcp", ":{}".format(self._display), "-screen", "0", self._console_resolution + "x16")
self._x11vnc_process = yield from asyncio.create_subprocess_exec("x11vnc", "-forever", "-nopw", "-display", "WAIT:{}".format(self._display), "-rfbport", str(self.console), "-noncache", "-listen", self._manager.port_manager.console_host)
x11_socket = os.path.join("/tmp/.X11-unix/", "X{}".format(self._display))
+18 -3
View File
@@ -43,6 +43,11 @@ DOCKER_CREATE_SCHEMA = {
"description": "console type",
"enum": ["telnet", "vnc"]
},
"console_resolution": {
"description": "console resolution for VNC",
"type": ["string", "null"],
"pattern": "^[0-9]+x[0-9]+$"
},
"aux": {
"description": "auxilary TCP port",
"minimum": 1,
@@ -92,6 +97,11 @@ DOCKER_UPDATE_SCHEMA = {
"maximum": 65535,
"type": ["integer", "null"]
},
"console_resolution": {
"description": "console resolution for VNC",
"type": ["string", "null"],
"pattern": "^[0-9]+x[0-9]+$"
},
"console_type": {
"description": "console type",
"enum": ["telnet", "vnc"]
@@ -143,13 +153,18 @@ DOCKER_OBJECT_SCHEMA = {
"description": "auxilary TCP port",
"minimum": 1,
"maximum": 65535,
"type": ["integer", "null"]
"type": "integer"
},
"console": {
"description": "console TCP port",
"minimum": 1,
"maximum": 65535,
"type": ["integer", "null"]
"type": "integer"
},
"console_resolution": {
"description": "console resolution for VNC",
"type": "string",
"pattern": "^[0-9]+x[0-9]+$"
},
"console_type": {
"description": "console type",
@@ -196,7 +211,7 @@ DOCKER_OBJECT_SCHEMA = {
}
},
"additionalProperties": False,
"required": ["vm_id", "project_id", "image", "container_id", "adapters", "aux", "console", "console_type", "start_command", "environment", "vm_directory"]
"required": ["vm_id", "project_id", "image", "container_id", "adapters", "aux", "console", "console_type", "console_resolution", "start_command", "environment", "vm_directory"]
}