Take wwn_with_extension into account, when configuring a boot device

Sometimes wwn is not enough to identify a device, and a vendor extension
has to be used. The wwn_with_extension field contains both, as it has
to be tried first.

Change-Id: Idf0ed93c8247d872735a4b49f7a6390c71514430
Closes-Bug: #1720780
(cherry picked from commit c68cf6b10e)
This commit is contained in:
Dmitry Tantsur 2017-10-02 14:23:24 +02:00
parent 63fc99996c
commit cec34e7440
2 changed files with 31 additions and 1 deletions

View File

@ -256,7 +256,7 @@ class ConfigureRootDeviceAction(base.TripleOAction):
{'strategy': strategy, 'node': node.uuid})
hint = None
for hint_name in ('wwn', 'serial'):
for hint_name in ('wwn_with_extension', 'wwn', 'serial'):
if root_device.get(hint_name):
hint = {hint_name: root_device[hint_name]}
break

View File

@ -202,6 +202,21 @@ class TestConfigureRootDeviceAction(base.TestCase):
self.assertEqual(mock.call('ABCDEFGH', expected_patch),
root_device_args)
def test_smallest_with_ext(self):
self.disks[2]['wwn_with_extension'] = 'wwnext'
action = baremetal.ConfigureRootDeviceAction(node_uuid='MOCK_UUID',
root_device='smallest')
action.run(self.context)
self.assertEqual(self.ironic.node.update.call_count, 1)
root_device_args = self.ironic.node.update.call_args_list[0]
expected_patch = [{'op': 'add', 'path': '/properties/root_device',
'value': {'wwn_with_extension': 'wwnext'}},
{'op': 'add', 'path': '/properties/local_gb',
'value': 4}]
self.assertEqual(mock.call('ABCDEFGH', expected_patch),
root_device_args)
def test_largest(self):
action = baremetal.ConfigureRootDeviceAction(node_uuid='MOCK_UUID',
root_device='largest')
@ -216,6 +231,21 @@ class TestConfigureRootDeviceAction(base.TestCase):
self.assertEqual(mock.call('ABCDEFGH', expected_patch),
root_device_args)
def test_largest_with_ext(self):
self.disks[3]['wwn_with_extension'] = 'wwnext'
action = baremetal.ConfigureRootDeviceAction(node_uuid='MOCK_UUID',
root_device='largest')
action.run(self.context)
self.assertEqual(self.ironic.node.update.call_count, 1)
root_device_args = self.ironic.node.update.call_args_list[0]
expected_patch = [{'op': 'add', 'path': '/properties/root_device',
'value': {'wwn_with_extension': 'wwnext'}},
{'op': 'add', 'path': '/properties/local_gb',
'value': 20}]
self.assertEqual(mock.call('ABCDEFGH', expected_patch),
root_device_args)
def test_no_overwrite(self):
self.node.properties['root_device'] = {'foo': 'bar'}