Fix iscsi url generate method for ipxe

Boot from volume feature has a ipxe template render step, and it need
to generate iscsi urls for booting the volume. However, it not works. In
the function, lun field should be hexadecimal instead of decimal,
according to SAN URIs description at https://ipxe.org/sanuri. So we
need to fix it.

Closes-Bug: #2055355
Change-Id: I080ca42c9ba05f2a4e0752312b79a32bef825752
Signed-off-by: frankming <chen27508959@outlook.com>
This commit is contained in:
frankming 2024-04-29 17:04:25 +08:00
parent cd117d1ed9
commit dcf059af9e
3 changed files with 33 additions and 1 deletions

View File

@ -1083,7 +1083,7 @@ def get_volume_pxe_options(task):
else: else:
host = portal host = portal
port = '' port = ''
return ("iscsi:%(host)s::%(port)s:%(lun)s:%(iqn)s" % return ("iscsi:%(host)s::%(port)s:%(lun)x:%(iqn)s" %
{'host': host, 'port': port, 'lun': lun, 'iqn': iqn}) {'host': host, 'port': port, 'lun': lun, 'iqn': iqn})
def __generate_iscsi_url(properties): def __generate_iscsi_url(properties):

View File

@ -2428,6 +2428,30 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase):
options = pxe_utils.get_volume_pxe_options(task) options = pxe_utils.get_volume_pxe_options(task)
self.assertEqual([], options['iscsi_volumes']) self.assertEqual([], options['iscsi_volumes'])
def test_get_volume_pxe_options_hexadecimal_lunid(self):
vol_id = uuidutils.generate_uuid()
object_utils.create_test_volume_target(
self.context, node_id=self.node.id, volume_type='iscsi',
boot_index=0, volume_id='1234', uuid=vol_id,
properties={'target_lun': 16,
'target_portal': 'fake_host:3260',
'target_iqns': 'fake_iqn'})
self.node.driver_internal_info.update({'boot_from_volume': vol_id})
driver_internal_info = self.node.driver_internal_info
driver_internal_info['boot_from_volume'] = vol_id
self.node.driver_internal_info = driver_internal_info
self.node.save()
expected = {'boot_from_volume': True,
'iscsi_boot_url': 'iscsi:fake_host::3260:10:fake_iqn',
'iscsi_initiator_iqn': None,
'iscsi_volumes': []
}
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
options = pxe_utils.get_volume_pxe_options(task)
self.assertEqual(expected, options)
def test_build_pxe_config_options_ipxe_rescue(self): def test_build_pxe_config_options_ipxe_rescue(self):
self._test_build_pxe_config_options_ipxe(mode='rescue') self._test_build_pxe_config_options_ipxe(mode='rescue')

View File

@ -0,0 +1,8 @@
---
fixes:
- |
[`bug 2011053 <https://storyboard.openstack.org/#!/story/2011053>`_]
Fix issue with boot from volume feature. Convert lun field from
decimal to hexadecimal when generating iscsi url so that ipxe firmware
could be able to identify the iSCSI SAN URI correctly, according to
SAN URIs description at https://ipxe.org/sanuri.