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.
pull/41896/head
Paul Neumann 6 years ago committed by Ganesh Nalawade
parent 348f87d3f4
commit d4b9105c9c

@ -101,7 +101,7 @@ class CliconfBase(with_metaclass(ABCMeta, object)):
logging of any commands based on the `nolog` argument.
: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 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
@ -117,7 +117,10 @@ class CliconfBase(with_metaclass(ABCMeta, object)):
}
if prompt is not None:
kwargs['prompt'] = to_bytes(prompt)
if isinstance(prompt, list):
kwargs['prompt'] = [to_bytes(p) for p in prompt]
else:
kwargs['prompt'] = to_bytes(prompt)
if answer is not None:
kwargs['answer'] = to_bytes(answer)

Loading…
Cancel
Save