From 8185637767f870b5887a369dc569cc2933aeec34 Mon Sep 17 00:00:00 2001 From: Satoshi Fujimoto Date: Thu, 2 Nov 2017 15:39:24 +0900 Subject: serivice/bgp: Fix ssh connection problem in Python 2.7 Currently, 'is_connected' attribute in SshServer is refered before it is created, in Python 2.7. This raises an Exception and the SSH operation won't work anymore after this happens. This commit ensures that 'is_connected' is created before it is refered. Signed-off-by: Satoshi Fujimoto Signed-off-by: FUJITA Tomonori --- ryu/services/protocols/bgp/operator/ssh.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ryu/services/protocols/bgp/operator/ssh.py b/ryu/services/protocols/bgp/operator/ssh.py index c228a899..cb2f63b4 100644 --- a/ryu/services/protocols/bgp/operator/ssh.py +++ b/ryu/services/protocols/bgp/operator/ssh.py @@ -96,6 +96,16 @@ class SshServer(paramiko.ServerInterface): super(SshServer, self).__init__() self.sock = sock self.addr = addr + self.is_connected = True + + # For pylint + self.buf = None + self.chan = None + self.curpos = None + self.histindex = None + self.history = None + self.prompted = None + self.promptlen = None # tweak InternalApi and RootCmd for non-bgp related commands self.api = InternalApi(log_handler=logging.StreamHandler(sys.stderr)) @@ -110,17 +120,6 @@ class SshServer(paramiko.ServerInterface): self.transport.add_server_key(host_key) self.transport.start_server(server=self) - self.is_connected = True - - # For pylint - self.buf = None - self.chan = None - self.curpos = None - self.histindex = None - self.history = None - self.prompted = None - self.promptlen = None - def check_auth_none(self, username): return paramiko.AUTH_SUCCESSFUL @@ -260,7 +259,8 @@ class SshServer(paramiko.ServerInterface): self.curpos = curpos self._movcursor(curpos) - def _startnewline(self, prompt=None, buf=''): + def _startnewline(self, prompt=None, buf=None): + buf = buf or [] if not prompt and self.prompted: prompt = self.PROMPT if isinstance(buf, str): -- cgit v1.2.3