@@ -739,6 +739,40 @@ def get_parser(self, prog_name):
739739 default = False ,
740740 help = _ ('Show details about quotas usage' ),
741741 )
742+ service_group = parser .add_mutually_exclusive_group ()
743+ service_group .add_argument (
744+ '--all' ,
745+ action = 'store_const' ,
746+ const = 'all' ,
747+ dest = 'service' ,
748+ default = 'all' ,
749+ help = _ ('Show quotas for all services' ),
750+ )
751+ service_group .add_argument (
752+ '--compute' ,
753+ action = 'store_const' ,
754+ const = 'compute' ,
755+ dest = 'service' ,
756+ default = 'all' ,
757+ help = _ ('Show compute quota' ),
758+ )
759+ service_group .add_argument (
760+ '--volume' ,
761+ action = 'store_const' ,
762+ const = 'volume' ,
763+ dest = 'service' ,
764+ default = 'all' ,
765+ help = _ ('Show volume quota' ),
766+ )
767+ service_group .add_argument (
768+ '--network' ,
769+ action = 'store_const' ,
770+ const = 'network' ,
771+ dest = 'service' ,
772+ default = 'all' ,
773+ help = _ ('Show network quota' ),
774+ )
775+
742776 return parser
743777
744778 def take_action (self , parsed_args ):
@@ -748,32 +782,39 @@ def take_action(self, parsed_args):
748782 project_info = get_project (self .app , parsed_args .project )
749783 project = project_info ['id' ]
750784
751- # NOTE(dtroyer): These quota API calls do not validate the project or
752- # class arguments and return what appears to be the default quota
753- # values if the project or class does not exist. If this is determined
754- # to be the intended behaviour of the API we will validate the argument
755- # with Identity ourselves later.
756- compute_quota_info = get_compute_quotas (
757- self .app ,
758- project ,
759- detail = parsed_args .usage ,
760- quota_class = parsed_args .quota_class ,
761- default = parsed_args .default ,
762- )
763- volume_quota_info = get_volume_quotas (
764- self .app ,
765- project ,
766- detail = parsed_args .usage ,
767- quota_class = parsed_args .quota_class ,
768- default = parsed_args .default ,
769- )
770- network_quota_info = get_network_quotas (
771- self .app ,
772- project ,
773- detail = parsed_args .usage ,
774- quota_class = parsed_args .quota_class ,
775- default = parsed_args .default ,
776- )
785+ compute_quota_info = {}
786+ volume_quota_info = {}
787+ network_quota_info = {}
788+
789+ # NOTE(stephenfin): These quota API calls do not validate the project
790+ # or class arguments and return what appears to be the default quota
791+ # values if the project or class does not exist. This is expected
792+ # behavior. However, we have already checked for the presence of the
793+ # project above so it shouldn't be an issue.
794+ if parsed_args .service in {'all' , 'compute' }:
795+ compute_quota_info = get_compute_quotas (
796+ self .app ,
797+ project ,
798+ detail = parsed_args .usage ,
799+ quota_class = parsed_args .quota_class ,
800+ default = parsed_args .default ,
801+ )
802+ if parsed_args .service in {'all' , 'volume' }:
803+ volume_quota_info = get_volume_quotas (
804+ self .app ,
805+ project ,
806+ detail = parsed_args .usage ,
807+ quota_class = parsed_args .quota_class ,
808+ default = parsed_args .default ,
809+ )
810+ if parsed_args .service in {'all' , 'network' }:
811+ network_quota_info = get_network_quotas (
812+ self .app ,
813+ project ,
814+ detail = parsed_args .usage ,
815+ quota_class = parsed_args .quota_class ,
816+ default = parsed_args .default ,
817+ )
777818
778819 info = {}
779820 info .update (compute_quota_info )
0 commit comments