Ensure to use tenant_quota_usages

Cinder generic group implementation accidentally used
quotas.tenant_limit_usages() which was removed by
https://review.openstack.org/#/c/526703/.

Change-Id: Ifdb36da7e5bd9d930d011e52b0041ed66be5bab5
Closes-Bug: #1815639
This commit is contained in:
Akihiro Motoki 2019-02-20 05:05:55 +09:00
parent 14f78157a6
commit b57eea0042
4 changed files with 23 additions and 20 deletions

View File

@ -136,14 +136,15 @@ class CreateGroupView(forms.ModalFormView):
volumes = api.cinder.volume_list(self.request,
search_opts=search_opts)
num_volumes = len(volumes)
usages = quotas.tenant_limit_usages(self.request)
usages = quotas.tenant_quota_usages(
self.request, targets=('volumes', 'gigabytes'))
if usages['totalVolumesUsed'] + num_volumes > \
usages['maxTotalVolumes']:
if (usages['volumes']['used'] + num_volumes >
usages['volumes']['quota']):
raise ValueError(_('Unable to create group due to '
'exceeding volume quota limit.'))
else:
usages['numRequestedItems'] = num_volumes
context['numRequestedItems'] = num_volumes
context['usages'] = usages
except ValueError as e:

View File

@ -1,4 +1,4 @@
{% extends "project/volumes/_volume_limits.html" %}
{% extends "project/volumes/_snapshot_limits.html" %}
{% load i18n horizon humanize %}
{% block title %}
@ -10,11 +10,11 @@
{% endblock %}
{% block gigabytes_used %}
{{ usages.totalGigabytesUsed|intcomma }}
{{ usages.gigabytes.used|intcomma }}
{% endblock %}
{% block gigabytes_used_progress %}
"{{ usages.totalGigabytesUsed }}"
"{{ usages.gigabytes.used }}"
{% endblock %}
{% block type_title %}
@ -22,11 +22,11 @@
{% endblock %}
{% block used %}
{{ usages.totalSnapshotsUsed|intcomma }}
{{ usages.snapshots.used|intcomma }}
{% endblock %}
{% block total %}
{{ usages.maxTotalSnapshots|intcomma|quota }}
{{ usages.snapshots.quota|intcomma|quota }}
{% endblock %}
{% block type_id %}
@ -34,9 +34,9 @@
{% endblock %}
{% block total_progress %}
"{{ usages.maxTotalSnapshots }}"
"{{ usages.snapshots.quota }}"
{% endblock %}
{% block used_progress %}
"{{ usages.totalSnapshotsUsed }}"
"{{ usages.snapshots.used }}"
{% endblock %}

View File

@ -3,5 +3,5 @@
{% block title %}{{ page_title }}{% endblock %}
{% block main %}
{% include 'project/volume_groups/_clone_cgroup.html' %}
{% include 'project/volume_groups/_clone_group.html' %}
{% endblock %}

View File

@ -203,14 +203,15 @@ class CreateSnapshotView(forms.ModalFormView):
volumes = api.cinder.volume_list(self.request,
search_opts=search_opts)
num_volumes = len(volumes)
usages = quotas.tenant_limit_usages(self.request)
usages = quotas.tenant_quota_usages(
self.request, targets=('snapshots', 'gigabytes'))
if usages['totalSnapshotsUsed'] + num_volumes > \
usages['maxTotalSnapshots']:
if (usages['snapshots']['used'] + num_volumes >
usages['snapshots']['quota']):
raise ValueError(_('Unable to create snapshots due to '
'exceeding snapshot quota limit.'))
else:
usages['numRequestedItems'] = num_volumes
context['numRequestedItems'] = num_volumes
context['usages'] = usages
except ValueError as e:
@ -246,14 +247,15 @@ class CloneGroupView(forms.ModalFormView):
volumes = api.cinder.volume_list(self.request,
search_opts=search_opts)
num_volumes = len(volumes)
usages = quotas.tenant_limit_usages(self.request)
usages = quotas.tenant_quota_usages(
self.request, targets=('volumes', 'gigabytes'))
if usages['totalVolumesUsed'] + num_volumes > \
usages['maxTotalVolumes']:
if (usages['volumes']['used'] + num_volumes >
usages['volumes']['quota']):
raise ValueError(_('Unable to create group due to '
'exceeding volume quota limit.'))
else:
usages['numRequestedItems'] = num_volumes
context['numRequestedItems'] = num_volumes
context['usages'] = usages
except ValueError as e: