diff options
author | Daniil Baturin <daniil@vyos.io> | 2022-06-17 09:06:01 -0400 |
---|---|---|
committer | Daniil Baturin <daniil@vyos.io> | 2022-06-17 09:06:01 -0400 |
commit | 651eb5794d22576d90ae8ff2fe0b1aeda92dd581 (patch) | |
tree | d0c327c2a47166f6681152842b0f772938e400f8 /src/op_mode/neighbor.py | |
parent | 53c9b500f085394ddfb92f03b6aae99b4e399460 (diff) | |
download | vyos-1x-651eb5794d22576d90ae8ff2fe0b1aeda92dd581.tar.gz vyos-1x-651eb5794d22576d90ae8ff2fe0b1aeda92dd581.zip |
T2719: handle non-existent interfaces in the neighbor script
Diffstat (limited to 'src/op_mode/neighbor.py')
-rwxr-xr-x | src/op_mode/neighbor.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/op_mode/neighbor.py b/src/op_mode/neighbor.py index b0b52c082..d86a372ac 100755 --- a/src/op_mode/neighbor.py +++ b/src/op_mode/neighbor.py @@ -32,12 +32,17 @@ import typing import vyos.opmode +def interface_exists(interface): + import os + return os.path.exists(f'/sys/class/net/{interface}') def get_raw_data(family, interface=None, state=None): from json import loads from vyos.util import cmd if interface: + if not interface_exists(interface): + raise ValueError(f"Interface '{interface}' does not exist in the system") interface = f"dev {interface}" else: interface = "" |