summaryrefslogtreecommitdiff
path: root/vymgmt
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2016-09-06 11:04:51 +0600
committerDaniil Baturin <daniil@baturin.org>2016-09-06 11:04:51 +0600
commit97dc89b45e6cf0f4419e6d006299e64cac875b65 (patch)
treebac06cf5d02e7e640b0d509ad06b17bff3fca717 /vymgmt
parent55a34298a135b273971c8c99f35b50220574a465 (diff)
downloadpython-vyos-mgmt-97dc89b45e6cf0f4419e6d006299e64cac875b65.tar.gz
python-vyos-mgmt-97dc89b45e6cf0f4419e6d006299e64cac875b65.zip
Add port parameter. Make password and port named rather than positional arguments.
Destroy the pxssh object on logout.
Diffstat (limited to 'vymgmt')
-rw-r--r--vymgmt/router.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/vymgmt/router.py b/vymgmt/router.py
index 74b8709..a652d21 100644
--- a/vymgmt/router.py
+++ b/vymgmt/router.py
@@ -22,7 +22,7 @@ class ConfigLocked(CommitError):
class Router(object):
- def __init__(self, address, user, password):
+ def __init__(self, address, user, password='', port=22):
"""Initial a router object
:param address: Router address,example:'192.168.10.10'
@@ -32,6 +32,7 @@ class Router(object):
self.__address = address
self.__user = user
self.__password = password
+ self.__port = port
# Session flags
self.__logged_in = False
@@ -79,7 +80,7 @@ class Router(object):
# There may or may not be a better way to handle it
self.__conn = pxssh.pxssh()
- self.__conn.login(self.__address, self.__user, self.__password)
+ self.__conn.login(self.__address, self.__user, password=self.__password, port=self.__port)
self.__logged_in = True
def logout(self):
@@ -94,6 +95,7 @@ class Router(object):
raise VyOSError("Cannot logout before exiting configuration mode")
else:
self.__conn.close()
+ self.__conn = None
self.__logged_in = False
def run_op_mode_command(self, command):