diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index 7e3202b3..f916c183 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -568,6 +568,10 @@ class CloudComputeContext(context.OSContextGenerator): 'neutron_plugin': _neutron_plugin(), 'neutron_url': url, } + # DNS domain is optional + dns_domain = relation_get('dns_domain', **rel) + if dns_domain: + neutron_ctxt['dns_domain'] = dns_domain admin_domain = relation_get('admin_domain_name', **rel) if admin_domain: neutron_ctxt['neutron_admin_domain_name'] = admin_domain @@ -678,6 +682,8 @@ class CloudComputeContext(context.OSContextGenerator): ctxt['auth_host'] = net_manager.get('keystone_host') ctxt['auth_port'] = net_manager.get('auth_port') ctxt['api_version'] = net_manager.get('api_version') + if net_manager.get('dns_domain'): + ctxt['dns_domain'] = net_manager.get('dns_domain') if net_manager.get('neutron_admin_domain_name'): ctxt['admin_domain_name'] = net_manager.get( 'neutron_admin_domain_name') diff --git a/templates/queens/nova.conf b/templates/queens/nova.conf index c0124ab7..43a5f16e 100644 --- a/templates/queens/nova.conf +++ b/templates/queens/nova.conf @@ -25,6 +25,12 @@ default_log_levels = "amqp=WARN, amqplib=WARN, boto=WARN, qpid=WARN, sqlalchemy= transport_url = {{ transport_url }} {% endif %} +{% if dns_domain -%} +# Per LP#1805645, dhcp_domain needs to be configured for nova-metadata-api +# It gets this information from neutron. +dhcp_domain = {{ dns_domain }} +{% endif -%} + {% if arch == 'aarch64' -%} libvirt_use_virtio_for_bridges=False libvirt_disk_prefix=vd diff --git a/templates/rocky/nova.conf b/templates/rocky/nova.conf index d2504779..35ae6ac3 100644 --- a/templates/rocky/nova.conf +++ b/templates/rocky/nova.conf @@ -25,6 +25,12 @@ default_log_levels = "amqp=WARN, amqplib=WARN, boto=WARN, qpid=WARN, sqlalchemy= transport_url = {{ transport_url }} {% endif %} +{% if dns_domain -%} +# Per LP#1805645, dhcp_domain needs to be configured for nova-metadata-api +# It gets this information from neutron. +dhcp_domain = {{ dns_domain }} +{% endif -%} + {% if arch == 'aarch64' -%} libvirt_use_virtio_for_bridges=False libvirt_disk_prefix=vd diff --git a/templates/stein/nova.conf b/templates/stein/nova.conf index ab258373..11a2b552 100644 --- a/templates/stein/nova.conf +++ b/templates/stein/nova.conf @@ -29,6 +29,12 @@ default_log_levels = "amqp=WARN, amqplib=WARN, boto=WARN, qpid=WARN, sqlalchemy= transport_url = {{ transport_url }} {% endif %} +{% if dns_domain -%} +# Per LP#1805645, dhcp_domain needs to be configured for nova-metadata-api +# It gets this information from neutron. +dhcp_domain = {{ dns_domain }} +{% endif -%} + {% if arch == 'aarch64' -%} libvirt_use_virtio_for_bridges=False libvirt_disk_prefix=vd diff --git a/templates/train/nova.conf b/templates/train/nova.conf index 2706d056..717e29b0 100644 --- a/templates/train/nova.conf +++ b/templates/train/nova.conf @@ -32,6 +32,12 @@ default_log_levels = "amqp=WARN, amqplib=WARN, boto=WARN, qpid=WARN, sqlalchemy= transport_url = {{ transport_url }} {% endif %} +{% if dns_domain -%} +# Per LP#1805645, dhcp_domain needs to be configured for nova-metadata-api +# It gets this information from neutron. +dhcp_domain = {{ dns_domain }} +{% endif -%} + {% if arch == 'aarch64' -%} libvirt_use_virtio_for_bridges=False libvirt_disk_prefix=vd diff --git a/unit_tests/test_nova_compute_contexts.py b/unit_tests/test_nova_compute_contexts.py index 99f6a07b..e0d32bcc 100644 --- a/unit_tests/test_nova_compute_contexts.py +++ b/unit_tests/test_nova_compute_contexts.py @@ -239,6 +239,56 @@ class NovaComputeContextTests(CharmTestCase): self._save_flag_file.assert_called_with( path='/etc/nova/nm.conf', data='neutron') + @patch.object(context, '_neutron_plugin') + @patch.object(context, '_neutron_url') + @patch.object(context, '_network_manager') + def test_cloud_compute_neutron_ctxt_dns_domain(self, netman, url, plugin): + self.relation_ids.return_value = 'cloud-compute:0' + self.related_units.return_value = 'nova-cloud-controller/0' + netman.return_value = 'neutron' + plugin.return_value = 'ovs' + url.return_value = 'http://nova-c-c:9696' + NEUTRON_CONTEXT.update({'dns_domain': 'example.tld'}) + self.test_relation.set(NEUTRON_CONTEXT) + cloud_compute = context.CloudComputeContext() + ex_ctxt = { + 'network_manager': 'neutron', + 'network_manager_config': { + 'api_version': '2.0', + 'auth_protocol': 'https', + 'service_protocol': 'http', + 'auth_port': '5000', + 'dns_domain': 'example.tld', + 'keystone_host': 'keystone_host', + 'neutron_admin_auth_url': 'https://keystone_host:5000/v2.0', + 'neutron_admin_password': 'openstack', + 'neutron_admin_tenant_name': 'admin', + 'neutron_admin_username': 'admin', + 'neutron_admin_domain_name': 'admin_domain', + 'neutron_auth_strategy': 'keystone', + 'neutron_plugin': 'ovs', + 'neutron_security_groups': True, + 'neutron_url': 'http://nova-c-c:9696', + 'service_protocol': 'http', + 'service_port': '5000', + }, + 'service_host': 'keystone_host', + 'admin_tenant_name': 'admin', + 'admin_user': 'admin', + 'admin_password': 'openstack', + 'admin_domain_name': 'admin_domain', + 'auth_port': '5000', + 'auth_protocol': 'https', + 'auth_host': 'keystone_host', + 'api_version': '2.0', + 'dns_domain': 'example.tld', + 'service_protocol': 'http', + 'service_port': '5000', + } + self.assertEqual(ex_ctxt, cloud_compute()) + self._save_flag_file.assert_called_with( + path='/etc/nova/nm.conf', data='neutron') + @patch.object(context, '_network_manager') @patch.object(context, '_neutron_plugin') def test_neutron_plugin_context_no_setting(self, plugin, nm):