Skip to content

Commit

Permalink
[openwrt] Fix firewall defaults parser
Browse files Browse the repository at this point in the history
The defaults section can be empty, so when parsing UCI to netjson
it is necessary to remove the defaults section if it is empty.
  • Loading branch information
jonathanunderwood committed Feb 9, 2021
1 parent bc7dc88 commit f15cf3c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions netjsonconfig/backends/openwrt/converters/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ def to_netjson_loop(self, block, result, index):

if _type == "defaults":
defaults = self.__netjson_defaults(block)
result["firewall"].setdefault("defaults", {})
result["firewall"]["defaults"].update(defaults)
if defaults: # note: default section can be empty
result["firewall"].setdefault("defaults", {})
result["firewall"]["defaults"].update(defaults)
if _type == "rule":
rule = self.__netjson_rule(block)
result["firewall"].setdefault("rules", [])
Expand Down

0 comments on commit f15cf3c

Please sign in to comment.