2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 19:10:10 +00:00

Implement resize from CLI client

The CLI resize is wired up for ssh usage.  At the time of this commit,
initial size is not handled.
This commit is contained in:
Jarrod Johnson 2018-11-26 15:31:36 -05:00
parent 9f137fa6d4
commit c60cb3a027
5 changed files with 21 additions and 0 deletions

View File

@ -582,6 +582,8 @@ def do_resize(a, b):
return
height, width = struct.unpack(
'hh', fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ, b'....'))[:2]
tlvdata.send(session.connection, {'operation': 'resize', 'width': width,
'height': height})
def startconsole(nodename):

View File

@ -372,6 +372,7 @@ class ConsoleHandler(object):
'error': self.error})
return
self.send_break = self._console.send_break
self.resize = self._console.resize
if self._attribwatcher:
self.cfgmgr.remove_watcher(self._attribwatcher)
self._attribwatcher = None
@ -739,6 +740,10 @@ class ProxyConsole(object):
def reopen(self):
tlvdata.send(self.remote, {'operation': 'reopen'})
def resize(self, width, height):
tlvdata.send(self.remote, {'operation': 'resize', 'width': width,
'height': height})
# this represents some api view of a console handler. This handles things like
# holding the caller specific queue data, for example, when http api should be
@ -807,6 +812,9 @@ class ConsoleSession(object):
"""
self.conshdl.send_break()
def resize(self, width, height):
self.conshdl.resize(width, height)
def get_buffer_age(self):
"""Get the age in seconds of the buffered data

View File

@ -41,6 +41,11 @@ class Console(object):
the remote console"""
return
def resize(self, width, height):
"""This function is responsible for relaying resize request from
client terminal to remote console"""
return
def ping(self):
"""This function is a hint to the console plugin that now would be a
nice time to assess health of console connection. Plugins that see

View File

@ -82,6 +82,9 @@ class SshShell(conapi.Console):
self.password = password
self.inputmode = 0 # 0 = username, 1 = password...
def resize(self, width, height):
self.shell.resize_pty(width=width, height=height)
def recvdata(self):
while self.connected:
pendingdata = self.shell.recv(8192)

View File

@ -291,6 +291,9 @@ def term_interact(authdata, authname, ccons, cfm, connection, consession,
elif data['operation'] == 'reopen':
consession.reopen()
continue
elif data['operation'] == 'resize':
consession.resize(width=data['width'], height=data['height'])
continue
else:
try:
process_request(connection, data, cfm, authdata, authname,