summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-12-31 02:43:43 +0000
committerGerrit Code Review <review@openstack.org>2014-12-31 02:43:43 +0000
commit60aec78c6f3bf6aacff7d904e5213f15cb66dc92 (patch)
treeb36a03db8e6d92b8e157cb0403d26438afc434e7 /openstackclient
parent50a8377969068cc18836117b0cafc07eb55082e0 (diff)
parent7ea5f89043b34c379f774577dee78560275fa797 (diff)
downloadpython-openstackclient-60aec78c6f3bf6aacff7d904e5213f15cb66dc92.tar.gz
Merge "Catch exception when getting quota"
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/common/quota.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py
index edf4ffdb..6d04b5c9 100644
--- a/openstackclient/common/quota.py
+++ b/openstackclient/common/quota.py
@@ -147,6 +147,21 @@ class ShowQuota(show.ShowOne):
)
return parser
+ def get_quota(self, client, parsed_args):
+ try:
+ if parsed_args.quota_class:
+ quota = client.quota_classes.get(parsed_args.project)
+ elif parsed_args.default:
+ quota = client.quotas.defaults(parsed_args.project)
+ else:
+ quota = client.quotas.get(parsed_args.project)
+ except Exception as e:
+ if type(e).__name__ == 'EndpointNotFound':
+ return {}
+ else:
+ raise e
+ return quota._info
+
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
@@ -159,23 +174,12 @@ class ShowQuota(show.ShowOne):
# does not exist. If this is determined to be the
# intended behaviour of the API we will validate
# the argument with Identity ourselves later.
- if parsed_args.quota_class:
- compute_quota = compute_client.quota_classes.get(
- parsed_args.project)
- volume_quota = volume_client.quota_classes.get(
- parsed_args.project)
- elif parsed_args.default:
- compute_quota = compute_client.quotas.defaults(
- parsed_args.project)
- volume_quota = volume_client.quotas.defaults(
- parsed_args.project)
- else:
- compute_quota = compute_client.quotas.get(parsed_args.project)
- volume_quota = volume_client.quotas.get(parsed_args.project)
+ compute_quota_info = self.get_quota(compute_client, parsed_args)
+ volume_quota_info = self.get_quota(volume_client, parsed_args)
info = {}
- info.update(compute_quota._info)
- info.update(volume_quota._info)
+ info.update(compute_quota_info)
+ info.update(volume_quota_info)
# Map the internal quota names to the external ones
for k, v in itertools.chain(