diff options
author | Christian Breunig <christian@breunig.cc> | 2023-11-27 17:47:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-27 17:47:19 +0100 |
commit | e2a29c83dc74864cd72e8ad9d65eeb4e81d82128 (patch) | |
tree | 09b25056d26c1d27194293f0c0f08e4766a783a0 | |
parent | 1d84de7ea6154fc97984195958a5ce6340b2c861 (diff) | |
parent | e0e4823855f1c02312154f802868d9d5038be8d1 (diff) | |
download | vyos-1x-e2a29c83dc74864cd72e8ad9d65eeb4e81d82128.tar.gz vyos-1x-e2a29c83dc74864cd72e8ad9d65eeb4e81d82128.zip |
Merge pull request #2549 from vyos/mergify/bp/sagitta/pr-2546
vyos.utils: T5749: fix get_vrf_members() call to iproute2 (backport #2546)
-rw-r--r-- | python/vyos/utils/network.py | 17 |
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): |