mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cliconf: Fix use of multiple prompts in send_command (#41885)
Upon preparing the commands for sending to the device, cliconf converts the optional prompt to a byte string. However, since there might be multiple prompts specified, the conversion has to happen for each prompt individually. Otherwise, wrong regexes will be compiled in _handle_prompt from network_cli Connection.
This commit is contained in:
parent
348f87d3f4
commit
d4b9105c9c
1 changed files with 5 additions and 2 deletions
|
@ -101,7 +101,7 @@ class CliconfBase(with_metaclass(ABCMeta, object)):
|
||||||
logging of any commands based on the `nolog` argument.
|
logging of any commands based on the `nolog` argument.
|
||||||
|
|
||||||
:param command: The command to send over the connection to the device
|
:param command: The command to send over the connection to the device
|
||||||
:param prompt: A regex pattern to evalue the expected prompt from the command
|
:param prompt: A single regex pattern or a sequence of patterns to evaluate the expected prompt from the command
|
||||||
:param answer: The answer to respond with if the prompt is matched.
|
:param answer: The answer to respond with if the prompt is matched.
|
||||||
:param sendonly: Bool value that will send the command but not wait for a result.
|
:param sendonly: Bool value that will send the command but not wait for a result.
|
||||||
:param newline: Bool value that will append the newline character to the command
|
:param newline: Bool value that will append the newline character to the command
|
||||||
|
@ -117,6 +117,9 @@ class CliconfBase(with_metaclass(ABCMeta, object)):
|
||||||
}
|
}
|
||||||
|
|
||||||
if prompt is not None:
|
if prompt is not None:
|
||||||
|
if isinstance(prompt, list):
|
||||||
|
kwargs['prompt'] = [to_bytes(p) for p in prompt]
|
||||||
|
else:
|
||||||
kwargs['prompt'] = to_bytes(prompt)
|
kwargs['prompt'] = to_bytes(prompt)
|
||||||
if answer is not None:
|
if answer is not None:
|
||||||
kwargs['answer'] = to_bytes(answer)
|
kwargs['answer'] = to_bytes(answer)
|
||||||
|
|
Loading…
Reference in a new issue