Merge "quota: Split up 'quota list' command"

This commit is contained in:
Zuul 2024-07-18 13:35:21 +00:00 committed by Gerrit Code Review
commit 2d59c675dd

View File

@ -241,14 +241,10 @@ class ListQuota(command.Lister):
)
return parser
def take_action(self, parsed_args):
result = []
project_ids = [
p.id for p in self.app.client_manager.identity.projects.list()
]
if parsed_args.compute:
def _list_quota_compute(self, parsed_args, project_ids):
compute_client = self.app.client_manager.compute
result = []
for p in project_ids:
try:
data = compute_client.quotas.get(p)
@ -309,8 +305,10 @@ class ListQuota(command.Lister):
(utils.get_dict_properties(s, columns) for s in result),
)
if parsed_args.volume:
def _list_quota_volume(self, parsed_args, project_ids):
volume_client = self.app.client_manager.volume
result = []
for p in project_ids:
try:
data = volume_client.quotas.get(p)
@ -360,8 +358,10 @@ class ListQuota(command.Lister):
(utils.get_dict_properties(s, columns) for s in result),
)
if parsed_args.network:
def _list_quota_network(self, parsed_args, project_ids):
client = self.app.client_manager.network
result = []
for p in project_ids:
try:
data = client.get_quota(p)
@ -417,6 +417,18 @@ class ListQuota(command.Lister):
(utils.get_dict_properties(s, columns) for s in result),
)
def take_action(self, parsed_args):
project_ids = [
p.id for p in self.app.client_manager.identity.projects.list()
]
if parsed_args.compute:
return self._list_quota_compute(parsed_args, project_ids)
elif parsed_args.volume:
return self._list_quota_volume(parsed_args, project_ids)
elif parsed_args.network:
return self._list_quota_network(parsed_args, project_ids)
# will never get here
return ((), ())