summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2020-04-30 18:00:10 +0200
committerMikael Magnusson <mikma@users.sourceforge.net>2020-05-20 21:40:44 +0200
commit752bf1b33b76a0beae7f8e7a2a1745d940e0687e (patch)
treec261e4b85ee240c4ecde1743421e9280e3e5296c
parent73de59b27bdd4323abaeca5166da61d268bea1a2 (diff)
Handle exceptions in ssh commandsfix/ssh-exception
-rw-r--r--ryu/services/protocols/bgp/operator/ssh.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/ryu/services/protocols/bgp/operator/ssh.py b/ryu/services/protocols/bgp/operator/ssh.py
index 5690f674..c4f4ca50 100644
--- a/ryu/services/protocols/bgp/operator/ssh.py
+++ b/ryu/services/protocols/bgp/operator/ssh.py
@@ -22,6 +22,7 @@ from copy import copy
import logging
import os.path
import sys
+import traceback
import paramiko
@@ -30,6 +31,7 @@ from ryu.lib import hub
from ryu.services.protocols.bgp.base import Activity
from ryu.services.protocols.bgp.operator.command import Command
from ryu.services.protocols.bgp.operator.command import CommandsResponse
+from ryu.services.protocols.bgp.operator.command import STATUS_ERROR
from ryu.services.protocols.bgp.operator.command import STATUS_OK
from ryu.services.protocols.bgp.operator.commands.root import RootCmd
from ryu.services.protocols.bgp.operator.internal_api import InternalApi
@@ -350,7 +352,12 @@ class SshServer(paramiko.ServerInterface):
return ret
def _execute_cmd(self, cmds):
- result, _ = self.root(cmds)
+ try:
+ result, _ = self.root(cmds)
+ except:
+ tb = traceback.format_exc()
+ LOG.error(tb)
+ result = CommandsResponse(STATUS_ERROR, 'Internal error')
LOG.debug("result: %s", result)
if cmds[0] == 'quit':
self.is_connected = False