Merge "check per_volume_gigabytes quota for cinder extend"
This commit is contained in:
commit
8128532b20
@ -3856,8 +3856,9 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
'fake2': {'key3': 'value3', 'key4': 'value4'}}
|
||||
self.assertEqual(expect_results, results)
|
||||
|
||||
@mock.patch.object(QUOTAS, 'limit_check')
|
||||
@mock.patch.object(QUOTAS, 'reserve')
|
||||
def test_extend_volume(self, reserve):
|
||||
def test_extend_volume(self, reserve, limit_check):
|
||||
"""Test volume can be extended at API level."""
|
||||
# create a volume and assign to host
|
||||
volume = tests_utils.create_volume(self.context, size=2,
|
||||
@ -3908,6 +3909,12 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
volume_api.extend, self.context,
|
||||
volume, 3)
|
||||
|
||||
limit_check.side_effect = exception.OverQuota(
|
||||
overs=['per_volume_gigabytes'], quotas={'per_volume_gigabytes': 2})
|
||||
self.assertRaises(exception.VolumeSizeExceedsLimit,
|
||||
volume_api.extend, self.context,
|
||||
volume, 3)
|
||||
|
||||
# clean up
|
||||
self.volume.delete_volume(self.context, volume['id'])
|
||||
|
||||
|
@ -1215,6 +1215,15 @@ class API(base.Base):
|
||||
'size': volume.size})
|
||||
raise exception.InvalidInput(reason=msg)
|
||||
|
||||
try:
|
||||
values = {'per_volume_gigabytes': new_size}
|
||||
QUOTAS.limit_check(context, project_id=context.project_id,
|
||||
**values)
|
||||
except exception.OverQuota as e:
|
||||
quotas = e.kwargs['quotas']
|
||||
raise exception.VolumeSizeExceedsLimit(
|
||||
size=new_size, limit=quotas['per_volume_gigabytes'])
|
||||
|
||||
try:
|
||||
reserve_opts = {'gigabytes': size_increase}
|
||||
QUOTAS.add_volume_type_opts(context, reserve_opts,
|
||||
|
Loading…
x
Reference in New Issue
Block a user