From e769d0d4b504e71ea152a31af28e09dd7bc1e43e Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sun, 12 Nov 2023 10:03:25 +0100 Subject: 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. (cherry picked from commit 7b27a20c8664460482301cc8d7554048f152485e) --- python/vyos/utils/network.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'python/vyos') diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py index 157530cc1..3b5e146e1 100644 --- a/python/vyos/utils/network.py +++ b/python/vyos/utils/network.py @@ -194,6 +194,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 -- cgit v1.2.3