Merge "Check all configdrive types if one errors out"
This commit is contained in:
@@ -176,14 +176,20 @@ class WindowsConfigDriveManager(base.BaseConfigDriveManager):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def _get_config_drive_files(self, cd_type, cd_location):
|
def _get_config_drive_files(self, cd_type, cd_location):
|
||||||
get_config_drive = self.config_drive_type_location.get(
|
try:
|
||||||
"{}_{}".format(cd_location, cd_type))
|
get_config_drive = self.config_drive_type_location.get(
|
||||||
if get_config_drive:
|
"{}_{}".format(cd_location, cd_type))
|
||||||
return get_config_drive()
|
if get_config_drive:
|
||||||
else:
|
return get_config_drive()
|
||||||
LOG.debug("Irrelevant type %(type)s in %(location)s location; "
|
else:
|
||||||
"skip",
|
LOG.debug("Irrelevant type %(type)s in %(location)s "
|
||||||
{"type": cd_type, "location": cd_location})
|
"location; skip",
|
||||||
|
{"type": cd_type, "location": cd_location})
|
||||||
|
except Exception as exc:
|
||||||
|
LOG.warning("Config type %(type)s not found in %(loc)s "
|
||||||
|
"location; Error: '%(err)r'",
|
||||||
|
{"type": cd_type, "loc": cd_location, "err": exc})
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_config_drive_files(self, searched_types=None,
|
def get_config_drive_files(self, searched_types=None,
|
||||||
|
|||||||
@@ -394,6 +394,14 @@ class TestWindowsConfigDriveManager(unittest.TestCase):
|
|||||||
self._test__get_config_drive_files(
|
self._test__get_config_drive_files(
|
||||||
"iso", "cdrom", func)
|
"iso", "cdrom", func)
|
||||||
|
|
||||||
|
@mock.patch('cloudbaseinit.metadata.services.osconfigdrive.windows.'
|
||||||
|
'WindowsConfigDriveManager.'
|
||||||
|
'_get_config_drive_from_cdrom_drive')
|
||||||
|
def test__get_config_drive_files_cdrom_iso_failed(self, func):
|
||||||
|
func.side_effect = Exception
|
||||||
|
self._test__get_config_drive_files(
|
||||||
|
"iso", "cdrom", func, found=False)
|
||||||
|
|
||||||
def test__get_config_drive_files_cdrom_vfat(self):
|
def test__get_config_drive_files_cdrom_vfat(self):
|
||||||
self._test__get_config_drive_files(
|
self._test__get_config_drive_files(
|
||||||
"vfat", "cdrom", None)
|
"vfat", "cdrom", None)
|
||||||
|
|||||||
@@ -105,6 +105,19 @@ class TestVfat(unittest.TestCase):
|
|||||||
expected_logging=expected_logging,
|
expected_logging=expected_logging,
|
||||||
expected_response=expected_response)
|
expected_response=expected_response)
|
||||||
|
|
||||||
|
def test_is_vfat_drive_with_wrong_label(self):
|
||||||
|
mock_out = b"Not volu label \r\n"
|
||||||
|
expected_logging = [
|
||||||
|
"Obtained label information for drive %r: %r"
|
||||||
|
% (mock.sentinel.drive, mock_out)
|
||||||
|
]
|
||||||
|
execute_process_value = (mock_out, None, 0)
|
||||||
|
expected_response = False
|
||||||
|
|
||||||
|
self._test_is_vfat_drive(execute_process_value=execute_process_value,
|
||||||
|
expected_logging=expected_logging,
|
||||||
|
expected_response=expected_response)
|
||||||
|
|
||||||
@testutils.ConfPatcher('mtools_path', 'mtools_path')
|
@testutils.ConfPatcher('mtools_path', 'mtools_path')
|
||||||
@mock.patch('os.chdir')
|
@mock.patch('os.chdir')
|
||||||
def test_copy(self, mock_os_chdir):
|
def test_copy(self, mock_os_chdir):
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ def is_vfat_drive(osutils, drive_path):
|
|||||||
LOG.debug("Obtained label information for drive %r: %r", drive_path, out)
|
LOG.debug("Obtained label information for drive %r: %r", drive_path, out)
|
||||||
out = out.decode().strip()
|
out = out.decode().strip()
|
||||||
match = VOLUME_LABEL_REGEX.search(out)
|
match = VOLUME_LABEL_REGEX.search(out)
|
||||||
return match.group(1) in CONFIG_DRIVE_LABELS
|
return match.group(1) in CONFIG_DRIVE_LABELS if match else False
|
||||||
|
|
||||||
|
|
||||||
def copy_from_vfat_drive(osutils, drive_path, target_path):
|
def copy_from_vfat_drive(osutils, drive_path, target_path):
|
||||||
|
|||||||
Reference in New Issue
Block a user