summaryrefslogtreecommitdiffstats
path: root/src/gen-group-defs.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/gen-group-defs.py')
-rwxr-xr-xsrc/gen-group-defs.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/gen-group-defs.py b/src/gen-group-defs.py
new file mode 100755
index 0000000..56ac00f
--- /dev/null
+++ b/src/gen-group-defs.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import yaml
+from argparse import ArgumentParser
+from mako.template import Template
+
+
+def generate(yaml_file, output_file):
+ with open(yaml_file, 'r') as yaml_input:
+ yaml_data = yaml.safe_load(yaml_input) or {}
+
+ with open(output_file, 'w') as gen_out:
+ gen_out.write(Template(filename='generated.mako.cpp').render(
+ events=yaml_data))
+
+
+if __name__ == '__main__':
+ parser = ArgumentParser()
+ # Groups of items and how they should be monitored yaml file
+ parser.add_argument(
+ "-y", "--yaml", dest="input_yaml",
+ default="example/monitoring_defs.yaml",
+ help="Input item monitoring definition yaml to parse")
+ parser.add_argument(
+ "-o", "--outdir", dest="output_dir",
+ default=os.path.abspath('.'),
+ help="Output directory for source files generated")
+ args = parser.parse_args(sys.argv[1:])
+
+ yaml_file = os.path.abspath(args.input_yaml)
+ generate(yaml_file, os.path.join(args.output_dir, "generated.cpp"))
OpenPOWER on IntegriCloud