aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve McIntyre <steve.mcintyre@linaro.org>2015-02-12 03:08:48 +0000
committerSteve McIntyre <steve.mcintyre@linaro.org>2015-02-12 03:08:48 +0000
commitbbd2ac833981edc87b4b0bf8c8985004a96ed58d (patch)
tree31be2d19bd2481213f43c5f7409c7dc1e3797cba
parent7b475d85f9b654165ddaba350e5564718f9335d6 (diff)
Cache login details so we can re-connect if needed
Change-Id: Ie70f5c2f8068ce30b6217cb9a6e407278a4cfaa2
-rw-r--r--drivers/CiscoSX300.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/CiscoSX300.py b/drivers/CiscoSX300.py
index 7706969..b68adf3 100644
--- a/drivers/CiscoSX300.py
+++ b/drivers/CiscoSX300.py
@@ -34,6 +34,9 @@ from errors import CriticalError, InputError
class CiscoSX300(SwitchDriver):
connection = None
+ _username = None
+ _password = None
+ _enable_password = None
# No extra capabilities for this switch/driver yet
_capabilities = [
@@ -58,7 +61,12 @@ class CiscoSX300(SwitchDriver):
def switch_connect(self, username, password, enablepassword):
logging.debug("Connecting to Switch with: %s" % self.exec_string)
self.connection = pexpect.spawn(self.exec_string, logfile = self.logfile)
- self._login(username, password)
+
+ self._username = username
+ self._password = password
+ self._enable_password = enablepassword
+
+ self._login()
# Avoid paged output
self._cli("terminal datadump")
@@ -325,13 +333,13 @@ class CiscoSX300(SwitchDriver):
### Internal functions
################################
- def _login(self, username, password):
- logging.debug("attempting login with username %s, password %s" % (username, password))
+ def _login(self):
+ logging.debug("attempting login with username %s, password %s" % (self._username, self._password))
self._cli("")
self.connection.expect("User Name:")
- self._cli("%s" % username)
+ self._cli("%s" % self._username)
self.connection.expect("Password:")
- self._cli("%s" % password, False)
+ self._cli("%s" % self._password, False)
self.connection.expect("\*\*")
while True:
index = self.connection.expect(['User Name:', 'authentication failed', r'(.*)#', 'Password:', '.+'])