mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Support to reset all console connections. Ref https://github.com/GNS3/gns3-server/issues/1619
This commit is contained in:
1 parent
4acc457674
commit
bdd703a0dc
17 files changed
+283
-7
No files matched your search
@@ -397,6 +397,14 @@ class BaseNode:
|
||||
self._wrapper_telnet_server.close()
|
||||
await self._wrapper_telnet_server.wait_closed()
|
||||
|
||||
async def reset_console(self):
|
||||
"""
|
||||
Reset console
|
||||
"""
|
||||
|
||||
await self.stop_wrap_console()
|
||||
await self.start_wrap_console()
|
||||
|
||||
async def start_websocket_console(self, request):
|
||||
"""
|
||||
Connect to console using Websocket.
|
||||
|
||||
@@ -743,6 +743,14 @@ class DockerVM(BaseNode):
|
||||
break
|
||||
await self.stop()
|
||||
|
||||
async def reset_console(self):
|
||||
"""
|
||||
Reset the console.
|
||||
"""
|
||||
|
||||
await self._clean_servers()
|
||||
await self._start_console()
|
||||
|
||||
async def is_running(self):
|
||||
"""
|
||||
Checks if the container is running.
|
||||
|
||||
@@ -569,17 +569,39 @@ class IOUVM(BaseNode):
|
||||
log.error("Could not start IOU {}: {}\n{}".format(self._path, e, iou_stdout))
|
||||
raise IOUError("Could not start IOU {}: {}\n{}".format(self._path, e, iou_stdout))
|
||||
|
||||
if self.console and self.console_type == "telnet":
|
||||
server = AsyncioTelnetServer(reader=self._iou_process.stdout, writer=self._iou_process.stdin, binary=True, echo=True)
|
||||
try:
|
||||
self._telnet_server = await asyncio.start_server(server.run, self._manager.port_manager.console_host, self.console)
|
||||
except OSError as e:
|
||||
await self.stop()
|
||||
raise IOUError("Could not start Telnet server on socket {}:{}: {}".format(self._manager.port_manager.console_host, self.console, e))
|
||||
await self.start_console()
|
||||
|
||||
# configure networking support
|
||||
await self._networking()
|
||||
|
||||
async def start_console(self):
|
||||
"""
|
||||
Start the Telnet server to provide console access.
|
||||
"""
|
||||
|
||||
if self.console and self.console_type == "telnet":
|
||||
server = AsyncioTelnetServer(reader=self._iou_process.stdout, writer=self._iou_process.stdin, binary=True,
|
||||
echo=True)
|
||||
try:
|
||||
self._telnet_server = await asyncio.start_server(server.run, self._manager.port_manager.console_host,
|
||||
self.console)
|
||||
except OSError as e:
|
||||
await self.stop()
|
||||
raise IOUError(
|
||||
"Could not start Telnet server on socket {}:{}: {}".format(self._manager.port_manager.console_host,
|
||||
self.console, e))
|
||||
|
||||
async def reset_console(self):
|
||||
"""
|
||||
Reset the console.
|
||||
"""
|
||||
|
||||
if self._telnet_server:
|
||||
self._telnet_server.close()
|
||||
await self._telnet_server.wait_closed()
|
||||
self._telnet_server = None
|
||||
await self.start_console()
|
||||
|
||||
@locking
|
||||
async def _networking(self):
|
||||
"""
|
||||
|
||||
@@ -979,6 +979,14 @@ class VirtualBoxVM(BaseNode):
|
||||
self._remote_pipe.close()
|
||||
self._telnet_server = None
|
||||
|
||||
async def reset_console(self):
|
||||
"""
|
||||
Reset the console.
|
||||
"""
|
||||
|
||||
await self._stop_remote_console()
|
||||
await self._start_console()
|
||||
|
||||
@BaseNode.console_type.setter
|
||||
def console_type(self, new_console_type):
|
||||
"""
|
||||
|
||||
@@ -891,6 +891,14 @@ class VMwareVM(BaseNode):
|
||||
self._remote_pipe.close()
|
||||
self._telnet_server = None
|
||||
|
||||
async def reset_console(self):
|
||||
"""
|
||||
Reset the console.
|
||||
"""
|
||||
|
||||
await self._stop_remote_console()
|
||||
await self._start_console()
|
||||
|
||||
@BaseNode.console_type.setter
|
||||
def console_type(self, new_console_type):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user