mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-23 23:38:21 +00:00
Fix issue when calling reset_console with running VPCS and Qemu nodes. Ref #1619
This commit is contained in:
parent
85679aaa94
commit
1148dbc48e
@ -386,7 +386,11 @@ class BaseNode:
|
||||
await AsyncioTelnetServer.write_client_intro(writer, echo=True)
|
||||
server = AsyncioTelnetServer(reader=reader, writer=writer, binary=True, echo=True)
|
||||
# warning: this will raise OSError exception if there is a problem...
|
||||
self._wrapper_telnet_server = await asyncio.start_server(server.run, self._manager.port_manager.console_host, self.console)
|
||||
self._wrapper_telnet_server = await asyncio.start_server(
|
||||
server.run,
|
||||
self._manager.port_manager.console_host,
|
||||
self.console
|
||||
)
|
||||
|
||||
async def stop_wrap_console(self):
|
||||
"""
|
||||
@ -397,14 +401,6 @@ 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.
|
||||
|
@ -977,7 +977,6 @@ class Router(BaseNode):
|
||||
raise DynamipsError('"{name}" must be stopped to change the console type to {console_type}'.format(name=self._name,
|
||||
console_type=console_type))
|
||||
|
||||
|
||||
self.console_type = console_type
|
||||
|
||||
if self._console and console_type == "telnet":
|
||||
@ -993,6 +992,13 @@ class Router(BaseNode):
|
||||
self.aux = aux
|
||||
await self._hypervisor.send('vm set_aux_tcp_port "{name}" {aux}'.format(name=self._name, aux=aux))
|
||||
|
||||
async def reset_console(self):
|
||||
"""
|
||||
Reset console
|
||||
"""
|
||||
|
||||
pass # reset console is not supported with Dynamips
|
||||
|
||||
async def get_cpu_usage(self, cpu_id=0):
|
||||
"""
|
||||
Shows cpu usage in seconds, "cpu_id" is ignored.
|
||||
|
@ -1567,6 +1567,15 @@ class QemuVM(BaseNode):
|
||||
self._process = None
|
||||
return False
|
||||
|
||||
async def reset_console(self):
|
||||
"""
|
||||
Reset console
|
||||
"""
|
||||
|
||||
await self.stop_wrap_console()
|
||||
if self.is_running():
|
||||
await self.start_wrap_console()
|
||||
|
||||
def command(self):
|
||||
"""
|
||||
Returns the QEMU command line.
|
||||
|
@ -344,6 +344,15 @@ class VPCSVM(BaseNode):
|
||||
return True
|
||||
return False
|
||||
|
||||
async def reset_console(self):
|
||||
"""
|
||||
Reset console
|
||||
"""
|
||||
|
||||
await self.stop_wrap_console()
|
||||
if self.is_running():
|
||||
await self.start_wrap_console()
|
||||
|
||||
@BaseNode.console_type.setter
|
||||
def console_type(self, new_console_type):
|
||||
"""
|
||||
|
@ -189,6 +189,7 @@ class AsyncioTelnetServer:
|
||||
sock = network_writer.get_extra_info("socket")
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
#log.debug("New connection from {}".format(sock.getpeername()))
|
||||
|
||||
# Keep track of connected clients
|
||||
@ -202,6 +203,7 @@ class AsyncioTelnetServer:
|
||||
except ConnectionError:
|
||||
async with self._lock:
|
||||
network_writer.close()
|
||||
await network_writer.wait_closed()
|
||||
if self._reader_process == network_reader:
|
||||
self._reader_process = None
|
||||
# Cancel current read from this reader
|
||||
@ -216,6 +218,8 @@ class AsyncioTelnetServer:
|
||||
try:
|
||||
writer.write_eof()
|
||||
await writer.drain()
|
||||
writer.close()
|
||||
await writer.wait_closed()
|
||||
except (AttributeError, ConnectionError):
|
||||
continue
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user