summaryrefslogtreecommitdiff
path: root/vymgmt/router.py
diff options
context:
space:
mode:
authorAndreas Maier <andreas.r.maier@gmx.de>2019-01-31 22:08:03 +0100
committerAndreas Maier <andreas.r.maier@gmx.de>2019-01-31 22:12:48 +0100
commit6cad7086b377f3faa04285c1caffac9ed2c98c79 (patch)
tree252297de4476b8853fe7951195a51bcd5ac735ca /vymgmt/router.py
parentb8f383f1bad5439f05a537f46cd8d04abb74b2c9 (diff)
downloadpython-vyos-mgmt-6cad7086b377f3faa04285c1caffac9ed2c98c79.tar.gz
python-vyos-mgmt-6cad7086b377f3faa04285c1caffac9ed2c98c79.zip
Added support for pxxsh timeout
This change adds an optional timeout parameter to the VRouter constructor, that is passed on to the pxxsh session timeout. Its default value is 30 which is the default of pxxsh, so that there is no change in behavior by default. Signed-off-by: Andreas Maier <andreas.r.maier@gmx.de>
Diffstat (limited to 'vymgmt/router.py')
-rw-r--r--vymgmt/router.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/vymgmt/router.py b/vymgmt/router.py
index 05af3ab..bc6ce51 100644
--- a/vymgmt/router.py
+++ b/vymgmt/router.py
@@ -59,7 +59,7 @@ class ConfigLocked(CommitError):
class Router(object):
""" Router configuration interface class
"""
- def __init__(self, address, user, password='', port=22, ssh_key=''):
+ def __init__(self, address, user, password='', port=22, ssh_key='', timeout=30):
""" Router configuration interface class
:param address: Router address,example:'192.0.2.1'
@@ -67,12 +67,14 @@ class Router(object):
:param password: Router user's password
:param port: SSH port
:param ssh_key: SSH private key
+ :param timeout: Timeout in seconds for the pxssh session to the router
"""
self.__address = address
self.__user = user
self.__password = password
self.__port = port
self.__ssh_key = ssh_key
+ self.__timeout = timeout
# Session flags
self.__logged_in = False
@@ -120,7 +122,7 @@ class Router(object):
# XXX: after logout, old pxssh instance stops working,
# so we create a new one for each login
# There may or may not be a better way to handle it
- self.__conn = pxssh.pxssh()
+ self.__conn = pxssh.pxssh(self.__timeout)
self.__conn.login(self.__address, self.__user, password=self.__password, port=self.__port, ssh_key=self.__ssh_key)
self.__logged_in = True