ibm-read-vpd: Switch to the right symlinked JSON

This commit:
* Makes the VPD parser use the symlinked JSON if one is setup.
  For example via a system VPD service.
* Makes the vpd-tool and vpd-manager use the symlinked JSON.

Signed-off-by: Santosh Puranik <santosh.puranik@in.ibm.com>
Change-Id: Id7f845e02917e3a66d1fa9754da71ed0005c0cb8
diff --git a/ibm_vpd_app.cpp b/ibm_vpd_app.cpp
index 48b930c..e4c2c06 100644
--- a/ibm_vpd_app.cpp
+++ b/ibm_vpd_app.cpp
@@ -539,7 +539,9 @@
             target = INVENTORY_JSON_2U;
         }
 
-        // unlink the symlink which is created at build time
+        // Create the directory for hosting the symlink
+        fs::create_directories(VPD_FILES_PATH);
+        // unlink the symlink previously created (if any)
         remove(INVENTORY_JSON_SYM_LINK);
         // create a new symlink based on the system
         fs::create_symlink(target, link);
@@ -576,8 +578,17 @@
 
         CLI11_PARSE(app, argc, argv);
 
+        auto jsonToParse = INVENTORY_JSON_DEFAULT;
+
+        // If the symlink exists, it means it has been setup for us, switch the
+        // path
+        if (fs::exists(INVENTORY_JSON_SYM_LINK))
+        {
+            jsonToParse = INVENTORY_JSON_SYM_LINK;
+        }
+
         // Make sure that the file path we get is for a supported EEPROM
-        ifstream inventoryJson(INVENTORY_JSON);
+        ifstream inventoryJson(jsonToParse);
         auto js = json::parse(inventoryJson);
 
         if ((js.find("frus") == js.end()) ||