Make the SX300 driver login more robust
Different switches are behaving differently with timing etc. Joy...
Change-Id: Idb2bfbb43dedae172cea2bf2af19e7e1a9004e2d
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 @@
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")