summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2018-05-16 02:05:06 +0200
committerDaniil Baturin <daniil@baturin.org>2018-05-16 02:05:06 +0200
commit3666ab2b4ed251718c6db549d273ef676bb77c2c (patch)
treefbeabeb88bab014dc02916fd54eea6028f0f04f1 /src
parent30030cc0cc808b9a1c942e89e8698ee2b522b87f (diff)
downloadvyos-1x-3666ab2b4ed251718c6db549d273ef676bb77c2c.tar.gz
vyos-1x-3666ab2b4ed251718c6db549d273ef676bb77c2c.zip
T643: correct the logic for generating node constraints and add emulation of multiple validation options.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/helpers/validate-value.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/helpers/validate-value.py b/src/helpers/validate-value.py
new file mode 100755
index 000000000..2625663a2
--- /dev/null
+++ b/src/helpers/validate-value.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+
+import re
+import os
+import sys
+import argparse
+
+parser = argparse.ArgumentParser()
+parser.add_argument('--regex', action='append')
+parser.add_argument('--exec', action='append')
+
+args = parser.parse_args()
+
+debug = False
+
+# Multiple arguments work like logical OR
+
+try:
+ for r in args.regex:
+ if re.match(r, args.value):
+ sys.exit(0)
+except Exception as exn:
+ if debug:
+ print(exn)
+ else:
+ pass
+
+try:
+ for cmd in args.exec:
+ if debug:
+ print(cmd)
+ res = os.system(cmd)
+ if res == 0:
+ sys.exit(0)
+except Exception as exn:
+ if debug:
+ print(exn)
+ else:
+ pass
+
+sys.exit(1)