Provide more debugging info for obtaining the VFAT drive label

This patch logs whatever mlabel returns. This can help us to debug
situations where the output is actually different that what it is
expected, which can lead to a is_vfat_drive to fail on a real
VFAT Config Drive.

Change-Id: I9fe6c19995b30335aeea2471164434b10626b004
This commit is contained in:
Claudiu Popa 2015-03-27 12:19:55 +02:00
parent 4e7e8ac867
commit df70ae91ca
2 changed files with 13 additions and 4 deletions

View File

@ -67,8 +67,12 @@ class TestVfat(unittest.TestCase):
expected_response=expected_response)
def test_is_vfat_drive_different_label(self):
expected_logging = []
execute_process_value = (b"Volume label is config", None, 0)
mock_out = b"Volume label is config"
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,
@ -76,8 +80,12 @@ class TestVfat(unittest.TestCase):
expected_response=expected_response)
def test_is_vfat_drive_works(self):
expected_logging = []
execute_process_value = (b"Volume label is config-2 \r\n", None, 0)
mock_out = b"Volume label is config-2 \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 = True
self._test_is_vfat_drive(execute_process_value=execute_process_value,

View File

@ -54,6 +54,7 @@ def is_vfat_drive(osutils, drive_path):
LOG.warning("mlabel failed with error %r", err)
return False
LOG.info("Obtained label information for drive %r: %r", drive_path, out)
out = out.decode().strip()
match = VOLUME_LABEL_REGEX.search(out)
return match.group(1) == CONFIG_DRIVE_LABEL