Support for Windows 2003 and 2003 R2

This commit is contained in:
Alessandro Pilotti
2013-01-31 16:43:00 +02:00
parent ab06a61726
commit 3ad38a1945
3 changed files with 34 additions and 9 deletions

View File

@@ -26,8 +26,8 @@ from ctypes import wintypes
from cloudbaseinit.openstack.common import log as logging
from windows.disk.physical_disk import *
from windows.disk.virtual_disk import *
from windows.disk import physical_disk
from windows.disk import virtual_disk
LOG = logging.getLogger(__name__)
@@ -114,7 +114,7 @@ class ConfigDriveManager(object):
offset += bytes_read
def _copy_iso_files(self, iso_file_path, target_path):
virt_disk = VirtualDisk(iso_file_path)
virt_disk = virtual_disk.VirtualDisk(iso_file_path)
virt_disk.open()
try:
virt_disk.attach()
@@ -130,7 +130,7 @@ class ConfigDriveManager(object):
def _extract_iso_disk_file(self, iso_file_path):
iso_disk_found = False
for path in self._get_physical_disks_path():
phys_disk = PhysicalDisk(path)
phys_disk = physical_disk.PhysicalDisk(path)
try:
phys_disk.open()
iso_file_size = self._get_iso_disk_size(phys_disk)

View File

@@ -20,7 +20,8 @@ from ctypes import windll
from ctypes import wintypes
kernel32 = windll.kernel32
virtdisk = windll.virtdisk
# VirtDisk.dll is available starting from Windows Server 2008 R2 / Windows7
virtdisk = None
class Win32_GUID(ctypes.Structure):
@@ -60,10 +61,17 @@ class VirtualDisk(object):
self._path = path
self._handle = 0
def _load_virtdisk_dll(self):
global virtdisk
if not virtdisk:
virtdisk = windll.virtdisk
def open(self):
if self._handle:
self.close()
self._load_virtdisk_dll()
vst = Win32_VIRTUAL_STORAGE_TYPE()
vst.DeviceId = self.VIRTUAL_STORAGE_TYPE_DEVICE_ISO
vst.VendorId = get_WIN32_VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT()