diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-10-31 02:37:54 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-10-31 02:37:54 +0100 |
commit | cd6fc1182e649a72e842567d9aaa6dd39f304e2a (patch) | |
tree | 02909b62bdc5945c90c402d3def901591c5b5314 /src/services/vyos-http-api-server | |
parent | 9805067e9d80ec1676cf2c2039be3136401c9fa3 (diff) | |
parent | c5aefce07b1f505a1796c440801459112ed734d1 (diff) | |
download | vyos-1x-cd6fc1182e649a72e842567d9aaa6dd39f304e2a.tar.gz vyos-1x-cd6fc1182e649a72e842567d9aaa6dd39f304e2a.zip |
Merge branch 'current' of github.com:vyos/vyos-1x into equuleus
* 'current' of github.com:vyos/vyos-1x:
[conf completion]: T1779: Add tunnels to completion
[XML templates] T1772: Changed old hacks to proper regex, according to the fix
Add a function for retrieving config dicts.
snmp: make script extension code more readable
snmp: use proper stat literals on chmod()
snmp: fix verify() indent on script extensions
snmp: fix verify() bail out early order
snmp: T1738: cleanup import statements
T1759: Fixing dependency bug from previous commit
T1773, T1774: add a show config operation with JSON and raw options.
T1759: Merging interface.py into ifconfig.py
Allow list arguments in the vyos.config show_config() function.
Replace the try and wait for segfault approach with explicit inSession check.
T1773: add a script for converting the config to JSON. It also exposes those functions in vyos.configtree
[XML templates] T1772: Add escaping of `\` symbol in `<regex>`
Diffstat (limited to 'src/services/vyos-http-api-server')
-rwxr-xr-x | src/services/vyos-http-api-server | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/services/vyos-http-api-server b/src/services/vyos-http-api-server index 04c44c2be..571ec1258 100755 --- a/src/services/vyos-http-api-server +++ b/src/services/vyos-http-api-server @@ -207,11 +207,21 @@ def get_value(): elif op == 'exists': res = config.exists(path) elif op == 'showConfig': - config_format = 'raw' + config_format = 'json' if 'configFormat' in command: config_format = command['configFormat'] - res = session.show_config(command['path'], format=config_format) + res = session.show_config(path=command['path']) + if config_format == 'json': + config_tree = vyos.configtree.ConfigTree(res) + res = json.loads(config_tree.to_json()) + elif config_format == 'json_ast': + config_tree = vyos.configtree.ConfigTree(res) + res = json.loads(config_tree.to_json_ast()) + elif config_format == 'raw': + pass + else: + return error(400, "\"{0}\" is not a valid config format") else: return error(400, "\"{0}\" is not a valid operation".format(op)) except VyOSError as e: |