diff options
author | John Estabrook <jestabro@vyos.io> | 2021-08-03 10:30:26 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2021-08-03 10:35:25 -0500 |
commit | 1d8f1f2a8a286aedefbf40451c6fcfd78bd5f723 (patch) | |
tree | 1f39275ae5b98f9bc2986d539bbd91a64ce4d2d4 /python/vyos/configquery.py | |
parent | 7a32e9ee70d6371dc38a5f4acb684c218bb8d4d3 (diff) | |
download | vyos-1x-1d8f1f2a8a286aedefbf40451c6fcfd78bd5f723.tar.gz vyos-1x-1d8f1f2a8a286aedefbf40451c6fcfd78bd5f723.zip |
configquery: T3402: add class using configtree to list tag node values
The class ConfigTreeActiveQuery uses configtree to access tag node
values; note that this will only report saved configuration data.
Diffstat (limited to 'python/vyos/configquery.py')
-rw-r--r-- | python/vyos/configquery.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/python/vyos/configquery.py b/python/vyos/configquery.py index ed7346f1f..0f0bc2f79 100644 --- a/python/vyos/configquery.py +++ b/python/vyos/configquery.py @@ -20,7 +20,7 @@ settings from op mode, and execution of arbitrary op mode commands. from subprocess import STDOUT from vyos.util import popen - +from vyos.configtree import ConfigTree class ConfigQueryError(Exception): pass @@ -70,6 +70,26 @@ class CliShellApiConfigQuery(GenericConfigQuery): raise ConfigQueryError('No values for given path') return out +class ConfigTreeActiveQuery(GenericConfigQuery): + def __init__(self): + super().__init__() + + with open('/config/config.boot') as f: + config_file = f.read() + self.configtree = ConfigTree(config_file) + + def exists(self, path: list): + return self.configtree.exists(path) + + def value(self, path: list): + return self.configtree.return_value(path) + + def values(self, path: list): + return self.configtree.return_values(path) + + def list_nodes(self, path: list): + return self.configtree.list_nodes(path) + class VbashOpRun(GenericOpRun): def __init__(self): super().__init__() |