Skip to content

Commit

Permalink
[OpenWrt] Fixed empty dns and dns-search bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Mar 22, 2016
1 parent e008ef6 commit c70ab76
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
10 changes: 4 additions & 6 deletions netjsonconfig/backends/openwrt/renderers.py
Expand Up @@ -165,14 +165,12 @@ def _get_ip_rules(self):
def __get_dns_servers(self):
dns = self.config.get('dns_servers', None)
if dns:
dns = ' '.join(dns)
return dns
return ' '.join(dns)

def __get_dns_search(self):
dns = self.config.get('dns_search', None)
if dns:
dns = ' '.join(dns)
return dns
dns_search = self.config.get('dns_search', None)
if dns_search:
return ' '.join(dns_search)

def _get_switches(self):
uci_switches = []
Expand Down
19 changes: 19 additions & 0 deletions tests/openwrt/test_network.py
Expand Up @@ -827,5 +827,24 @@ def test_ula_prefix(self):
config globals 'globals'
option ula_prefix 'fd8e:f40a:6701::/48'
""")
self.assertEqual(o.render(), expected)

def test_empty_dns(self):
o = OpenWrt({
"interfaces": [
{
"name": "eth0",
"type": "ethernet"
}
],
"dns_servers": [],
"dns_search": []
})
expected = self._tabs("""package network
config interface 'eth0'
option ifname 'eth0'
option proto 'none'
""")
self.assertEqual(o.render(), expected)

0 comments on commit c70ab76

Please sign in to comment.