summaryrefslogtreecommitdiff
path: root/python/vyos/opmode.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2023-01-10 17:53:14 +0000
committerDaniil Baturin <daniil@baturin.org>2023-01-10 18:28:57 +0000
commita29460d38bb99043b032ef0c5045a37a77084fa0 (patch)
tree88972d32f49ad5df89a2d7bc0889557cfcf8e1d5 /python/vyos/opmode.py
parent0e5ea5a63ab9db9ae04ab09e3af42a6e8e1c4c55 (diff)
downloadvyos-1x-a29460d38bb99043b032ef0c5045a37a77084fa0.tar.gz
vyos-1x-a29460d38bb99043b032ef0c5045a37a77084fa0.zip
opmode: T4564: add generate to the list of op mode functions
Diffstat (limited to 'python/vyos/opmode.py')
-rw-r--r--python/vyos/opmode.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/python/vyos/opmode.py b/python/vyos/opmode.py
index 19c476b1c..30e893d74 100644
--- a/python/vyos/opmode.py
+++ b/python/vyos/opmode.py
@@ -70,13 +70,13 @@ class InternalError(Error):
def _is_op_mode_function_name(name):
- if re.match(r"^(show|clear|reset|restart|add|delete)", name):
+ if re.match(r"^(show|clear|reset|restart|add|delete|generate)", name):
return True
else:
return False
-def _is_show(name):
- if re.match(r"^show", name):
+def _capture_output(name):
+ if re.match(r"^(show|generate)", name):
return True
else:
return False
@@ -203,14 +203,14 @@ def run(module):
# it would cause an extra argument error when we pass the dict to a function
del args["subcommand"]
- # Show commands must always get the "raw" argument,
- # but other commands (clear/reset/restart) should not,
+ # Show and generate commands must always get the "raw" argument,
+ # but other commands (clear/reset/restart/add/delete) should not,
# because they produce no output and it makes no sense for them.
- if ("raw" not in args) and _is_show(function_name):
+ if ("raw" not in args) and _capture_output(function_name):
args["raw"] = False
- if re.match(r"^show", function_name):
- # Show commands are slightly special:
+ if _capture_output(function_name):
+ # Show and generate commands are slightly special:
# they may return human-formatted output
# or a raw dict that we need to serialize in JSON for printing
res = func(**args)