Fix double prompt issue in network_cli (#35439)

Fixes #33993

In current implementation while trying to fetch the
current cli prompt terminal plugin executes `\r` on remote host.

This causes if command execution results in a prompt for
example executing `enable` command results in `Password:` prompt
there by executing `\r` on password prompt which is not intended.

To fix it while fetching current prompt from terminal plugin use `get_prompt()`
api in network_cli that returns the latest matched prompt instead of
unnecessary executing `\r` on remote host.
This commit is contained in:
Ganesh Nalawade 2018-01-31 11:43:08 +05:30 committed by GitHub
parent dc35baa8db
commit 311918828f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -69,11 +69,7 @@ class TerminalBase(with_metaclass(ABCMeta, object)):
:returns: A byte string of the prompt
"""
# 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
return self._connection.get_prompt()
def on_open_shell(self):
"""Called after the SSH session is established