From 0065905e1aad15bd35edc4957a56e5fd7fca963a Mon Sep 17 00:00:00 2001 From: Ratan Gupta Date: Thu, 23 Feb 2017 17:29:08 +0530 Subject: inventory: write sensor yaml parser Write python-based parser for sensor.yaml. The parser generates sensor-gen.cpp,which is having a map of sensorid(key) and sensorinfo(value). Change-Id: I5aa2d2bc871ced06e5e4c164a67eeb5974031d5d Signed-off-by: Ratan Gupta --- scripts/writesensor.mako.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 scripts/writesensor.mako.cpp (limited to 'scripts/writesensor.mako.cpp') diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp new file mode 100644 index 0000000..0b8d5f1 --- /dev/null +++ b/scripts/writesensor.mako.cpp @@ -0,0 +1,54 @@ +## This file is a template. The comment below is emitted +## into the rendered file; feel free to edit this file. + +// !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!! + +#include "types.hpp" +using namespace ipmi::sensor; + +extern const IdInfoMap sensors = { +% for key in sensorDict.iterkeys(): + % if key: +{${key},{ +<% + sensor = sensorDict[key] + interfaces = sensor["interfaces"] + path = sensor["path"] + sensorType = sensor["sensorType"] + readingType = sensor["sensorReadingType"] +%> + ${sensorType},"${path}",${readingType},{ + % for interface,properties in interfaces.iteritems(): + {"${interface}",{ + % for dbus_property,property_value in properties.iteritems(): + {"${dbus_property}",{ + % for offset,values in property_value.iteritems(): + { ${offset},{ +<% + valueType = values["type"] +%> + % for name,value in values.iteritems(): + % if name == "type": +<% + continue +%> + % endif + % if valueType == "string": + std::string("${value}"), + % else: + ${value}, + % endif + % endfor + } + }, + % endfor + }}, + % endfor + }}, + % endfor + } +}}, + % endif +% endfor +}; + -- cgit v1.2.1