diff options
author | John Estabrook <jestabro@vyos.io> | 2023-11-27 21:25:46 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-12-16 20:37:10 -0600 |
commit | af81dafa28947f364409e347227a2ac1d0b6c53d (patch) | |
tree | ec00811b21bd508b3050b5fecc1638edb5f9601b /src/op_mode/image_manager.py | |
parent | bbbe388b437b03427e5f80a0f955b6f2759ea946 (diff) | |
download | vyos-1x-af81dafa28947f364409e347227a2ac1d0b6c53d.tar.gz vyos-1x-af81dafa28947f364409e347227a2ac1d0b6c53d.zip |
image-tools: T5751: add arg no_prompt for non-interactive calls
(cherry picked from commit 0fae5b412a359874f1d61a5330064e87a7e6b899)
Diffstat (limited to 'src/op_mode/image_manager.py')
-rwxr-xr-x | src/op_mode/image_manager.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/op_mode/image_manager.py b/src/op_mode/image_manager.py index dcbd290c9..e75485f9f 100755 --- a/src/op_mode/image_manager.py +++ b/src/op_mode/image_manager.py @@ -36,7 +36,7 @@ MSG_DELETE_IMAGE_DEFAULT: str = 'Default image cannot be deleted; set another im @compat.grub_cfg_update def delete_image(image_name: Optional[str] = None, - prompt: bool = True) -> None: + no_prompt: bool = False) -> None: """Remove installed image files and boot entry Args: @@ -44,7 +44,7 @@ def delete_image(image_name: Optional[str] = None, """ available_images: list[str] = grub.version_list() if image_name is None: - if not prompt: + if no_prompt: exit('An image name is required for delete action') else: image_name = select_entry(available_images, @@ -60,8 +60,9 @@ def delete_image(image_name: Optional[str] = None, if not persistence_storage: exit('Persistence storage cannot be found') - if not ask_yes_no(f'Do you really want to delete the image {image_name}?', - default=False): + if (not no_prompt and + not ask_yes_no(f'Do you really want to delete the image {image_name}?', + default=False)): exit() # remove files and menu entry @@ -171,6 +172,8 @@ def parse_arguments() -> Namespace: choices=['delete', 'set', 'rename', 'list'], required=True, help='action to perform with an image') + parser.add_argument('--no-prompt', action='store_true', + help='perform action non-interactively') parser.add_argument( '--image-name', help= @@ -189,7 +192,7 @@ if __name__ == '__main__': try: args: Namespace = parse_arguments() if args.action == 'delete': - delete_image(args.image_name) + delete_image(args.image_name, args.no_prompt) if args.action == 'set': set_image(args.image_name) if args.action == 'rename': |