This allows a custom interface driver to use the reference DHCP agent
to provide DHCP service to unbridged TAP interfaces, by overriding the
definition of the property as follows.
@property
def bridged(self):
return False
Partial-Bug: #
1486649
Change-Id: I2c6bbd9df6833a65088173b021790eb23e64616b
'--no-hosts',
'--no-resolv',
'--strict-order',
- '--bind-interfaces',
- '--interface=%s' % self.interface_name,
'--except-interface=lo',
'--pid-file=%s' % pid_file,
'--dhcp-hostsfile=%s' % self.get_conf_file_name('host'),
'--dhcp-leasefile=%s' % self.get_conf_file_name('leases'),
'--dhcp-match=set:ipxe,175',
]
+ if self.device_manager.driver.bridged:
+ cmd += [
+ '--bind-interfaces',
+ '--interface=%s' % self.interface_name,
+ ]
+ else:
+ cmd += [
+ '--bind-dynamic',
+ '--interface=%s' % self.interface_name,
+ '--interface=tap*',
+ '--bridge-interface=%s,tap*' % self.interface_name,
+ ]
possible_leases = 0
for i, subnet in enumerate(self.network.subnets):
def unplug(self, device_name, bridge=None, namespace=None, prefix=None):
"""Unplug the interface."""
+ @property
+ def bridged(self):
+ """Whether the DHCP port is bridged to the VM TAP interfaces.
+
+ When the DHCP port is bridged to the TAP interfaces for the
+ VMs for which it is providing DHCP service - as is the case
+ for most Neutron network implementations - the DHCP server
+ only needs to listen on the DHCP port, and will still receive
+ DHCP requests from all the relevant VMs.
+
+ If the DHCP port is not bridged to the relevant VM TAP
+ interfaces, the DHCP server needs to listen explicitly on
+ those TAP interfaces, and to treat those as aliases of the
+ DHCP port where the IP subnet is defined.
+ """
+ return True
+
class NullDriver(LinuxInterfaceDriver):
def plug_new(self, network_id, port_id, device_name, mac_address,
self.external_process = mock.patch(
'neutron.agent.linux.external_process.ProcessManager').start()
+ self.mock_mgr.return_value.driver.bridged = True
+
class TestDhcpBase(TestBase):
'--no-hosts',
'--no-resolv',
'--strict-order',
- '--bind-interfaces',
- '--interface=tap0',
'--except-interface=lo',
'--pid-file=%s' % expected_pid_file,
'--dhcp-hostsfile=/dhcp/%s/host' % network.id,
'--addn-hosts=/dhcp/%s/addn_hosts' % network.id,
'--dhcp-optsfile=/dhcp/%s/opts' % network.id,
'--dhcp-leasefile=/dhcp/%s/leases' % network.id,
- '--dhcp-match=set:ipxe,175']
+ '--dhcp-match=set:ipxe,175',
+ '--bind-interfaces',
+ '--interface=tap0',
+ ]
seconds = ''
if lease_duration == -1: