From df70ae91cafe1ec161baed7d7786c46932fafcb0 Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Fri, 27 Mar 2015 12:19:55 +0200 Subject: [PATCH] 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 --- cloudbaseinit/tests/utils/windows/test_vfat.py | 16 ++++++++++++---- cloudbaseinit/utils/windows/vfat.py | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cloudbaseinit/tests/utils/windows/test_vfat.py b/cloudbaseinit/tests/utils/windows/test_vfat.py index d0d821fb..ebfd8786 100644 --- a/cloudbaseinit/tests/utils/windows/test_vfat.py +++ b/cloudbaseinit/tests/utils/windows/test_vfat.py @@ -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, diff --git a/cloudbaseinit/utils/windows/vfat.py b/cloudbaseinit/utils/windows/vfat.py index c9fac8d7..69992177 100644 --- a/cloudbaseinit/utils/windows/vfat.py +++ b/cloudbaseinit/utils/windows/vfat.py @@ -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