summaryrefslogtreecommitdiff
path: root/openstackclient/common
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2017-05-01 17:27:15 -0500
committerDean Troyer <dtroyer@gmail.com>2017-05-02 14:09:16 -0500
commitd930b043eef262f3eb34489f01b9856077dc2dc4 (patch)
treefd53dce7363379a105026bad52b6635bd08c1f23 /openstackclient/common
parent346ac9da622396575766ac97d108edfd17a21465 (diff)
downloadpython-openstackclient-d930b043eef262f3eb34489f01b9856077dc2dc4.tar.gz
Funcional tests: quota list
The quota list tests have a race in them where occasionally a project is deleted in another test between the time that quota list gets a list of all projects and it gets the quota for the projects from the service; the get quota call fails on the non-existant project. The quota list functional tests have been substantially re-written to properly test the exception handling. Change-Id: I71e6bbb5d46fcea4718a5a870f9a66a2c20fff0f
Diffstat (limited to 'openstackclient/common')
-rw-r--r--openstackclient/common/quota.py78
1 files changed, 62 insertions, 16 deletions
diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py
index 73dfd909..6ed9e370 100644
--- a/openstackclient/common/quota.py
+++ b/openstackclient/common/quota.py
@@ -132,13 +132,27 @@ class ListQuota(command.Lister):
if parsed_args.compute:
compute_client = self.app.client_manager.compute
for p in project_ids:
- data = compute_client.quotas.get(p)
- result_data = _xform_get_quota(data, p,
- COMPUTE_QUOTAS.keys())
+ try:
+ data = compute_client.quotas.get(p)
+ except Exception as ex:
+ if type(ex).__name__ == 'NotFound':
+ # Project not found, move on to next one
+ LOG.warning("Project %s not found: %s" % (p, ex))
+ continue
+ else:
+ raise
+
+ result_data = _xform_get_quota(
+ data,
+ p,
+ COMPUTE_QUOTAS.keys(),
+ )
default_data = compute_client.quotas.defaults(p)
- result_default = _xform_get_quota(default_data,
- p,
- COMPUTE_QUOTAS.keys())
+ result_default = _xform_get_quota(
+ default_data,
+ p,
+ COMPUTE_QUOTAS.keys(),
+ )
if result_default != result_data:
result += result_data
@@ -174,16 +188,31 @@ class ListQuota(command.Lister):
(utils.get_dict_properties(
s, columns,
) for s in result))
+
if parsed_args.volume:
volume_client = self.app.client_manager.volume
for p in project_ids:
- data = volume_client.quotas.get(p)
- result_data = _xform_get_quota(data, p,
- VOLUME_QUOTAS.keys())
+ try:
+ data = volume_client.quotas.get(p)
+ except Exception as ex:
+ if type(ex).__name__ == 'NotFound':
+ # Project not found, move on to next one
+ LOG.warning("Project %s not found: %s" % (p, ex))
+ continue
+ else:
+ raise
+
+ result_data = _xform_get_quota(
+ data,
+ p,
+ VOLUME_QUOTAS.keys(),
+ )
default_data = volume_client.quotas.defaults(p)
- result_default = _xform_get_quota(default_data,
- p,
- VOLUME_QUOTAS.keys())
+ result_default = _xform_get_quota(
+ default_data,
+ p,
+ VOLUME_QUOTAS.keys(),
+ )
if result_default != result_data:
result += result_data
@@ -209,14 +238,31 @@ class ListQuota(command.Lister):
(utils.get_dict_properties(
s, columns,
) for s in result))
+
if parsed_args.network:
client = self.app.client_manager.network
for p in project_ids:
- data = client.get_quota(p)
- result_data = _xform_get_quota(data, p, NETWORK_KEYS)
+ try:
+ data = client.get_quota(p)
+ except Exception as ex:
+ if type(ex).__name__ == 'NotFound':
+ # Project not found, move on to next one
+ LOG.warning("Project %s not found: %s" % (p, ex))
+ continue
+ else:
+ raise
+
+ result_data = _xform_get_quota(
+ data,
+ p,
+ NETWORK_KEYS,
+ )
default_data = client.get_quota_default(p)
- result_default = _xform_get_quota(default_data,
- p, NETWORK_KEYS)
+ result_default = _xform_get_quota(
+ default_data,
+ p,
+ NETWORK_KEYS,
+ )
if result_default != result_data:
result += result_data