build : provide FRU yaml as configurable input
In preparation for the openpower-vpd-parser recipe, make it possible to
provide the FRU data YAML file as a build-configurable input.
Use writefru.yaml as default.
Change-Id: I32dba99bcb6c8dd4da259f907b0499b3192cc412
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/writefru.py b/writefru.py
index 97418ca..eb5d5b8 100755
--- a/writefru.py
+++ b/writefru.py
@@ -3,10 +3,18 @@
import os
import yaml
from mako.template import Template
+import argparse
-if __name__ == '__main__':
- script_dir = os.path.dirname(os.path.realpath(__file__))
- with open(os.path.join(script_dir, 'writefru.yaml'), 'r') as fd:
+def main():
+ parser = argparse.ArgumentParser(
+ description="OpenPOWER FRU VPD parser and code generator")
+
+ parser.add_argument(
+ '-i', '--inventory_yaml', dest='inventory_yaml',
+ default='writefru.yaml', help='input inventory yaml file to parse')
+ args = parser.parse_args()
+
+ with open(os.path.join(script_dir, args.inventory_yaml), 'r') as fd:
yamlDict = yaml.safe_load(fd)
# Render the mako template
@@ -16,3 +24,8 @@
fd.write(
t.render(
fruDict=yamlDict))
+
+
+if __name__ == '__main__':
+ script_dir = os.path.dirname(os.path.realpath(__file__))
+ main()