summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2023-01-11 17:49:34 +0200
committerGitHub <noreply@github.com>2023-01-11 17:49:34 +0200
commitf9a6c00a2550911137457a2b73fd43255f46fcd3 (patch)
treeb5bbf4d216068ed0871d13b2e76b06b29c480c60 /python
parent2b00908524e6c5097ca3452b50288e0ac18a73f5 (diff)
parenta29460d38bb99043b032ef0c5045a37a77084fa0 (diff)
downloadvyos-1x-f9a6c00a2550911137457a2b73fd43255f46fcd3.tar.gz
vyos-1x-f9a6c00a2550911137457a2b73fd43255f46fcd3.zip
Merge pull request #1747 from dmbaturin/op-mode-generate-method
opmode: T4564: add generate to the list of op mode functions
Diffstat (limited to 'python')
-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)