From f15cf3c5f9593af6a19fa314387ad71fdc2f86d8 Mon Sep 17 00:00:00 2001 From: "Jonathan G. Underwood" Date: Tue, 9 Feb 2021 22:52:26 +0000 Subject: [PATCH] [openwrt] Fix firewall defaults parser The defaults section can be empty, so when parsing UCI to netjson it is necessary to remove the defaults section if it is empty. --- netjsonconfig/backends/openwrt/converters/firewall.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/netjsonconfig/backends/openwrt/converters/firewall.py b/netjsonconfig/backends/openwrt/converters/firewall.py index de0c046ca..514d7629e 100644 --- a/netjsonconfig/backends/openwrt/converters/firewall.py +++ b/netjsonconfig/backends/openwrt/converters/firewall.py @@ -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", [])