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
This commit is contained in:
parent
9ec3d74af2
commit
212e8b889c
@ -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
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user