Adding ONOS Segment Routing CLI files to new repo
diff --git a/cli/validate/input_files/lint b/cli/validate/input_files/lint
new file mode 100755
index 0000000..8229520
--- /dev/null
+++ b/cli/validate/input_files/lint
@@ -0,0 +1,6 @@
+enable
+config
+internal
+lint
+end
+
diff --git a/cli/validate/input_files/permute b/cli/validate/input_files/permute
new file mode 100755
index 0000000..2745b82
--- /dev/null
+++ b/cli/validate/input_files/permute
@@ -0,0 +1,6 @@
+enable
+config
+internal
+permute
+end
+
diff --git a/cli/validate/input_files/qualify b/cli/validate/input_files/qualify
new file mode 100755
index 0000000..1f4b4c3
--- /dev/null
+++ b/cli/validate/input_files/qualify
@@ -0,0 +1,6 @@
+enable
+config
+internal
+qualify
+end
+
diff --git a/cli/validate/validator.py b/cli/validate/validator.py
new file mode 100755
index 0000000..e3d5597
--- /dev/null
+++ b/cli/validate/validator.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2013 Big Switch Networks, Inc.
+#
+# Licensed under the Eclipse Public License, Version 1.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+import os
+import subprocess
+import re
+
+VALIDATE_DIR = os.path.dirname(os.path.realpath(__file__))
+CLI_PATH = os.path.realpath(os.path.join(VALIDATE_DIR, "../cli.py"))
+INPUT_DIR = os.path.join(VALIDATE_DIR, "input_files")
+OUTPUT_DIR = "cli_validate"
+
+def validator(input_path, output_path):
+ print "Validator started."
+ print "Input path: %s" % input_path
+ print "Output path: %s" % output_path
+ subprocess.call("python %s < %s > %s" % (CLI_PATH, input_path, output_path), shell=True)
+
+
+def sanitize(path):
+ filters = [r"^[^<>#()]+(> .*)", r"^[^<>#()]+(# .*)", r"^[^<>#()]+(\([^()]+\)# .*)",
+ r"^Need error", r"^SDNShell", r"^default controller:",
+ r"^PERMUTE", r"^SUBMODE", r"^Exiting"]
+ patterns = [re.compile(f) for f in filters]
+ tmp_path = "%s.tmp" % path
+ f1 = open(path)
+ f2 = open(tmp_path, "w")
+
+ def matchRegexList(compiledRegexList, line):
+ for cr in compiledRegexList:
+ if cr.search(line):
+ return True
+ return False
+
+ for line in f1:
+ if matchRegexList(patterns, line):
+ continue
+ f2.write(line)
+ f1.close()
+ f2.close()
+ os.remove(path)
+ os.rename(tmp_path, path)
+
+
+def main():
+ subprocess.call(["rm", "-rf", OUTPUT_DIR])
+ subprocess.call(["mkdir", "-p", OUTPUT_DIR])
+ for f in os.listdir(INPUT_DIR):
+ in_path = os.path.join(INPUT_DIR, f)
+ out_path = os.path.join(OUTPUT_DIR, "%s_output" % f)
+ validator(in_path, out_path)
+ sanitize(out_path)
+
+if __name__ == "__main__":
+ main()
+