Replaces WMI with Win32 API in host rename

This is necessary to be able to execute the plugin
in the specialize step after Sysprep
This commit is contained in:
Alessandro Pilotti
2013-11-14 22:03:24 +02:00
parent 72c75ed1ba
commit e707754f3d
2 changed files with 47 additions and 14 deletions

View File

@@ -47,16 +47,13 @@ class ConfigDriveManager(object):
def _get_config_drive_cdrom_mount_point(self):
osutils = osutils_factory.OSUtilsFactory().get_os_utils()
conn = wmi.WMI(moniker='//./root/cimv2')
q = conn.query('SELECT Drive FROM Win32_CDROMDrive WHERE '
'MediaLoaded = True')
for r in q:
label = osutils.get_volume_label(r.Drive)
for drive in osutils.get_cdrom_drives():
label = osutils.get_volume_label(drive)
if label == "config-2" and \
os.path.exists(os.path.join(r.Drive,
os.path.exists(os.path.join(drive,
'openstack\\latest\\'
'meta_data.json')):
return r.Drive + "\\"
return drive
return None
def _c_char_array_to_c_ushort(self, buf, offset):