The oslo.vmware.image_transfer Module

Functions and classes for image transfer between ESX/VC & image service.

class oslo.vmware.image_transfer.BlockingQueue(max_size, max_transfer_size)

Bases: eventlet.queue.LightQueue

Producer-Consumer queue to share data between reader/writer threads.

close()
read(chunk_size)

Read data from the queue.

This method blocks until data is available. The input chunk size is ignored since we have ensured that the data chunks written to the pipe by the image reader thread is the same as the chunks asked for by the image writer thread.

seek(offset, whence=0)

Set the file’s current position at the offset.

This method throws IOError since seek cannot be supported for a pipe.

tell()

Get the current file position.

write(data)

Write data into the queue.

Parameters:data – data to be written
class oslo.vmware.image_transfer.FileReadWriteTask(input_file, output_file)

Bases: object

Task which reads data from the input file and writes to the output file.

This class defines the task which copies the given input file to the given output file. The copy operation involves reading chunks of data from the input file and writing the same to the output file.

start()

Start the file read - file write task.

Returns:the event indicating the status of the read-write task
stop()

Stop the read-write task.

wait()

Wait for the file read-write task to complete.

This method returns True if the read-write thread completes successfully. In case of error, it raises ImageTransferException.

Raises :ImageTransferException
class oslo.vmware.image_transfer.ImageWriter(context, input_file, image_service, image_id, image_meta=None)

Bases: object

Class to write the image to the image service from an input file.

close()

This is a NOP.

start()

Start the image write task.

Returns:the event indicating the status of the write task
stop()

Stop the image writing task.

wait()

Wait for the image writer task to complete.

This method returns True if the writer thread completes successfully. In case of error, it raises ImageTransferException.

:raises ImageTransferException

oslo.vmware.image_transfer.copy_stream_optimized_disk(context, timeout_secs, write_handle, **kwargs)

Copy virtual disk from VMware server to the given write handle.

Parameters:
  • context – context
  • timeout_secs – time in seconds to wait for the copy to complete
  • write_handle – copy destination
  • kwargs – keyword arguments to configure the source VMDK read handle
Raises :

VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException, ImageTransferException, ValueError

oslo.vmware.image_transfer.download_flat_image(context, timeout_secs, image_service, image_id, **kwargs)

Download flat image from the image service to VMware server.

Parameters:
  • context – image service write context
  • timeout_secs – time in seconds to wait for the download to complete
  • image_service – image service handle
  • image_id – ID of the image to be downloaded
  • kwargs – keyword arguments to configure the destination file write handle
Raises :

VimConnectionException, ImageTransferException, ValueError

oslo.vmware.image_transfer.download_stream_optimized_data(context, timeout_secs, read_handle, **kwargs)

Download stream optimized data to VMware server.

Parameters:
  • context – image service write context
  • timeout_secs – time in seconds to wait for the download to complete
  • read_handle – handle from which to read the image data
  • kwargs – keyword arguments to configure the destination VMDK write handle
Returns:

managed object reference of the VM created for import to VMware server

Raises :

VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException, ImageTransferException, ValueError

oslo.vmware.image_transfer.download_stream_optimized_image(context, timeout_secs, image_service, image_id, **kwargs)

Download stream optimized image from image service to VMware server.

Parameters:
  • context – image service write context
  • timeout_secs – time in seconds to wait for the download to complete
  • image_service – image service handle
  • image_id – ID of the image to be downloaded
  • kwargs – keyword arguments to configure the destination VMDK write handle
Returns:

managed object reference of the VM created for import to VMware server

Raises :

VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException, ImageTransferException, ValueError

oslo.vmware.image_transfer.upload_image(context, timeout_secs, image_service, image_id, owner_id, **kwargs)

Upload the VM’s disk file to image service.

Parameters:
  • context – image service write context
  • timeout_secs – time in seconds to wait for the upload to complete
  • image_service – image service handle
  • image_id – upload destination image ID
  • kwargs – keyword arguments to configure the source VMDK read handle
Raises :

VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException, ImageTransferException, ValueError

Previous topic

The oslo.vmware.exceptions Module

Next topic

The oslo.vmware.objects.datastore Module

This Page