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

Support for none console type (Qemu & Docker only)

This commit is contained in:
grossmj 2018-03-23 15:44:16 +07:00
parent a40fdb3641
commit b8353bc0d5
6 changed files with 17 additions and 19 deletions

View File

@ -76,9 +76,11 @@ class BaseNode:
self._allocate_aux = allocate_aux
self._wrap_console = wrap_console
self._wrapper_telnet_server = None
self._internal_console_port = None
if self._console is not None:
if console_type == "vnc":
# VNC is a special case and the range must be 5900-6000
self._console = self._manager.port_manager.reserve_tcp_port(self._console, self._project, port_range_start=5900, port_range_end=6000)
else:
self._console = self._manager.port_manager.reserve_tcp_port(self._console, self._project)
@ -87,13 +89,6 @@ class BaseNode:
if self._aux is not None:
self._aux = self._manager.port_manager.reserve_tcp_port(self._aux, self._project)
if self._console is None:
if console_type == "vnc":
# VNC is a special case and the range must be 5900-6000
self._console = self._manager.port_manager.get_free_tcp_port(self._project, port_range_start=5900, port_range_end=6000)
else:
self._console = self._manager.port_manager.get_free_tcp_port(self._project)
if self._wrap_console:
self._internal_console_port = self._manager.port_manager.get_free_tcp_port(self._project)
@ -457,7 +452,10 @@ class BaseNode:
if console_type != self._console_type:
# get a new port if the console type change
self._manager.port_manager.release_tcp_port(self._console, self._project)
if console_type == "vnc":
if console_type == "none":
# no need to allocate a port when the console type is none
self._console = None
elif console_type == "vnc":
# VNC is a special case and the range must be 5900-6000
self._console = self._manager.port_manager.get_free_tcp_port(self._project, 5900, 6000)
else:

View File

@ -973,7 +973,7 @@ class QemuVM(BaseNode):
try:
yield from self.start_wrap_console()
except OSError as e:
raise QemuError("Could not start QEMU console {}\n".format(e))
raise QemuError("Could not start Telnet QEMU console {}\n".format(e))
@asyncio.coroutine
def _termination_callback(self, returncode):
@ -1803,7 +1803,7 @@ class QemuVM(BaseNode):
command.extend(self._vnc_options())
elif self._console_type == "spice":
command.extend(self._spice_options())
else:
elif self._console_type != "none":
raise QemuError("Console type {} is unknown".format(self._console_type))
command.extend(self._monitor_options())
command.extend((yield from self._network_options()))

View File

@ -41,7 +41,7 @@ DOCKER_CREATE_SCHEMA = {
},
"console_type": {
"description": "Console type",
"enum": ["telnet", "vnc", "http", "https"]
"enum": ["telnet", "vnc", "http", "https", "none"]
},
"console_resolution": {
"description": "Console resolution for VNC",
@ -126,7 +126,7 @@ DOCKER_OBJECT_SCHEMA = {
"description": "Console TCP port",
"minimum": 1,
"maximum": 65535,
"type": "integer"
"type": ["integer", "null"]
},
"console_resolution": {
"description": "Console resolution for VNC",
@ -135,7 +135,7 @@ DOCKER_OBJECT_SCHEMA = {
},
"console_type": {
"description": "Console type",
"enum": ["telnet", "vnc", "http", "https"]
"enum": ["telnet", "vnc", "http", "https", "none"]
},
"console_http_port": {
"description": "Internal port in the container for the HTTP server",

View File

@ -144,7 +144,7 @@ NODE_OBJECT_SCHEMA = {
},
"console_type": {
"description": "Console type",
"enum": ["vnc", "telnet", "http", "https", "spice", None]
"enum": ["vnc", "telnet", "http", "https", "spice", "none"]
},
"properties": {
"description": "Properties specific to an emulator",

View File

@ -63,7 +63,7 @@ QEMU_CREATE_SCHEMA = {
},
"console_type": {
"description": "Console type",
"enum": ["telnet", "vnc", "spice"]
"enum": ["telnet", "vnc", "spice", "none"]
},
"hda_disk_image": {
"description": "QEMU hda disk image path",
@ -244,7 +244,7 @@ QEMU_UPDATE_SCHEMA = {
},
"console_type": {
"description": "Console type",
"enum": ["telnet", "vnc", "spice"]
"enum": ["telnet", "vnc", "spice", "none"]
},
"linked_clone": {
"description": "Whether the VM is a linked clone or not",
@ -537,11 +537,11 @@ QEMU_OBJECT_SCHEMA = {
"description": "Console TCP port",
"minimum": 1,
"maximum": 65535,
"type": "integer"
"type": ["integer", "null"]
},
"console_type": {
"description": "Console type",
"enum": ["telnet", "vnc", "spice"]
"enum": ["telnet", "vnc", "spice", "none"]
},
"initrd": {
"description": "QEMU initrd path",

View File

@ -81,7 +81,7 @@ class UBridgeHypervisor:
if not connection_success:
raise UbridgeError("Couldn't connect to hypervisor on {}:{} :{}".format(host, self._port, last_exception))
else:
log.info("Connected to uBridge hypervisor after {:.4f} seconds".format(time.time() - begin))
log.info("Connected to uBridge hypervisor on {}:{} after {:.4f} seconds".format(host, self._port, time.time() - begin))
try:
version = yield from self.send("hypervisor version")