summaryrefslogtreecommitdiff
path: root/plugins/module_utils
diff options
context:
space:
mode:
authoromnom62 <75066712+omnom62@users.noreply.github.com>2025-03-03 09:10:38 +1000
committerGitHub <noreply@github.com>2025-03-03 09:10:38 +1000
commit41e4b0734ca961d18c0a016a50b3c6e598a10dff (patch)
tree4a8a944a951eec56087dc842f4ab24ac3a77b88e /plugins/module_utils
parent241de488727ba60af9b883ef8ed31571a119b856 (diff)
downloadvyos.vyos-main.tar.gz
vyos.vyos-main.zip
T6829 (area interfaces in OSPFv3 1.3-1.5) re-init (#399)HEADmain
* T6829 re-init * re-init T6829 ospfv3 area interface for 1.3- * changelog * changelog fix * Doc is updated * adding 1.4+ support * ospfv3 area interfaces for 1.4+ * fixed ospfv3 facts and added area interface unit test for 1.4 * ospfv3 clean-up * doc updates
Diffstat (limited to 'plugins/module_utils')
-rw-r--r--plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py6
-rw-r--r--plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py42
-rw-r--r--plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py10
3 files changed, 54 insertions, 4 deletions
diff --git a/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py b/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py
index a59606dd..61704345 100644
--- a/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py
+++ b/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py
@@ -47,6 +47,12 @@ class Ospfv3Args(object): # pylint: disable=R0903
"area_id": {"type": "str"},
"export_list": {"type": "str"},
"import_list": {"type": "str"},
+ "interface": {
+ "aliases": ["interfaces"],
+ "type": "list",
+ "elements": "dict",
+ "options": {"name": {"type": "str"}},
+ },
"range": {
"elements": "dict",
"options": {
diff --git a/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py b/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py
index 25d9a0ea..2538a6f5 100644
--- a/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py
+++ b/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py
@@ -33,6 +33,10 @@ from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils
_in_target,
_is_w_same,
)
+from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.version import (
+ LooseVersion,
+)
+from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import get_os_version
class Ospfv3(ConfigBase):
@@ -264,10 +268,12 @@ class Ospfv3(ConfigBase):
name = {
"redistribute": "route_type",
"range": "address",
+ "interface": "name",
}
leaf_dict = {
"redistribute": ("route_map", "route_type"),
"range": ("address", "advertise", "not_advertise"),
+ "interface": ("name"),
}
leaf = leaf_dict[attr]
w = want.get(attr) or []
@@ -282,14 +288,26 @@ class Ospfv3(ConfigBase):
cmd = self._compute_command(opr=opr)
h_item = search_obj_in_list(w_item[name[attr]], h, name[attr])
if opr and key in leaf and not _is_w_same(w_item, h_item, key):
- if key == "route_type" or (
+ if key in ["route_type", "name"] or (
key == "address"
and "advertise" not in w_item
and "not-advertise" not in w_item
):
if not val:
cmd = cmd.replace("set", "delete")
- commands.append(cmd + attr + " " + str(val))
+ if (
+ LooseVersion(get_os_version(self._module)) >= LooseVersion("1.4")
+ and attr == "interface"
+ ):
+ words = cmd.split()
+ cmd14_list = []
+ for word in words:
+ cmd14_list.append(word)
+ if word == "ospfv3":
+ cmd14_list.append(attr + " " + str(val))
+ commands.append(" ".join(cmd14_list))
+ else:
+ commands.append(cmd + attr + " " + str(val))
elif key in leaf_dict["range"] and key != "address":
commands.append(
cmd + attr + " " + w_item[name[attr]] + " " + key.replace("_", "-"),
@@ -306,8 +324,20 @@ class Ospfv3(ConfigBase):
+ str(val),
)
elif not opr and key in leaf and not _in_target(h_item, key):
- if key in ("route_type", "address"):
- commands.append(cmd + attr + " " + str(val))
+ if key in ("route_type", "address", "name"):
+ if (
+ LooseVersion(get_os_version(self._module)) >= LooseVersion("1.4")
+ and attr == "interface"
+ ):
+ words = cmd.split()
+ cmd14_list = []
+ for word in words:
+ cmd14_list.append(word)
+ if word == "ospfv3":
+ cmd14_list.append(attr + " " + str(val))
+ commands.append(" ".join(cmd14_list))
+ else:
+ commands.append(cmd + attr + " " + str(val))
else:
commands.append(cmd + (attr + " " + w_item[name[attr]] + " " + key))
return commands
@@ -373,6 +403,10 @@ class Ospfv3(ConfigBase):
commands.extend(
self._render_list_dict_param(key, w_area, h_area, cmd, opr),
)
+ elif key == "interface":
+ commands.extend(
+ self._render_list_dict_param(key, w_area, h_area, cmd, opr),
+ )
return commands
def _form_attr_cmd(self, key=None, attr=None, val=None, opr=True):
diff --git a/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py b/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py
index 547ff793..ae67a4b6 100644
--- a/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py
+++ b/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py
@@ -22,6 +22,10 @@ from ansible_collections.ansible.netcommon.plugins.module_utils.network.common i
from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.ospfv3.ospfv3 import (
Ospfv3Args,
)
+from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.version import (
+ LooseVersion,
+)
+from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import get_os_version
class Ospfv3Facts(object):
@@ -100,6 +104,9 @@ class Ospfv3Facts(object):
for item in set(items):
i_regex = r" %s .+$" % item
cfg = "\n".join(findall(i_regex, conf, M))
+ if LooseVersion(get_os_version(self._module)) >= LooseVersion("1.4"):
+ cfg14 = findall(r"(interface .+) area '%s'$" % item, conf, M)
+ cfg += "\n " + item + " " + " ".join(cfg14)
if attrib == "area":
obj = self.parse_area(cfg, item)
else:
@@ -121,6 +128,8 @@ class Ospfv3Facts(object):
rule = self.parse_attrib(conf, "area_id", match=area_id)
r_sub = {"range": self.parse_attrib_list(conf, "range", "address")}
rule.update(r_sub)
+ r_int = {"interface": self.parse_attrib_list(conf, "interface", "name")}
+ rule.update(r_int)
return rule
def parse_attrib(self, conf, param, match=None):
@@ -133,6 +142,7 @@ class Ospfv3Facts(object):
"area_id": ["export_list", "import_list"],
"redistribute": ["route_map"],
"range": ["advertise", "not_advertise"],
+ "interface": ["name"],
"parameters": ["router_id"],
}
cfg_dict = self.parse_attr(conf, param_lst[param], match)