mock.patch.multiple(
'cinder.volume.drivers.windows.vhdutils',
ctypes=fake_ctypes, kernel32=mock.DEFAULT,
- virtdisk=mock.DEFAULT, Win32_GUID=mock.DEFAULT,
+ wintypes=mock.DEFAULT, virtdisk=mock.DEFAULT,
+ Win32_GUID=mock.DEFAULT,
Win32_RESIZE_VIRTUAL_DISK_PARAMETERS=mock.DEFAULT,
Win32_CREATE_VIRTUAL_DISK_PARAMETERS=mock.DEFAULT,
Win32_VIRTUAL_STORAGE_TYPE=mock.DEFAULT,
vhdutils.VIRTUAL_DISK_ACCESS_NONE, None,
vhdutils.CREATE_VIRTUAL_DISK_FLAG_NONE, 0,
vhdutils.ctypes.byref(fake_params), None,
- vhdutils.ctypes.byref(vhdutils.ctypes.wintypes.HANDLE()))
+ vhdutils.ctypes.byref(vhdutils.wintypes.HANDLE()))
self.assertTrue(self._vhdutils._close.called)
def test_create_vhd_exception(self):
vhdutils.ctypes.byref(fake_vst),
vhdutils.ctypes.c_wchar_p(self._FAKE_VHD_PATH),
fake_access_mask, fake_open_flag, fake_params,
- vhdutils.ctypes.byref(vhdutils.ctypes.wintypes.HANDLE()))
+ vhdutils.ctypes.byref(vhdutils.wintypes.HANDLE()))
self.assertEqual(fake_device_id, fake_vst.DeviceId)
fake_info_member = vhdutils.GET_VIRTUAL_DISK_INFO_SIZE
fake_info = mock.Mock()
fake_info.VhdInfo.Size._fields_ = [
- ("VirtualSize", vhdutils.ctypes.wintypes.ULARGE_INTEGER),
- ("PhysicalSize", vhdutils.ctypes.wintypes.ULARGE_INTEGER)]
+ ("VirtualSize", vhdutils.wintypes.ULARGE_INTEGER),
+ ("PhysicalSize", vhdutils.wintypes.ULARGE_INTEGER)]
fake_info.VhdInfo.Size.VirtualSize = self._FAKE_VHD_SIZE
fake_info.VhdInfo.Size.PhysicalSize = fake_physical_size
import os
if os.name == 'nt':
+ from ctypes import wintypes
kernel32 = ctypes.windll.kernel32
virtdisk = ctypes.windll.virtdisk
if os.name == 'nt':
class Win32_GUID(ctypes.Structure):
- _fields_ = [("Data1", ctypes.wintypes.DWORD),
- ("Data2", ctypes.wintypes.WORD),
- ("Data3", ctypes.wintypes.WORD),
- ("Data4", ctypes.wintypes.BYTE * 8)]
+ _fields_ = [("Data1", wintypes.DWORD),
+ ("Data2", wintypes.WORD),
+ ("Data3", wintypes.WORD),
+ ("Data4", wintypes.BYTE * 8)]
class Win32_VIRTUAL_STORAGE_TYPE(ctypes.Structure):
_fields_ = [
- ('DeviceId', ctypes.wintypes.ULONG),
+ ('DeviceId', wintypes.ULONG),
('VendorId', Win32_GUID)
]
class Win32_RESIZE_VIRTUAL_DISK_PARAMETERS(ctypes.Structure):
_fields_ = [
- ('Version', ctypes.wintypes.DWORD),
+ ('Version', wintypes.DWORD),
('NewSize', ctypes.c_ulonglong)
]
class Win32_OPEN_VIRTUAL_DISK_PARAMETERS_V1(ctypes.Structure):
_fields_ = [
- ('Version', ctypes.wintypes.DWORD),
+ ('Version', wintypes.DWORD),
('RWDepth', ctypes.c_ulong),
]
class Win32_OPEN_VIRTUAL_DISK_PARAMETERS_V2(ctypes.Structure):
_fields_ = [
- ('Version', ctypes.wintypes.DWORD),
- ('GetInfoOnly', ctypes.wintypes.BOOL),
- ('ReadOnly', ctypes.wintypes.BOOL),
+ ('Version', wintypes.DWORD),
+ ('GetInfoOnly', wintypes.BOOL),
+ ('ReadOnly', wintypes.BOOL),
('ResiliencyGuid', Win32_GUID)
]
class Win32_MERGE_VIRTUAL_DISK_PARAMETERS(ctypes.Structure):
_fields_ = [
- ('Version', ctypes.wintypes.DWORD),
+ ('Version', wintypes.DWORD),
('MergeDepth', ctypes.c_ulong)
]
class Win32_CREATE_VIRTUAL_DISK_PARAMETERS(ctypes.Structure):
_fields_ = [
- ('Version', ctypes.wintypes.DWORD),
+ ('Version', wintypes.DWORD),
('UniqueId', Win32_GUID),
('MaximumSize', ctypes.c_ulonglong),
- ('BlockSizeInBytes', ctypes.wintypes.ULONG),
- ('SectorSizeInBytes', ctypes.wintypes.ULONG),
- ('PhysicalSectorSizeInBytes', ctypes.wintypes.ULONG),
- ('ParentPath', ctypes.wintypes.LPCWSTR),
- ('SourcePath', ctypes.wintypes.LPCWSTR),
- ('OpenFlags', ctypes.wintypes.DWORD),
+ ('BlockSizeInBytes', wintypes.ULONG),
+ ('SectorSizeInBytes', wintypes.ULONG),
+ ('PhysicalSectorSizeInBytes', wintypes.ULONG),
+ ('ParentPath', wintypes.LPCWSTR),
+ ('SourcePath', wintypes.LPCWSTR),
+ ('OpenFlags', wintypes.DWORD),
('ParentVirtualStorageType', Win32_VIRTUAL_STORAGE_TYPE),
('SourceVirtualStorageType', Win32_VIRTUAL_STORAGE_TYPE),
('ResiliencyGuid', Win32_GUID)
]
class Win32_SIZE(ctypes.Structure):
- _fields_ = [("VirtualSize", ctypes.wintypes.ULARGE_INTEGER),
- ("PhysicalSize", ctypes.wintypes.ULARGE_INTEGER),
- ("BlockSize", ctypes.wintypes.ULONG),
- ("SectorSize", ctypes.wintypes.ULONG)]
+ _fields_ = [("VirtualSize", wintypes.ULARGE_INTEGER),
+ ("PhysicalSize", wintypes.ULARGE_INTEGER),
+ ("BlockSize", wintypes.ULONG),
+ ("SectorSize", wintypes.ULONG)]
class Win32_PARENT_LOCATION(ctypes.Structure):
- _fields_ = [('ParentResolved', ctypes.wintypes.BOOL),
- ('ParentLocationBuffer', ctypes.wintypes.WCHAR * 512)]
+ _fields_ = [('ParentResolved', wintypes.BOOL),
+ ('ParentLocationBuffer', wintypes.WCHAR * 512)]
class Win32_PHYSICAL_DISK(ctypes.Structure):
- _fields_ = [("LogicalSectorSize", ctypes.wintypes.ULONG),
- ("PhysicalSectorSize", ctypes.wintypes.ULONG),
- ("IsRemote", ctypes.wintypes.BOOL)]
+ _fields_ = [("LogicalSectorSize", wintypes.ULONG),
+ ("PhysicalSectorSize", wintypes.ULONG),
+ ("IsRemote", wintypes.BOOL)]
class Win32_VHD_INFO(ctypes.Union):
_fields_ = [("Size", Win32_SIZE),
("Identifier", Win32_GUID),
("ParentLocation", Win32_PARENT_LOCATION),
("ParentIdentifier", Win32_GUID),
- ("ParentTimestamp", ctypes.wintypes.ULONG),
+ ("ParentTimestamp", wintypes.ULONG),
("VirtualStorageType", Win32_VIRTUAL_STORAGE_TYPE),
- ("ProviderSubtype", ctypes.wintypes.ULONG),
- ("Is4kAligned", ctypes.wintypes.BOOL),
+ ("ProviderSubtype", wintypes.ULONG),
+ ("Is4kAligned", wintypes.BOOL),
("PhysicalDisk", Win32_PHYSICAL_DISK),
- ("VhdPhysicalSectorSize", ctypes.wintypes.ULONG),
+ ("VhdPhysicalSectorSize", wintypes.ULONG),
("SmallestSafeVirtualSize",
- ctypes.wintypes.ULARGE_INTEGER),
- ("FragmentationPercentage", ctypes.wintypes.ULONG)]
+ wintypes.ULARGE_INTEGER),
+ ("FragmentationPercentage", wintypes.ULONG)]
class Win32_GET_VIRTUAL_DISK_INFO_PARAMETERS(ctypes.Structure):
- _fields_ = [("VERSION", ctypes.wintypes.UINT),
+ _fields_ = [("VERSION", wintypes.UINT),
("VhdInfo", Win32_VHD_INFO)]
class Win32_SET_VIRTUAL_DISK_INFO_PARAMETERS(ctypes.Structure):
_fields_ = [
- ('Version', ctypes.wintypes.DWORD),
- ('ParentFilePath', ctypes.wintypes.LPCWSTR)
+ ('Version', wintypes.DWORD),
+ ('ParentFilePath', wintypes.LPCWSTR)
]
guid.Data1 = 0xec984aec
guid.Data2 = 0xa0f9
guid.Data3 = 0x47e9
- ByteArray8 = ctypes.wintypes.BYTE * 8
+ ByteArray8 = wintypes.BYTE * 8
guid.Data4 = ByteArray8(0x90, 0x1f, 0x71, 0x41, 0x5a, 0x66, 0x34, 0x5b)
return guid
vst.DeviceId = device_id
vst.VendorId = self._msft_vendor_id
- handle = ctypes.wintypes.HANDLE()
+ handle = wintypes.HANDLE()
ret_val = virtdisk.OpenVirtualDisk(ctypes.byref(vst),
ctypes.c_wchar_p(vhd_path),
params.SourceVirtualStorageType.DeviceId = src_device_id
params.SourceVirtualStorageType.VendorId = self._msft_vendor_id
- handle = ctypes.wintypes.HANDLE()
+ handle = wintypes.HANDLE()
create_virtual_disk_flag = self.create_virtual_disk_flags.get(
new_vhd_type)
infoSize = ctypes.sizeof(virt_disk_info)
- virtdisk.GetVirtualDiskInformation.restype = ctypes.wintypes.DWORD
+ virtdisk.GetVirtualDiskInformation.restype = wintypes.DWORD
ret_val = virtdisk.GetVirtualDiskInformation(
vhd_file, ctypes.byref(ctypes.c_ulong(infoSize)),