diff options
| author | Daniil Baturin <daniil@vyos.io> | 2026-09-17 15:54:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-17 15:54:00 +0100 |
| commit | 03500232bca1e1e2eda017428171faf9b4a3dc27 (patch) | |
| tree | 60ab94d5e11118f0ad8596403c0fd2f9070d239c /python | |
| parent | c91d7eb13252306629243d9699c92e38a5a12a71 (diff) | |
| parent | 9d9f3bf5aa29a7bdd7dd1abfa879eab1647b751a (diff) | |
| download | vyos-1x-03500232bca1e1e2eda017428171faf9b4a3dc27.tar.gz vyos-1x-03500232bca1e1e2eda017428171faf9b4a3dc27.zip | |
Merge pull request #5471 from c-po/smoketest-T9316
smoketest: T9316: do not race the DHCP client when checking VRF membership
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/utils/network.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py index 3a26fe193..e7987c053 100644 --- a/python/vyos/utils/network.py +++ b/python/vyos/utils/network.py @@ -135,6 +135,31 @@ def get_vrf_members(vrf: str) -> list: pass return interfaces +def get_vrf_pids(vrf: str) -> list[tuple[int, str]]: + """ + Get list of processes running inside a given VRF + + "ip vrf pids <vrf>" prints one "<pid> <name>" pair per line: + 44425 dhclient + + :param vrf: str + :return: list of (pid, process_name) tuples + """ + processes = [] + if not interface_exists(vrf): + return processes + try: + output = cmdl(['ip', 'vrf', 'pids', vrf]) + except Exception: + return processes + for line in output.splitlines(): + tmp = line.split(maxsplit=1) + # skip blank lines and any output not of the "<pid> <name>" form + if len(tmp) != 2 or not tmp[0].isdigit(): + continue + processes.append((int(tmp[0]), tmp[1].strip())) + return processes + def get_interface_vrf(interface): """ Returns VRF of given interface """ from vyos.utils.dict import dict_search |
