287
287
return (num_instances, base_options, image)
290
def _ephemeral_size(instance_type, ephemeral_name):
291
num = block_device.ephemeral_num(ephemeral_name)
293
# TODO(yamahata): ephemeralN where N > 0
294
# Only ephemeral0 is allowed for now because InstanceTypes
295
# table only allows single local disk, local_gb.
296
# In order to enhance it, we need to add a new columns to
297
# instance_types table.
301
return instance_type.get('local_gb')
290
def _volume_size(instance_type, virtual_name):
292
if virtual_name == 'swap':
293
size = instance_type.get('swap', 0)
294
elif block_device.is_ephemeral(virtual_name):
295
num = block_device.ephemeral_num(virtual_name)
297
# TODO(yamahata): ephemeralN where N > 0
298
# Only ephemeral0 is allowed for now because InstanceTypes
299
# table only allows single local disk, local_gb.
300
# In order to enhance it, we need to add a new columns to
301
# instance_types table.
305
size = instance_type.get('local_gb')
303
309
def _update_image_block_device_mapping(self, elevated_context,
304
310
instance_type, instance_id,
319
325
if not block_device.is_swap_or_ephemeral(virtual_name):
323
if virtual_name == 'swap':
324
size = instance_type.get('swap', 0)
325
elif block_device.is_ephemeral(virtual_name):
326
size = self._ephemeral_size(instance_type, virtual_name)
328
size = self._volume_size(instance_type, virtual_name)
355
356
virtual_name = bdm.get('virtual_name')
356
357
if (virtual_name is not None and
357
block_device.is_ephemeral(virtual_name)):
358
size = self._ephemeral_size(instance_type, virtual_name)
358
block_device.is_swap_or_ephemeral(virtual_name)):
359
size = self._volume_size(instance_type, virtual_name)
361
362
values['volume_size'] = size