Support using LABEL as identifier for rootfs
Add possibility to use disk LABEL to identify rootfs uuid for Software RAID deployment Change-Id: I77f36e70ddc539af0190db1c1abe0fb2c66f34b4 Story: 2008303 Task: 41188
This commit is contained in:
parent
f356356486
commit
694ea7425d
ironic_python_agent
releasenotes/notes
@ -61,7 +61,8 @@ def _get_partition(device, uuid):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
_rescan_device(device)
|
_rescan_device(device)
|
||||||
lsblk = utils.execute('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE', device)
|
lsblk = utils.execute(
|
||||||
|
'lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL', device)
|
||||||
report = lsblk[0]
|
report = lsblk[0]
|
||||||
for line in report.split('\n'):
|
for line in report.split('\n'):
|
||||||
part = {}
|
part = {}
|
||||||
@ -84,6 +85,10 @@ def _get_partition(device, uuid):
|
|||||||
LOG.debug("Partition %(uuid)s found on device "
|
LOG.debug("Partition %(uuid)s found on device "
|
||||||
"%(dev)s", {'uuid': uuid, 'dev': device})
|
"%(dev)s", {'uuid': uuid, 'dev': device})
|
||||||
return '/dev/' + part.get('KNAME')
|
return '/dev/' + part.get('KNAME')
|
||||||
|
if part.get('LABEL') == uuid:
|
||||||
|
LOG.debug("Partition %(uuid)s found on device "
|
||||||
|
"%(dev)s", {'uuid': uuid, 'dev': device})
|
||||||
|
return '/dev/' + part.get('KNAME')
|
||||||
else:
|
else:
|
||||||
# NOTE(TheJulia): We may want to consider moving towards using
|
# NOTE(TheJulia): We may want to consider moving towards using
|
||||||
# findfs in the future, if we're comfortable with the execution
|
# findfs in the future, if we're comfortable with the execution
|
||||||
|
@ -1109,7 +1109,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
|
|||||||
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
||||||
delay_on_retry=True),
|
delay_on_retry=True),
|
||||||
mock.call('udevadm', 'settle'),
|
mock.call('udevadm', 'settle'),
|
||||||
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE',
|
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
|
||||||
self.fake_dev)]
|
self.fake_dev)]
|
||||||
mock_execute.assert_has_calls(expected)
|
mock_execute.assert_has_calls(expected)
|
||||||
self.assertFalse(mock_dispatch.called)
|
self.assertFalse(mock_dispatch.called)
|
||||||
@ -1133,7 +1133,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
|
|||||||
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
||||||
delay_on_retry=True),
|
delay_on_retry=True),
|
||||||
mock.call('udevadm', 'settle'),
|
mock.call('udevadm', 'settle'),
|
||||||
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE',
|
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
|
||||||
self.fake_dev)]
|
self.fake_dev)]
|
||||||
mock_execute.assert_has_calls(expected)
|
mock_execute.assert_has_calls(expected)
|
||||||
self.assertFalse(mock_dispatch.called)
|
self.assertFalse(mock_dispatch.called)
|
||||||
@ -1156,7 +1156,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
|
|||||||
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
||||||
delay_on_retry=True),
|
delay_on_retry=True),
|
||||||
mock.call('udevadm', 'settle'),
|
mock.call('udevadm', 'settle'),
|
||||||
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE',
|
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
|
||||||
self.fake_dev),
|
self.fake_dev),
|
||||||
mock.call('findfs', 'UUID=%s' % self.fake_root_uuid),
|
mock.call('findfs', 'UUID=%s' % self.fake_root_uuid),
|
||||||
mock.call('findfs', 'PARTUUID=%s' % self.fake_root_uuid)]
|
mock.call('findfs', 'PARTUUID=%s' % self.fake_root_uuid)]
|
||||||
@ -1176,7 +1176,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
|
|||||||
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
||||||
delay_on_retry=True),
|
delay_on_retry=True),
|
||||||
mock.call('udevadm', 'settle'),
|
mock.call('udevadm', 'settle'),
|
||||||
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE',
|
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
|
||||||
self.fake_dev)]
|
self.fake_dev)]
|
||||||
mock_execute.assert_has_calls(expected)
|
mock_execute.assert_has_calls(expected)
|
||||||
self.assertFalse(mock_dispatch.called)
|
self.assertFalse(mock_dispatch.called)
|
||||||
@ -1187,6 +1187,26 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
|
|||||||
mock_is_md_device.side_effect = [False, False]
|
mock_is_md_device.side_effect = [False, False]
|
||||||
lsblk_output = ('''KNAME="test" UUID="" TYPE="disk"
|
lsblk_output = ('''KNAME="test" UUID="" TYPE="disk"
|
||||||
KNAME="test1" UUID="256a39e3-ca3c-4fb8-9cc2-b32eec441f47" TYPE="part"
|
KNAME="test1" UUID="256a39e3-ca3c-4fb8-9cc2-b32eec441f47" TYPE="part"
|
||||||
|
KNAME="test2" UUID="903e7bf9-8a13-4f7f-811b-25dc16faf6f7" TYPE="part" \
|
||||||
|
LABEL="%s"''' % self.fake_root_uuid)
|
||||||
|
mock_execute.side_effect = (None, None, [lsblk_output])
|
||||||
|
|
||||||
|
root_part = image._get_partition(self.fake_dev, self.fake_root_uuid)
|
||||||
|
self.assertEqual('/dev/test2', root_part)
|
||||||
|
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
||||||
|
delay_on_retry=True),
|
||||||
|
mock.call('udevadm', 'settle'),
|
||||||
|
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
|
||||||
|
self.fake_dev)]
|
||||||
|
mock_execute.assert_has_calls(expected)
|
||||||
|
self.assertFalse(mock_dispatch.called)
|
||||||
|
|
||||||
|
@mock.patch.object(hardware, 'is_md_device', autospec=True)
|
||||||
|
def test__get_partition_label(self, mock_is_md_device, mock_execute,
|
||||||
|
mock_dispatch):
|
||||||
|
mock_is_md_device.side_effect = [False, False]
|
||||||
|
lsblk_output = ('''KNAME="test" UUID="" TYPE="disk"
|
||||||
|
KNAME="test1" UUID="256a39e3-ca3c-4fb8-9cc2-b32eec441f47" TYPE="part"
|
||||||
KNAME="test2" PARTUUID="%s" TYPE="part"''' % self.fake_root_uuid)
|
KNAME="test2" PARTUUID="%s" TYPE="part"''' % self.fake_root_uuid)
|
||||||
mock_execute.side_effect = (None, None, [lsblk_output])
|
mock_execute.side_effect = (None, None, [lsblk_output])
|
||||||
|
|
||||||
@ -1195,7 +1215,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
|
|||||||
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
||||||
delay_on_retry=True),
|
delay_on_retry=True),
|
||||||
mock.call('udevadm', 'settle'),
|
mock.call('udevadm', 'settle'),
|
||||||
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE',
|
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
|
||||||
self.fake_dev)]
|
self.fake_dev)]
|
||||||
mock_execute.assert_has_calls(expected)
|
mock_execute.assert_has_calls(expected)
|
||||||
self.assertFalse(mock_dispatch.called)
|
self.assertFalse(mock_dispatch.called)
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
For Software RAID, the IPA will use partition LABEL along with UUID and PARTUUID
|
||||||
|
passed from the conductor to identify the root partition. The root file system
|
||||||
|
LABEL can be set as value of the ``rootfs_uuid`` image metadata property.
|
Loading…
x
Reference in New Issue
Block a user