Render correct driver in nova-compute.conf

Commit abe5a289 fixed the rendering of the ironic driver in the
nova-compute.conf file for OpenStack versions >= Wallaby. However, it
always renders the nova-compute.conf file for train and above, which is
hard-coded to the Ironic libvirt driver.

This adds additional templating logic to the nova-compute.conf driver in
order to render the correct driver to use.

Related-Bug: #1968547
Change-Id: I12cd4bf5953170d227d52793764c49f3871e25f9
This commit is contained in:
Billy Olsen 2022-04-19 20:00:02 -07:00
parent 1655b04178
commit f6c536baec
2 changed files with 12 additions and 2 deletions

View File

@ -1,2 +1,10 @@
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
###############################################################################
[DEFAULT]
compute_driver=ironic.IronicDriver
{% if virt_type == "ironic" -%}
compute_driver=ironic.IronicDriver
{% else -%}
compute_driver=libvirt.LibvirtDriver
{% endif -%}

View File

@ -658,16 +658,18 @@ class NovaComputeUtilsTests(CharmTestCase):
rendered_config.read_string(content)
return rendered_config
@patch.object(compute_context, 'config')
@patch.object(compute_context, 'relation_ids')
@patch.object(compute_context, 'os_release')
@patch.object(utils, 'nova_metadata_requirement')
def test_resource_map_ironic_train(self, _metadata, _os_release,
_relation_ids):
_relation_ids, cctxt_config):
_metadata.return_value = (True, None)
self.relation_ids.return_value = []
self.os_release.return_value = 'train'
_os_release.return_value = 'train'
self.test_config.set('virt-type', 'ironic')
cctxt_config.side_effect = self.test_config.get
result = utils.resource_map()
self.assertTrue(utils.NOVA_COMPUTE_CONF in result)
self.assertFalse(utils.QEMU_CONF in result)