1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix aruba initial prompt issue (#39195)

Fixes #33414

Issue a newline when the initial connection
results in a prompt and expects user input.
This commit is contained in:
Ganesh Nalawade 2018-04-26 11:06:27 +05:30 committed by GitHub
parent 5439f141ee
commit 354454ad58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 1 deletions

View file

@ -312,7 +312,8 @@ class Connection(ConnectionBase):
else: else:
display.vvvv('unable to load cliconf for network_os %s' % network_os) display.vvvv('unable to load cliconf for network_os %s' % network_os)
self.receive() self.receive(prompts=self._terminal.terminal_initial_prompt, answer=self._terminal.terminal_initial_answer,
newline=self._terminal.terminal_inital_prompt_newline)
display.vvvv('firing event: on_open_shell()', host=self._play_context.remote_addr) display.vvvv('firing event: on_open_shell()', host=self._play_context.remote_addr)
self._terminal.on_open_shell() self._terminal.on_open_shell()

View file

@ -52,6 +52,15 @@ class TerminalBase(with_metaclass(ABCMeta, object)):
re.compile(br'\x08.') re.compile(br'\x08.')
] ]
#: terminal initial prompt
terminal_initial_prompt = None
#: terminal initial answer
terminal_initial_answer = None
#: Send newline after prompt match
terminal_inital_prompt_newline = True
def __init__(self, connection): def __init__(self, connection):
self._connection = connection self._connection = connection

View file

@ -29,10 +29,18 @@ from ansible.plugins.terminal import TerminalBase
class TerminalModule(TerminalBase): class TerminalModule(TerminalBase):
ansi_re = [
# check ECMA-48 Section 5.4 (Control Sequences)
re.compile(br'(\x1b\[\?1h\x1b=)'),
re.compile(br'((?:\x9b|\x1b\x5b)[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e])'),
re.compile(br'\x08.')
]
terminal_stdout_re = [ terminal_stdout_re = [
re.compile(br"[\r\n]?[\w]*\(.+\) ?#(?:\s*)$"), re.compile(br"[\r\n]?[\w]*\(.+\) ?#(?:\s*)$"),
re.compile(br"[pP]assword:$"), re.compile(br"[pP]assword:$"),
re.compile(br"(?<=\s)[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\s*#\s*$"), re.compile(br"(?<=\s)[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\s*#\s*$"),
re.compile(br"[\r\n]?[\w\+\-\.:\/\[\]]+(?:\([^\)]+\)){0,3}(?:[>#]) ?$"),
] ]
terminal_stderr_re = [ terminal_stderr_re = [
@ -47,6 +55,12 @@ class TerminalModule(TerminalBase):
re.compile(br"'[^']' +returned error code: ?\d+"), re.compile(br"'[^']' +returned error code: ?\d+"),
] ]
terminal_initial_prompt = b'Press any key to continue'
terminal_initial_answer = b'\r'
terminal_inital_prompt_newline = False
def on_open_shell(self): def on_open_shell(self):
try: try:
self._exec_cli_command(b'no pag') self._exec_cli_command(b'no pag')