diff options
| author | John Estabrook <jestabro@vyos.io> | 2025-09-23 08:29:27 -0500 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2025-09-23 08:29:27 -0500 |
| commit | bb5797b834151aab46909b7a7cb45060687e70f2 (patch) | |
| tree | ea83c1d8013172db112ac9522df6c96ad220db46 /python | |
| parent | 803deabc0d54747aa5ac4a982105a9a971edcb32 (diff) | |
| download | vyos-1x-bb5797b834151aab46909b7a7cb45060687e70f2.tar.gz vyos-1x-bb5797b834151aab46909b7a7cb45060687e70f2.zip | |
T7850: make op_mode_config_dict edit level aware
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/configquery.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/python/vyos/configquery.py b/python/vyos/configquery.py index b661b1a9e..3f385d97b 100644 --- a/python/vyos/configquery.py +++ b/python/vyos/configquery.py @@ -39,6 +39,7 @@ from vyos.xml_ref import is_tag from vyos.base import Warning from vyos.utils.backend import vyconf_backend from vyos.configsource import ConfigSourceVyconfSession +from vyos.utils.list import list_strip config_file = os.path.join(directories['config'], 'config.boot') @@ -199,9 +200,19 @@ def op_mode_config_dict( ): if path is None: path = [] + command = ['/bin/cli-shell-api', '--show-active-only', 'showConfig'] - rc, out = op_mode_run(command + path) + edit_level = os.environ.get('VYATTA_EDIT_LEVEL', '') + if edit_level: + tmp = edit_level.split('/') + edit_path = [el for el in tmp if el] + relative_path = list_strip(path, edit_path) + else: + relative_path = path + + rc, out = op_mode_run(command + relative_path) + if rc == cli_shell_api_err.VYOS_EMPTY_CONFIG: out = '' if rc == cli_shell_api_err.VYOS_INVALID_PATH: |
