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.

Fixed argument from original backport due to changes that were
introduced later in ironic-lib.

Change-Id: I1dd196841fc3599333d68459eac606bd3b104b7b
Story: #2003547
Task: #24834
(cherry picked from commit 65b3df1aa8)
This commit is contained in:
Yolanda Robla 2018-08-24 10:04:15 +02:00 committed by Julia Kreger
parent b1e08db19c
commit 99b3182e34
2 changed files with 17 additions and 1 deletions

View File

@ -631,7 +631,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

@ -796,6 +796,22 @@ class WholeDiskPartitionTestCases(test_base.BaseTestCase):
]
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),
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, '')]