supress dhcp router opt for subnets with null gw

fixes bug 1045617

This patch supresses the default gateway for subnets without gateway
defined.

Change-Id: I29d84863e51f613d8529153870eb7542d992be0e
This commit is contained in:
Mark McClain
2012-09-05 00:27:27 -04:00
parent aaec26c7db
commit bb68d9c93e
2 changed files with 43 additions and 14 deletions

View File

@@ -95,6 +95,16 @@ class FakeV4SubnetNoDHCP:
dns_nameservers = []
class FakeV4SubnetNoGateway:
id = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'
ip_version = 4
cidr = '192.168.1.0/24'
gateway_ip = None
enable_dhcp = True
host_routes = []
dns_nameservers = []
class FakeV4Network:
id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
subnets = [FakeV4Subnet()]
@@ -119,6 +129,12 @@ class FakeDualNetworkSingleDHCP:
ports = [FakePort1(), FakePort2(), FakePort3()]
class FakeV4NoGatewayNetwork:
id = 'cccccccc-cccc-cccc-cccc-cccccccccccc'
subnets = [FakeV4SubnetNoGateway()]
ports = [FakePort1()]
class TestDhcpBase(unittest.TestCase):
def test_base_abc_error(self):
self.assertRaises(TypeError, dhcp.DhcpBase, None)
@@ -460,6 +476,16 @@ tag:tag0,option:router,192.168.0.1""".lstrip()
self.safe.assert_called_once_with('/foo/opts', expected)
def test_output_opts_file_no_gateway(self):
expected = "tag:tag0,option:router"
with mock.patch.object(dhcp.Dnsmasq, 'get_conf_file_name') as conf_fn:
conf_fn.return_value = '/foo/opts'
dm = dhcp.Dnsmasq(self.conf, FakeV4NoGatewayNetwork())
dm._output_opts_file()
self.safe.assert_called_once_with('/foo/opts', expected)
def test_reload_allocations(self):
exp_host_name = '/dhcp/cccccccc-cccc-cccc-cccc-cccccccccccc/host'
exp_host_data = """