diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/extra-properties-example.yaml | 11 | ||||
-rw-r--r-- | scripts/extra-properties.mako.cpp | 24 | ||||
-rwxr-xr-x | scripts/extra-properties.py | 34 |
3 files changed, 69 insertions, 0 deletions
diff --git a/scripts/extra-properties-example.yaml b/scripts/extra-properties-example.yaml new file mode 100644 index 0000000..626ef33 --- /dev/null +++ b/scripts/extra-properties-example.yaml @@ -0,0 +1,11 @@ +/system/chassis/motherboard/cpu0: + xyz.openbmc_project.Inventory.Decorator.Replaceable: + FieldReplaceable: 'true' + xyz.openbmc_project.Inventory.Decorator.Cacheable: + Cached: 'true' + +/system/chassis/motherboard/dimm0: + xyz.openbmc_project.Inventory.Decorator.Replaceable: + FieldReplaceable: 'true' + xyz.openbmc_project.Inventory.Decorator.Cacheable: + Cached: 'true' diff --git a/scripts/extra-properties.mako.cpp b/scripts/extra-properties.mako.cpp new file mode 100644 index 0000000..03c730a --- /dev/null +++ b/scripts/extra-properties.mako.cpp @@ -0,0 +1,24 @@ +## This file is a template. The comment below is emitted +## into the rendered file; feel free to edit this file. +// WARNING: Generated source. Do not edit! + +#include "types.hpp" + +using namespace ipmi::vpd; + +extern const std::map<Path, InterfaceMap> extras = { +% for path in dict.iterkeys(): +<% + interfaces = dict[path] +%>\ + {"${path}",{ + % for interface,properties in interfaces.iteritems(): + {"${interface}",{ + % for property,value in properties.iteritems(): + {"${property}", ${value}}, + % endfor + }}, + % endfor + }}, +% endfor +}; diff --git a/scripts/extra-properties.py b/scripts/extra-properties.py new file mode 100755 index 0000000..0baa3e0 --- /dev/null +++ b/scripts/extra-properties.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +import os +import yaml +from mako.template import Template +import argparse + + +def main(): + parser = argparse.ArgumentParser( + description="IPMI FRU VPD parser and code generator") + + parser.add_argument( + '-e', '--extra_props_yaml', + dest='extra_props_yaml', + default='extra-properties-example.yaml', + help='input extra properties yaml file to parse') + args = parser.parse_args() + + with open(os.path.join(script_dir, args.extra_props_yaml), 'r') as fd: + yamlDict = yaml.safe_load(fd) + + # Render the mako template + template = os.path.join(script_dir, 'extra-properties.mako.cpp') + t = Template(filename=template) + with open('extra-properties-gen.cpp', 'w') as fd: + fd.write( + t.render( + dict=yamlDict)) + + +if __name__ == '__main__': + script_dir = os.path.dirname(os.path.realpath(__file__)) + main() |