summaryrefslogtreecommitdiff
path: root/python/vyos/utils
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-11-12 10:03:25 +0100
committerChristian Breunig <christian@breunig.cc>2023-11-12 10:03:25 +0100
commit7b27a20c8664460482301cc8d7554048f152485e (patch)
treec7c8d0b934bf1effc34f5f6bc6c61243b456334f /python/vyos/utils
parent709c578e123bcf258eba1d15842b63eb63413523 (diff)
downloadvyos-1x-7b27a20c8664460482301cc8d7554048f152485e.tar.gz
vyos-1x-7b27a20c8664460482301cc8d7554048f152485e.zip
T5658: add common methods interface_list() and vrf_list() to vyos.utils.network
Reduce amount of duplicated (3 times) code in op-mode scripts for ping, traceroute and mtr.
Diffstat (limited to 'python/vyos/utils')
-rw-r--r--python/vyos/utils/network.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py
index 9354bd495..5d19f256b 100644
--- a/python/vyos/utils/network.py
+++ b/python/vyos/utils/network.py
@@ -197,6 +197,21 @@ def get_all_vrfs():
data[name] = entry
return data
+def interface_list() -> list:
+ """
+ Get list of interfaces in system
+ :rtype: list
+ """
+ return Section.interfaces()
+
+
+def vrf_list() -> list:
+ """
+ Get list of VRFs in system
+ :rtype: list
+ """
+ return list(get_all_vrfs().keys())
+
def mac2eui64(mac, prefix=None):
"""
Convert a MAC address to a EUI64 address or, with prefix provided, a full