Skip to content

Commit 032202a

Browse files
committed
T7319: check unsaved_commits before upgrade
1 parent c3a6ba9 commit 032202a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/op_mode/image_installer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@
6363
from vyos.utils.auth import get_local_users
6464
from vyos.utils.auth import get_user_home_dir
6565
from vyos.version import get_version_data
66+
from vyos.config_mgmt import unsaved_commits
6667

6768
# define text messages
6869
MSG_ERR_NOT_LIVE: str = 'The system is already installed. Please use "add system image" instead.'
6970
MSG_ERR_LIVE: str = 'The system is in live-boot mode. Please use "install image" instead.'
7071
MSG_ERR_NOT_ENOUGH_SPACE: str = 'Image upgrade requires at least 2GB of free drive space.'
72+
MSG_ERR_UNSAVED_COMMITS: str = 'There are unsaved changes to the configuration. Either save or revert before upgrade.'
7173
MSG_ERR_NO_DISK: str = 'No suitable disk was found. There must be at least one disk of 2GB or greater size.'
7274
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.'
7375
MSG_ERR_INCOMPATIBLE_IMAGE: str = 'Image compatibility check failed, aborting installation.'
@@ -1102,6 +1104,9 @@ def add_image(image_path: str, vrf: str = None, username: str = '',
11021104
if disk_usage('/').free < (2 * 1024**3):
11031105
exit(MSG_ERR_NOT_ENOUGH_SPACE)
11041106

1107+
if unsaved_commits():
1108+
exit(MSG_ERR_UNSAVED_COMMITS)
1109+
11051110
environ['REMOTE_USERNAME'] = username
11061111
environ['REMOTE_PASSWORD'] = password
11071112

0 commit comments

Comments
 (0)