Fixes prompt doubling issue that impacted missing ios enable password prompts. (#33794)
* Fixes a prompt doubling issue that impacted missing ios enable password prompts. Due to get_prompt sending a '\n' the prompts became doubled and out-of-sync with what was expected. This caused the enable command prompts to be missed. Also added verification that on_become succeeded to reach enable prompt. * Moved prompt doubling comment per shippable
This commit is contained in:
parent
3c0a84349b
commit
d59bba4652
2 changed files with 9 additions and 2 deletions
|
@ -69,7 +69,10 @@ class TerminalBase(with_metaclass(ABCMeta, object)):
|
|||
|
||||
:returns: A byte string of the prompt
|
||||
"""
|
||||
self._exec_cli_command(b'\n')
|
||||
# do not send '\n' here, exec_cli_command sends '\r' already,
|
||||
# doing so causes double prompts.
|
||||
self._exec_cli_command(b'')
|
||||
|
||||
return self._connection._matched_prompt
|
||||
|
||||
def on_open_shell(self):
|
||||
|
|
|
@ -65,8 +65,12 @@ class TerminalModule(TerminalBase):
|
|||
|
||||
try:
|
||||
self._exec_cli_command(to_bytes(json.dumps(cmd), errors='surrogate_or_strict'))
|
||||
prompt = self._get_prompt()
|
||||
if not prompt.endswith(b'#'):
|
||||
raise AnsibleConnectionFailure('failed to elevate privilege to enable mode still at prompt [%s]' % prompt)
|
||||
except AnsibleConnectionFailure:
|
||||
raise AnsibleConnectionFailure('unable to elevate privilege to enable mode')
|
||||
prompt = self._get_prompt()
|
||||
raise AnsibleConnectionFailure('unable to elevate privilege to enable mode, at prompt [%s]' % prompt)
|
||||
|
||||
def on_unbecome(self):
|
||||
prompt = self._get_prompt()
|
||||
|
|
Loading…
Reference in a new issue