Skip to content

Commit 2cbc242

Browse files
committed
[OpenWrt] Fixed autostart when False
1 parent 269c7bf commit 2cbc242

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

netjsonconfig/backends/openwrt/renderers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _get_interfaces(self):
4444
uci_interface = deepcopy(interface)
4545
if network:
4646
del uci_interface['network']
47-
if uci_interface.get('autostart'):
47+
if 'autostart' in uci_interface:
4848
uci_interface['auto'] = interface['autostart']
4949
del uci_interface['autostart']
5050
if uci_interface.get('disabled'):

tests/openwrt/test_network.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,3 +1039,23 @@ def test_igmp(self):
10391039
o.config['interfaces'][0]['igmp_snooping'] = 'wrong'
10401040
with self.assertRaises(ValidationError):
10411041
o.validate()
1042+
1043+
def test_autostart(self):
1044+
o = OpenWrt({
1045+
"interfaces": [
1046+
{
1047+
"name": "eth0",
1048+
"type": "ethernet",
1049+
"autostart": False
1050+
}
1051+
]
1052+
})
1053+
expected = self._tabs("""package network
1054+
1055+
config interface 'eth0'
1056+
option auto '0'
1057+
option ifname 'eth0'
1058+
option proto 'none'
1059+
""")
1060+
self.assertEqual(o.render(), expected)
1061+

0 commit comments

Comments
 (0)