From 47cc7ab10b9b6bc6fe21025440687a020bd16e35 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 29 Oct 2025 08:58:35 -0500 Subject: T7969: expose boolean test value_exists --- python/vyos/configtree.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'python') diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py index aeeb329c5..21b37e638 100644 --- a/python/vyos/configtree.py +++ b/python/vyos/configtree.py @@ -145,6 +145,10 @@ class ConfigTree(object): self.__exists.argtypes = [c_void_p, c_char_p] self.__exists.restype = c_int + self.__value_exists = self.__lib.value_exists + self.__value_exists.argtypes = [c_void_p, c_char_p, c_char_p] + self.__value_exists.restype = c_int + self.__list_nodes = self.__lib.list_nodes self.__list_nodes.argtypes = [c_void_p, c_char_p] self.__list_nodes.restype = c_char_p @@ -361,6 +365,16 @@ class ConfigTree(object): else: return True + def value_exists(self, path, value): + check_path(path) + path_str = ' '.join(map(str, path)).encode() + + res = self.__value_exists(self.__config, path_str, value) + if res == 0: + return False + else: + return True + def list_nodes(self, path, path_must_exist=True): check_path(path) path_str = ' '.join(map(str, path)).encode() -- cgit v1.2.3