From 6e621e42f463d8643b504916a1cc7c967f5bd6f1 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Wed, 12 Jul 2023 21:05:12 +0200 Subject: bgp: T5338: simplify XML and code handling --- python/vyos/utils/__init__.py | 1 + python/vyos/utils/network.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'python/vyos') diff --git a/python/vyos/utils/__init__.py b/python/vyos/utils/__init__.py index 0d3998053..5c7a9ecb8 100644 --- a/python/vyos/utils/__init__.py +++ b/python/vyos/utils/__init__.py @@ -14,3 +14,4 @@ # License along with this library. If not, see . from vyos.utils import network +from vyos.utils import boot diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py index 7386d44f0..209bc9ecc 100644 --- a/python/vyos/utils/network.py +++ b/python/vyos/utils/network.py @@ -13,8 +13,6 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see . -import os - def get_protocol_by_name(protocol_name): """Get protocol number by protocol name @@ -34,3 +32,12 @@ def interface_exists_in_netns(interface_name, netns): if rc == 0: return True return False + +def get_interface_vrf(interface): + """ Returns VRF of given interface """ + from vyos.util import dict_search + from vyos.util import get_interface_config + tmp = get_interface_config(interface) + if dict_search('linkinfo.info_slave_kind', tmp) == 'vrf': + return tmp['master'] + return 'default' -- cgit v1.2.3