summaryrefslogtreecommitdiff
path: root/python/vyos/utils
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-11-27 11:23:22 +0100
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2023-11-27 14:26:02 +0000
commite0e4823855f1c02312154f802868d9d5038be8d1 (patch)
tree09b25056d26c1d27194293f0c0f08e4766a783a0 /python/vyos/utils
parent1d84de7ea6154fc97984195958a5ce6340b2c861 (diff)
downloadvyos-1x-e0e4823855f1c02312154f802868d9d5038be8d1.tar.gz
vyos-1x-e0e4823855f1c02312154f802868d9d5038be8d1.zip
vyos.utils: T5749: fix get_vrf_members() call to iproute2
The iproute2 master argument is used for both a VRF and a bridge device. Using this in the VRF context would retrieve and report back the wrong interfaces: Old implementation: =================== >>> from vyos.utils.network import get_vrf_members >>> get_vrf_members('br1') ['eth1', 'eth2', 'vxlan1'] >>> get_vrf_members('black') ['br1.3002', 'br1.4000', 'pim6reg10200'] The new implementation: ======================= >>> from vyos.utils.network import get_vrf_members >>> get_vrf_members('br1') [] >>> get_vrf_members('black') ['br1.3002', 'br1.4000', 'pim6reg10200'] (cherry picked from commit e02546655adefe1a6fb3660402e697f872d3ffe7)
Diffstat (limited to 'python/vyos/utils')
-rw-r--r--python/vyos/utils/network.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py
index 4f7021509..7a1eecdfb 100644
--- a/python/vyos/utils/network.py
+++ b/python/vyos/utils/network.py
@@ -55,14 +55,17 @@ def get_vrf_members(vrf: str) -> list:
"""
import json
from vyos.utils.process import cmd
- if not interface_exists(vrf):
- raise ValueError(f'VRF "{vrf}" does not exist!')
- output = cmd(f'ip --json --brief link show master {vrf}')
- answer = json.loads(output)
interfaces = []
- for data in answer:
- if 'ifname' in data:
- interfaces.append(data.get('ifname'))
+ try:
+ if not interface_exists(vrf):
+ raise ValueError(f'VRF "{vrf}" does not exist!')
+ output = cmd(f'ip --json --brief link show vrf {vrf}')
+ answer = json.loads(output)
+ for data in answer:
+ if 'ifname' in data:
+ interfaces.append(data.get('ifname'))
+ except:
+ pass
return interfaces
def get_interface_vrf(interface):