summaryrefslogtreecommitdiff
path: root/openstackclient/common
diff options
context:
space:
mode:
authorJose Castro Leon <jose.castro.leon@cern.ch>2020-03-12 14:43:18 +0100
committermbu <mat.bultel@gmail.com>2022-07-06 06:29:56 +0000
commit223ad11c680d88032fdb3d7326ffbd1785035e38 (patch)
treea84cf5641d343939d2a3425bfb20fdd81f1ba12f /openstackclient/common
parentc609d6b97f1bfdaba3dc6178a073332ac7603943 (diff)
downloadpython-openstackclient-223ad11c680d88032fdb3d7326ffbd1785035e38.tar.gz
Allow os quota list query to filter by project
In the os quota list command, project parameter is completely ignored ending up in a request to all projects and then all quotas. This patch enables back the parameter and does a single call to quotas if specified. Change-Id: Ie17c256e2bdc307dcd94ad5be7abdbffa776d369 Story: 2007422 Task: 39043 (cherry picked from commit 3e83e7471b57ed1a2c29a5402059e21da6db0666)
Diffstat (limited to 'openstackclient/common')
-rw-r--r--openstackclient/common/quota.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py
index fb4e8603..6d122642 100644
--- a/openstackclient/common/quota.py
+++ b/openstackclient/common/quota.py
@@ -274,9 +274,18 @@ class ListQuota(command.Lister, BaseQuota):
return parser
def take_action(self, parsed_args):
- projects = self.app.client_manager.identity.projects.list()
result = []
- project_ids = [getattr(p, 'id', '') for p in projects]
+ project_ids = []
+ if parsed_args.project is None:
+ for p in self.app.client_manager.identity.projects.list():
+ project_ids.append(getattr(p, 'id', ''))
+ else:
+ identity_client = self.app.client_manager.identity
+ project = utils.find_resource(
+ identity_client.projects,
+ parsed_args.project,
+ )
+ project_ids.append(getattr(project, 'id', ''))
if parsed_args.compute:
if parsed_args.detail: