psu-ng: Created map of supported PS configurations
The supported configutation entity manager object provides at a minimum
the supported type and model for the system. Check for "PowerSupply"
type, and PSU model. Then store the rest of the properties if present
such as max count and input voltage.
Replace MaxCount with RedundantCount since that's the property to be
used with power supplies.
Use a multimap since there may be mutiple supported configurations for
the same model, example, the system could support 2 PSU model 51E9 with
input voltage 220, or 4 PSU of the same model 51E9 with input voltage
110. The multimap would then look like:
51E9: 2, 220
51E9: 4, 110
The monitor app can then read the PSU model that's present, and search
for all the supported combinations that the system supports for that
model.
Tested: Verified that multiple supported configuration objects in
Rainier populated the multimap as expected.
Change-Id: I44283f56f9e5defb37f42c5149cec63d902efd76
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/phosphor-power-supply/psu_manager.cpp b/phosphor-power-supply/psu_manager.cpp
index 8045a41..73a974e 100644
--- a/phosphor-power-supply/psu_manager.cpp
+++ b/phosphor-power-supply/psu_manager.cpp
@@ -19,12 +19,10 @@
constexpr auto supportedConfIntf =
"xyz.openbmc_project.Configuration.SupportedConfiguration";
-constexpr auto maxCountProp = "MaxCount";
PSUManager::PSUManager(sdbusplus::bus::bus& bus, const sdeventplus::Event& e) :
bus(bus)
{
- sysProperties = {0};
// Subscribe to InterfacesAdded before doing a property read, otherwise
// the interface could be created after the read attempt but before the
// match is created.
@@ -145,15 +143,55 @@
{
try
{
- auto propIt = properties.find(maxCountProp);
+ auto propIt = properties.find("SupportedType");
+ if (propIt == properties.end())
+ {
+ return;
+ }
+ const std::string* type = std::get_if<std::string>(&(propIt->second));
+ if ((type == nullptr) || (*type != "PowerSupply"))
+ {
+ return;
+ }
+
+ std::vector<std::string> models;
+ propIt = properties.find("SupportedModel");
+ if (propIt == properties.end())
+ {
+ return;
+ }
+ const std::vector<std::string>* modelsPtr =
+ std::get_if<std::vector<std::string>>(&(propIt->second));
+ if (modelsPtr == nullptr)
+ {
+ return;
+ }
+ models = *modelsPtr;
+
+ sys_properties sys{0, 0};
+ propIt = properties.find("RedundantCount");
if (propIt != properties.end())
{
const uint64_t* count = std::get_if<uint64_t>(&(propIt->second));
if (count != nullptr)
{
- sysProperties.maxPowerSupplies = *count;
+ sys.maxPowerSupplies = *count;
}
}
+ propIt = properties.find("InputVoltage");
+ if (propIt != properties.end())
+ {
+ const uint64_t* voltage = std::get_if<uint64_t>(&(propIt->second));
+ if (voltage != nullptr)
+ {
+ sys.inputVoltage = *voltage;
+ }
+ }
+
+ for (const auto& model : models)
+ {
+ supportedConfigs.insert(std::make_pair(model, sys));
+ }
}
catch (std::exception& e)
{