Recognize uppercase vfat disk labels
New mkfs.vfat and fatlabel tools included in the dosfsutils package no longer support creating vfat disks with lowercase labels. They silently default to an all uppercase label eg CONFIG-2 instead of config-2. This change makes cloud-init handle either upper or lower case. Change-Id: Iec927db04b9621b20c9bee2c8d81325d7af80f9b Closes-Bug: #1598783
This commit is contained in:
parent
c77216965d
commit
24365043e3
@ -92,6 +92,19 @@ class TestVfat(unittest.TestCase):
|
||||
expected_logging=expected_logging,
|
||||
expected_response=expected_response)
|
||||
|
||||
def test_is_vfat_drive_works_uppercase(self):
|
||||
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,
|
||||
expected_logging=expected_logging,
|
||||
expected_response=expected_response)
|
||||
|
||||
@testutils.ConfPatcher('mtools_path', 'mtools_path')
|
||||
@mock.patch('os.chdir')
|
||||
def test_copy(self, mock_os_chdir):
|
||||
|
@ -22,7 +22,7 @@ from cloudbaseinit import exception
|
||||
|
||||
|
||||
CONF = cloudbaseinit_conf.CONF
|
||||
CONFIG_DRIVE_LABEL = 'config-2'
|
||||
CONFIG_DRIVE_LABELS = ['config-2', 'CONFIG-2']
|
||||
LOG = oslo_logging.getLogger(__name__)
|
||||
VOLUME_LABEL_REGEX = re.compile("Volume label is (.*?)$")
|
||||
|
||||
@ -50,7 +50,7 @@ def is_vfat_drive(osutils, drive_path):
|
||||
LOG.debug("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
|
||||
return match.group(1) in CONFIG_DRIVE_LABELS
|
||||
|
||||
|
||||
def copy_from_vfat_drive(osutils, drive_path, target_path):
|
||||
|
Loading…
x
Reference in New Issue
Block a user