diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py index e989542f38..2bba1bb84a 100644 --- a/ironic/common/pxe_utils.py +++ b/ironic/common/pxe_utils.py @@ -1083,7 +1083,7 @@ def get_volume_pxe_options(task): else: host = portal 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}) def __generate_iscsi_url(properties): diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py index 6803d27164..14b587e5f2 100644 --- a/ironic/tests/unit/common/test_pxe_utils.py +++ b/ironic/tests/unit/common/test_pxe_utils.py @@ -2428,6 +2428,30 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase): options = pxe_utils.get_volume_pxe_options(task) 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): self._test_build_pxe_config_options_ipxe(mode='rescue') diff --git a/releasenotes/notes/bug-2011053-085a8b5a36bb9b59.yaml b/releasenotes/notes/bug-2011053-085a8b5a36bb9b59.yaml new file mode 100644 index 0000000000..272af20d84 --- /dev/null +++ b/releasenotes/notes/bug-2011053-085a8b5a36bb9b59.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + [`bug 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.