Get inventory list using expanded location code
This commit implements api to get inventory list with respect to
a given location code in expanded format.
In case no inventory is found at the given location or location code
is not correct, corresponding error is returned to the caller.
Tested on simics.
This api is under com.ibm.vpd.Manager interface. So vpd-manager app
needs to be running for this api to work.
Sample command for simics:
busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager
GetFRUsByUnexpandedLocationCode sq <location_code> <node_number>
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
Change-Id: Ifa47d73a64338cbd228b5be1346027c69695612a
diff --git a/vpd-manager/reader_impl.hpp b/vpd-manager/reader_impl.hpp
index 465f414..dab8b8e 100644
--- a/vpd-manager/reader_impl.hpp
+++ b/vpd-manager/reader_impl.hpp
@@ -32,18 +32,29 @@
* code.
* @return Expanded location code.
*/
- std::string getExpandedLocationCode(
- const std::string& locationCode, const uint16_t& nodeNumber,
+ inventory::LocationCode getExpandedLocationCode(
+ const inventory::LocationCode& locationCode,
+ const inventory::NodeNumber& nodeNumber,
const inventory::LocationCodeMap& frusLocationCode) const;
- /** @brief An api to get list of all the FRUs at the given location code
+ /** @brief An API to get list of all the FRUs at the given location code
* @param[in] - location code in unexpanded format
* @param[in] - node number
* @param[in] - mapping of location code and Inventory path
* @return list of Inventory paths at the given location
*/
inventory::ListOfPaths getFrusAtLocation(
- const std::string& locationCode, const uint16_t& nodeNumber,
+ const inventory::LocationCode& locationCode,
+ const inventory::NodeNumber& nodeNumber,
+ const inventory::LocationCodeMap& frusLocationCode) const;
+
+ /** @brief An API to get list of all the FRUs at the given location code
+ * @param[in] - location code in unexpanded format
+ * @param[in] - mapping of location code and Inventory path
+ * @return list of Inventory paths at the given location
+ */
+ inventory::ListOfPaths getFRUsByExpandedLocationCode(
+ const inventory::LocationCode& locationCode,
const inventory::LocationCodeMap& frusLocationCode) const;
private:
@@ -51,7 +62,16 @@
* @param[in] - location code
* @return true/false based on validity check
*/
- bool isValidLocationCode(const std::string& locationCode) const;
+ bool isValidLocationCode(const inventory::LocationCode& locationCode) const;
+
+ /** @brief An API to split expanded location code to its un-expanded
+ * format as represented in VPD JSON and the node number.
+ * @param[in] Location code in expanded format.
+ * @return Location code in un-expanded format and its node number.
+ */
+ std::tuple<inventory::LocationCode, inventory::NodeNumber>
+ getCollapsedLocationCode(
+ const inventory::LocationCode& locationCode) const;
}; // class ReaderImpl