Merge "DHCP: fix regression with DNS nameservers"

This commit is contained in:
Jenkins 2016-02-05 14:02:53 +00:00 committed by Gerrit Code Review
commit 00bbd20091
2 changed files with 19 additions and 1 deletions

View File

@ -874,7 +874,7 @@ class Dnsmasq(DhcpLocalProcess):
for ip_version in (4, 6):
vx_ips = [ip for ip in ips
if netaddr.IPAddress(ip).version == ip_version]
if vx_ips:
if len(vx_ips) > 1:
options.append(
self._format_option(
ip_version, i, 'dns-server',

View File

@ -385,6 +385,14 @@ class FakeV4MultipleAgentsWithoutDnsProvided(object):
namespace = 'qdhcp-ns'
class FakeV4AgentWithoutDnsProvided(object):
id = 'ffffffff-ffff-ffff-ffff-ffffffffffff'
subnets = [FakeV4SubnetMultipleAgentsWithoutDnsProvided()]
ports = [FakePort1(), FakePort2(), FakePort3(), FakeRouterPort(),
FakePortMultipleAgents1()]
namespace = 'qdhcp-ns'
class FakeV4AgentWithManyDnsProvided(object):
id = 'ffffffff-ffff-ffff-ffff-ffffffffffff'
subnets = [FakeV4SubnetAgentWithManyDnsProvided()]
@ -1251,6 +1259,16 @@ class TestDnsmasq(TestBase):
self._test_output_opts_file(expected,
FakeV4MultipleAgentsWithoutDnsProvided())
def test_output_opts_file_agent_dns_provided(self):
expected = ('tag:tag0,option:classless-static-route,'
'169.254.169.254/32,192.168.0.1,0.0.0.0/0,192.168.0.1\n'
'tag:tag0,249,169.254.169.254/32,192.168.0.1,0.0.0.0/0,'
'192.168.0.1\ntag:tag0,option:router,192.168.0.1'
).lstrip()
self._test_output_opts_file(expected,
FakeV4AgentWithoutDnsProvided())
def test_output_opts_file_agent_with_many_dns_provided(self):
expected = ('tag:tag0,'
'option:dns-server,2.2.2.2,9.9.9.9,1.1.1.1,3.3.3.3\n'