summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-11-02 15:39:24 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-11-05 21:10:03 +0900
commit8185637767f870b5887a369dc569cc2933aeec34 (patch)
tree1db591be4a68b44fbd34bab089e8071b3af30969
parent5bde6ae440c6aa67dafe02b5ad1cd2d933ee4350 (diff)
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 <satoshi.fujimoto7@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/services/protocols/bgp/operator/ssh.py24
1 files 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):