summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2025-10-29 08:58:35 -0500
committerJohn Estabrook <jestabro@vyos.io>2025-11-05 07:49:39 -0600
commit47cc7ab10b9b6bc6fe21025440687a020bd16e35 (patch)
treede52e6334ae22a475acacb9c6cda62d1055d0e04 /python
parentcc60275ab0db2c45f2ad7387d6a91a96fa9d6337 (diff)
downloadvyos-1x-47cc7ab10b9b6bc6fe21025440687a020bd16e35.tar.gz
vyos-1x-47cc7ab10b9b6bc6fe21025440687a020bd16e35.zip
T7969: expose boolean test value_exists
Diffstat (limited to 'python')
-rw-r--r--python/vyos/configtree.py14
1 files changed, 14 insertions, 0 deletions
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()