Merge "Omit mode keyword when spawning dnsmasq with some ipv6 subnets"
This commit is contained in:
commit
8e600ec5b1
@ -359,6 +359,7 @@ class Dnsmasq(DhcpLocalProcess):
|
||||
|
||||
possible_leases = 0
|
||||
for i, subnet in enumerate(self.network.subnets):
|
||||
mode = None
|
||||
# if a subnet is specified to have dhcp disabled
|
||||
if not subnet.enable_dhcp:
|
||||
continue
|
||||
@ -373,6 +374,7 @@ class Dnsmasq(DhcpLocalProcess):
|
||||
elif getattr(subnet, 'ipv6_ra_mode', None) is None:
|
||||
# RA mode is not set - do not launch dnsmasq
|
||||
continue
|
||||
|
||||
if self.version >= self.MINIMUM_VERSION:
|
||||
set_tag = 'set:'
|
||||
else:
|
||||
@ -385,9 +387,15 @@ class Dnsmasq(DhcpLocalProcess):
|
||||
else:
|
||||
lease = '%ss' % self.conf.dhcp_lease_duration
|
||||
|
||||
cmd.append('--dhcp-range=%s%s,%s,%s,%s' %
|
||||
(set_tag, self._TAG_PREFIX % i,
|
||||
cidr.network, mode, lease))
|
||||
# mode is optional and is not set - skip it
|
||||
if mode:
|
||||
cmd.append('--dhcp-range=%s%s,%s,%s,%s' %
|
||||
(set_tag, self._TAG_PREFIX % i,
|
||||
cidr.network, mode, lease))
|
||||
else:
|
||||
cmd.append('--dhcp-range=%s%s,%s,%s' %
|
||||
(set_tag, self._TAG_PREFIX % i,
|
||||
cidr.network, lease))
|
||||
|
||||
possible_leases += cidr.size
|
||||
|
||||
|
@ -684,7 +684,8 @@ class TestDhcpLocalProcess(TestBase):
|
||||
|
||||
class TestDnsmasq(TestBase):
|
||||
def _test_spawn(self, extra_options, network=FakeDualNetwork(),
|
||||
max_leases=16777216, lease_duration=86400):
|
||||
max_leases=16777216, lease_duration=86400,
|
||||
has_static=True):
|
||||
def mock_get_conf_file_name(kind, ensure_conf_dir=False):
|
||||
return '/dhcp/%s/%s' % (network.id, kind)
|
||||
|
||||
@ -719,7 +720,11 @@ class TestDnsmasq(TestBase):
|
||||
lease_duration = 'infinite'
|
||||
else:
|
||||
seconds = 's'
|
||||
expected.extend('--dhcp-range=set:tag%d,%s,static,%s%s' %
|
||||
if has_static:
|
||||
prefix = '--dhcp-range=set:tag%d,%s,static,%s%s'
|
||||
else:
|
||||
prefix = '--dhcp-range=set:tag%d,%s,%s%s'
|
||||
expected.extend(prefix %
|
||||
(i, s.cidr.split('/')[0], lease_duration, seconds)
|
||||
for i, s in enumerate(network.subnets))
|
||||
|
||||
@ -765,6 +770,14 @@ class TestDnsmasq(TestBase):
|
||||
self.conf.set_override('dhcp_domain', '')
|
||||
self._test_spawn(['--conf-file='])
|
||||
|
||||
def test_spawn_no_dnsmasq_ipv6_mode(self):
|
||||
network = FakeV6Network()
|
||||
subnet = FakeV6Subnet()
|
||||
subnet.ipv6_ra_mode = True
|
||||
network.subnets = [subnet]
|
||||
self._test_spawn(['--conf-file=', '--domain=openstacklocal'],
|
||||
network, has_static=False)
|
||||
|
||||
def test_spawn_cfg_dns_server(self):
|
||||
self.conf.set_override('dnsmasq_dns_servers', ['8.8.8.8'])
|
||||
self._test_spawn(['--conf-file=',
|
||||
|
Loading…
Reference in New Issue
Block a user