regulators: Add inventory path to Chassis class
A previous commit added the "inventory_path" property to the "chassis"
object in the JSON configuration file.
This commit adds that new property to the C++ implementation:
* Chassis class and associated gtests
* JSON configuration file parser functions and associated gtests
* Other gtests affected by the change to the Chassis constructor
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I7406f874263d01e6faa2b8c333cb1baf915cf2ac
diff --git a/phosphor-regulators/src/config_file_parser.cpp b/phosphor-regulators/src/config_file_parser.cpp
index 99abd6c..5238741 100644
--- a/phosphor-regulators/src/config_file_parser.cpp
+++ b/phosphor-regulators/src/config_file_parser.cpp
@@ -203,6 +203,15 @@
}
++propertyCount;
+ // Optional inventory_path property. Will be required in future.
+ std::string inventoryPath{"/xyz/openbmc_project/inventory/system/chassis"};
+ auto inventoryPathIt = element.find("inventory_path");
+ if (inventoryPathIt != element.end())
+ {
+ inventoryPath = parseInventoryPath(*inventoryPathIt);
+ ++propertyCount;
+ }
+
// Optional devices property
std::vector<std::unique_ptr<Device>> devices{};
auto devicesIt = element.find("devices");
@@ -215,7 +224,7 @@
// Verify no invalid properties exist
verifyPropertyCount(element, propertyCount);
- return std::make_unique<Chassis>(number, std::move(devices));
+ return std::make_unique<Chassis>(number, inventoryPath, std::move(devices));
}
std::vector<std::unique_ptr<Chassis>> parseChassisArray(const json& element)