[bfv] Set the correct iqn for pxe

Set the initiator iqn to the connecting node not the target.

Closes-Bug: #1724275
Change-Id: Ife5570c2eebeded360ace8d37c699726b2661d44
This commit is contained in:
Derek Higgins 2017-10-17 16:02:20 +01:00
parent 9d9022f297
commit 217b3f84ac
3 changed files with 31 additions and 4 deletions

View File

@ -297,10 +297,14 @@ def _get_volume_pxe_options(task):
pxe_options['username'] = properties['auth_username']
if 'auth_password' in properties:
pxe_options['password'] = properties['auth_password']
iscsi_initiator_iqn = None
for vc in task.volume_connectors:
if vc.type == 'iqn':
iscsi_initiator_iqn = vc.connector_id
pxe_options.update(
{'iscsi_boot_url': __generate_iscsi_url(volume.properties),
'iscsi_initiator_iqn': (__get_property(properties,
'target_iqn') or None)})
'iscsi_initiator_iqn': iscsi_initiator_iqn})
# NOTE(TheJulia): This may be the route to multi-path, define
# volumes via sanhook in the ipxe template and let the OS sort it out.
additional_targets = []

View File

@ -378,7 +378,7 @@ class PXEPrivateMethodsTestCase(db_base.DbTestCase):
expected_options.update({
'boot_from_volume': True,
'iscsi_boot_url': 'iscsi:fake_host::3260:0:fake_iqn',
'iscsi_initiator_iqn': 'fake_iqn',
'iscsi_initiator_iqn': 'fake_iqn_initiator',
'iscsi_volumes': ['iscsi:fake_host::3260:1:fake_iqn'],
'username': 'fake_username',
'password': 'fake_password'})
@ -419,6 +419,12 @@ class PXEPrivateMethodsTestCase(db_base.DbTestCase):
def test__build_pxe_config_options_ipxe_and_iscsi_boot(self):
vol_id = uuidutils.generate_uuid()
vol_id2 = uuidutils.generate_uuid()
obj_utils.create_test_volume_connector(
self.context,
uuid=uuidutils.generate_uuid(),
type='iqn',
node_id=self.node.id,
connector_id='fake_iqn_initiator')
obj_utils.create_test_volume_target(
self.context, node_id=self.node.id, volume_type='iscsi',
boot_index=0, volume_id='1234', uuid=vol_id,
@ -439,6 +445,12 @@ class PXEPrivateMethodsTestCase(db_base.DbTestCase):
def test__build_pxe_config_options_ipxe_and_iscsi_boot_from_lists(self):
vol_id = uuidutils.generate_uuid()
vol_id2 = uuidutils.generate_uuid()
obj_utils.create_test_volume_connector(
self.context,
uuid=uuidutils.generate_uuid(),
type='iqn',
node_id=self.node.id,
connector_id='fake_iqn_initiator')
obj_utils.create_test_volume_target(
self.context, node_id=self.node.id, volume_type='iscsi',
boot_index=0, volume_id='1234', uuid=vol_id,
@ -460,6 +472,12 @@ class PXEPrivateMethodsTestCase(db_base.DbTestCase):
def test__get_volume_pxe_options(self):
vol_id = uuidutils.generate_uuid()
vol_id2 = uuidutils.generate_uuid()
obj_utils.create_test_volume_connector(
self.context,
uuid=uuidutils.generate_uuid(),
type='iqn',
node_id=self.node.id,
connector_id='fake_iqn_initiator')
obj_utils.create_test_volume_target(
self.context, node_id=self.node.id, volume_type='iscsi',
boot_index=0, volume_id='1234', uuid=vol_id,
@ -483,7 +501,7 @@ class PXEPrivateMethodsTestCase(db_base.DbTestCase):
expected = {'boot_from_volume': True,
'username': 'fake_username', 'password': 'fake_password',
'iscsi_boot_url': 'iscsi:fake_host::3260:0:fake_iqn',
'iscsi_initiator_iqn': 'fake_iqn',
'iscsi_initiator_iqn': 'fake_iqn_initiator',
'iscsi_volumes': ['iscsi:fake_host::3260:1:fake_iqn']}
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:

View File

@ -0,0 +1,5 @@
---
fixes:
- Fixes a problem when using boot from volume with the pxe boot interface,
now when booting the correct iscsi initiator is used.
`bug 1724275 <https://bugs.launchpad.net/ironic/+bug/1724275>`_