diff options
author | Deepak Kodihalli <dkodihal@in.ibm.com> | 2017-02-17 00:29:02 -0600 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-02-20 14:20:21 +0000 |
commit | bdfd123563a41175076b6b9a82c13886c7240cfe (patch) | |
tree | fd1fcf53e0d43f2c81db718bc2dc12454d67f5f7 /extra-properties.py | |
parent | 76794495882082db189e2fc6d6c05dfe3756338a (diff) | |
download | openpower-vpd-parser-bdfd123563a41175076b6b9a82c13886c7240cfe.tar.gz openpower-vpd-parser-bdfd123563a41175076b6b9a82c13886c7240cfe.zip |
inventory: enable updating extra properties
While the openpower vpd parser, in order to update inventory, retrieves
most properties from the vpd itself, there could be some properties
whose values could be provided by other sources, such as the Machine
Readable Workbook.
Provide a mechanism to enable the above by having the extra property
information and values supplied via a YAML file, via which code is
generated, which in turn can be used by the parser to update inventory.
Change-Id: I4005c8a8d429085cc9ad279cb28e216c50b63c5d
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'extra-properties.py')
-rwxr-xr-x | extra-properties.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/extra-properties.py b/extra-properties.py new file mode 100755 index 0000000..728fc14 --- /dev/null +++ b/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="OpenPOWER 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.hpp') + t = Template(filename=template) + with open('extra-properties-gen.hpp', 'w') as fd: + fd.write( + t.render( + dict=yamlDict)) + + +if __name__ == '__main__': + script_dir = os.path.dirname(os.path.realpath(__file__)) + main() |