diff options
author | Daniil Baturin <daniil@baturin.org> | 2018-05-16 03:23:20 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2018-05-16 03:23:20 +0200 |
commit | a41145f0179c3f18234d613e41f6c5de9dcf006f (patch) | |
tree | f41ba1b1921f8228c3af8cbc7a6f1feadd30fb5d | |
parent | 2a477e6bfc80cf7994ad0873b80ca36cab06a456 (diff) | |
download | vyos-1x-a41145f0179c3f18234d613e41f6c5de9dcf006f.tar.gz vyos-1x-a41145f0179c3f18234d613e41f6c5de9dcf006f.zip |
T643: correct support for regex validators.
-rwxr-xr-x | scripts/build-command-templates | 4 | ||||
-rwxr-xr-x | src/helpers/validate-value.py | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/scripts/build-command-templates b/scripts/build-command-templates index 415104e65..9f51c00cd 100755 --- a/scripts/build-command-templates +++ b/scripts/build-command-templates @@ -142,13 +142,13 @@ def get_properties(p): if v_argument is None: v_argument = "" - validators.append("{0} {1} \\\'$VAR(@)\\\'".format(v_name, v_argument)) + validators.append("{0} {1}".format(v_name, v_argument)) regex_args = " ".join(map(lambda s: "--regex \\\'{0}\\\'".format(s), regexes)) validator_args = " ".join(map(lambda s: "--exec \\\"{0}\\\"".format(s), validators)) validator_script = '${vyos_libexecdir}/validate-value.py' - validator_string = "exec \"{0} {1} {2}\"; \"{3}\"".format(validator_script, regex_args, validator_args, error_msg) + validator_string = "exec \"{0} {1} {2} --value \\\'$VAR(@)\\\'\"; \"{3}\"".format(validator_script, regex_args, validator_args, error_msg) props["constraint"] = validator_string except Exception as exn: diff --git a/src/helpers/validate-value.py b/src/helpers/validate-value.py index 2625663a2..e49bfb6f4 100755 --- a/src/helpers/validate-value.py +++ b/src/helpers/validate-value.py @@ -8,6 +8,7 @@ import argparse parser = argparse.ArgumentParser() parser.add_argument('--regex', action='append') parser.add_argument('--exec', action='append') +parser.add_argument('--value', action='store') args = parser.parse_args() @@ -27,6 +28,7 @@ except Exception as exn: try: for cmd in args.exec: + cmd = "{0} {1}".format(cmd, args.value) if debug: print(cmd) res = os.system(cmd) |