From 383289edd8ea222ce1a6e77ed0298ecdb21608a1 Mon Sep 17 00:00:00 2001 From: Valery Tschopp Date: Tue, 2 Feb 2021 12:56:55 +0100 Subject: Implements hide image openstack image set [--hidden|--unhidden] IMAGE openstack image list --hidden Task: 41734 Story: 2008581 Change-Id: Ie84f10c0f7aa2e7b7f78bfadc70132a10673866e --- openstackclient/image/v2/image.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'openstackclient/image') diff --git a/openstackclient/image/v2/image.py b/openstackclient/image/v2/image.py index ad38c01e..644fbbb4 100644 --- a/openstackclient/image/v2/image.py +++ b/openstackclient/image/v2/image.py @@ -615,6 +615,12 @@ class ListImage(command.Lister): default=None, help=_('Filter images based on tag.'), ) + parser.add_argument( + '--hidden', + action='store_true', + default=False, + help=_('List hidden images'), + ) parser.add_argument( '--long', action='store_true', @@ -686,6 +692,8 @@ class ListImage(command.Lister): parsed_args.project_domain, ).id kwargs['owner'] = project_id + if parsed_args.hidden: + kwargs['is_hidden'] = True if parsed_args.long: columns = ( 'ID', @@ -1016,6 +1024,22 @@ class SetImage(command.Command): action="store_true", help=_("Reset the image membership to 'pending'"), ) + + hidden_group = parser.add_mutually_exclusive_group() + hidden_group.add_argument( + "--hidden", + dest='hidden', + default=None, + action="store_true", + help=_("Hide the image"), + ) + hidden_group.add_argument( + "--unhidden", + dest='hidden', + default=None, + action="store_false", + help=_("Unhide the image"), + ) return parser def take_action(self, parsed_args): @@ -1106,6 +1130,9 @@ class SetImage(command.Command): # Tags should be extended, but duplicates removed kwargs['tags'] = list(set(image.tags).union(set(parsed_args.tags))) + if parsed_args.hidden is not None: + kwargs['is_hidden'] = parsed_args.hidden + try: image = image_client.update_image(image.id, **kwargs) except Exception: -- cgit v1.2.1