diff options
author | Steve McIntyre <steve.mcintyre@linaro.org> | 2015-02-12 04:46:45 +0000 |
---|---|---|
committer | Steve McIntyre <steve.mcintyre@linaro.org> | 2015-02-12 04:46:45 +0000 |
commit | 9295d50c60f8b94c32f3e21068b50ebeeb4ff017 (patch) | |
tree | b315f8ed460699e22953c704787dc1ff1382d427 | |
parent | 3c3f4fcc165b2b91804371b5f80957f3b4a698ee (diff) |
Split out switch_connect so we can re-use it internally
Change-Id: I27ba0384eaf7ea7299f8d03c410f456371d099ea
-rw-r--r-- | drivers/CiscoSX300.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/CiscoSX300.py b/drivers/CiscoSX300.py index a7aeb6f..32d0f39 100644 --- a/drivers/CiscoSX300.py +++ b/drivers/CiscoSX300.py @@ -60,12 +60,20 @@ class CiscoSX300(SwitchDriver): # Connect to the switch and log in 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._username = username self._password = password self._enable_password = enablepassword + self._switch_connect() + + # Connect to the switch and log in + def _switch_connect(self): + + if not self.connection is None: + self.connection.close(True) + self.connection = None + + logging.debug("Connecting to Switch with: %s" % self.exec_string) + self.connection = pexpect.spawn(self.exec_string, logfile = self.logfile) self._login() |