inventory: enable updating extra properties

While the IPMI FRU parser, in order to update inventory, receives
most properties from the host IPMI, 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: I30a2a9129d97485a0c31c3dec0155d5e1a008101
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
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()