summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2022-10-20 22:44:22 +0100
committerGitHub <noreply@github.com>2022-10-20 22:44:22 +0100
commitc8dbd6ce6cd466bd7903987e58b885f0e92d1691 (patch)
tree2666d714b496f6616d81188813100c259aeb44fc
parent66fb698a106ed56677fdaaef1a934d0ea7b96561 (diff)
parent40cf5f7c1b8d8ae27b5c404807294f8a2a76842d (diff)
downloadvyos-1x-c8dbd6ce6cd466bd7903987e58b885f0e92d1691.tar.gz
vyos-1x-c8dbd6ce6cd466bd7903987e58b885f0e92d1691.zip
Merge pull request #1608 from jestabro/T4765
T4765: normalize fields only if 'raw' is true; output must be dict
-rw-r--r--python/vyos/opmode.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/python/vyos/opmode.py b/python/vyos/opmode.py
index ac9c0c353..5f9c2c1ce 100644
--- a/python/vyos/opmode.py
+++ b/python/vyos/opmode.py
@@ -185,10 +185,12 @@ def run(module):
# they may return human-formatted output
# or a raw dict that we need to serialize in JSON for printing
res = func(**args)
- res = _normalize_field_names(res)
if not args["raw"]:
return res
else:
+ if not isinstance(res, dict):
+ raise InternalError("'raw' output of 'show_*' command must be a dict")
+ res = _normalize_field_names(res)
from json import dumps
return dumps(res, indent=4)
else: