metalsmith_instances module, pass hostname in reserve

The allocation name/hostname is set during the provision step, but it
is also possible to set it during the reserve step, which is done in
this change.

Setting the name during reservation is more correct, and triggers some
extra sanity checks during provision. But it also enables this change[1]
which attempts to reserve the node with the same name as the
allocation.

[1] https://review.opendev.org/c/openstack/ironic/+/845856

Change-Id: I0da4644a955b8e9fbf509c074b939b97c64739cb
This commit is contained in:
Steve Baker 2022-06-15 11:17:41 +12:00
parent cf6b37ab22
commit e6568a02bd
2 changed files with 4 additions and 0 deletions

View File

@ -55,6 +55,7 @@ class TestMetalsmithInstances(unittest.TestCase):
def test_reserve(self):
provisioner = mock.Mock()
instances = [{
'hostname': 'node-1',
'name': 'node',
'candidates': ['other_node'],
'resource_class': 'boxen',
@ -73,6 +74,7 @@ class TestMetalsmithInstances(unittest.TestCase):
result = mi.reserve(provisioner, instances, True)
provisioner.reserve_node.assert_has_calls([
mock.call(
hostname='node-1',
candidates=['other_node', 'node'],
capabilities={'foo': 'bar'},
conductor_group='group',
@ -80,6 +82,7 @@ class TestMetalsmithInstances(unittest.TestCase):
traits=['this', 'that']
),
mock.call(
hostname=None,
candidates=None,
capabilities=None,
conductor_group=None,

View File

@ -268,6 +268,7 @@ def reserve(provisioner, instances, clean_up):
candidates = None
try:
node = provisioner.reserve_node(
hostname=instance.get('hostname'),
resource_class=instance.get('resource_class', 'baremetal'),
capabilities=instance.get('capabilities'),
candidates=candidates,