@@ -233,19 +233,26 @@ class ListQuota(command.Lister):
233233
234234 def get_parser (self , prog_name ):
235235 parser = super ().get_parser (prog_name )
236+ # TODO(stephenfin): Remove in OSC 8.0
236237 parser .add_argument (
237238 '--project' ,
238239 metavar = '<project>' ,
239- help = _ ('List quotas for this project <project> (name or ID)' ),
240+ help = _ (
241+ "**Deprecated** List quotas for this project <project> "
242+ "(name or ID). "
243+ "Use 'quota show' instead."
244+ ),
240245 )
241- # TODO(stephenfin): This doesn't belong here. We should put it into the
242- # 'quota show' command and deprecate this.
246+ # TODO(stephenfin): Remove in OSC 8.0
243247 parser .add_argument (
244248 '--detail' ,
245249 dest = 'detail' ,
246250 action = 'store_true' ,
247251 default = False ,
248- help = _ ('Show details about quotas usage' ),
252+ help = _ (
253+ "**Deprecated** Show details about quotas usage. "
254+ "Use 'quota show --usage' instead."
255+ ),
249256 )
250257 option = parser .add_mutually_exclusive_group (required = True )
251258 option .add_argument (
@@ -332,6 +339,19 @@ def _get_detailed_quotas(self, parsed_args):
332339 )
333340
334341 def take_action (self , parsed_args ):
342+ if parsed_args .detail :
343+ msg = _ (
344+ "The --detail option has been deprecated. "
345+ "Use 'openstack quota show --usage' instead."
346+ )
347+ self .log .warning (msg )
348+ elif parsed_args .project : # elif to avoid being too noisy
349+ msg = _ (
350+ "The --project option has been deprecated. "
351+ "Use 'openstack quota show' instead."
352+ )
353+ self .log .warning (msg )
354+
335355 result = []
336356 project_ids = []
337357 if parsed_args .project is None :
@@ -678,7 +698,7 @@ def take_action(self, parsed_args):
678698 ** network_kwargs )
679699
680700
681- class ShowQuota (command .ShowOne ):
701+ class ShowQuota (command .Lister ):
682702 _description = _ (
683703 "Show quotas for project or class. "
684704 "Specify ``--os-compute-api-version 2.50`` or higher to see "
@@ -692,7 +712,10 @@ def get_parser(self, prog_name):
692712 'project' ,
693713 metavar = '<project/class>' ,
694714 nargs = '?' ,
695- help = _ ('Show quotas for this project or class (name or ID)' ),
715+ help = _ (
716+ 'Show quotas for this project or class (name or ID) '
717+ '(defaults to current project)'
718+ ),
696719 )
697720 type_group = parser .add_mutually_exclusive_group ()
698721 type_group .add_argument (
@@ -709,6 +732,13 @@ def get_parser(self, prog_name):
709732 default = False ,
710733 help = _ ('Show default quotas for <project>' ),
711734 )
735+ type_group .add_argument (
736+ '--usage' ,
737+ dest = 'usage' ,
738+ action = 'store_true' ,
739+ default = False ,
740+ help = _ ('Show details about quotas usage' ),
741+ )
712742 return parser
713743
714744 def take_action (self , parsed_args ):
@@ -726,18 +756,21 @@ def take_action(self, parsed_args):
726756 compute_quota_info = get_compute_quotas (
727757 self .app ,
728758 project ,
759+ detail = parsed_args .usage ,
729760 quota_class = parsed_args .quota_class ,
730761 default = parsed_args .default ,
731762 )
732763 volume_quota_info = get_volume_quotas (
733764 self .app ,
734765 project ,
766+ detail = parsed_args .usage ,
735767 quota_class = parsed_args .quota_class ,
736768 default = parsed_args .default ,
737769 )
738770 network_quota_info = get_network_quotas (
739771 self .app ,
740772 project ,
773+ detail = parsed_args .usage ,
741774 quota_class = parsed_args .quota_class ,
742775 default = parsed_args .default ,
743776 )
@@ -762,20 +795,46 @@ def take_action(self, parsed_args):
762795 info [v ] = info [k ]
763796 info .pop (k )
764797
798+ # Remove the 'id' field since it's not very useful
799+ if 'id' in info :
800+ del info ['id' ]
801+
765802 # Remove the 'location' field for resources from openstacksdk
766803 if 'location' in info :
767804 del info ['location' ]
768805
769- # Handle class or project ID specially as they only appear in output
770- if parsed_args .quota_class :
771- info .pop ('id' , None )
772- elif 'id' in info :
773- info ['project' ] = info .pop ('id' )
774- if 'project_id' in info :
775- del info ['project_id' ]
776- info ['project_name' ] = project_info ['name' ]
777-
778- return zip (* sorted (info .items ()))
806+ if not parsed_args .usage :
807+ result = [
808+ {'resource' : k , 'limit' : v } for k , v in info .items ()
809+ ]
810+ else :
811+ result = [
812+ {'resource' : k , ** v } for k , v in info .items ()
813+ ]
814+
815+ columns = (
816+ 'resource' ,
817+ 'limit' ,
818+ )
819+ column_headers = (
820+ 'Resource' ,
821+ 'Limit' ,
822+ )
823+
824+ if parsed_args .usage :
825+ columns += (
826+ 'in_use' ,
827+ 'reserved' ,
828+ )
829+ column_headers += (
830+ 'In Use' ,
831+ 'Reserved' ,
832+ )
833+
834+ return (
835+ column_headers ,
836+ (utils .get_dict_properties (s , columns ) for s in result ),
837+ )
779838
780839
781840class DeleteQuota (command .Command ):
0 commit comments