filename = self.get_conf_file_name('host')
LOG.debug('Building host file: %s', filename)
+ dhcp_enabled_subnet_ids = [s.id for s in self.network.subnets
+ if s.enable_dhcp]
for (port, alloc, hostname, name) in self._iter_hosts():
+ # don't write ip address which belongs to a dhcp disabled subnet.
+ if alloc.subnet_id not in dhcp_enabled_subnet_ids:
+ continue
+
# (dzyu) Check if it is legal ipv6 address, if so, need wrap
# it with '[]' to let dnsmasq to distinguish MAC address from
# IPv6 address.
admin_state_up = False
device_owner = 'foo3'
fixed_ips = [FakeIPAllocation('192.168.0.4',
- 'ffda:3ba5:a17a:4ba3:0216:3eff:fec2:771d')]
+ 'dddddddd-dddd-dddd-dddd-dddddddddddd'),
+ FakeIPAllocation('ffda:3ba5:a17a:4ba3:0216:3eff:fec2:771d',
+ 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee')]
mac_address = '00:16:3E:C2:77:1D'
def __init__(self):
self.safe.assert_has_calls([mock.call(exp_host_name,
exp_host_data)])
+ def test_only_populates_dhcp_enabled_subnet_on_a_network(self):
+ exp_host_name = '/dhcp/cccccccc-cccc-cccc-cccc-cccccccccccc/host'
+ exp_host_data = ('00:00:80:aa:bb:cc,host-192-168-0-2.openstacklocal,'
+ '192.168.0.2\n'
+ '00:00:f3:aa:bb:cc,host-192-168-0-3.openstacklocal,'
+ '192.168.0.3\n'
+ '00:00:0f:aa:bb:cc,host-192-168-0-4.openstacklocal,'
+ '192.168.0.4\n'
+ '00:00:0f:rr:rr:rr,host-192-168-0-1.openstacklocal,'
+ '192.168.0.1\n').lstrip()
+ dm = dhcp.Dnsmasq(self.conf, FakeDualNetworkSingleDHCP(),
+ version=dhcp.Dnsmasq.MINIMUM_VERSION)
+ dm._output_hosts_file()
+ self.safe.assert_has_calls([mock.call(exp_host_name,
+ exp_host_data)])
+
def test_should_enable_metadata_namespaces_disabled_returns_false(self):
self.conf.set_override('use_namespaces', False)
self.assertFalse(dhcp.Dnsmasq.should_enable_metadata(self.conf,