diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py | 32 | ||||
-rw-r--r-- | plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py | 6 |
2 files changed, 25 insertions, 13 deletions
diff --git a/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py b/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py index 7e978ff..34dc0ed 100644 --- a/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py +++ b/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py @@ -476,14 +476,23 @@ class Firewall_global(ConfigBase): for key, val in iteritems(w): if val and key != "connection_type": if opr and key in l_set and not (h and self._is_w_same(w, h, key)): - commands.append( - self._form_attr_cmd( - key=attr + " " + w["connection_type"], - attr=key, - val=self._bool_to_str(val), - opr=opr, - ), - ) + if key == "log" and LooseVersion(get_os_version(self._module)) >= LooseVersion("1.4"): + commands.append( + self._form_attr_cmd( + key=attr + " " + w["connection_type"], + attr=key, + opr=opr, + ), + ) + else: + commands.append( + self._form_attr_cmd( + key=attr + " " + w["connection_type"], + attr=key, + val=self._bool_to_str(val), + opr=opr, + ), + ) elif not opr and key in l_set: if not h: commands.append( @@ -645,14 +654,17 @@ class Firewall_global(ConfigBase): cmd = "delete firewall " else: cmd = "set firewall " - if key != "group" and LooseVersion(get_os_version(self._module)) >= LooseVersion("1.4"): + if attr and key != "group" and LooseVersion(get_os_version(self._module)) >= LooseVersion("1.4"): cmd += "global-options " if key: cmd += key.replace("_", "-") + " " if attr: cmd += attr.replace("_", "-") if val and opr: - cmd += " '" + str(val) + "'" + if key == "state_policy" and LooseVersion(get_os_version(self._module)) >= LooseVersion("1.4"): + cmd += "" + else: + cmd += " '" + str(val) + "'" return cmd.strip() def _bool_to_str(self, val): diff --git a/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py b/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py index 97386e9..a46f856 100644 --- a/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py +++ b/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py @@ -111,7 +111,7 @@ class Firewall_globalFacts(object): rr_lst = [] v6_attr = findall( - r"^set firewall (?:global-options )(?:ipv6-src-route|ipv6-receive-redirects) (\S+)", + r"^set firewall (?:global-options )?(?:ipv6-src-route|ipv6-receive-redirects) (\S+)", conf, M, ) @@ -121,7 +121,7 @@ class Firewall_globalFacts(object): rr_lst.append(obj) v4_attr = findall( - r"^set firewall (?:global-options )(?:ip-src-route|receive-redirects|send-redirects) (\S+)", + r"^set firewall (?:global-options )?(?:ip-src-route|receive-redirects|send-redirects) (\S+)", conf, M, ) @@ -174,7 +174,7 @@ class Firewall_globalFacts(object): :return: generated rule list configuration. """ sp_lst = [] - policies = findall(r"^set firewall (?:global-options )state-policy (\S+)", conf, M) + policies = findall(r"^set firewall (?:global-options )?state-policy (\S+)", conf, M) policies = list(set(policies)) # remove redundancies if policies: rules_lst = [] |