summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authoromnom62 <75066712+omnom62@users.noreply.github.com>2025-02-13 09:01:45 +1000
committerGitHub <noreply@github.com>2025-02-13 09:01:45 +1000
commitcfc4c93253d57de953c4cae7acc5f2b2890614ac (patch)
tree5bb2265c6c6f42f49512ec55e98ea47f3a3ab8d8 /plugins
parent8f7cc603d7f6700302f3d34c7ecfd6faa13ef264 (diff)
downloadvyos.vyos-cfc4c93253d57de953c4cae7acc5f2b2890614ac.tar.gz
vyos.vyos-cfc4c93253d57de953c4cae7acc5f2b2890614ac.zip
T7002 fw global integration fix (#379)
* T7002 fw_global integration tests fix init * adding 1.3 structure * v1.3- integration tests for fw_global * fixed integration tests for 1.3 and fw_global * D.R.Y. for firewall_global integration tests * changelog * config-trap is fixed for 1.4 * fw_global log mod fixed * firewall_gobal 1.4 integration and unit tests fixes * firewall_gobal unit tests fix * T7002 firewall_global integration tests fixed * clean-up work things * some updates from PR review * populate_commands for fw_global * D.R.Y fw_global integration tests * linter fw_global * linter * fragments for T7002 updated * linter
Diffstat (limited to 'plugins')
-rw-r--r--plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py32
-rw-r--r--plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py6
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 7e978ff9..34dc0ed6 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 97386e99..a46f8563 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 = []