diff options
| author | John Estabrook <jestabro@vyos.io> | 2025-11-21 14:04:43 -0600 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2025-11-25 21:51:23 -0600 |
| commit | 7ed7e7acf4f7da84420f6c4972ceb56bb7d05c2c (patch) | |
| tree | c193fc76a97b77516f645d12da365025d029fcd1 /src | |
| parent | 844d517fa43f2b31dee9320e4e2cb19e2b351684 (diff) | |
| download | vyos-1x-7ed7e7acf4f7da84420f6c4972ceb56bb7d05c2c.tar.gz vyos-1x-7ed7e7acf4f7da84420f6c4972ceb56bb7d05c2c.zip | |
T7319: check unsaved_commits before upgrade
Diffstat (limited to 'src')
| -rwxr-xr-x | src/op_mode/image_installer.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/op_mode/image_installer.py b/src/op_mode/image_installer.py index d17cfb2af..9e2009a0a 100755 --- a/src/op_mode/image_installer.py +++ b/src/op_mode/image_installer.py @@ -63,11 +63,13 @@ from vyos.utils.process import cmd, run, rc_cmd from vyos.utils.auth import get_local_users from vyos.utils.auth import get_user_home_dir from vyos.version import get_version_data +from vyos.config_mgmt import unsaved_commits # define text messages MSG_ERR_NOT_LIVE: str = 'The system is already installed. Please use "add system image" instead.' MSG_ERR_LIVE: str = 'The system is in live-boot mode. Please use "install image" instead.' MSG_ERR_NOT_ENOUGH_SPACE: str = 'Image upgrade requires at least 2GB of free drive space.' +MSG_ERR_UNSAVED_COMMITS: str = 'There are unsaved changes to the configuration. Either save or revert before upgrade.' MSG_ERR_NO_DISK: str = 'No suitable disk was found. There must be at least one disk of 2GB or greater size.' MSG_ERR_IMPROPER_IMAGE: str = 'Missing sha256sum.txt.\nEither this image is corrupted, or of era 1.2.x (md5sum) and would downgrade image tools;\ndisallowed in either case.' MSG_ERR_INCOMPATIBLE_IMAGE: str = 'Image compatibility check failed, aborting installation.' @@ -91,6 +93,7 @@ MSG_INFO_INSTALL_PARTITONING: str = 'Creating partition table...' MSG_INPUT_CONFIG_FOUND: str = 'An active configuration was found. Would you like to copy it to the new image?' MSG_INPUT_CONFIG_CHOICE: str = 'The following config files are available for boot:' MSG_INPUT_CONFIG_CHOOSE: str = 'Which file would you like as boot config?' +MSG_INPUT_UNSAVED_COMMITS: str = 'There are unsaved changes to the configuration. They will not be copied to the new image. Continue without saving?' MSG_INPUT_IMAGE_NAME: str = 'What would you like to name this image?' MSG_INPUT_IMAGE_NAME_TAKEN: str = 'There is already an installed image by that name; please choose again' MSG_INPUT_IMAGE_DEFAULT: str = 'Would you like to set the new image as the default one for boot?' @@ -1102,6 +1105,13 @@ def add_image(image_path: str, vrf: str = None, username: str = '', if disk_usage('/').free < (2 * 1024**3): exit(MSG_ERR_NOT_ENOUGH_SPACE) + if unsaved_commits(): + if not no_prompt: + if not ask_yes_no(MSG_INPUT_UNSAVED_COMMITS, default=False): + exit() + else: + exit(MSG_ERR_UNSAVED_COMMITS) + environ['REMOTE_USERNAME'] = username environ['REMOTE_PASSWORD'] = password |
