From 3bdedd9f38eab5e94b2d1761d35773d9b88fbd7d Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Thu, 14 May 2020 13:23:25 +0300 Subject: [PATCH] Fix case sensitive path comparisons While Windows paths are case insensitive, a few os-win checks are case sensitive and are addressed by this patch. Change-Id: I60c0d3e12501d7b2f62df8f95a3d3f328de83817 Closes-Bug: #1878588 (cherry picked from commit 94046df43a480e685ec61f24aaac72ea481108b5) --- os_win/utils/compute/vmutils.py | 3 ++- os_win/utils/compute/vmutils10.py | 6 ++++-- os_win/utils/hostutils10.py | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/os_win/utils/compute/vmutils.py b/os_win/utils/compute/vmutils.py index ee32cc9b..b31d6e43 100644 --- a/os_win/utils/compute/vmutils.py +++ b/os_win/utils/compute/vmutils.py @@ -1064,7 +1064,8 @@ class VMUtils(baseutils.BaseUtilsVirt): # need to accept Msvm_DiskDrive object paths for image files as well, # an extra check will be needed, but that may lead to some other # inconsistencies. - is_physical = r'root\virtualization\v2:Msvm_DiskDrive' in drive_path + is_physical = (r'root\virtualization\v2:Msvm_DiskDrive'.lower() in + drive_path.lower()) drive = self._get_mounted_disk_resource_from_path( drive_path, is_physical=is_physical) diff --git a/os_win/utils/compute/vmutils10.py b/os_win/utils/compute/vmutils10.py index 6b9f1a34..21c9aa3d 100644 --- a/os_win/utils/compute/vmutils10.py +++ b/os_win/utils/compute/vmutils10.py @@ -229,7 +229,8 @@ class VMUtils10(vmutils.VMUtils6_3): pattern = re.compile( "^(.*)VEN_%(vendor_id)s&DEV_%(product_id)s&(.*)$" % { - 'vendor_id': vendor_id, 'product_id': product_id}) + 'vendor_id': vendor_id, 'product_id': product_id}, + re.IGNORECASE) for dev in pci_devices: if pattern.match(dev.DeviceID): # NOTE(claudiub): if the given PCI device is already assigned, @@ -260,7 +261,8 @@ class VMUtils10(vmutils.VMUtils6_3): pattern = re.compile( "^(.*)VEN_%(vendor_id)s&DEV_%(product_id)s&(.*)$" % { - 'vendor_id': vendor_id, 'product_id': product_id}) + 'vendor_id': vendor_id, 'product_id': product_id}, + re.IGNORECASE) pci_sds = _wqlutils.get_element_associated_class( self._conn, self._PCI_EXPRESS_SETTING_DATA, diff --git a/os_win/utils/hostutils10.py b/os_win/utils/hostutils10.py index c7626b39..5a9b24cd 100644 --- a/os_win/utils/hostutils10.py +++ b/os_win/utils/hostutils10.py @@ -27,8 +27,8 @@ class HostUtils10(hostutils.HostUtils): _HGS_NAMESPACE = '//%s/Root/Microsoft/Windows/Hgs' - _PCI_VENDOR_ID_REGEX = re.compile('VEN_(.*)&DEV') - _PCI_PRODUCT_ID_REGEX = re.compile('DEV_(.*)&SUBSYS') + _PCI_VENDOR_ID_REGEX = re.compile('VEN_(.*)&DEV', re.IGNORECASE) + _PCI_PRODUCT_ID_REGEX = re.compile('DEV_(.*)&SUBSYS', re.IGNORECASE) _PCI_ADDRESS_REGEX = re.compile(r'\b\d+\b') def __init__(self, host='.'):