From 212e8b889cb6430dd8ac8aba7abd8ad84d78fdbe Mon Sep 17 00:00:00 2001 From: Rebecca Finn Date: Tue, 9 Aug 2016 23:38:38 +0000 Subject: [PATCH] Fix volume storage usage value When calculating the used volume storage value to compare against "Total Size of Volumes and Snapshots", only the size of volumes was being used while volume snapshots were ignored. This allows a user to update the "Total Size of Volumes and Snapshots" quota to a value that is below what was currently being used without the expected error. This patch updates _get_tenant_volume_usages to use both volumes and volume snapshots. It also updates a test to reflect the correct "used" value. Change-Id: Ifb2586b048edbabfe9740a5c72b7abfbcf12576d Closes-Bug: #1611027 --- openstack_dashboard/test/tests/quotas.py | 2 +- openstack_dashboard/usage/quotas.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openstack_dashboard/test/tests/quotas.py b/openstack_dashboard/test/tests/quotas.py index 25ea0a9cd3..337a9e7c95 100644 --- a/openstack_dashboard/test/tests/quotas.py +++ b/openstack_dashboard/test/tests/quotas.py @@ -67,7 +67,7 @@ class QuotaTests(test.APITestCase): usages.update({'volumes': {'available': 0, 'used': 4, 'quota': 1}, 'snapshots': {'available': 0, 'used': 3, 'quota': 1}, - 'gigabytes': {'available': 880, 'used': 120, + 'gigabytes': {'available': 600, 'used': 400, 'quota': 1000}}) return usages diff --git a/openstack_dashboard/usage/quotas.py b/openstack_dashboard/usage/quotas.py index dfacd58b81..2da948d8b3 100644 --- a/openstack_dashboard/usage/quotas.py +++ b/openstack_dashboard/usage/quotas.py @@ -372,7 +372,9 @@ def _get_tenant_volume_usages(request, usages, disabled_quotas, tenant_id): else: volumes = cinder.volume_list(request) snapshots = cinder.volume_snapshot_list(request) - usages.tally('gigabytes', sum([int(v.size) for v in volumes])) + volume_usage = sum([int(v.size) for v in volumes]) + snapshot_usage = sum([int(s.size) for s in snapshots]) + usages.tally('gigabytes', (snapshot_usage + volume_usage)) usages.tally('volumes', len(volumes)) usages.tally('snapshots', len(snapshots)) except cinder.cinder_exception.ClientException: