Merge "Prevent boot if ephemeral disk size > flavor value"
This commit is contained in:
commit
1f2776b633
@ -1310,7 +1310,7 @@ class API(base.Base):
|
||||
"(source: 'blank', dest: 'volume') need to have non-zero "
|
||||
"size"))
|
||||
|
||||
ephemeral_size = sum(bdm.volume_size or 0
|
||||
ephemeral_size = sum(bdm.volume_size or instance_type['ephemeral_gb']
|
||||
for bdm in block_device_mappings
|
||||
if block_device.new_format_is_ephemeral(bdm))
|
||||
if ephemeral_size > instance_type['ephemeral_gb']:
|
||||
|
@ -219,7 +219,9 @@ class InvalidBDMLocalsLimit(InvalidBDM):
|
||||
|
||||
class InvalidBDMEphemeralSize(InvalidBDM):
|
||||
msg_fmt = _("Ephemeral disks requested are larger than "
|
||||
"the instance type allows.")
|
||||
"the instance type allows. If no size is given "
|
||||
"in one block device mapping, flavor ephemeral "
|
||||
"size will be used.")
|
||||
|
||||
|
||||
class InvalidBDMSwapSize(InvalidBDM):
|
||||
|
@ -1056,6 +1056,40 @@ class ComputeVolumeTestCase(BaseTestCase):
|
||||
self.context, instance, instance_type,
|
||||
mappings_)
|
||||
|
||||
def test_validate_bdm_with_more_than_one_default(self):
|
||||
instance_type = {'swap': 1, 'ephemeral_gb': 1}
|
||||
all_mappings = [fake_block_device.FakeDbBlockDeviceDict({
|
||||
'id': 1,
|
||||
'no_device': None,
|
||||
'source_type': 'volume',
|
||||
'destination_type': 'volume',
|
||||
'snapshot_id': None,
|
||||
'volume_size': 1,
|
||||
'device_name': 'vda',
|
||||
'boot_index': 0,
|
||||
'delete_on_termination': False}, anon=True),
|
||||
fake_block_device.FakeDbBlockDeviceDict({
|
||||
'device_name': '/dev/vdb',
|
||||
'source_type': 'blank',
|
||||
'destination_type': 'local',
|
||||
'device_type': 'disk',
|
||||
'volume_size': None,
|
||||
'boot_index': -1}, anon=True),
|
||||
fake_block_device.FakeDbBlockDeviceDict({
|
||||
'device_name': '/dev/vdc',
|
||||
'source_type': 'blank',
|
||||
'destination_type': 'local',
|
||||
'device_type': 'disk',
|
||||
'volume_size': None,
|
||||
'boot_index': -1}, anon=True)]
|
||||
all_mappings = block_device_obj.block_device_make_list_from_dicts(
|
||||
self.context, all_mappings)
|
||||
|
||||
self.assertRaises(exception.InvalidBDMEphemeralSize,
|
||||
self.compute_api._validate_bdm,
|
||||
self.context, self.instance,
|
||||
instance_type, all_mappings)
|
||||
|
||||
def test_validate_bdm_media_service_exceptions(self):
|
||||
instance_type = {'swap': 1, 'ephemeral_gb': 1}
|
||||
bdms = [fake_block_device.FakeDbBlockDeviceDict({
|
||||
|
Loading…
Reference in New Issue
Block a user