From 886b0a5d748ae1deda3a039734f831d7c0cf0476 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 5 Jul 2017 15:29:17 +0100 Subject: [PATCH] conf: Undeprecate and move the 'dhcp_domain' option The metadata service makes use of the deprecated '[DEFAULT] dhcp_domain' option when providing a hostname to the instance. This is used by cloud-init to configure the hostname in the instance. This use was not captured when the option was initially deprecated. This option is now undeprecated and moved to the '[api]' group to ensure it won't be removed alongside the other nova-network options. Change-Id: I3940ebd1888d8019716e7d4eb6d4a413a37b9b78 Closes-Bug: #1698010 --- nova/api/metadata/base.py | 6 +++-- nova/conf/api.py | 24 +++++++++++++++++++ nova/conf/network.py | 18 -------------- nova/network/linux_net.py | 10 ++++---- nova/tests/unit/network/test_linux_net.py | 8 +++---- nova/tests/unit/test_metadata.py | 4 ++-- ...cate-dhcp_domain-opt-77c9154c5b06e0ff.yaml | 8 +++++++ 7 files changed, 47 insertions(+), 31 deletions(-) create mode 100644 releasenotes/notes/undeprecate-dhcp_domain-opt-77c9154c5b06e0ff.yaml diff --git a/nova/api/metadata/base.py b/nova/api/metadata/base.py index e3e25fe54115..42e76a86b7f6 100644 --- a/nova/api/metadata/base.py +++ b/nova/api/metadata/base.py @@ -528,8 +528,10 @@ class InstanceMetadata(object): return self._check_version(required, requested, OPENSTACK_VERSIONS) def _get_hostname(self): - if CONF.dhcp_domain: - return '.'.join([self.instance.hostname, CONF.dhcp_domain]) + # TODO(stephenfin): At some point in the future, we may wish to + # retrieve this information from neutron. + if CONF.api.dhcp_domain: + return '.'.join([self.instance.hostname, CONF.api.dhcp_domain]) return self.instance.hostname diff --git a/nova/conf/api.py b/nova/conf/api.py index 574370e68e93..a36e9e2f1be3 100644 --- a/nova/conf/api.py +++ b/nova/conf/api.py @@ -208,6 +208,30 @@ cell boundaries, then you can run nova-metadata API service per cell. When running nova-metadata API service per cell, you should also configure each Neutron metadata-agent to point to the corresponding nova-metadata API service. +"""), + cfg.StrOpt("dhcp_domain", + deprecated_group="DEFAULT", + default="novalocal", + help=""" +Domain name used to configure FQDN for instances. + +This option has two purposes: + +#. For *neutron* and *nova-network* users, it is used to configure a + fully-qualified domain name for instance hostnames. If unset, only the + hostname without a domain will be configured. +#. (Deprecated) For *nova-network* users, this option configures the DNS + domains used for the DHCP server. Refer to the ``--domain`` option of the + ``dnsmasq`` utility for more information. Like *nova-network* itself, this + purpose is deprecated. + +Possible values: + +* Any string that is a valid domain name. + +Related options: + +* ``use_neutron`` """), ] diff --git a/nova/conf/network.py b/nova/conf/network.py index 4ab64c1c7baf..5e6323196248 100644 --- a/nova/conf/network.py +++ b/nova/conf/network.py @@ -463,24 +463,6 @@ Possible values: Related options: -* ``use_neutron`` -"""), - cfg.StrOpt("dhcp_domain", - default="novalocal", - deprecated_for_removal=True, - deprecated_since='15.0.0', - deprecated_reason=""" -nova-network is deprecated, as are any related configuration options. -""", - help=""" -This option allows you to specify the domain for the DHCP server. - -Possible values: - -* Any string that is a valid domain name. - -Related options: - * ``use_neutron`` """), cfg.StrOpt("l3_lib", diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index da06724d0b84..9abecc546d3c 100644 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -1007,8 +1007,8 @@ def restart_dhcp(context, dev, network_ref, fixedips): # dnsmasq currently gives an error for an empty domain, # rather than ignoring. So only specify it if defined. - if CONF.dhcp_domain: - cmd.append('--domain=%s' % CONF.dhcp_domain) + if CONF.api.dhcp_domain: + cmd.append('--domain=%s' % CONF.api.dhcp_domain) dns_servers = CONF.dns_server if CONF.use_network_dns_servers: @@ -1096,20 +1096,20 @@ def _host_dhcp(fixedip): net = _host_dhcp_network(fixedip.virtual_interface_id) return '%s,%s.%s,%s,net:%s' % (fixedip.virtual_interface.address, hostname, - CONF.dhcp_domain, + CONF.api.dhcp_domain, fixedip.address, net) else: return '%s,%s.%s,%s' % (fixedip.virtual_interface.address, hostname, - CONF.dhcp_domain, + CONF.api.dhcp_domain, fixedip.address) def _host_dns(fixedip): return '%s\t%s.%s' % (fixedip.address, fixedip.instance.hostname, - CONF.dhcp_domain) + CONF.api.dhcp_domain) def _host_dhcp_opts(vif_id=None, gateway=None): diff --git a/nova/tests/unit/network/test_linux_net.py b/nova/tests/unit/network/test_linux_net.py index d40598487ad3..f184f8ffa9a2 100644 --- a/nova/tests/unit/network/test_linux_net.py +++ b/nova/tests/unit/network/test_linux_net.py @@ -734,10 +734,10 @@ class LinuxNetworkTestCase(test.NoDBTestCase): dev = 'br100' - default_domain = CONF.dhcp_domain + default_domain = CONF.api.dhcp_domain for domain in ('', default_domain): executes = [] - self.flags(dhcp_domain=domain) + self.flags(dhcp_domain=domain, group='api') fixedips = self._get_fixedips(network_ref) linux_net.restart_dhcp(self.context, dev, network_ref, fixedips) expected = ['env', @@ -761,8 +761,8 @@ class LinuxNetworkTestCase(test.NoDBTestCase): '--no-hosts', '--leasefile-ro'] - if CONF.dhcp_domain: - expected.append('--domain=%s' % CONF.dhcp_domain) + if CONF.api.dhcp_domain: + expected.append('--domain=%s' % CONF.api.dhcp_domain) if extra_expected: expected += extra_expected diff --git a/nova/tests/unit/test_metadata.py b/nova/tests/unit/test_metadata.py index d8fe32395601..a1ec39896aa2 100644 --- a/nova/tests/unit/test_metadata.py +++ b/nova/tests/unit/test_metadata.py @@ -311,14 +311,14 @@ class MetadataTestCase(test.TestCase): self._test_security_groups() def test_local_hostname(self): - self.flags(dhcp_domain=None) + self.flags(dhcp_domain=None, group='api') md = fake_InstanceMetadata(self, self.instance.obj_clone()) data = md.get_ec2_metadata(version='2009-04-04') self.assertEqual(data['meta-data']['local-hostname'], self.instance['hostname']) def test_local_hostname_fqdn(self): - self.flags(dhcp_domain='fakedomain') + self.flags(dhcp_domain='fakedomain', group='api') md = fake_InstanceMetadata(self, self.instance.obj_clone()) data = md.get_ec2_metadata(version='2009-04-04') self.assertEqual('%s.fakedomain' % self.instance['hostname'], diff --git a/releasenotes/notes/undeprecate-dhcp_domain-opt-77c9154c5b06e0ff.yaml b/releasenotes/notes/undeprecate-dhcp_domain-opt-77c9154c5b06e0ff.yaml new file mode 100644 index 000000000000..794431fd1caa --- /dev/null +++ b/releasenotes/notes/undeprecate-dhcp_domain-opt-77c9154c5b06e0ff.yaml @@ -0,0 +1,8 @@ +--- +other: + - | + The ``dhcp_domain`` option has been undeprecated and moved to the ``[api]`` + group. It is used by the metadata service to configure fully-qualified + domain names for instances, in addition to its role configuring DHCP + services for *nova-network*. This use case was missed when deprecating the + option initially.