mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-18 07:23:47 +02:00
After an iou reload you can write on the console
This commit is contained in:
parent
5e59145948
commit
62afef06af
@ -171,6 +171,9 @@ class TTY(Console):
|
|||||||
self.epoll = epoll
|
self.epoll = epoll
|
||||||
epoll.register(self.fd, select.EPOLLIN | select.EPOLLET)
|
epoll.register(self.fd, select.EPOLLIN | select.EPOLLET)
|
||||||
|
|
||||||
|
def unregister(self, epoll):
|
||||||
|
epoll.unregister(self.fd)
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
try:
|
try:
|
||||||
self.fd = open('/dev/tty', 'r+b', buffering=0)
|
self.fd = open('/dev/tty', 'r+b', buffering=0)
|
||||||
@ -240,6 +243,9 @@ class TelnetServer(Console):
|
|||||||
self.epoll = epoll
|
self.epoll = epoll
|
||||||
epoll.register(self.sock_fd, select.EPOLLIN)
|
epoll.register(self.sock_fd, select.EPOLLIN)
|
||||||
|
|
||||||
|
def unregister(self, epoll):
|
||||||
|
epoll.unregister(self.sock_fd)
|
||||||
|
|
||||||
def _read_block(self, bufsize):
|
def _read_block(self, bufsize):
|
||||||
buf = self._read_cur(bufsize, socket.MSG_WAITALL)
|
buf = self._read_cur(bufsize, socket.MSG_WAITALL)
|
||||||
# If we don't get everything we were looking for then the
|
# If we don't get everything we were looking for then the
|
||||||
@ -420,6 +426,9 @@ class IOU:
|
|||||||
self.epoll = epoll
|
self.epoll = epoll
|
||||||
epoll.register(self.fd, select.EPOLLIN | select.EPOLLET)
|
epoll.register(self.fd, select.EPOLLIN | select.EPOLLET)
|
||||||
|
|
||||||
|
def unregister(self, epoll):
|
||||||
|
epoll.unregister(self.fd)
|
||||||
|
|
||||||
def fileno(self):
|
def fileno(self):
|
||||||
return self.fd.fileno()
|
return self.fd.fileno()
|
||||||
|
|
||||||
@ -468,12 +477,11 @@ def mkdir_netio(netio_dir):
|
|||||||
raise NetioError("Couldn't create directory {}: {}".format(netio_dir, e))
|
raise NetioError("Couldn't create directory {}: {}".format(netio_dir, e))
|
||||||
|
|
||||||
|
|
||||||
def send_recv_loop(console, router, esc_char, stop_event):
|
def send_recv_loop(epoll, console, router, esc_char, stop_event):
|
||||||
|
|
||||||
epoll = select.epoll()
|
|
||||||
router.register(epoll)
|
router.register(epoll)
|
||||||
console.register(epoll)
|
console.register(epoll)
|
||||||
|
|
||||||
|
try:
|
||||||
router_fileno = router.fileno()
|
router_fileno = router.fileno()
|
||||||
esc_quit = bytes(ESC_QUIT.upper(), 'ascii')
|
esc_quit = bytes(ESC_QUIT.upper(), 'ascii')
|
||||||
esc_state = False
|
esc_state = False
|
||||||
@ -532,6 +540,10 @@ def send_recv_loop(console, router, esc_char, stop_event):
|
|||||||
esc_state = True
|
esc_state = True
|
||||||
else:
|
else:
|
||||||
router.write(buf)
|
router.write(buf)
|
||||||
|
finally:
|
||||||
|
log.debug("Finally")
|
||||||
|
router.unregister(epoll)
|
||||||
|
console.unregister(epoll)
|
||||||
|
|
||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
@ -609,6 +621,7 @@ def start_ioucon(cmdline_args, stop_event):
|
|||||||
'ADDR:PORT (like 127.0.0.1:20000)')
|
'ADDR:PORT (like 127.0.0.1:20000)')
|
||||||
|
|
||||||
while not stop_event.is_set():
|
while not stop_event.is_set():
|
||||||
|
epoll = select.epoll()
|
||||||
try:
|
try:
|
||||||
if args.telnet_server:
|
if args.telnet_server:
|
||||||
with TelnetServer(addr, nport, stop_event) as console:
|
with TelnetServer(addr, nport, stop_event) as console:
|
||||||
@ -616,12 +629,12 @@ def start_ioucon(cmdline_args, stop_event):
|
|||||||
while not stop_event.is_set():
|
while not stop_event.is_set():
|
||||||
try:
|
try:
|
||||||
with IOU(ttyC, ttyS, stop_event) as router:
|
with IOU(ttyC, ttyS, stop_event) as router:
|
||||||
send_recv_loop(console, router, b'', stop_event)
|
send_recv_loop(epoll, console, router, b'', stop_event)
|
||||||
except ConnectionRefusedError:
|
except ConnectionRefusedError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
with IOU(ttyC, ttyS, stop_event) as router, TTY() as console:
|
with IOU(ttyC, ttyS, stop_event) as router, TTY() as console:
|
||||||
send_recv_loop(console, router, esc_char, stop_event)
|
send_recv_loop(epoll, console, router, esc_char, stop_event)
|
||||||
except ConnectionRefusedError:
|
except ConnectionRefusedError:
|
||||||
pass
|
pass
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
Loading…
Reference in New Issue
Block a user