Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes the reboot/fast-reboot command args validation and gets the user confirmation before reboot. #698

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kalimuthu-Velappan
Copy link
Contributor

@Kalimuthu-Velappan Kalimuthu-Velappan commented Oct 9, 2019

- 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.

    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]
    ....

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.

      if (reboot -h |grep “skip the user confirmation”) is present
             reboot -y
      else
             reboot

- How I did it

The following changes are done in both reboot and fast-reboot commands.

  • Added command line args validation
  • Added support to perform the user confirmation before the system reboot
  • Added a new option "-y" to skip user confirmation on both the reboot commands
  • Added a new option "-f" to preform the force/quick reboot.

- How to verify it

  1. 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]

     root@sonic:/home/admin# fast-reboot
     Are you sure you want to reboot? [y/N]
    
  2. Check the reboot command to skip the user confirmation
    root@sonic:/home/admin# reboot -y
    ...

     root@sonic:/home/admin# fast-reboot -y
     ...
    
  3. 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.

      Available options:
             -h, -? : getting this help
             -y     : skip the user confirmation
             -f     : force reboot
    

- 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)

-->

@Kalimuthu-Velappan Kalimuthu-Velappan marked this pull request as ready for review October 11, 2019 06:41
@Kalimuthu-Velappan Kalimuthu-Velappan changed the title Fixes the reboot/fast-reboot command args validation and gets the use… Fixes the reboot/fast-reboot command args validation and gets the user confirmation before reboot. Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant