Fix problems in handling of CLI "exec" mode and "config" mode commands with prompts. #71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Root cause analysis:
Commands containing a "prompt/answer" sequence require
the user to specify a dictionary containing the command, prompt,
and "answer" (for the prompt). The previously existing handling enclosed the
entire command dictionary (containing the "command", "prompt",
and "answer" key/value pairs) in quotes as the value for an
unintended outer "command" key. The other items in the
dictionary input to the "send_command" API (for sending
commands to a device) were set to defaults (for exec commands)
or left unspecified (for configuration commands).
For example:
an exec command "list" containing a single command/prompt/answer sequence:
["{'command': 'image remove all', 'prompt': '\\[y/N\\]:', 'answer': 'N'}"]
above to prepare for invoking the "send_command" API:
{'command': "{'command': 'image remove all', 'prompt': '\\[y/N\\]:', 'answer': 'N'}", 'output': None, 'prompt': None, 'answer': None, 'newline': True, 'sendonly': False, 'check_all': False}
is:
{'command': 'image remove all', 'prompt': '\\[y/N\\]:', 'answer': 'N', 'newline': True, 'sendonly': False, 'check_all': False}
Fix:
SUMMARY
ISSUE TYPE
COMPONENT NAME
sonic_command, sonic_cli
ADDITIONAL INFORMATION
Unit and Regression Test Results:
prompt_fix_sonic_command_regression_comparison.txt
Base regression test result
prompt_fix_PR_regression-base-2022-04-21-23-29-14.pdf
Fix regression test results (The port breakout test was re-run after editing the selected ports to match the
switch configuration.)
prompt_fix_PR_regression-2022-04-22-00-35-17.pdf
prompt_fix_PR_port_breakout_regression-2022-04-22-14-22-30.pdf