Skip to content

Commit 3468ea1

Browse files
M V P NiteshDean Troyer
authored andcommitted
Added 'openstack image set --visibility'
This feature will allow image owners to share images across multiple tenants/projects without explicitly creating members individually through the glance API V2. “Community images” will not appear iu user's default image listings Change-Id: Ic02bf44cca5d6d793d68a8737d3cfe3f44407d88 Closes-Bug: #1626837
1 parent 22bed5d commit 3468ea1

3 files changed

Lines changed: 55 additions & 6 deletions

File tree

doc/source/cli/command-objects/image.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Create/upload an image
5757
[--force]
5858
[--checksum <checksum>]
5959
[--protected | --unprotected]
60-
[--public | --private]
60+
[--public | --private | --community | --shared]
6161
[--property <key=value> [...] ]
6262
[--tag <tag> [...] ]
6363
[--project <project> [--project-domain <project-domain>]]
@@ -143,6 +143,14 @@ Create/upload an image
143143
144144
Image is inaccessible to the public (default)
145145
146+
.. option:: --community
147+
148+
Image is accessible to the community
149+
150+
.. option:: --shared
151+
152+
Image can be shared
153+
146154
.. option:: --property <key=value>
147155
148156
Set a property on this image (repeat for multiple values)
@@ -310,7 +318,7 @@ Set image properties
310318
[--disk-format <disk-format>]
311319
[--size <size>]
312320
[--protected | --unprotected]
313-
[--public | --private]
321+
[--public | --private | --community | --shared]
314322
[--store <store>]
315323
[--location <image-url>]
316324
[--copy-from <image-url>]
@@ -376,6 +384,14 @@ Set image properties
376384
377385
Image is inaccessible to the public (default)
378386
387+
.. option:: --community
388+
389+
Image is accessible to the community
390+
391+
.. option:: --shared
392+
393+
Image can be shared
394+
379395
.. option:: --store <store>
380396
381397
Upload image to this store

openstackclient/image/v2/image.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,16 @@ def get_parser(self, prog_name):
205205
action="store_true",
206206
help=_("Image is inaccessible to the public (default)"),
207207
)
208+
public_group.add_argument(
209+
"--community",
210+
action="store_true",
211+
help=_("Image is accessible to the community"),
212+
)
213+
public_group.add_argument(
214+
"--shared",
215+
action="store_true",
216+
help=_("Image can be shared"),
217+
)
208218
parser.add_argument(
209219
"--property",
210220
dest="properties",
@@ -260,7 +270,7 @@ def take_action(self, parsed_args):
260270
kwargs = {}
261271
copy_attrs = ('name', 'id',
262272
'container_format', 'disk_format',
263-
'min_disk', 'min_ram', 'tags')
273+
'min_disk', 'min_ram', 'tags', 'visibility')
264274
for attr in copy_attrs:
265275
if attr in parsed_args:
266276
val = getattr(parsed_args, attr, None)
@@ -288,7 +298,10 @@ def take_action(self, parsed_args):
288298
kwargs['visibility'] = 'public'
289299
if parsed_args.private:
290300
kwargs['visibility'] = 'private'
291-
301+
if parsed_args.community:
302+
kwargs['visibility'] = 'community'
303+
if parsed_args.shared:
304+
kwargs['visibility'] = 'shared'
292305
# Handle deprecated --owner option
293306
project_arg = parsed_args.project
294307
if parsed_args.owner:
@@ -698,6 +711,16 @@ def get_parser(self, prog_name):
698711
action="store_true",
699712
help=_("Image is inaccessible to the public (default)"),
700713
)
714+
public_group.add_argument(
715+
"--community",
716+
action="store_true",
717+
help=_("Image is accessible to the community"),
718+
)
719+
public_group.add_argument(
720+
"--shared",
721+
action="store_true",
722+
help=_("Image can be shared"),
723+
)
701724
parser.add_argument(
702725
"--property",
703726
dest="properties",
@@ -817,7 +840,7 @@ def take_action(self, parsed_args):
817840
copy_attrs = ('architecture', 'container_format', 'disk_format',
818841
'file', 'instance_id', 'kernel_id', 'locations',
819842
'min_disk', 'min_ram', 'name', 'os_distro', 'os_version',
820-
'prefix', 'progress', 'ramdisk_id', 'tags')
843+
'prefix', 'progress', 'ramdisk_id', 'tags', 'visibility')
821844
for attr in copy_attrs:
822845
if attr in parsed_args:
823846
val = getattr(parsed_args, attr, None)
@@ -845,7 +868,10 @@ def take_action(self, parsed_args):
845868
kwargs['visibility'] = 'public'
846869
if parsed_args.private:
847870
kwargs['visibility'] = 'private'
848-
871+
if parsed_args.community:
872+
kwargs['visibility'] = 'community'
873+
if parsed_args.shared:
874+
kwargs['visibility'] = 'shared'
849875
# Handle deprecated --owner option
850876
project_arg = parsed_args.project
851877
if parsed_args.owner:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
fixes:
3+
- Add ``--community`` and ``--shared`` options to the ``image create`` and
4+
``image set`` commands to allow image owners to share images across
5+
multiple projects without explicitly creating image members.
6+
“Community images” will not appear in user’s default
7+
image listings.

0 commit comments

Comments
 (0)