@@ -163,6 +163,67 @@ def get_data_from_stdin():
163163 return None
164164
165165
166+ def _add_is_protected_args (parser ):
167+ protected_group = parser .add_mutually_exclusive_group ()
168+ protected_group .add_argument (
169+ "--protected" ,
170+ action = "store_true" ,
171+ dest = "is_protected" ,
172+ default = None ,
173+ help = _ ("Prevent image from being deleted" ),
174+ )
175+ protected_group .add_argument (
176+ "--unprotected" ,
177+ action = "store_false" ,
178+ dest = "is_protected" ,
179+ default = None ,
180+ help = _ ("Allow image to be deleted (default)" ),
181+ )
182+
183+
184+ def _add_visibility_args (parser ):
185+ public_group = parser .add_mutually_exclusive_group ()
186+ public_group .add_argument (
187+ "--public" ,
188+ action = "store_const" ,
189+ const = "public" ,
190+ dest = "visibility" ,
191+ help = _ ("Image is accessible and visisble to all users" ),
192+ )
193+ public_group .add_argument (
194+ "--private" ,
195+ action = "store_const" ,
196+ const = "private" ,
197+ dest = "visibility" ,
198+ help = _ (
199+ "Image is only accessible by the owner "
200+ "(default until --os-image-api-version 2.5)"
201+ ),
202+ )
203+ public_group .add_argument (
204+ "--community" ,
205+ action = "store_const" ,
206+ const = "community" ,
207+ dest = "visibility" ,
208+ help = _ (
209+ "Image is accessible by all users but does not appear in the "
210+ "default image list of any user except the owner "
211+ "(requires --os-image-api-version 2.5 or later)"
212+ ),
213+ )
214+ public_group .add_argument (
215+ "--shared" ,
216+ action = "store_const" ,
217+ const = "shared" ,
218+ dest = "visibility" ,
219+ help = _ (
220+ "Image is only accessible by the owner and image members "
221+ "(requires --os-image-api-version 2.5 or later) "
222+ "(default since --os-image-api-version 2.5)"
223+ ),
224+ )
225+
226+
166227class AddProjectToImage (command .ShowOne ):
167228 _description = _ ("Associate project with image" )
168229
@@ -322,50 +383,8 @@ def get_parser(self, prog_name):
322383 "Only use in combination with --sign-key-path"
323384 ),
324385 )
325- protected_group = parser .add_mutually_exclusive_group ()
326- protected_group .add_argument (
327- "--protected" ,
328- action = "store_true" ,
329- dest = "is_protected" ,
330- default = None ,
331- help = _ ("Prevent image from being deleted" ),
332- )
333- protected_group .add_argument (
334- "--unprotected" ,
335- action = "store_false" ,
336- dest = "is_protected" ,
337- default = None ,
338- help = _ ("Allow image to be deleted (default)" ),
339- )
340- public_group = parser .add_mutually_exclusive_group ()
341- public_group .add_argument (
342- "--public" ,
343- action = "store_const" ,
344- const = "public" ,
345- dest = "visibility" ,
346- help = _ ("Image is accessible to the public" ),
347- )
348- public_group .add_argument (
349- "--private" ,
350- action = "store_const" ,
351- const = "private" ,
352- dest = "visibility" ,
353- help = _ ("Image is inaccessible to the public (default)" ),
354- )
355- public_group .add_argument (
356- "--community" ,
357- action = "store_const" ,
358- const = "community" ,
359- dest = "visibility" ,
360- help = _ ("Image is accessible to the community" ),
361- )
362- public_group .add_argument (
363- "--shared" ,
364- action = "store_const" ,
365- const = "shared" ,
366- dest = "visibility" ,
367- help = _ ("Image can be shared" ),
368- )
386+ _add_is_protected_args (parser )
387+ _add_visibility_args (parser )
369388 parser .add_argument (
370389 "--property" ,
371390 dest = "properties" ,
@@ -726,14 +745,20 @@ def get_parser(self, prog_name):
726745 action = "store_const" ,
727746 const = "community" ,
728747 dest = "visibility" ,
729- help = _ ("List only community images" ),
748+ help = _ (
749+ "List only community images "
750+ "(requires --os-image-api-version 2.5 or later)"
751+ ),
730752 )
731753 public_group .add_argument (
732754 "--shared" ,
733755 action = "store_const" ,
734756 const = "shared" ,
735757 dest = "visibility" ,
736- help = _ ("List only shared images" ),
758+ help = _ (
759+ "List only shared images "
760+ "(requires --os-image-api-version 2.5 or later)"
761+ ),
737762 )
738763 public_group .add_argument (
739764 "--all" ,
@@ -1073,50 +1098,8 @@ def get_parser(self, prog_name):
10731098 help = _ ("Image disk format. The supported options are: %s" )
10741099 % ', ' .join (DISK_CHOICES ),
10751100 )
1076- protected_group = parser .add_mutually_exclusive_group ()
1077- protected_group .add_argument (
1078- "--protected" ,
1079- action = "store_true" ,
1080- dest = "is_protected" ,
1081- default = None ,
1082- help = _ ("Prevent image from being deleted" ),
1083- )
1084- protected_group .add_argument (
1085- "--unprotected" ,
1086- action = "store_false" ,
1087- dest = "is_protected" ,
1088- default = None ,
1089- help = _ ("Allow image to be deleted (default)" ),
1090- )
1091- public_group = parser .add_mutually_exclusive_group ()
1092- public_group .add_argument (
1093- "--public" ,
1094- action = "store_const" ,
1095- const = "public" ,
1096- dest = "visibility" ,
1097- help = _ ("Image is accessible to the public" ),
1098- )
1099- public_group .add_argument (
1100- "--private" ,
1101- action = "store_const" ,
1102- const = "private" ,
1103- dest = "visibility" ,
1104- help = _ ("Image is inaccessible to the public (default)" ),
1105- )
1106- public_group .add_argument (
1107- "--community" ,
1108- action = "store_const" ,
1109- const = "community" ,
1110- dest = "visibility" ,
1111- help = _ ("Image is accessible to the community" ),
1112- )
1113- public_group .add_argument (
1114- "--shared" ,
1115- action = "store_const" ,
1116- const = "shared" ,
1117- dest = "visibility" ,
1118- help = _ ("Image can be shared" ),
1119- )
1101+ _add_is_protected_args (parser )
1102+ _add_visibility_args (parser )
11201103 parser .add_argument (
11211104 "--property" ,
11221105 dest = "properties" ,
0 commit comments