Catch an exception of API call when retrieving quota usage.

Fixes bug 1037438

Before this commit, api.nova.tenant_quota_usages() is called multiple
times when rendering a template. This commit fixes it and now the API
call is called only once.

Change-Id: Ia9eb1fb2b956966ad26501e7b6af65e927067f20
This commit is contained in:
Akihiro MOTOKI 2012-08-16 16:00:01 +09:00
parent fbb33d1b49
commit dfe0cf8e26

View File

@ -105,8 +105,14 @@ class BaseUsage(object):
self.summary[key] += value
def quota(self):
quotas = api.nova.tenant_quota_usages(self.request)
return quotas
if not hasattr(self, "_quotas"):
try:
self._quotas = api.nova.tenant_quota_usages(self.request)
except:
self._quotas = {}
exceptions.handle(self.request,
_("Unable to retrieve quota information."))
return self._quotas
def csv_link(self):
form = self.get_form()