From a332678312d13437ba597494784d02c57daa576c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 7 Jan 2016 10:30:30 -0500 Subject: [PATCH] Avoid double connect on shell start When a shell session is initiated, it registers a recipient at the same time it would be trying to establish session for not being a 'wait for recipient'. Aggressively mark the state as connecting to avoid the recipient erroneously thinking things have not be set into motion yet. Additionally, have the ssh plugin avoid a traceback when disconnecting before completing connection. --- confluent_server/confluent/consoleserver.py | 1 + confluent_server/confluent/plugins/shell/ssh.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/consoleserver.py b/confluent_server/confluent/consoleserver.py index 5c561f91..d9996b7e 100644 --- a/confluent_server/confluent/consoleserver.py +++ b/confluent_server/confluent/consoleserver.py @@ -89,6 +89,7 @@ class ConsoleHandler(object): (self.node,), self._genwatchattribs, self._attribschanged) self.check_isondemand() if not self._isondemand: + self.connectstate = 'connecting' eventlet.spawn(self._connect) def check_isondemand(self): diff --git a/confluent_server/confluent/plugins/shell/ssh.py b/confluent_server/confluent/plugins/shell/ssh.py index 8f583b44..03047ab1 100644 --- a/confluent_server/confluent/plugins/shell/ssh.py +++ b/confluent_server/confluent/plugins/shell/ssh.py @@ -29,6 +29,7 @@ class SshShell(conapi.Console): def __init__(self, node, config, username='', password=''): self.node = node + self.ssh = None self.nodeconfig = config self.username = username self.password = password @@ -96,7 +97,8 @@ class SshShell(conapi.Console): self.shell.sendall(data) def close(self): - self.ssh.close() + if self.ssh is not None: + self.ssh.close() def create(nodes, element, configmanager, inputdata): if len(nodes) == 1: