summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py10
-rw-r--r--plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py9
-rw-r--r--plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py26
-rw-r--r--plugins/modules/vyos_firewall_global.py18
4 files changed, 57 insertions, 6 deletions
diff --git a/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py b/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py
index 92a0255..baafa89 100644
--- a/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py
+++ b/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py
@@ -45,6 +45,11 @@ class Firewall_globalArgs(object): # pylint: disable=R0903
"address_group": {
"elements": "dict",
"options": {
+ "afi": {
+ "choices": ["ipv4", "ipv6"],
+ "default": "ipv4",
+ "type": "str",
+ },
"description": {"type": "str"},
"members": {
"elements": "dict",
@@ -58,6 +63,11 @@ class Firewall_globalArgs(object): # pylint: disable=R0903
"network_group": {
"elements": "dict",
"options": {
+ "afi": {
+ "choices": ["ipv4", "ipv6"],
+ "default": "ipv4",
+ "type": "str",
+ },
"description": {"type": "str"},
"members": {
"elements": "dict",
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 29da3ec..be8b172 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
@@ -378,8 +378,15 @@ class Firewall_global(ConfigBase):
if w_grp:
for want in w_grp:
- cmd = self._compute_command(key="group", attr=attr, opr=opr)
h = self.search_attrib_in_have(h_grp, want, "name")
+ if "afi" in want and want["afi"] == "ipv6":
+ cmd = self._compute_command(
+ key="group", attr="ipv6-" + attr, opr=opr
+ )
+ else:
+ cmd = self._compute_command(
+ key="group", attr=attr, opr=opr
+ )
for key, val in iteritems(want):
if val:
if (
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 e6e42d7..1b1076c 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
@@ -207,17 +207,24 @@ class Firewall_globalFacts(object):
:return: generated config dictionary.
"""
cfg_dict = {}
- cfg_dict["port_group"] = self.parse_group_lst(conf, "port-group")
- cfg_dict["address_group"] = self.parse_group_lst(conf, "address-group")
- cfg_dict["network_group"] = self.parse_group_lst(conf, "network-group")
+ cfg_dict["port_group"] = self.parse_group_lst(
+ conf, "port-group", False
+ )
+ cfg_dict["address_group"] = self.parse_group_lst(
+ conf, "address-group"
+ ) + self.parse_group_lst(conf, "ipv6-address-group")
+ cfg_dict["network_group"] = self.parse_group_lst(
+ conf, "network-group"
+ ) + self.parse_group_lst(conf, "ipv6-network-group")
return cfg_dict
- def parse_group_lst(self, conf, type):
+ def parse_group_lst(self, conf, type, include_afi=True):
"""
This function fetches the name of group and invoke function to
parse group attributes'.
:param conf: configuration data.
:param type: type of group.
+ :param include_afi: if the afi should be included in the parsed object
:return: generated group list configuration.
"""
g_lst = []
@@ -228,7 +235,16 @@ class Firewall_globalFacts(object):
for gr in set(groups):
gr_regex = r" %s .+$" % gr
cfg = "\n".join(findall(gr_regex, conf, M))
- obj = self.parse_groups(cfg, type, gr)
+ if "ipv6" in type:
+ # fmt: off
+ obj = self.parse_groups(cfg, type[len("ipv6-"):], gr)
+ # fmt: on
+ if include_afi:
+ obj["afi"] = "ipv6"
+ else:
+ obj = self.parse_groups(cfg, type, gr)
+ if include_afi:
+ obj["afi"] = "ipv4"
obj["name"] = gr.strip("'")
if obj:
rules_lst.append(obj)
diff --git a/plugins/modules/vyos_firewall_global.py b/plugins/modules/vyos_firewall_global.py
index 71dc4a6..91d97a9 100644
--- a/plugins/modules/vyos_firewall_global.py
+++ b/plugins/modules/vyos_firewall_global.py
@@ -123,6 +123,15 @@ options:
type: list
elements: dict
suboptions:
+ afi:
+ description:
+ - Specifies IP address type
+ type: str
+ default: ipv4
+ choices:
+ - ipv4
+ - ipv6
+ required: false
name:
description:
- Name of the firewall address group.
@@ -149,6 +158,15 @@ options:
type: list
elements: dict
suboptions:
+ afi:
+ description:
+ - Specifies network address type
+ type: str
+ default: ipv4
+ choices:
+ - ipv4
+ - ipv6
+ required: false
name:
description:
- Name of the firewall network group.