diff --git a/openstack_dashboard/dashboards/project/floating_ips/forms.py b/openstack_dashboard/dashboards/project/floating_ips/forms.py index 7b9964583f..e838bf71c8 100644 --- a/openstack_dashboard/dashboards/project/floating_ips/forms.py +++ b/openstack_dashboard/dashboards/project/floating_ips/forms.py @@ -56,7 +56,8 @@ class FloatingIpAllocate(forms.SelfHandlingForm): # Prevent allocating more IP than the quota allows usages = quotas.tenant_quota_usages(request, targets=('floatingip', )) - if usages['floatingip']['available'] <= 0: + if ('floatingip' in usages and + usages['floatingip']['available'] <= 0): error_message = _('You are already using all of your available' ' floating IPs.') self.api_error(error_message) diff --git a/openstack_dashboard/dashboards/project/floating_ips/tables.py b/openstack_dashboard/dashboards/project/floating_ips/tables.py index fe0984491a..de7b0fb58e 100644 --- a/openstack_dashboard/dashboards/project/floating_ips/tables.py +++ b/openstack_dashboard/dashboards/project/floating_ips/tables.py @@ -49,7 +49,7 @@ class AllocateIP(tables.LinkAction): def allowed(self, request, fip=None): usages = quotas.tenant_quota_usages(request, targets=('floatingip', )) - if usages['floatingip']['available'] <= 0: + if 'floatingip' in usages and usages['floatingip']['available'] <= 0: if "disabled" not in self.classes: self.classes = [c for c in self.classes] + ['disabled'] self.verbose_name = format_lazy( diff --git a/openstack_dashboard/dashboards/project/floating_ips/templates/floating_ips/_allocate.html b/openstack_dashboard/dashboards/project/floating_ips/templates/floating_ips/_allocate.html index 6bd9e48ac2..8dd1801008 100644 --- a/openstack_dashboard/dashboards/project/floating_ips/templates/floating_ips/_allocate.html +++ b/openstack_dashboard/dashboards/project/floating_ips/templates/floating_ips/_allocate.html @@ -5,26 +5,30 @@
{% trans "Allocate a floating IP from a given floating IP pool." %}
+ {% if usages %} +