Fixes the reboot/fast-reboot command args validation and gets the user confirmation before reboot. #698
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.
- What I did
Fixes the reboot/fast-reboot command args validation and gets the user confirmation before the system reboot:
Reboot command takes all types of arguments and doesn't do any argument validation. Reboot command is a sensitive command and it may cause loss of unsaved data if the command is given accidentally. So, to avoid the accidental issue of reboot command, user confirmation is added before the system reboot.
New option '-y' is added to skip the user configuration.
This change might impact the automation scripts. It is recommended to use the below logic in the automation script to support both the varients of reboot command.
- How I did it
The following changes are done in both reboot and fast-reboot commands.
- How to verify it
Check the reboot command with user confirmation
root@sonic:/home/admin# reboot
Warning: This command would cause the switch to reboot
and result in traffic disruption.
Are you sure you want to reboot? [y/N]
Check the reboot command to skip the user confirmation
root@sonic:/home/admin# reboot -y
...
Verify the invalid command-line options
root@sonic:/home/admin# reboot junk
Unsupported reboot option
Usage /usr/bin/reboot [options]
Request rebooting the device. Invoke platform-specific tool when available.
This script will shutdown syncd before rebooting.
- Previous command output (if the output of a command-line utility has changed)
- New command output (if the output of a command-line utility has changed)
-->