def copy_volume_to_image(self, context, volume, image_service, image_meta): """Copy the volume to the specified image.""" volume['provider_location'] = ( self.create_export(context, volume, None)['provider_location']) connection_data = self.initialize_connection(volume, None)['data'] target_connector = ( connector.InitiatorConnector.factory(initiator.NVME, utils.get_root_helper())) try: device_info = target_connector.connect_volume(connection_data) except Exception: LOG.info('Could not connect SPDK target device') return connection_data['device_path'] = device_info['path'] try: volume_utils.upload_volume(context, image_service, image_meta, device_info['path'], volume) finally: target_connector.disconnect_volume(connection_data, volume)
def copy_volume_to_image(self, context, volume, image_service, image_meta): """Copy the volume to the specified image.""" # If snapshots exist, flatten to a temporary image, and upload it active_file = self.get_active_image_from_info(volume) active_file_path = os.path.join(self._local_volume_dir(volume), active_file) backing_file = self._vhdutils.get_vhd_parent_path(active_file_path) root_file_fmt = self.get_volume_format(volume) temp_path = None try: if backing_file: temp_file_name = '%s.temp_image.%s.%s' % ( volume.id, image_meta['id'], root_file_fmt) temp_path = os.path.join(self._local_volume_dir(volume), temp_file_name) self._vhdutils.convert_vhd(active_file_path, temp_path) upload_path = temp_path else: upload_path = active_file_path volume_utils.upload_volume(context, image_service, image_meta, upload_path, volume, root_file_fmt) finally: if temp_path: self._delete(temp_path)
def copy_volume_to_image(self, context, volume, image_service, image_meta): """Copy the volume to the specified image.""" volume_utils.upload_volume(context, image_service, image_meta, self.local_path(volume), volume)
def copy_volume_to_image(self, context, volume, image_service, image_meta): tmp_dir = volume_utils.image_conversion_dir() tmp_file = os.path.join(tmp_dir, volume.name + '-' + image_meta['id']) with fileutils.remove_path_on_error(tmp_file): vol_name = utils.convert_str(volume.name) self._try_execute( 'qemu-img', 'convert', '-f', 'raw', 'vitastor:image=' + vol_name.replace(':', '\\:') + self._qemu_args(), '-O', 'raw', tmp_file) # FIXME: Copy directly if the destination image is also in Vitastor volume_utils.upload_volume(context, image_service, image_meta, tmp_file, volume) os.unlink(tmp_file)
def _copy_volume_to_image(self, context, volume, image_service, image_meta): """Copy the volume to the specified image.""" volume_format = self.get_volume_format(volume) if volume_format == DISK_FORMAT_PLOOP: with PloopDevice(self.local_path(volume), execute=self._execute) as dev: volume_utils.upload_volume(context, image_service, image_meta, dev, volume) else: super(VZStorageDriver, self)._copy_volume_to_image(context, volume, image_service, image_meta)
def copy_volume_to_image(self, context, volume, image_service, image_meta): """Copy the volume to the specified image.""" disk_format = self._tgt_utils.get_supported_disk_format() temp_vhd_path = os.path.join(CONF.image_conversion_dir, str(image_meta['id']) + '.' + disk_format) try: with self._temporary_snapshot(volume.name) as tmp_snap_name: # qemu-img cannot access VSS snapshots, for which reason it # must be exported first. self._tgt_utils.export_snapshot(tmp_snap_name, temp_vhd_path) volume_utils.upload_volume(context, image_service, image_meta, temp_vhd_path, volume, 'vhd') finally: fileutils.delete_if_exists(temp_vhd_path)
def _copy_vol_to_image(self, context, image_service, image_meta, rsc_path, volume): return volume_utils.upload_volume(context, image_service, image_meta, rsc_path, volume)