From 651eb5794d22576d90ae8ff2fe0b1aeda92dd581 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 17 Jun 2022 09:06:01 -0400 Subject: T2719: handle non-existent interfaces in the neighbor script --- src/op_mode/neighbor.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/op_mode') 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 = "" -- cgit v1.2.3