Merge "Do not allow resize to zero disk flavor"
This commit is contained in:
@@ -2362,6 +2362,10 @@ class API(base.Base):
|
||||
else:
|
||||
new_instance_type = flavors.get_flavor_by_flavor_id(
|
||||
flavor_id, read_deleted="no")
|
||||
if (new_instance_type.get('root_gb') == 0 and
|
||||
current_instance_type.get('root_gb') != 0):
|
||||
reason = _('Resize to zero disk flavor is not allowed.')
|
||||
raise exception.CannotResizeDisk(reason=reason)
|
||||
|
||||
current_instance_type_name = current_instance_type['name']
|
||||
new_instance_type_name = new_instance_type['name']
|
||||
|
@@ -1159,6 +1159,18 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||
self.compute_api.resize, self.context,
|
||||
fake_inst, flavor_id='flavor-id')
|
||||
|
||||
@mock.patch.object(flavors, 'get_flavor_by_flavor_id')
|
||||
def test_resize_to_zero_disk_flavor_fails(self, get_flavor_by_flavor_id):
|
||||
fake_inst = self._create_instance_obj()
|
||||
fake_flavor = dict(id=200, flavorid='flavor-id', name='foo',
|
||||
root_gb=0)
|
||||
|
||||
get_flavor_by_flavor_id.return_value = fake_flavor
|
||||
|
||||
self.assertRaises(exception.CannotResizeDisk,
|
||||
self.compute_api.resize, self.context,
|
||||
fake_inst, flavor_id='flavor-id')
|
||||
|
||||
def test_resize_quota_exceeds_fails(self):
|
||||
self.mox.StubOutWithMock(flavors, 'get_flavor_by_flavor_id')
|
||||
self.mox.StubOutWithMock(self.compute_api, '_upsize_quota_delta')
|
||||
|
Reference in New Issue
Block a user