Skip to content

Commit 886b0a5

Browse files
stephenfinmriedem
authored andcommitted
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
1 parent 97549a2 commit 886b0a5

File tree

7 files changed

+47
-31
lines changed

7 files changed

+47
-31
lines changed

nova/api/metadata/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,10 @@ def _check_os_version(self, required, requested):
528528
return self._check_version(required, requested, OPENSTACK_VERSIONS)
529529

530530
def _get_hostname(self):
531-
if CONF.dhcp_domain:
532-
return '.'.join([self.instance.hostname, CONF.dhcp_domain])
531+
# TODO(stephenfin): At some point in the future, we may wish to
532+
# retrieve this information from neutron.
533+
if CONF.api.dhcp_domain:
534+
return '.'.join([self.instance.hostname, CONF.api.dhcp_domain])
533535

534536
return self.instance.hostname
535537

nova/conf/api.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,30 @@
208208
running nova-metadata API service per cell, you should also configure each
209209
Neutron metadata-agent to point to the corresponding nova-metadata API
210210
service.
211+
"""),
212+
cfg.StrOpt("dhcp_domain",
213+
deprecated_group="DEFAULT",
214+
default="novalocal",
215+
help="""
216+
Domain name used to configure FQDN for instances.
217+
218+
This option has two purposes:
219+
220+
#. For *neutron* and *nova-network* users, it is used to configure a
221+
fully-qualified domain name for instance hostnames. If unset, only the
222+
hostname without a domain will be configured.
223+
#. (Deprecated) For *nova-network* users, this option configures the DNS
224+
domains used for the DHCP server. Refer to the ``--domain`` option of the
225+
``dnsmasq`` utility for more information. Like *nova-network* itself, this
226+
purpose is deprecated.
227+
228+
Possible values:
229+
230+
* Any string that is a valid domain name.
231+
232+
Related options:
233+
234+
* ``use_neutron``
211235
"""),
212236
]
213237

nova/conf/network.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -463,24 +463,6 @@
463463
464464
Related options:
465465
466-
* ``use_neutron``
467-
"""),
468-
cfg.StrOpt("dhcp_domain",
469-
default="novalocal",
470-
deprecated_for_removal=True,
471-
deprecated_since='15.0.0',
472-
deprecated_reason="""
473-
nova-network is deprecated, as are any related configuration options.
474-
""",
475-
help="""
476-
This option allows you to specify the domain for the DHCP server.
477-
478-
Possible values:
479-
480-
* Any string that is a valid domain name.
481-
482-
Related options:
483-
484466
* ``use_neutron``
485467
"""),
486468
cfg.StrOpt("l3_lib",

nova/network/linux_net.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,8 @@ def restart_dhcp(context, dev, network_ref, fixedips):
10071007

10081008
# dnsmasq currently gives an error for an empty domain,
10091009
# rather than ignoring. So only specify it if defined.
1010-
if CONF.dhcp_domain:
1011-
cmd.append('--domain=%s' % CONF.dhcp_domain)
1010+
if CONF.api.dhcp_domain:
1011+
cmd.append('--domain=%s' % CONF.api.dhcp_domain)
10121012

10131013
dns_servers = CONF.dns_server
10141014
if CONF.use_network_dns_servers:
@@ -1096,20 +1096,20 @@ def _host_dhcp(fixedip):
10961096
net = _host_dhcp_network(fixedip.virtual_interface_id)
10971097
return '%s,%s.%s,%s,net:%s' % (fixedip.virtual_interface.address,
10981098
hostname,
1099-
CONF.dhcp_domain,
1099+
CONF.api.dhcp_domain,
11001100
fixedip.address,
11011101
net)
11021102
else:
11031103
return '%s,%s.%s,%s' % (fixedip.virtual_interface.address,
11041104
hostname,
1105-
CONF.dhcp_domain,
1105+
CONF.api.dhcp_domain,
11061106
fixedip.address)
11071107

11081108

11091109
def _host_dns(fixedip):
11101110
return '%s\t%s.%s' % (fixedip.address,
11111111
fixedip.instance.hostname,
1112-
CONF.dhcp_domain)
1112+
CONF.api.dhcp_domain)
11131113

11141114

11151115
def _host_dhcp_opts(vif_id=None, gateway=None):

nova/tests/unit/network/test_linux_net.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,10 +734,10 @@ def fake_add_dhcp_mangle_rule(*args, **kwargs):
734734

735735
dev = 'br100'
736736

737-
default_domain = CONF.dhcp_domain
737+
default_domain = CONF.api.dhcp_domain
738738
for domain in ('', default_domain):
739739
executes = []
740-
self.flags(dhcp_domain=domain)
740+
self.flags(dhcp_domain=domain, group='api')
741741
fixedips = self._get_fixedips(network_ref)
742742
linux_net.restart_dhcp(self.context, dev, network_ref, fixedips)
743743
expected = ['env',
@@ -761,8 +761,8 @@ def fake_add_dhcp_mangle_rule(*args, **kwargs):
761761
'--no-hosts',
762762
'--leasefile-ro']
763763

764-
if CONF.dhcp_domain:
765-
expected.append('--domain=%s' % CONF.dhcp_domain)
764+
if CONF.api.dhcp_domain:
765+
expected.append('--domain=%s' % CONF.api.dhcp_domain)
766766

767767
if extra_expected:
768768
expected += extra_expected

nova/tests/unit/test_metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,14 @@ def test_neutron_security_groups(self):
311311
self._test_security_groups()
312312

313313
def test_local_hostname(self):
314-
self.flags(dhcp_domain=None)
314+
self.flags(dhcp_domain=None, group='api')
315315
md = fake_InstanceMetadata(self, self.instance.obj_clone())
316316
data = md.get_ec2_metadata(version='2009-04-04')
317317
self.assertEqual(data['meta-data']['local-hostname'],
318318
self.instance['hostname'])
319319

320320
def test_local_hostname_fqdn(self):
321-
self.flags(dhcp_domain='fakedomain')
321+
self.flags(dhcp_domain='fakedomain', group='api')
322322
md = fake_InstanceMetadata(self, self.instance.obj_clone())
323323
data = md.get_ec2_metadata(version='2009-04-04')
324324
self.assertEqual('%s.fakedomain' % self.instance['hostname'],
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
other:
3+
- |
4+
The ``dhcp_domain`` option has been undeprecated and moved to the ``[api]``
5+
group. It is used by the metadata service to configure fully-qualified
6+
domain names for instances, in addition to its role configuring DHCP
7+
services for *nova-network*. This use case was missed when deprecating the
8+
option initially.

0 commit comments

Comments
 (0)