summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2017-02-17 00:29:02 -0600
committerPatrick Williams <patrick@stwcx.xyz>2017-02-20 14:20:21 +0000
commitbdfd123563a41175076b6b9a82c13886c7240cfe (patch)
treefd1fcf53e0d43f2c81db718bc2dc12454d67f5f7
parent76794495882082db189e2fc6d6c05dfe3756338a (diff)
downloadopenpower-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>
-rw-r--r--extra-properties-example.yaml7
-rw-r--r--extra-properties.mako.hpp40
-rwxr-xr-xextra-properties.py34
3 files changed, 81 insertions, 0 deletions
diff --git a/extra-properties-example.yaml b/extra-properties-example.yaml
new file mode 100644
index 0000000..09d9844
--- /dev/null
+++ b/extra-properties-example.yaml
@@ -0,0 +1,7 @@
+/system/bmc:
+ xyz.openbmc_project.Inventory.Decorator.Replaceable:
+ FieldReplaceable: 'false'
+
+/system/bmc/ethernet:
+ xyz.openbmc_project.Inventory.Decorator.Replaceable:
+ FieldReplaceable: 'false'
diff --git a/extra-properties.mako.hpp b/extra-properties.mako.hpp
new file mode 100644
index 0000000..6b006c2
--- /dev/null
+++ b/extra-properties.mako.hpp
@@ -0,0 +1,40 @@
+## This file is a template. The comment below is emitted
+## into the rendered file; feel free to edit this file.
+// WARNING: Generated header. Do not edit!
+
+#pragma once
+
+#include <string>
+#include <map>
+#include "types.hpp"
+
+namespace openpower
+{
+namespace vpd
+{
+namespace inventory
+{
+namespace extra
+{
+
+const std::map<Path, InterfaceMap> objects = {
+% 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
+};
+
+} // namespace extra
+} // namespace inventory
+} // namespace vpd
+} // namespace openpower
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()
OpenPOWER on IntegriCloud