Merge "metalsmith_instances module, unprovision by hostname"

This commit is contained in:
Zuul 2022-06-24 00:34:48 +00:00 committed by Gerrit Code Review
commit 3f91201be5
2 changed files with 23 additions and 1 deletions

View File

@ -260,3 +260,24 @@ class TestMetalsmithInstances(unittest.TestCase):
mock.call(1),
mock.call(2)
])
@mock.patch('metalsmith.sources.detect', autospec=True)
@mock.patch('metalsmith.instance_config.CloudInitConfig', autospec=True)
def test_unprovision(self, mock_config, mock_detect):
provisioner = mock.Mock()
instances = [{
'name': 'node-1',
'hostname': 'overcloud-controller-1',
'image': {'href': 'overcloud-full'},
'state': 'absent'
}, {
'name': 'node-2',
'image': {'href': 'overcloud-full'},
'state': 'absent'
}]
self.assertTrue(mi.unprovision(provisioner, instances))
provisioner.unprovision_node.assert_has_calls([
mock.call('overcloud-controller-1'),
mock.call('node-2')
])

View File

@ -375,7 +375,8 @@ def _provision_instance(provisioner, instance, nodes, timeout, wait):
def unprovision(provisioner, instances):
for instance in instances:
provisioner.unprovision_node(instance.get('name'))
provisioner.unprovision_node(instance.get('hostname',
instance.get('name')))
return True