def fetch_image(context, image, instance, **kwargs): """Download image from the glance image server.""" LOG.debug(_("Downloading image %s from glance image server") % image) (glance_client, image_id) = glance.get_glance_client(context, image) metadata, read_iter = glance_client.get_image(image_id) read_file_handle = read_write_util.GlanceFileRead(read_iter) file_size = int(metadata['size']) write_file_handle = read_write_util.VMWareHTTPWriteFile( kwargs.get("host"), kwargs.get("data_center_name"), kwargs.get("datastore_name"), kwargs.get("cookies"), kwargs.get("file_path"), file_size) start_transfer(read_file_handle, file_size, write_file_handle=write_file_handle) LOG.debug(_("Downloaded image %s from glance image server") % image)
def fetch_image(context, image, instance, **kwargs): """Download image from the glance image server.""" LOG.debug(_("Downloading image %s from glance image server") % image, instance=instance) (image_service, image_id) = glance.get_remote_image_service(context, image) metadata = image_service.show(context, image_id) file_size = int(metadata['size']) f = StringIO.StringIO() image_service.download(context, image_id, f) read_file_handle = read_write_util.GlanceFileRead(f) write_file_handle = read_write_util.VMWareHTTPWriteFile( kwargs.get("host"), kwargs.get("data_center_name"), kwargs.get("datastore_name"), kwargs.get("cookies"), kwargs.get("file_path"), file_size) start_transfer(read_file_handle, file_size, write_file_handle=write_file_handle) LOG.debug(_("Downloaded image %s from glance image server") % image, instance=instance)