def copy_image_to_volume(self, context, volume, image_service, image_id): """Fetch the image from image_service and write it to the volume.""" volume_format = self.get_volume_format(volume, qemu_format=True) image_meta = image_service.show(context, image_id) qemu_version = self.get_qemu_version() if qemu_version < [1, 7] and ( volume_format == self._DISK_FORMAT_VHDX and image_meta["disk_format"] != volume_format ): err_msg = _( "Unsupported volume format: vhdx. qemu-img 1.7 or " "higher is required in order to properly support this " "format." ) raise exception.InvalidVolume(err_msg) image_utils.fetch_to_volume_format( context, image_service, image_id, self.local_path(volume), volume_format, self.configuration.volume_dd_blocksize, ) self._do_extend_volume(self.local_path(volume), volume["size"], volume["name"]) data = image_utils.qemu_img_info(self.local_path(volume)) virt_size = data.virtual_size / units.Gi if virt_size != volume["size"]: raise exception.ImageUnacceptable( image_id=image_id, reason=(_("Expected volume size was %d") % volume["size"]) + (_(" but size is now %d.") % virt_size), )
def copy_image_to_volume(self, context, volume, image_service, image_id): """Fetch the image from image_service and write it to the volume.""" volume_format = self.get_volume_format(volume, qemu_format=True) image_meta = image_service.show(context, image_id) fetch_format = volume_format fetch_path = self.local_path(volume) self._delete(fetch_path) qemu_version = self.get_qemu_version() needs_conversion = False if (qemu_version < [1, 7] and ( volume_format == self._DISK_FORMAT_VHDX and image_meta['disk_format'] != self._DISK_FORMAT_VHDX)): needs_conversion = True fetch_format = 'vpc' temp_file_name = '%s.temp_image.%s.%s' % ( volume['id'], image_meta['id'], self._DISK_FORMAT_VHD) fetch_path = os.path.join(self._local_volume_dir(volume), temp_file_name) image_utils.fetch_to_volume_format( context, image_service, image_id, fetch_path, fetch_format, self.configuration.volume_dd_blocksize) if needs_conversion: self.vhdutils.convert_vhd(fetch_path, self.local_path(volume)) self._delete(fetch_path) self.vhdutils.resize_vhd(self.local_path(volume), volume['size'] * units.Gi)
def copy_image_to_volume(self, context, volume, image_service, image_id): """Fetch the image from image_service and write it to the volume.""" volume_format = self.get_volume_format(volume, qemu_format=True) image_meta = image_service.show(context, image_id) qemu_version = self.get_qemu_version() if (qemu_version < [1, 7] and (volume_format == self._DISK_FORMAT_VHDX and image_meta['disk_format'] != volume_format)): err_msg = _("Unsupported volume format: vhdx. qemu-img 1.7 or " "higher is required in order to properly support this " "format.") raise exception.InvalidVolume(err_msg) image_utils.fetch_to_volume_format( context, image_service, image_id, self.local_path(volume), volume_format, self.configuration.volume_dd_blocksize) self._do_extend_volume(self.local_path(volume), volume['size'], volume['name']) data = image_utils.qemu_img_info(self.local_path(volume)) virt_size = data.virtual_size / units.Gi if virt_size != volume['size']: raise exception.ImageUnacceptable( image_id=image_id, reason=(_("Expected volume size was %d") % volume['size']) + (_(" but size is now %d.") % virt_size))
def fetch(self, ctxt, image_service, image_id): image_utils.fetch_to_volume_format( ctxt, image_service, image_id, self.file_path, self.file_format, self.block_size, run_as_root=self.root) self.reload(file_size=True)
def copy_image_to_volume(self, context, volume, image_service, image_id): """Fetch the image from image_service and write it to the volume.""" with temp_lvm_device(self, volume): image_utils.fetch_to_volume_format( context, image_service, image_id, self._mapper_path(volume), 'qcow2', self.configuration.volume_dd_blocksize, size=volume['size'])
def copy_image_to_volume(self, context, volume, image_service, image_id): """Fetch the image from image_service and write it to the volume.""" with temp_lvm_device(self, volume): image_utils.fetch_to_volume_format(context, image_service, image_id, self._mapper_path(volume), 'qcow2', self.configuration. volume_dd_blocksize, size=volume['size'])
def copy_image_to_volume(self, context, volume, image_service, image_id): """Fetch the image from image_service and write it to the volume.""" volume_path = self.local_path(volume) volume_format = self.get_volume_format(volume, qemu_format=True) self._delete(volume_path) image_utils.fetch_to_volume_format( context, image_service, image_id, volume_path, volume_format, self.configuration.volume_dd_blocksize) self._extend_vhd_if_needed(self.local_path(volume), volume['size'])
def copy_image_to_volume(self, context, volume, image_service, image_id): """Fetch the image from image_service and write it to the volume.""" volume_path = self.local_path(volume) volume_format = self.get_volume_format(volume, qemu_format=True) self._delete(volume_path) image_utils.fetch_to_volume_format( context, image_service, image_id, volume_path, volume_format, self.configuration.volume_dd_blocksize) self._vhdutils.resize_vhd(self.local_path(volume), volume.size * units.Gi, is_file_max_size=False)
def copy_image_to_volume(self, context, volume, image_service, image_id): """Fetch the image from image_service and write it to the volume.""" volume_format = self.get_volume_format(volume) image_path = self.local_path(volume) if volume_format == DISK_FORMAT_PLOOP: image_path = os.path.join(image_path, PLOOP_BASE_DELTA_NAME) image_utils.fetch_to_volume_format( context, image_service, image_id, image_path, volume_format, self.configuration.volume_dd_blocksize) if volume_format == DISK_FORMAT_PLOOP: self._recreate_ploop_desc(self.local_path(volume), image_path) self._do_extend_volume(self.local_path(volume), volume.size, volume_format) # Query qemu-img info to cache the output self._qemu_img_info(self.local_path(volume), volume.name)
def copy_image_to_volume(self, context, volume, image_service, image_id): """Fetch the image from image_service and write it to the volume.""" volume_format = self.get_volume_format(volume, qemu_format=True) image_utils.fetch_to_volume_format( context, image_service, image_id, self.local_path(volume), volume_format, self.configuration.volume_dd_blocksize) self._do_extend_volume(self.local_path(volume), volume['size'], volume['name']) data = image_utils.qemu_img_info(self.local_path(volume)) virt_size = data.virtual_size / units.Gi if virt_size != volume['size']: raise exception.ImageUnacceptable( image_id=image_id, reason=(_("Expected volume size was %d") % volume['size']) + (_(" but size is now %d.") % virt_size))
def copy_image_to_volume(self, context, volume, image_service, image_id): """Fetch the image from image_service and write it to the volume.""" volume_format = self.get_volume_format(volume) image_path = self.local_path(volume) if volume_format == DISK_FORMAT_PLOOP: image_path = os.path.join(image_path, PLOOP_BASE_DELTA_NAME) image_utils.fetch_to_volume_format( context, image_service, image_id, image_path, volume_format, self.configuration.volume_dd_blocksize) if volume_format == DISK_FORMAT_PLOOP: self._recreate_ploop_desc(self.local_path(volume), image_path) self._do_extend_volume(self.local_path(volume), volume.size, volume_format)