diff options
author | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2024-02-20 10:44:01 +0100 |
---|---|---|
committer | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2024-03-07 16:32:41 +0100 |
commit | 4a882d3f8dfcf1900da9f98f5993c9d63e70d3a8 (patch) | |
tree | 62ad90ae6305d9f1d18ae844480c4c7256076979 /src/op_mode/image_manager.py | |
parent | 94b2a3a26827ffc7f212075641dc5c67866a1ac7 (diff) | |
download | vyos-1x-4a882d3f8dfcf1900da9f98f5993c9d63e70d3a8.tar.gz vyos-1x-4a882d3f8dfcf1900da9f98f5993c9d63e70d3a8.zip |
config: T4919: Support copying encrypted volumes during install
Re-implements https://github.com/vyos/vyatta-cfg-system/pull/194
Diffstat (limited to 'src/op_mode/image_manager.py')
-rwxr-xr-x | src/op_mode/image_manager.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/op_mode/image_manager.py b/src/op_mode/image_manager.py index e64a85b95..1510a667c 100755 --- a/src/op_mode/image_manager.py +++ b/src/op_mode/image_manager.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright 2023 VyOS maintainers and contributors <maintainers@vyos.io> +# Copyright 2023-2024 VyOS maintainers and contributors <maintainers@vyos.io> # # This file is part of VyOS. # @@ -95,6 +95,15 @@ def delete_image(image_name: Optional[str] = None, except Exception as err: exit(f'Unable to remove the image "{image_name}": {err}') + # remove LUKS volume if it exists + luks_path: Path = Path(f'{persistence_storage}/luks/{image_name}') + if luks_path.is_file(): + try: + luks_path.unlink() + print(f'The encrypted config for "{image_name}" was successfully deleted') + except Exception as err: + exit(f'Unable to remove the encrypted config for "{image_name}": {err}') + @compat.grub_cfg_update def set_image(image_name: Optional[str] = None, @@ -174,6 +183,16 @@ def rename_image(name_old: str, name_new: str) -> None: except Exception as err: exit(f'Unable to rename image "{name_old}" to "{name_new}": {err}') + # rename LUKS volume if it exists + old_luks_path: Path = Path(f'{persistence_storage}/luks/{name_old}') + if old_luks_path.is_file(): + try: + new_luks_path: Path = Path(f'{persistence_storage}/luks/{name_new}') + old_luks_path.rename(new_luks_path) + print(f'The encrypted config for "{name_old}" was successfully renamed to "{name_new}"') + except Exception as err: + exit(f'Unable to rename the encrypted config for "{name_old}" to "{name_new}": {err}') + def list_images() -> None: """Print list of available images for CLI hints""" |