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
This commit is contained in:
Stephen Finucane 2017-07-05 15:29:17 +01:00 committed by Matt Riedemann
parent 97549a2c41
commit 886b0a5d74
7 changed files with 47 additions and 31 deletions

View File

@ -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

View File

@ -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``
"""),
]

View File

@ -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",

View File

@ -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):

View File

@ -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

View File

@ -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'],

View File

@ -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.