Skip to content

Commit

Permalink
[openwrt] Fixed interface enabled bug #57
Browse files Browse the repository at this point in the history
See #57
  • Loading branch information
nemesifier committed Jan 17, 2017
1 parent 4a63d7f commit 88ef58c
Show file tree
Hide file tree
Showing 2 changed files with 17 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 @@ -80,7 +80,7 @@ def _get_interfaces(self):
if 'autostart' in uci_interface:
uci_interface['auto'] = interface['autostart']
del uci_interface['autostart']
if uci_interface.get('disabled'):
if 'disabled' in uci_interface:
uci_interface['enabled'] = not interface['disabled']
del uci_interface['disabled']
if 'addresses' in uci_interface:
Expand Down
16 changes: 16 additions & 0 deletions tests/openwrt/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,3 +1151,19 @@ def test_macaddr_override(self):
option proto 'none'
""")
self.assertEqual(o.render(), expected)

def test_interface_disabled_bug(self):
"""
see https://github.com/openwisp/netjsonconfig/issues/57
"""
o = OpenWrt({
"interfaces": [
{
"type": "ethernet",
"name": "eth0",
"disabled": False
}
]
})
self.assertNotIn("disabled '0'", o.render())
self.assertIn("enabled '1'", o.render())

0 comments on commit 88ef58c

Please sign in to comment.