Skip to content

Commit

Permalink
[OpenWrt] Fixed autostart when False
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Apr 1, 2016
1 parent 269c7bf commit 2cbc242
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion netjsonconfig/backends/openwrt/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _get_interfaces(self):
uci_interface = deepcopy(interface)
if network:
del uci_interface['network']
if uci_interface.get('autostart'):
if 'autostart' in uci_interface:
uci_interface['auto'] = interface['autostart']
del uci_interface['autostart']
if uci_interface.get('disabled'):
Expand Down
20 changes: 20 additions & 0 deletions tests/openwrt/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,3 +1039,23 @@ def test_igmp(self):
o.config['interfaces'][0]['igmp_snooping'] = 'wrong'
with self.assertRaises(ValidationError):
o.validate()

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

0 comments on commit 2cbc242

Please sign in to comment.