From e6568a02bd30957561b3998fcfe23ec65adde863 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Wed, 15 Jun 2022 11:17:41 +1200 Subject: [PATCH] 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 --- metalsmith/test/test_metalsmith_instances.py | 3 +++ .../ansible_plugins/modules/metalsmith_instances.py | 1 + 2 files changed, 4 insertions(+) diff --git a/metalsmith/test/test_metalsmith_instances.py b/metalsmith/test/test_metalsmith_instances.py index da91b20..7a0578c 100644 --- a/metalsmith/test/test_metalsmith_instances.py +++ b/metalsmith/test/test_metalsmith_instances.py @@ -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, diff --git a/metalsmith_ansible/ansible_plugins/modules/metalsmith_instances.py b/metalsmith_ansible/ansible_plugins/modules/metalsmith_instances.py index 405a080..4aad599 100644 --- a/metalsmith_ansible/ansible_plugins/modules/metalsmith_instances.py +++ b/metalsmith_ansible/ansible_plugins/modules/metalsmith_instances.py @@ -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,