summaryrefslogtreecommitdiff
path: root/plugins/module_utils/network
diff options
context:
space:
mode:
authorGomathiselviS <gomathiselvi@gmail.com>2022-05-23 12:03:58 -0400
committerGitHub <noreply@github.com>2022-05-23 16:03:58 +0000
commitac9a0c2fd95edc93753b5f4c236991fb3634750a (patch)
tree5d21f11f6c17517dd8d74e78dd87d2843e5d2d02 /plugins/module_utils/network
parent5baf4a4495aebda69d1b2e74d2ff6700b1b70c83 (diff)
downloadvyos-ansible-collection-ac9a0c2fd95edc93753b5f4c236991fb3634750a.tar.gz
vyos-ansible-collection-ac9a0c2fd95edc93753b5f4c236991fb3634750a.zip
Add support for icmpv6 type-name in firewall_rules (#258)
Add support for icmpv6 type-name in firewall_rules Signed-off-by: GomathiselviS gomathiselvi@gmail.com SUMMARY Fixes #257 ISSUE TYPE Feature Pull Request COMPONENT NAME ADDITIONAL INFORMATION Reviewed-by: Sagar Paul <sagpaul@redhat.com>
Diffstat (limited to 'plugins/module_utils/network')
-rw-r--r--plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py b/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py
index 2920878..ca47652 100644
--- a/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py
+++ b/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py
@@ -29,6 +29,7 @@ from ansible.module_utils.six import iteritems
from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import (
list_diff_want_only,
)
+import re
class Firewall_rules(ConfigBase):
@@ -575,10 +576,27 @@ class Firewall_rules(ConfigBase):
and not (h_icmp and self._is_w_same(w[attr], h_icmp, item))
):
if item == "type_name":
+ os_version = self._get_os_version()
+ ver = re.search(
+ "vyos ([\\d\\.]+)-?.*", # noqa: W605
+ os_version,
+ re.IGNORECASE,
+ )
+ if ver.group(1) >= "1.4":
+ param_name = "type-name"
+ else:
+ param_name = "type"
if "ipv6-name" in cmd:
commands.append(
cmd
- + (" " + "icmpv6" + " " + "type" + " " + val)
+ + (
+ " "
+ + "icmpv6"
+ + " "
+ + param_name
+ + " "
+ + val
+ )
)
else:
commands.append(
@@ -1040,3 +1058,11 @@ class Firewall_rules(ConfigBase):
"enable_default_log",
)
return True if key in r_set else False
+
+ def _get_os_version(self):
+ os_version = "1.2"
+ if self._connection:
+ os_version = self._connection.get_device_info()[
+ "network_os_version"
+ ]
+ return os_version