aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve McIntyre <steve.mcintyre@linaro.org>2014-12-23 15:34:29 +0000
committerSteve McIntyre <steve.mcintyre@linaro.org>2014-12-23 15:34:29 +0000
commitca6c5a31f6b243aba4a84ac9dd36d807c46adefb (patch)
tree513a98556ca7be036298f89b57332edc13de8a24
parent7460d9788f246a180501f6205f73ce82a7916953 (diff)
downloadvland-ca6c5a31f6b243aba4a84ac9dd36d807c46adefb.tar.gz
Make the SX300 driver login more robust
Different switches are behaving differently with timing etc. Joy... Change-Id: Idb2bfbb43dedae172cea2bf2af19e7e1a9004e2d
-rw-r--r--drivers/CiscoSX300.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/CiscoSX300.py b/drivers/CiscoSX300.py
index 14947a2..03e24bb 100644
--- a/drivers/CiscoSX300.py
+++ b/drivers/CiscoSX300.py
@@ -324,14 +324,18 @@ class CiscoSX300(SwitchDriver):
self._cli("%s" % username)
self.connection.expect("Password:")
self._cli("%s" % password, False)
+ self.connection.expect("\*\*")
while True:
- index = self.connection.expect(['User Name:', 'authentication failed', r'(.*)#', '.*'])
+ index = self.connection.expect(['User Name:', 'authentication failed', r'(.*)#', 'Password:', '.+'])
if index == 0 or index == 1: # Failed to log in!
logging.error("Login failure: %s\n" % self.connection.match)
raise IOError
elif index == 2:
self._prompt_name = self.connection.match.group(1).strip()
+ logging.debug("Got prompt name %s" % self._prompt_name)
return 0
+ elif index == 3 or index == 4:
+ self._cli("", False)
def _logout(self):
logging.debug("Logging out")