Esempio n. 1
0
def upload_stream_optimized_disk(context, timeout_secs, read_handle, **kwargs):
    """Upload virtual disk in streamOptimized format to VMware server."""
    LOG.debug("Uploading virtual disk file: %(path)s to create backing with "
              "spec: %(spec)s.",
              {'path': read_handle.name,
               'spec': kwargs.get('vm_create_spec')})
    file_size = kwargs.get('vmdk_size')
    write_handle = rw_util.VMwareHTTPWriteVmdk(kwargs.get('session'),
                                               kwargs.get('host'),
                                               kwargs.get('resource_pool'),
                                               kwargs.get('vm_folder'),
                                               kwargs.get('vm_create_spec'),
                                               file_size)
    start_transfer(context, timeout_secs, read_handle, file_size,
                   write_file_handle=write_handle)
    LOG.debug("Uploaded virtual disk file: %s.", read_handle.name)
    return write_handle.get_imported_vm()
Esempio n. 2
0
def fetch_stream_optimized_image(context, timeout_secs, image_service,
                                 image_id, **kwargs):
    """Download stream optimized image from glance image server."""
    LOG.debug("Downloading image: %s from glance image server using HttpNfc"
              " import." % image_id)
    file_size = int(kwargs.get('image_size'))
    read_iter = image_service.download(context, image_id)
    read_handle = rw_util.GlanceFileRead(read_iter)
    write_handle = rw_util.VMwareHTTPWriteVmdk(kwargs.get('session'),
                                               kwargs.get('host'),
                                               kwargs.get('resource_pool'),
                                               kwargs.get('vm_folder'),
                                               kwargs.get('vm_create_spec'),
                                               file_size)
    start_transfer(context, timeout_secs, read_handle, file_size,
                   write_file_handle=write_handle)
    LOG.info(_("Downloaded image: %s from glance image server.") % image_id)