@@ -124,13 +124,15 @@ def get_parser(self, prog_name):
124124 public_group .add_argument (
125125 "--public" ,
126126 action = "store_true" ,
127- default = False ,
127+ dest = "is_public" ,
128+ default = None ,
128129 help = _ ("Volume type is accessible to the public" ),
129130 )
130131 public_group .add_argument (
131132 "--private" ,
132- action = "store_true" ,
133- default = False ,
133+ action = "store_false" ,
134+ dest = "is_public" ,
135+ default = None ,
134136 help = _ ("Volume type is not accessible to the public" ),
135137 )
136138 parser .add_argument (
@@ -201,15 +203,13 @@ def take_action(self, parsed_args):
201203 identity_client = self .app .client_manager .identity
202204 volume_client = self .app .client_manager .volume
203205
204- if parsed_args .project and not parsed_args .private :
206+ if parsed_args .project and parsed_args .is_public is not False :
205207 msg = _ ("--project is only allowed with --private" )
206208 raise exceptions .CommandError (msg )
207209
208210 kwargs = {}
209- if parsed_args .public :
210- kwargs ['is_public' ] = True
211- if parsed_args .private :
212- kwargs ['is_public' ] = False
211+ if parsed_args .is_public is not None :
212+ kwargs ['is_public' ] = parsed_args .is_public
213213
214214 volume_type = volume_client .volume_types .create (
215215 parsed_args .name , description = parsed_args .description , ** kwargs
@@ -329,11 +329,15 @@ def get_parser(self, prog_name):
329329 public_group .add_argument (
330330 "--public" ,
331331 action = "store_true" ,
332+ dest = "is_public" ,
333+ default = None ,
332334 help = _ ("List only public types" ),
333335 )
334336 public_group .add_argument (
335337 "--private" ,
336- action = "store_true" ,
338+ action = "store_false" ,
339+ dest = "is_public" ,
340+ default = None ,
337341 help = _ ("List only private types (admin only)" ),
338342 )
339343 parser .add_argument (
@@ -348,8 +352,15 @@ def get_parser(self, prog_name):
348352
349353 def take_action (self , parsed_args ):
350354 volume_client = self .app .client_manager .volume
355+
351356 if parsed_args .long :
352- columns = ['ID' , 'Name' , 'Is Public' , 'Description' , 'Extra Specs' ]
357+ columns = [
358+ 'ID' ,
359+ 'Name' ,
360+ 'Is Public' ,
361+ 'Description' ,
362+ 'Extra Specs' ,
363+ ]
353364 column_headers = [
354365 'ID' ,
355366 'Name' ,
@@ -360,15 +371,13 @@ def take_action(self, parsed_args):
360371 else :
361372 columns = ['ID' , 'Name' , 'Is Public' ]
362373 column_headers = ['ID' , 'Name' , 'Is Public' ]
374+
363375 if parsed_args .default :
364376 data = [volume_client .volume_types .default ()]
365377 else :
366- is_public = None
367- if parsed_args .public :
368- is_public = True
369- if parsed_args .private :
370- is_public = False
371- data = volume_client .volume_types .list (is_public = is_public )
378+ data = volume_client .volume_types .list (
379+ is_public = parsed_args .is_public
380+ )
372381
373382 formatters = {'Extra Specs' : format_columns .DictColumn }
374383
0 commit comments