From f6c536baec29a34b79a13708f2f0b82dd0db0530 Mon Sep 17 00:00:00 2001 From: Billy Olsen Date: Tue, 19 Apr 2022 20:00:02 -0700 Subject: [PATCH] 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 --- templates/train/nova-compute.conf | 10 +++++++++- unit_tests/test_nova_compute_utils.py | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/templates/train/nova-compute.conf b/templates/train/nova-compute.conf index 90942428..4b2d66be 100644 --- a/templates/train/nova-compute.conf +++ b/templates/train/nova-compute.conf @@ -1,2 +1,10 @@ +############################################################################### +# [ WARNING ] +# Configuration file maintained by Juju. Local changes may be overwritten. +############################################################################### [DEFAULT] -compute_driver=ironic.IronicDriver \ No newline at end of file +{% if virt_type == "ironic" -%} +compute_driver=ironic.IronicDriver +{% else -%} +compute_driver=libvirt.LibvirtDriver +{% endif -%} diff --git a/unit_tests/test_nova_compute_utils.py b/unit_tests/test_nova_compute_utils.py index 285cfacc..ba8de4ea 100644 --- a/unit_tests/test_nova_compute_utils.py +++ b/unit_tests/test_nova_compute_utils.py @@ -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)