Update dump inventory and dump object

VPD-Tool currently tries to populate interfaces in case of dump object
and dump inventory without confrming if the object implements that
interface. This can cause Dbus exceptions which can be seen along with
output.

The commit add a pre-check and populates interfaces only which are
applicable. It also adds support for some more interface(s).

Test:

verified both dump object and dump inventory.
Works without giving any exceptions.

root@rain203bmc:~# /tmp/vpd-tool -o -O /system
[
    {
        "/system": {
            "LocationCode": "U9824.42A.13E0C40",
            "Model": "9824-42A",
            "PrettyName": "System",
            "SerialNumber": "13E0C40",
            "SubModel": "S0",
            "TYPE": "FRU",
            "type": "xyz.openbmc_project.Inventory.Item.System"
        }
    }
]
root@rain203bmc:~#
/tmp/vpd-tool -o -O /system/chassis/motherboard/pcieslot10/pcie_card10
[
    {
        "/system/chassis/motherboard/pcieslot10/pcie_card10": {
            "Address": "80",
            "Bus": "29",
            "CC": "6B87",
            "DR": "NVME JBOF  RISER",
            "FN": "03FL195",
            "LocationCode": "U78DB.ND0.WZS0019-P0-C10",
            "PN": "03FL286",
            "PrettyName": "PCIe4 x16 or PCIe5 x8 adapter",
            "SN": "YA30UF13S01P",
            "SlotNumber": "10",
            "TYPE": "FRU",
            "type": "xyz.openbmc_project.Inventory.Item.FabricAdapter"
        }
    }
]

Change-Id: I97ecfbec734c14cddff075f2bbf6469f70f6e25e
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-tool/include/tool_constants.hpp b/vpd-tool/include/tool_constants.hpp
index 84b7025..00c64b8 100644
--- a/vpd-tool/include/tool_constants.hpp
+++ b/vpd-tool/include/tool_constants.hpp
@@ -24,7 +24,7 @@
 constexpr auto vpdManagerObjectPath = "/com/ibm/VPD/Manager";
 constexpr auto vpdManagerInfName = "com.ibm.VPD.Manager";
 constexpr auto inventoryItemInf = "xyz.openbmc_project.Inventory.Item";
-constexpr auto kwdVpdInf = "com.ibm.ipzvpd.VINI";
+constexpr auto viniInf = "com.ibm.ipzvpd.VINI";
 constexpr auto locationCodeInf = "com.ibm.ipzvpd.Location";
 constexpr auto assetInf = "xyz.openbmc_project.Inventory.Decorator.Asset";
 constexpr auto objectMapperService = "xyz.openbmc_project.ObjectMapper";
@@ -38,5 +38,11 @@
 constexpr auto dbusObjectPath = "/org/freedesktop/DBus";
 constexpr auto dbusInterface = "org.freedesktop.DBus";
 constexpr auto biosConfigMgrService = "xyz.openbmc_project.BIOSConfigManager";
+constexpr auto networkInf =
+    "xyz.openbmc_project.Inventory.Item.NetworkInterface";
+constexpr auto pcieSlotInf = "xyz.openbmc_project.Inventory.Item.PCIeSlot";
+constexpr auto slotNumInf = "xyz.openbmc_project.Inventory.Decorator.Slot";
+constexpr auto i2cDeviceInf =
+    "xyz.openbmc_project.Inventory.Decorator.I2CDevice";
 } // namespace constants
 } // namespace vpd
diff --git a/vpd-tool/include/vpd_tool.hpp b/vpd-tool/include/vpd_tool.hpp
index 67a52fc..0004949 100644
--- a/vpd-tool/include/vpd_tool.hpp
+++ b/vpd-tool/include/vpd_tool.hpp
@@ -43,6 +43,38 @@
     nlohmann::json getFruProperties(const std::string& i_objectPath) const;
 
     /**
+     * @brief API to populate FRU JSON.
+     *
+     * The API will create FRUs JSON, which will have property value pairs for
+     * all the interfaces required for that particular FRU.
+     *
+     * @param[in] i_inventoryObjPath - FRU inventory path.
+     * @param[in, out] io_fruJsonObject - JSON object.
+     * @param[in] i_interfaceList - list of interfaces implemented by the FRU on
+     * Dbus.
+     */
+    void populateFruJson(const std::string& i_inventoryObjPath,
+                         nlohmann::json& io_fruJsonObject,
+                         const std::vector<std::string>& i_interfaceList) const;
+
+    /**
+     * @brief API to populate JSON for an interface.
+     *
+     * The API will create interface JSON, which will have property value pairs
+     * for all the properties required under that interface.
+     *
+     * @param[in] i_inventoryObjPath - FRU inventory path.
+     * @param[in] i_infName - interface whose JSON need to be populated.
+     * @param[in] i_propList - List of properties needed in the JSON.
+     * @param[in, out] io_fruJsonObject - JSON object.
+     */
+    template <typename PropertyType>
+    void populateInterfaceJson(const std::string& i_inventoryObjPath,
+                               const std::string& i_infName,
+                               const std::vector<std::string>& i_propList,
+                               nlohmann::json& io_fruJsonObject) const;
+
+    /**
      * @brief Get any inventory property in JSON.
      *
      * API to get any property of a FRU in JSON format. Given an object path,