diff --git a/horizon/api/nova.py b/horizon/api/nova.py
index 2b798081949..1099f56c680 100644
--- a/horizon/api/nova.py
+++ b/horizon/api/nova.py
@@ -67,7 +67,8 @@ def __init__(self, apiresource):
for k in apiresource._info.keys():
if k in ['id']:
continue
- v = int(apiresource._info[k])
+ limit = apiresource._info[k]
+ v = int(limit) if limit is not None else limit
q = Quota(k, v)
self.items.append(q)
setattr(self, k, v)
@@ -421,8 +422,12 @@ def tenant_quota_usages(request):
usages[usage]['used'] += getattr(
flavors[instance.flavor['id']], flavor_field, 0)
usages[usage]['quota'] = getattr(quotas, usage)
- usages[usage]['available'] = usages[usage]['quota'] - \
- usages[usage]['used']
+ if usages[usage]['quota'] is None:
+ usages[usage]['quota'] = float("inf")
+ usages[usage]['available'] = float("inf")
+ else:
+ usages[usage]['available'] = usages[usage]['quota'] - \
+ usages[usage]['used']
return usages
diff --git a/horizon/dashboards/nova/templates/nova/access_and_security/floating_ips/_allocate.html b/horizon/dashboards/nova/templates/nova/access_and_security/floating_ips/_allocate.html
index ed8a197579e..a68a4ddc5d4 100644
--- a/horizon/dashboards/nova/templates/nova/access_and_security/floating_ips/_allocate.html
+++ b/horizon/dashboards/nova/templates/nova/access_and_security/floating_ips/_allocate.html
@@ -20,7 +20,7 @@
{% trans "Description:" %}
{% trans "Project Quotas" %}
{% trans "Floating IP" %} ({{ usages.floating_ips.used }})
-
{{ usages.floating_ips.available }} {% trans "Available" %}
+
{{ usages.floating_ips.available|quota }}
{% horizon_progress_bar usages.floating_ips.used usages.floating_ips.quota %}
diff --git a/horizon/dashboards/nova/templates/nova/images_and_snapshots/images/_launch.html b/horizon/dashboards/nova/templates/nova/images_and_snapshots/images/_launch.html
index 840dc1645b6..0b1c0f5cea8 100644
--- a/horizon/dashboards/nova/templates/nova/images_and_snapshots/images/_launch.html
+++ b/horizon/dashboards/nova/templates/nova/images_and_snapshots/images/_launch.html
@@ -21,28 +21,28 @@ {% trans "Project Quotas" %}
{% trans "Instance Count" %} ({{ usages.instances.used }})
-
{{ usages.instances.available }} {% trans "Available" %}
+
{{ usages.instances.available|quota }}
{% horizon_progress_bar usages.instances.used usages.instances.quota %}
{% trans "VCPUs" %} ({{ usages.cores.used }})
-
{{ usages.cores.available }} {% trans "Available" %}
+
{{ usages.cores.available|quota }}
{% horizon_progress_bar usages.cores.used usages.cores.quota %}
{% trans "Disk" %} ({{ usages.gigabytes.used }} {% trans "GB" %})
-
{{ usages.gigabytes.available }} {% trans "GB" %} {% trans "Available" %}
+
{{ usages.gigabytes.available|quota:"GB" }}
{% horizon_progress_bar usages.gigabytes.used usages.gigabytes.quota %}
{% trans "Memory" %} ({{ usages.ram.used }} {% trans "MB" %})
-
{{ usages.ram.available }} {% trans "MB" %} {% trans "Available" %}
+
{{ usages.ram.available|quota:"MB" }}
{% horizon_progress_bar usages.ram.used usages.ram.quota %}
diff --git a/horizon/dashboards/syspanel/projects/views.py b/horizon/dashboards/syspanel/projects/views.py
index f42d4f6f76b..738bc1dea51 100644
--- a/horizon/dashboards/syspanel/projects/views.py
+++ b/horizon/dashboards/syspanel/projects/views.py
@@ -172,7 +172,7 @@ def get_initial(self):
'injected_file_content_bytes': quotas.injected_file_content_bytes,
'volumes': quotas.volumes,
'gigabytes': quotas.gigabytes,
- 'ram': int(quotas.ram),
+ 'ram': quotas.ram,
'floating_ips': quotas.floating_ips,
'instances': quotas.instances,
'injected_files': quotas.injected_files,
diff --git a/horizon/dashboards/syspanel/quotas/views.py b/horizon/dashboards/syspanel/quotas/views.py
index b89b75501f0..1343510fb18 100644
--- a/horizon/dashboards/syspanel/quotas/views.py
+++ b/horizon/dashboards/syspanel/quotas/views.py
@@ -20,10 +20,10 @@
import logging
-from django import shortcuts
-from django.contrib import messages
+from django.utils.translation import ugettext as _
from horizon import api
+from horizon import exceptions
from horizon import tables
from .tables import QuotasTable
@@ -40,9 +40,6 @@ def get_data(self):
quota_set = api.tenant_quota_defaults(self.request,
self.request.user.tenant_id)
data = quota_set.items
- except Exception, e:
- data = []
- LOG.exception('Exception while getting quota info')
- messages.error(self.request,
- _('Unable to get quota info: %s') % e)
+ except:
+ exceptions.handle(self.request, _('Unable to get quota info.'))
return data
diff --git a/horizon/templatetags/horizon.py b/horizon/templatetags/horizon.py
index 68df33eee61..06bc5de83a5 100644
--- a/horizon/templatetags/horizon.py
+++ b/horizon/templatetags/horizon.py
@@ -17,6 +17,7 @@
from __future__ import absolute_import
from django import template
+from django.utils.translation import ugettext as _
from django.utils.datastructures import SortedDict
from horizon.base import Horizon
@@ -114,6 +115,16 @@ def horizon_progress_bar(current_val, max_val):
'max_val': max_val}
+@register.filter
+def quota(val, units=None):
+ if val == float("inf"):
+ return _("No Limit")
+ elif units is not None:
+ return "%s %s %s" % (val, units, _("Available"))
+ else:
+ return "%s %s" % (val, _("Available"))
+
+
class JSTemplateNode(template.Node):
""" Helper node for the ``jstemplate`` template tag. """
def __init__(self, nodelist):