Permalink
Browse files

[OpenWrt] Avoid adding dns and dns_search if proto is none

Avoid adding "dns" and "dns_search" config options for interfaces
that have "proto" set to "none".
  • Loading branch information...
nemesisdesign committed Apr 12, 2016
1 parent 6cf39d2 commit c588e5db396fc3bfafeef6cec9ecd90580e67c8e
Showing with 24 additions and 2 deletions.
  1. +5 −2 netjsonconfig/backends/openwrt/renderers.py
  2. +19 −0 tests/openwrt/test_network.py
@@ -184,8 +184,8 @@ def __get_dns_servers(self, uci, address):
# allow override
if 'dns' in uci:
return uci['dns']
# ignore if using DHCP
if address['proto'] == 'dhcp':
# ignore if using DHCP or if "proto" is none
if address['proto'] in ['dhcp', 'none']:
return None
# general setting
dns = self.config.get('dns_servers', None)
@@ -196,6 +196,9 @@ def __get_dns_search(self, uci, address):
# allow override
if 'dns_search' in uci:
return uci['dns_search']
# ignore if "proto" is none
if address['proto'] == 'none':
return None
# general setting
dns_search = self.config.get('dns_search', None)
if dns_search:
@@ -585,6 +585,25 @@ def test_dns_dhcpv6_ignored(self):
""")
self.assertEqual(o.render(), expected)
def test_dhcp_ignored_proto_none(self):
o = OpenWrt({
"interfaces": [
{
"name": "eth0",
"type": "ethernet",
}
],
"dns_servers": ["10.11.12.13", "8.8.8.8"],
"dns_search": ["netjson.org", "openwisp.org"],
})
expected = self._tabs("""package network
config interface 'eth0'
option ifname 'eth0'
option proto 'none'
""")
self.assertEqual(o.render(), expected)
def test_rules(self):
o = OpenWrt({
"ip_rules": [

0 comments on commit c588e5d

Please sign in to comment.