diff --git a/confluent_client/bin/confetty b/confluent_client/bin/confetty index e1126df8..e14a55ed 100755 --- a/confluent_client/bin/confetty +++ b/confluent_client/bin/confetty @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2014 IBM Corporation @@ -654,13 +654,17 @@ def quitconfetty(code=0, fullexit=False, fixterm=True): def get_session_node(shellargs): # straight to node console if len(shellargs) == 1 and ' ' not in shellargs[0]: - return shellargs[0] + targ = "/nodes/%s/console/session" % shellargs[0] + return targ, shellargs[0] if len(shellargs) == 2 and shellargs[0] == 'start': args = [s for s in shellargs[1].split('/') if s] if len(args) == 4 and args[0] == 'nodes' and args[2] == 'console' and \ args[3] == 'session': - return args[1] - return None + return shellargs[1], args[1] + if len(args) == 5 and args[0] == 'nodes' and args[2] == 'shell' and \ + args[3] == 'sessions': + return shellargs[1], args[1] + return None, None def run_inline_command(path, arg, completion, **kwargs): @@ -917,10 +921,10 @@ def main(): doexit = False inconsole = False pendingcommand = "" - session_node = get_session_node(shellargs) + targ, session_node = get_session_node(shellargs) if session_node is not None: consoleonly = True - do_command("start /nodes/%s/console/session" % session_node, netserver) + do_command("start %s" % targ, netserver) doexit = True elif shellargs: do_command(shellargs, netserver) diff --git a/confluent_server/confluent/plugins/shell/ssh.py b/confluent_server/confluent/plugins/shell/ssh.py index f802f842..cbb8586e 100644 --- a/confluent_server/confluent/plugins/shell/ssh.py +++ b/confluent_server/confluent/plugins/shell/ssh.py @@ -93,7 +93,10 @@ class SshShell(conapi.Console): self.height = height if not self.connected: return - self.shell.resize_pty(width=width, height=height) + try: + self.shell.resize_pty(width=width, height=height) + except Exception: + pass def recvdata(self): while self.connected: @@ -254,6 +257,7 @@ class SshShell(conapi.Console): self.shell.sendall(data) def close(self): + self.connected = False if self.ssh is not None: self.ssh.close() self.datacallback = None diff --git a/confluent_server/confluent/shellserver.py b/confluent_server/confluent/shellserver.py index 4e81ec2b..386f7f56 100644 --- a/confluent_server/confluent/shellserver.py +++ b/confluent_server/confluent/shellserver.py @@ -73,6 +73,7 @@ class _ShellHandler(consoleserver.ConsoleHandler): self._send_rcpts({'connectstate': self.connectstate}) for session in list(self.livesessions): session.destroy() + self.feedbuffer('\x1bc') @@ -136,9 +137,14 @@ class ShellSession(consoleserver.ConsoleSession): while str(self.sessionid) in activesessions[(tenant, self.node, self.username)]: self.sessionid += 1 self.sessionid = str(self.sessionid) - if self.sessionid not in activesessions[(tenant, self.node, self.username)]: + conshdl = activesessions[(tenant, self.node, self.username)].get(self.sessionid, None) + if conshdl and conshdl.connectstate == 'closed': + del activesessions[(tenant, self.node, self.username)][self.sessionid] + conshdl = None + if not conshdl: activesessions[(tenant, self.node, self.username)][self.sessionid] = _ShellHandler(self.node, self.configmanager, width=self.width, height=self.height, prefix='s_{}_{}'.format(self.username, self.sessionid)) - self.conshdl = activesessions[(self.configmanager.tenant, self.node, self.username)][self.sessionid] + conshdl = activesessions[(self.configmanager.tenant, self.node, self.username)][self.sessionid] + self.conshdl = conshdl self.conshdl.numusers += 1 def destroy(self):