Add ability to load inventory from file instead of hardcoding.

This commit allows inventory_items.py to load the inventory from
/usr/share/inventory/inventory.json instead of using the hardcoded
array in <System>.py.  A future commit will generate inventory.json
from the machine readable workbook XML for at least one system.

If the code can't load the json file, it will fall back to the
hardcoded array, which at this point we know is always present.

Even though pyinventorymgr will probably be rewritten in C++ at
some point, this series of commits illustrates how the OpenBMC
can utilize a data-driven design, and this component was chosen
as it takes a minimal amount of changes.

Change-Id: Ie749a068d6f47c5671677b21ff3ef5418739f161
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/pyinventorymgr/inventory_items.py b/pyinventorymgr/inventory_items.py
index d6d3d1d..41e3093 100644
--- a/pyinventorymgr/inventory_items.py
+++ b/pyinventorymgr/inventory_items.py
@@ -84,6 +84,17 @@
     bus = get_dbus()
     mainloop = gobject.MainLoop()
     obj_parent = Inventory(bus, '/org/openbmc/inventory')
+    INVENTORY_FILE = os.path.join(sys.prefix, 'share',
+                                  'inventory', 'inventory.json')
+
+    if os.path.exists(INVENTORY_FILE):
+        with open(INVENTORY_FILE, 'r') as f:
+            try:
+                inv = json.load(f)
+            except ValueError:
+                print "Invalid JSON detected in " + INVENTORY_FILE
+            else:
+                FRUS = inv
 
     for f in FRUS.keys():
         obj_path = f.replace("<inventory_root>", System.INVENTORY_ROOT)