def _check_and_update_root_device(self, vm_gen, image_meta, block_device_info, slot_map): # either booting from volume, or booting from image/iso root_disk = {} root_device = (driver.block_device_info_get_root(block_device_info) or self._DEFAULT_ROOT_DEVICE) if self.is_boot_from_volume(block_device_info): root_volume = self._get_root_device_bdm(block_device_info, root_device) root_disk['type'] = constants.VOLUME root_disk['path'] = None root_disk['connection_info'] = root_volume['connection_info'] else: root_disk['type'] = self._TYPE_FOR_DISK_FORMAT.get( image_meta.disk_format) if root_disk['type'] is None: raise exception.InvalidImageFormat( format=image_meta.disk_format) root_disk['path'] = None root_disk['connection_info'] = None root_disk['disk_bus'] = (constants.CTRL_TYPE_IDE if vm_gen == constants.VM_GEN_1 else constants.CTRL_TYPE_SCSI) (root_disk['drive_addr'], root_disk['ctrl_disk_addr']) = self._get_available_controller_slot( root_disk['disk_bus'], slot_map) root_disk['boot_index'] = 0 root_disk['mount_device'] = root_device block_device_info['root_disk'] = root_disk
def __init__(self, format): """Create a new abstract image :param format: one of the format constants """ super(Image, self).__init__() self.format = format if format not in ALL_FORMATS: raise exception.InvalidImageFormat(format=format)