summaryrefslogtreecommitdiff
path: root/python/vyos/opmode.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/vyos/opmode.py')
-rw-r--r--python/vyos/opmode.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/python/vyos/opmode.py b/python/vyos/opmode.py
index c9827d634..5ff768859 100644
--- a/python/vyos/opmode.py
+++ b/python/vyos/opmode.py
@@ -16,6 +16,7 @@
import re
import sys
import typing
+from humps import decamelize
class Error(Exception):
@@ -44,6 +45,18 @@ class PermissionDenied(Error):
"""
pass
+class IncorrectValue(Error):
+ """ Requested operation is valid, but an argument provided has an
+ incorrect value, preventing successful completion.
+ """
+ pass
+
+class CommitInProgress(Error):
+ """ Requested operation is valid, but not possible at the time due
+ to a commit being in progress.
+ """
+ pass
+
class InternalError(Error):
""" Any situation when VyOS detects that it could not perform
an operation correctly due to logic errors in its own code
@@ -101,6 +114,10 @@ def _get_arg_type(t):
return t
def _normalize_field_name(name):
+ # Convert the name to string if it is not
+ # (in some cases they may be numbers)
+ name = str(name)
+
# Replace all separators with underscores
name = re.sub(r'(\s|[\(\)\[\]\{\}\-\.\,:\"\'\`])+', '_', name)
@@ -196,6 +213,7 @@ def run(module):
if not args["raw"]:
return res
else:
+ res = decamelize(res)
res = _normalize_field_names(res)
from json import dumps
return dumps(res, indent=4)