From 5138216f1e6e53cdeba69b28549a90278159bfaf Mon Sep 17 00:00:00 2001
From: Wieger Bontekoe <wieger.bontekoe@gmail.com>
Date: Fri, 19 May 2023 15:58:22 +0200
Subject: Facts nw interfaces (#318)

* Update l3_interfaces.py

Fix for issue:
https://github.com/ansible-collections/vyos.vyos/issues/295

* Added Changelog Fragment

* Add support for Tunnel, Bridge and Dummy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kate Case <kcase@redhat.com>
---
 changelogs/fragments/l3_interfaces-support.yaml                     | 3 +++
 galaxy.yml                                                          | 2 +-
 plugins/module_utils/network/vyos/facts/interfaces/interfaces.py    | 2 +-
 .../module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py  | 2 +-
 plugins/module_utils/network/vyos/utils/utils.py                    | 6 ++++++
 5 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 changelogs/fragments/l3_interfaces-support.yaml

diff --git a/changelogs/fragments/l3_interfaces-support.yaml b/changelogs/fragments/l3_interfaces-support.yaml
new file mode 100644
index 00000000..41bcd07b
--- /dev/null
+++ b/changelogs/fragments/l3_interfaces-support.yaml
@@ -0,0 +1,3 @@
+---
+minor_changes:
+  - vyos-l3_interface_support - Add support for Tunnel, Bridge and Dummy interfaces. (https://github.com/ansible-collections/vyos.vyos/issues/265)
diff --git a/galaxy.yml b/galaxy.yml
index fb02e073..d2d6ce3d 100644
--- a/galaxy.yml
+++ b/galaxy.yml
@@ -11,4 +11,4 @@ readme: README.md
 repository: https://github.com/ansible-collections/vyos.vyos
 issues: https://github.com/ansible-collections/vyos.vyos/issues
 tags: [vyos, networking]
-version: 4.0.3-dev
+version: 4.1.0-dev
diff --git a/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py b/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py
index 9fd00c1e..51c3a10a 100644
--- a/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py
+++ b/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py
@@ -59,7 +59,7 @@ class InterfacesFacts(object):
 
         objs = []
         interface_names = findall(
-            r"^set interfaces (?:ethernet|bonding|vti|loopback|vxlan|openvpn|wireguard) (?:\'*)(\S+)(?:\'*)",
+            r"^set interfaces (?:ethernet|bonding|bridge|dummy|tunnel|vti|loopback|vxlan|openvpn|wireguard) (?:\'*)(\S+)(?:\'*)",
             data,
             M,
         )
diff --git a/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py
index ebfab030..845d79e7 100644
--- a/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py
+++ b/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py
@@ -60,7 +60,7 @@ class L3_interfacesFacts(object):
         # operate on a collection of resource x
         objs = []
         interface_names = re.findall(
-            r"set interfaces (?:ethernet|bonding|vti|vxlan) (?:\'*)(\S+)(?:\'*)",
+            r"set interfaces (?:ethernet|bonding|bridge|dummy|tunnel|vti|vxlan) (?:\'*)(\S+)(?:\'*)",
             data,
             re.M,
         )
diff --git a/plugins/module_utils/network/vyos/utils/utils.py b/plugins/module_utils/network/vyos/utils/utils.py
index 4d447448..d2ca7038 100644
--- a/plugins/module_utils/network/vyos/utils/utils.py
+++ b/plugins/module_utils/network/vyos/utils/utils.py
@@ -40,6 +40,12 @@ def get_interface_type(interface):
         return "openvpn"
     elif interface.startswith("wg"):
         return "wireguard"
+    elif interface.startswith("tun"):
+        return "tunnel"
+    elif interface.startswith("br"):
+        return "bridge"
+    elif interface.startswith("dum"):
+        return "dummy"
 
 
 def dict_delete(base, comparable):
-- 
cgit v1.2.3