Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions ansible/plugins/connection/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _build_command(self):

self._ssh_command += ['-o', 'GSSAPIAuthentication=no',
'-o', 'PubkeyAuthentication=no']
self._ssh_command += ['-o', 'ConnectTimeout=60']
self._ssh_command += ['-o', 'ConnectTimeout=' + str(self.timeout)]

def _spawn_connect(self):
last_user = None
Expand All @@ -71,7 +71,7 @@ def _spawn_connect(self):
self._display.vvv("SSH: EXEC {0}".format(' '.join(cmd)),
host=self.host)
last_user = user
client = pexpect.spawn(' '.join(cmd), env={'TERM': 'dumb'}, timeout=60)
client = pexpect.spawn(' '.join(cmd), env={'TERM': 'dumb'}, timeout=self.timeout)
i = client.expect(['[Pp]assword:', pexpect.EOF])
if i == 1:
self._display.vvv("Server closed the connection, retry in %d seconds" % self.connection_retry_interval, host=self.host)
Expand All @@ -81,7 +81,6 @@ def _spawn_connect(self):

self._display.vvv("Try password %s..." % login_passwd[0:4], host=self.host)
client.sendline(login_passwd)
client.timeout = 60
i = client.expect(['>', '#', '[Pp]assword:', pexpect.EOF])
if i < 2:
break
Expand Down Expand Up @@ -184,14 +183,14 @@ def exec_command(self, *args, **kwargs):
self.reboot = kwargs['reboot']
if kwargs['root']:
self.login['user'] = 'root'
if kwargs['timeout']:
self.timeout = int(kwargs['timeout'])
else:
self.timeout = 60
self._build_command()

client = self._spawn_connect()

# Set command timeout after connection is spawned
if kwargs['timeout']:
client.timeout = int(kwargs['timeout'])

# "%s>": non privileged prompt
# "%s(\([a-z\-]+\))?#": privileged prompt including configure mode
# Prompt includes Login, Password, and yes/no for "start shell" case in Dell FTOS (launch bash shell)
Expand Down