# Path: oslo_vmware/exceptions.py
# LOG = logging.getLogger(__name__)
# ALREADY_EXISTS = 'AlreadyExists'
# CANNOT_DELETE_FILE = 'CannotDeleteFile'
# DUPLICATE_NAME = 'DuplicateName'
# FILE_ALREADY_EXISTS = 'FileAlreadyExists'
# FILE_FAULT = 'FileFault'
# FILE_LOCKED = 'FileLocked'
# FILE_NOT_FOUND = 'FileNotFound'
# INVALID_POWER_STATE = 'InvalidPowerState'
# INVALID_PROPERTY = 'InvalidProperty'
# NO_DISK_SPACE = 'NoDiskSpace'
# NO_PERMISSION = 'NoPermission'
# NOT_AUTHENTICATED = 'NotAuthenticated'
# SECURITY_ERROR = "SecurityError"
# MANAGED_OBJECT_NOT_FOUND = 'ManagedObjectNotFound'
# TASK_IN_PROGRESS = 'TaskInProgress'
# TOOLS_UNAVAILABLE = 'ToolsUnavailable'
# class VMwareDriverException(Exception):
# class VimException(VMwareDriverException):
# class VimSessionOverLoadException(VMwareDriverException):
# class VimConnectionException(VMwareDriverException):
# class VimAttributeException(VMwareDriverException):
# class VimFaultException(VimException):
# class ImageTransferException(VMwareDriverException):
# class VMwareDriverConfigurationException(VMwareDriverException):
# class UseLinkedCloneConfigurationFault(VMwareDriverConfigurationException):
# class MissingParameter(VMwareDriverException):
# class AlreadyExistsException(VimException):
# class CannotDeleteFileException(VimException):
# class FileAlreadyExistsException(VimException):
# class FileFaultException(VimException):
# class FileLockedException(VimException):
# class FileNotFoundException(VimException):
# class InvalidPowerStateException(VimException):
# class InvalidPropertyException(VimException):
# class NoPermissionException(VimException):
# class NotAuthenticatedException(VimException):
# class TaskInProgress(VimException):
# class DuplicateName(VimException):
# class NoDiskSpaceException(VimException):
# class ToolsUnavailableException(VimException):
# class ManagedObjectNotFoundException(VimException):
#     def __str__(self):
#     def __init__(self, message=None, details=None, **kwargs):
#     def msg(self):
#     def description(self):
#     def __init__(self, message=None, cause=None, details=None, **kwargs):
#     def __init__(self, message, cause=None):
#     def __init__(self, message, cause=None):
#     def __init__(self, message, cause=None):
#     def __init__(self, fault_list, message, cause=None, details=None):
#     def description(self):
#     def __init__(self, message, cause=None):
# def _print_deprecation_warning(clazz):
#     def __init__(self, message=None, details=None, **kwargs):
#     def __init__(self, message=None, details=None, **kwargs):
# def get_fault_class(name):
# def translate_fault(localized_method_fault, excep_msg=None):
# def register_fault_class(name, exception):
# 
# Path: oslo_vmware/image_transfer.py
# LOG = logging.getLogger(__name__)
# NFC_LEASE_UPDATE_PERIOD = 60  # update NFC lease every 60sec.
# CHUNK_SIZE = 64 * units.Ki  # default chunk size for image transfer
# def _create_progress_updater(handle):
# def _start_transfer(read_handle, write_handle, timeout_secs):
# def download_image(image, image_meta, session, datastore, rel_path,
#                    bypass=True, timeout_secs=7200):
# def download_flat_image(context, timeout_secs, image_service, image_id,
#                         **kwargs):
# def download_file(
#         read_handle, host, port, dc_name, ds_name, cookies,
#         upload_file_path, file_size, cacerts, timeout_secs):
# def download_stream_optimized_data(context, timeout_secs, read_handle,
#                                    **kwargs):
# def _get_vmdk_handle(ova_handle):
# def download_stream_optimized_image(context, timeout_secs, image_service,
#                                     image_id, **kwargs):
# def copy_stream_optimized_disk(
#         context, timeout_secs, write_handle, **kwargs):
# def upload_image(context, timeout_secs, image_service, image_id, owner_id,
#                  **kwargs):


import io
from unittest import mock
from oslo_vmware import exceptions
from oslo_vmware import image_transfer
from oslo_vmware.tests import base
        if container:
            image_service.show.return_value = {'container_format': container}
        read_iter = mock.sentinel.read_iter
        image_service.download.return_value = read_iter
        read_handle = mock.sentinel.read_handle
        image_read_handle.return_value = read_handle

        if container == 'ova':
            if invalid_ova:
                get_vmdk_handle.return_value = None
            else:
                vmdk_handle = mock.sentinel.vmdk_handle
                get_vmdk_handle.return_value = vmdk_handle

        imported_vm = mock.sentinel.imported_vm
        download_stream_optimized_data.return_value = imported_vm

        context = mock.sentinel.context
        timeout_secs = mock.sentinel.timeout_secs
        image_id = mock.sentinel.image_id
        session = mock.sentinel.session
        image_size = mock.sentinel.image_size
        host = mock.sentinel.host
        port = mock.sentinel.port
        resource_pool = mock.sentinel.port
        vm_folder = mock.sentinel.vm_folder
        vm_import_spec = mock.sentinel.vm_import_spec

        if container == 'ova' and invalid_ova:
            self.assertRaises(exceptions.ImageTransferException,

# Path: oslo_vmware/exceptions.py
# LOG = logging.getLogger(__name__)
# ALREADY_EXISTS = 'AlreadyExists'
# CANNOT_DELETE_FILE = 'CannotDeleteFile'
# DUPLICATE_NAME = 'DuplicateName'
# FILE_ALREADY_EXISTS = 'FileAlreadyExists'
# FILE_FAULT = 'FileFault'
# FILE_LOCKED = 'FileLocked'
# FILE_NOT_FOUND = 'FileNotFound'
# INVALID_POWER_STATE = 'InvalidPowerState'
# INVALID_PROPERTY = 'InvalidProperty'
# NO_DISK_SPACE = 'NoDiskSpace'
# NO_PERMISSION = 'NoPermission'
# NOT_AUTHENTICATED = 'NotAuthenticated'
# SECURITY_ERROR = "SecurityError"
# MANAGED_OBJECT_NOT_FOUND = 'ManagedObjectNotFound'
# TASK_IN_PROGRESS = 'TaskInProgress'
# TOOLS_UNAVAILABLE = 'ToolsUnavailable'
# class VMwareDriverException(Exception):
# class VimException(VMwareDriverException):
# class VimSessionOverLoadException(VMwareDriverException):
# class VimConnectionException(VMwareDriverException):
# class VimAttributeException(VMwareDriverException):
# class VimFaultException(VimException):
# class ImageTransferException(VMwareDriverException):
# class VMwareDriverConfigurationException(VMwareDriverException):
# class UseLinkedCloneConfigurationFault(VMwareDriverConfigurationException):
# class MissingParameter(VMwareDriverException):
# class AlreadyExistsException(VimException):
# class CannotDeleteFileException(VimException):
# class FileAlreadyExistsException(VimException):
# class FileFaultException(VimException):
# class FileLockedException(VimException):
# class FileNotFoundException(VimException):
# class InvalidPowerStateException(VimException):
# class InvalidPropertyException(VimException):
# class NoPermissionException(VimException):
# class NotAuthenticatedException(VimException):
# class TaskInProgress(VimException):
# class DuplicateName(VimException):
# class NoDiskSpaceException(VimException):
# class ToolsUnavailableException(VimException):
# class ManagedObjectNotFoundException(VimException):
#     def __str__(self):
#     def __init__(self, message=None, details=None, **kwargs):
#     def msg(self):
#     def description(self):
#     def __init__(self, message=None, cause=None, details=None, **kwargs):
#     def __init__(self, message, cause=None):
#     def __init__(self, message, cause=None):
#     def __init__(self, message, cause=None):
#     def __init__(self, fault_list, message, cause=None, details=None):
#     def description(self):
#     def __init__(self, message, cause=None):
# def _print_deprecation_warning(clazz):
#     def __init__(self, message=None, details=None, **kwargs):
#     def __init__(self, message=None, details=None, **kwargs):
# def get_fault_class(name):
# def translate_fault(localized_method_fault, excep_msg=None):
# def register_fault_class(name, exception):
# 
# Path: oslo_vmware/image_transfer.py
# LOG = logging.getLogger(__name__)
# NFC_LEASE_UPDATE_PERIOD = 60  # update NFC lease every 60sec.
# CHUNK_SIZE = 64 * units.Ki  # default chunk size for image transfer
# def _create_progress_updater(handle):
# def _start_transfer(read_handle, write_handle, timeout_secs):
# def download_image(image, image_meta, session, datastore, rel_path,
#                    bypass=True, timeout_secs=7200):
# def download_flat_image(context, timeout_secs, image_service, image_id,
#                         **kwargs):
# def download_file(
#         read_handle, host, port, dc_name, ds_name, cookies,
#         upload_file_path, file_size, cacerts, timeout_secs):
# def download_stream_optimized_data(context, timeout_secs, read_handle,
#                                    **kwargs):
# def _get_vmdk_handle(ova_handle):
# def download_stream_optimized_image(context, timeout_secs, image_service,
#                                     image_id, **kwargs):
# def copy_stream_optimized_disk(
#         context, timeout_secs, write_handle, **kwargs):
# def upload_image(context, timeout_secs, image_service, image_id, owner_id,
#                  **kwargs):


# Path: oslo_vmware/tests/test_image_transfer.py
import io
from unittest import mock
from oslo_vmware import exceptions
from oslo_vmware import image_transfer
from oslo_vmware.tests import base

        if container:
            image_service.show.return_value = {'container_format': container}
        read_iter = mock.sentinel.read_iter
        image_service.download.return_value = read_iter
        read_handle = mock.sentinel.read_handle
        image_read_handle.return_value = read_handle

        if container == 'ova':
            if invalid_ova:
                get_vmdk_handle.return_value = None
            else:
                vmdk_handle = mock.sentinel.vmdk_handle
                get_vmdk_handle.return_value = vmdk_handle

        imported_vm = mock.sentinel.imported_vm
        download_stream_optimized_data.return_value = imported_vm

        context = mock.sentinel.context
        timeout_secs = mock.sentinel.timeout_secs
        image_id = mock.sentinel.image_id
        session = mock.sentinel.session
        image_size = mock.sentinel.image_size
        host = mock.sentinel.host
        port = mock.sentinel.port
        resource_pool = mock.sentinel.port
        vm_folder = mock.sentinel.vm_folder
        vm_import_spec = mock.sentinel.vm_import_spec

        if container == 'ova' and invalid_ova:
            self.assertRaises(exceptions.ImageTransferException,

                              image_transfer.download_stream_optimized_image,