Merge "Allow DHCP_OPT_CLIENT_ID_NUM to be string"

This commit is contained in:
Zuul 2018-06-22 07:23:32 +00:00 committed by Gerrit Code Review
commit 0a00561a46
2 changed files with 24 additions and 2 deletions

View File

@ -737,7 +737,8 @@ class Dnsmasq(DhcpLocalProcess):
if self._get_port_extra_dhcp_opts(port):
for opt in port.extra_dhcp_opts:
if opt.opt_name in (edo_ext.DHCP_OPT_CLIENT_ID,
DHCP_OPT_CLIENT_ID_NUM):
DHCP_OPT_CLIENT_ID_NUM,
str(DHCP_OPT_CLIENT_ID_NUM)):
return opt.opt_value
def _read_hosts_file_leases(self, filename):
@ -1026,7 +1027,8 @@ class Dnsmasq(DhcpLocalProcess):
for ip in port.fixed_ips])
for opt in port.extra_dhcp_opts:
if opt.opt_name in (edo_ext.DHCP_OPT_CLIENT_ID,
DHCP_OPT_CLIENT_ID_NUM):
DHCP_OPT_CLIENT_ID_NUM,
str(DHCP_OPT_CLIENT_ID_NUM)):
continue
opt_ip_version = opt.ip_version
if opt_ip_version in port_ip_versions:

View File

@ -363,6 +363,13 @@ class FakePortWithClientIdNum(object):
opt_value='test_client_id_num')]
class FakePortWithClientIdNumStr(object):
def __init__(self):
self.extra_dhcp_opts = [
DhcpOpt(opt_name=str(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'
@ -638,6 +645,14 @@ class FakeV4NetworkClientIdNum(object):
self.namespace = 'qdhcp-ns'
class FakeV4NetworkClientIdNumStr(object):
def __init__(self):
self.id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
self.subnets = [FakeV4Subnet()]
self.ports = [FakePortWithClientIdNumStr()]
self.namespace = 'qdhcp-ns'
class FakeV6Network(object):
def __init__(self):
self.id = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'
@ -2641,6 +2656,11 @@ class TestDnsmasq(TestBase):
self.assertEqual('test_client_id_num',
dm._get_client_id(FakePortWithClientIdNum()))
def test_client_id_num_str(self):
dm = self._get_dnsmasq(FakeV4NetworkClientIdNumStr())
self.assertEqual('test_client_id_num',
dm._get_client_id(FakePortWithClientIdNumStr()))
class TestDeviceManager(TestConfBase):
def setUp(self):