Browse Source

Pass Domain Name to dhcp options

On subnet create dns_options are passed to OVN.
This patch adds missing domain_name field, which
is needed to support InternalDNS functionality.

Change-Id: I01e95ceb10bd6b4e0d9562c9a2abbefa85cdf1d7
changes/23/660423/4
Maciej Józefczyk 3 years ago
parent
commit
8c9501f6d7
  1. 6
      networking_ovn/common/ovn_client.py
  2. 41
      networking_ovn/tests/functional/test_ovn_db_resources.py
  3. 5
      networking_ovn/tests/functional/test_ovn_db_sync.py

6
networking_ovn/common/ovn_client.py

@ -1524,6 +1524,12 @@ class OVNClient(object):
'mtu': str(mtu),
}
net_dns_domain = network.get('dns_domain', '').rstrip('.')
if net_dns_domain:
# NOTE(mjozefcz): String field should be with quotes,
# otherwise ovn will try to resolve it as variable.
options['domain_name'] = '"%s"' % net_dns_domain
if subnet['gateway_ip']:
options['router'] = subnet['gateway_ip']

41
networking_ovn/tests/functional/test_ovn_db_resources.py

@ -28,6 +28,7 @@ from networking_ovn.tests.functional import base
class TestNBDbResources(base.TestOVNFunctionalBase):
_extension_drivers = ['dns']
def setUp(self):
super(TestNBDbResources, self).setUp()
@ -720,6 +721,46 @@ class TestNBDbResources(base.TestOVNFunctionalBase):
# empty.
self._verify_dhcp_option_row_for_port(p1['id'], {})
def test_dhcp_options_domain_name(self):
"""Test for DHCP_Options domain name option
This test needs dns extension_driver to be enabled.
Test test_dhcp_options* are too complex so this case
has been moved to separated one.
"""
cidr = '10.0.0.0/24'
data = {
'network':
{'name': 'foo',
'dns_domain': 'foo.com.',
'tenant_id': self._tenant_id}}
req = self.new_create_request('networks', data, self.fmt)
res = req.get_response(self.api)
net = self.deserialize(self.fmt, res)['network']
res = self._create_subnet(self.fmt, net['id'], cidr)
subnet = self.deserialize(self.fmt, res)['subnet']
dhcp_mac = self._get_subnet_dhcp_mac(subnet)
p = self._make_port(
self.fmt, net['id'],
fixed_ips=[
{'subnet_id': subnet['id']}])
expected_dhcp_options_rows = {
'cidr': '10.0.0.0/24',
'external_ids': {'subnet_id': subnet['id']},
'options': {'dns_server': '{10.10.10.10}',
'domain_name': '"foo.com"',
'lease_time': '43200',
'mtu': '1450',
'router': '10.0.0.1',
'server_id': '10.0.0.1',
'server_mac': dhcp_mac}}
self._verify_dhcp_option_row_for_port(
p['port']['id'], expected_dhcp_options_rows)
class TestPortSecurity(base.TestOVNFunctionalBase):

5
networking_ovn/tests/functional/test_ovn_db_sync.py

@ -123,6 +123,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
'dns_server': '{10.10.10.10}',
'lease_time': str(12 * 60 * 60),
'mtu': str(n1['network']['mtu']),
'domain_name': '"ovn.test"',
'router': n1_s1['subnet']['gateway_ip']}})
self.expected_dhcp_options_rows.append({
'cidr': '2001:dba::/64',
@ -190,6 +191,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
'mtu': str(n1['network']['mtu']),
'router': n1_s1['subnet']['gateway_ip'],
'tftp_server': '20.0.0.20',
'domain_name': '"ovn.test"',
'dns_server': '8.8.8.8'}})
self.expected_dhcp_options_rows.append({
'cidr': '2001:dba::/64',
@ -259,6 +261,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
'mtu': str(n1['network']['mtu']),
'router': n1_s1['subnet']['gateway_ip'],
'tftp_server': '20.0.0.20',
'domain_name': '"ovn.test"',
'dns_server': '8.8.8.8'}})
self.expected_dhcp_options_rows.append({
'cidr': '2001:dba::/64',
@ -291,6 +294,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
'dns_server': '{10.10.10.10}',
'lease_time': str(12 * 60 * 60),
'mtu': str(n2['network']['mtu']),
'domain_name': '"ovn.test"',
'router': n2_s1['subnet']['gateway_ip']}})
self.expected_dhcp_options_rows.append({
'cidr': '2001:dbd::/64',
@ -318,6 +322,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
'mtu': str(n1['network']['mtu']),
'router': n2_s1['subnet']['gateway_ip'],
'tftp_server': '20.0.0.20',
'domain_name': '"ovn.test"',
'dns_server': '8.8.8.8'}})
self.missed_dhcp_options.extend([
opts['uuid']

Loading…
Cancel
Save