def transport_diff_and_merge(self, dst_cloud, info, instance_id): convertor = convert_image_to_file.ConvertImageToFile(self.init, cloud='dst_cloud') transporter = task_transfer.TaskTransfer( self.init, TRANSPORTER_MAP[ISCSI][ISCSI], resource_name=utl.INSTANCES_TYPE, resource_root_name=utl.DIFF_BODY) image_id = info[INSTANCES][instance_id][utl.INSTANCE_BODY]['image_id'] base_file = "%s/%s" % (dst_cloud.cloud_config.cloud.temp, "temp%s_base" % instance_id) diff_file = "%s/%s" % (dst_cloud.cloud_config.cloud.temp, "temp%s" % instance_id) info[INSTANCES][instance_id][DIFF][PATH_DST] = diff_file info[INSTANCES][instance_id][DIFF][HOST_DST] = dst_cloud.getIpSsh() convertor.run(image_id=image_id, base_filename=base_file) transporter.run(info=info) self.merge_file(dst_cloud, base_file, diff_file) image_res = dst_cloud.resources[utl.IMAGE_RESOURCE] images = image_res.read_info(image_id=image_id) image = images[utl.IMAGE_RESOURCE][utl.IMAGES_TYPE][image_id] disk_format = image[utl.IMAGE_BODY]['disk_format'] if image_res.config.image.convert_to_raw: if disk_format.lower() != utl.RAW: self.convert_file_to_raw(dst_cloud.cloud_config.cloud.host, disk_format, base_file) disk_format = utl.RAW converter = convert_file_to_image.ConvertFileToImage(self.init, cloud='dst_cloud') dst_image_id = converter.run(file_path=base_file, image_format=disk_format, image_name="%s-image" % instance_id) info[INSTANCES][instance_id][INSTANCE_BODY]['image_id'] = dst_image_id
def convert_image_to_file(self, cloud, image_id, filename): convertor = convert_image_to_file.ConvertImageToFile(self.init, cloud=cloud) convertor.run(image_id=image_id, base_filename=filename)