Cache login details so we can re-connect if needed
Change-Id: Ie70f5c2f8068ce30b6217cb9a6e407278a4cfaa2
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 @@
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 @@
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 @@
### 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:', '.+'])