Make search for config drive partition case insensitive

Currently the search for config drive is just done for config-2
in lowercase. If we pass the label with vfat, the label will
be in uppercase by convention. So the comparison will fail, and
this needs to be case insensitive to work.

Change-Id: I1dd196841fc3599333d68459eac606bd3b104b7b
Story: #2003547
Task: #24834
This commit is contained in:
Yolanda Robla 2018-08-24 10:04:15 +02:00
parent 03accb9e49
commit 65b3df1aa8
2 changed files with 17 additions and 1 deletions

View File

@ -693,7 +693,7 @@ def _get_labelled_partition(device_path, label, node_uuid):
for v in shlex.split(device))}
if not dev:
continue
if dev['LABEL'] == label:
if dev['LABEL'].upper() == label.upper():
if found_part:
found_2 = '/dev/%(part)s' % {'part': dev['NAME'].strip()}
found = [found_part, found_2]

View File

@ -909,6 +909,22 @@ class WholeDiskPartitionTestCases(base.IronicLibTestCase):
]
mock_execute.assert_has_calls(execute_calls)
def test_get_partition_present_uppercase(self, mock_execute):
lsblk_output = 'NAME="fake12" LABEL="CONFIG-2"\n'
part_result = '/dev/fake12'
mock_execute.side_effect = [(None, ''), (lsblk_output, '')]
result = disk_utils._get_labelled_partition(self.dev,
self.config_part_label,
self.node_uuid)
self.assertEqual(part_result, result)
execute_calls = [
mock.call('partprobe', self.dev, run_as_root=True, attempts=10),
mock.call('lsblk', '-Po', 'name,label', self.dev,
check_exit_code=[0, 1],
use_standard_locale=True, run_as_root=True)
]
mock_execute.assert_has_calls(execute_calls)
def test_get_partition_absent(self, mock_execute):
mock_execute.side_effect = [(None, ''),
(None, '')]