summaryrefslogtreecommitdiff
path: root/vymgmt/router.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2019-02-01 04:33:56 +0700
committerGitHub <noreply@github.com>2019-02-01 04:33:56 +0700
commitc1f8661a4cf7ce52c55e5bc43008f9305790a72e (patch)
tree252297de4476b8853fe7951195a51bcd5ac735ca /vymgmt/router.py
parentb8f383f1bad5439f05a537f46cd8d04abb74b2c9 (diff)
parent6cad7086b377f3faa04285c1caffac9ed2c98c79 (diff)
downloadpython-vyos-mgmt-c1f8661a4cf7ce52c55e5bc43008f9305790a72e.tar.gz
python-vyos-mgmt-c1f8661a4cf7ce52c55e5bc43008f9305790a72e.zip
Merge pull request #2 from andy-maier/andy/add-timeoutHEADmaster
Added support for pxxsh timeout
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