summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorRuben van Dijk <15885455+RubenNL@users.noreply.github.com>2025-04-03 00:26:52 +0200
committerGitHub <noreply@github.com>2025-04-02 22:26:52 +0000
commitef8ddefce682656a1f1f1155707cfcff67a29c0f (patch)
treee98ba896a701c969a815cb1b181064b0975b5a1a /plugins
parent640519ab2bd3e95840d140a96d278659a9d0850d (diff)
downloadvyos.vyos-ef8ddefce682656a1f1f1155707cfcff67a29c0f.tar.gz
vyos.vyos-ef8ddefce682656a1f1f1155707cfcff67a29c0f.zip
T7284: Allow deletion of firewall description (#406)
* T7284 (Delete firewall description not possible) Added failing tests. * T7284 (Delete firewall description not possible) Functional code. * T7284 (Delete firewall description not possible) Fixed pep8. * T7284 (Delete firewall description not possible) Added changelog. * T7284 (Delete firewall description not possible) Fixed changelog.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py7
-rw-r--r--plugins/module_utils/network/vyos/utils/utils.py10
2 files changed, 12 insertions, 5 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 34dc0ed6..e2a25e32 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
@@ -29,6 +29,7 @@ from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.u
from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import Facts
from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import (
list_diff_want_only,
+ in_target_not_none,
)
from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import get_os_version
@@ -374,11 +375,7 @@ class Firewall_global(ConfigBase):
if key == "name" and self._is_grp_del(h, want, key):
commands.append(cmd + " " + want["name"])
continue
- if not (h and self._in_target(h, key)) and not self._is_grp_del(
- h,
- want,
- key,
- ):
+ if not (h and in_target_not_none(h, key)) and not self._is_grp_del(h, want, "name"):
commands.append(cmd + " " + want["name"] + " " + key)
elif key == "members":
commands.extend(
diff --git a/plugins/module_utils/network/vyos/utils/utils.py b/plugins/module_utils/network/vyos/utils/utils.py
index a6b03c80..4c371962 100644
--- a/plugins/module_utils/network/vyos/utils/utils.py
+++ b/plugins/module_utils/network/vyos/utils/utils.py
@@ -276,3 +276,13 @@ def _in_target(h, key):
:return: True/False.
"""
return True if h and key in h else False
+
+
+def in_target_not_none(h, key):
+ """
+ This function checks whether the target exist,key present in target config, and the value is not None.
+ :param h: target config.
+ :param key: attribute name.
+ :return: True/False.
+ """
+ return True if h and key in h and h[key] is not None else False