Merge "Use Param DHCP_OPT_CLIENT_ID_NUM"

This commit is contained in:
Zuul 2018-05-19 12:23:36 +00:00 committed by Gerrit Code Review
commit 010959d73e
3 changed files with 35 additions and 2 deletions

View File

@ -61,6 +61,9 @@ DNSMASQ_SERVICE_NAME = 'dnsmasq'
DHCP_RELEASE_TRIES = 3
DHCP_RELEASE_TRIES_SLEEP = 0.3
# this variable will be removed when neutron-lib is updated with this value
DHCP_OPT_CLIENT_ID_NUM = 61
class DictModel(dict):
"""Convert dict into an object that provides attribute access to values."""
@ -733,7 +736,8 @@ class Dnsmasq(DhcpLocalProcess):
def _get_client_id(self, port):
if self._get_port_extra_dhcp_opts(port):
for opt in port.extra_dhcp_opts:
if opt.opt_name == edo_ext.DHCP_OPT_CLIENT_ID:
if opt.opt_name in (edo_ext.DHCP_OPT_CLIENT_ID,
DHCP_OPT_CLIENT_ID_NUM):
return opt.opt_value
def _read_hosts_file_leases(self, filename):
@ -1021,7 +1025,8 @@ class Dnsmasq(DhcpLocalProcess):
[netaddr.IPAddress(ip.ip_address).version
for ip in port.fixed_ips])
for opt in port.extra_dhcp_opts:
if opt.opt_name == edo_ext.DHCP_OPT_CLIENT_ID:
if opt.opt_name in (edo_ext.DHCP_OPT_CLIENT_ID,
DHCP_OPT_CLIENT_ID_NUM):
continue
opt_ip_version = opt.ip_version
if opt_ip_version in port_ip_versions:

View File

@ -356,6 +356,13 @@ class FakePortMultipleAgents2(object):
self.extra_dhcp_opts = []
class FakePortWithClientIdNum(object):
def __init__(self):
self.extra_dhcp_opts = [
DhcpOpt(opt_name=dhcp.DHCP_OPT_CLIENT_ID_NUM,
opt_value='test_client_id_num')]
class FakeV4HostRoute(object):
def __init__(self):
self.destination = '20.0.0.1/24'
@ -623,6 +630,14 @@ class FakeV4NetworkClientId(object):
self.namespace = 'qdhcp-ns'
class FakeV4NetworkClientIdNum(object):
def __init__(self):
self.id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
self.subnets = [FakeV4Subnet()]
self.ports = [FakePortWithClientIdNum()]
self.namespace = 'qdhcp-ns'
class FakeV6Network(object):
def __init__(self):
self.id = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'
@ -2621,6 +2636,11 @@ class TestDnsmasq(TestBase):
self._test__generate_opts_per_subnet_helper(
config, True, network_class=FakeNonLocalSubnets)
def test_client_id_num(self):
dm = self._get_dnsmasq(FakeV4NetworkClientIdNum())
self.assertEqual('test_client_id_num',
dm._get_client_id(FakePortWithClientIdNum()))
class TestDeviceManager(TestConfBase):
def setUp(self):

View File

@ -0,0 +1,8 @@
---
fixes:
- |
For Infiniband support, Ironic needs to send the 'client-id' DHCP option
as a number in order for IP address assignment to work.
This is now supported in Neutron, and can be specified as option number
61 as defined in RFC 4776. For more information see bug
`1770932 <https://bugs.launchpad.net/neutron/+bug/1770932>`_