diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2017-04-17 15:49:37 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-05-15 16:59:22 -0400 |
commit | db440d4cfe3fa2cba5621342eb58b9928af6912a (patch) | |
tree | 7c3c7150260bf2179b204efec77a561ca325e642 | |
parent | c5736432ac09d19cd0e513e11082a7637a196829 (diff) | |
download | phosphor-dbus-monitor-db440d4cfe3fa2cba5621342eb58b9928af6912a.tar.gz phosphor-dbus-monitor-db440d4cfe3fa2cba5621342eb58b9928af6912a.zip |
Base monitoring generation script
Monitoring source generation script with mako template to
generate an empty set of events. The events will be parsed and added
under openbmc/openbmc#1493
Resolves openbmc/openbmc#1343
Change-Id: I40225f070212af36f410d99bc7ead95961e70997
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | src/Makefile.am | 6 | ||||
-rwxr-xr-x | src/gen-group-defs.py | 33 | ||||
-rw-r--r-- | src/generated.mako.cpp | 25 |
4 files changed, 67 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 816882c..38e8d79 100644 --- a/configure.ac +++ b/configure.ac @@ -12,6 +12,9 @@ AM_PROG_AR AC_PROG_INSTALL AC_PROG_MAKE_SET AC_PROG_AWK +AM_PATH_PYTHON([2.7], + [AC_SUBST([PYTHON], [echo "$PYTHON"])], + [AC_MSG_ERROR([Could not find python-2.7 installed...python-2.7 is required])]) # Checks for libraries. PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus],, AC_MSG_ERROR(["Requires sdbusplus package."])) diff --git a/src/Makefile.am b/src/Makefile.am index 8c57553..233b610 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,3 +14,9 @@ phosphor_dbus_monitor_LDADD = \ phosphor_dbus_monitor_CXXFLAGS = \ $(SDBUSPLUS_CFLAGS) \ $(PHOSPHOR_LOGGING_CFLAGS) + +BUILT_SOURCES = generated.cpp +CLEANFILES = generated.cpp + +generated.cpp: + $(AM_V_GEN)$(PYTHON) ${srcdir}/gen-group-defs.py -y ${srcdir}/example/monitoring_defs.yaml -o ${builddir} 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")) diff --git a/src/generated.mako.cpp b/src/generated.mako.cpp new file mode 100644 index 0000000..a8f6d60 --- /dev/null +++ b/src/generated.mako.cpp @@ -0,0 +1,25 @@ +## This file is a template, the comment below is emitted into the generated file +/* This is an auto generated file. Do not edit. */ +#include "data_types.hpp" +#include "monitor.hpp" +#include "functor.hpp" +#include "conditions.hpp" +#include "actions.hpp" + +namespace phosphor +{ +namespace dbus +{ +namespace monitoring +{ + +const std::vector<std::tuple<std::vector<std::shared_ptr<Event>>, + std::vector<Action>>> + Monitor::events +{ + +}; + +} // namespace monitoring +} // namespace dbus +} // namespace phosphor |