psu-ng: Update supported configuration properties
The Supported Configuration schema has been updated to have a single
model instead of array of models, and to have an array of input voltages
instead of a single voltage.
In addition, update the name of the supported number of power supplies
from max to count, so that it better reflects that a specific number of
power supplies are expected, and not an 'up to' max number.
Change-Id: I7a4bfa9b195ce7b9d13802dbb234018c6f217fda
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 73a974e..c6d5855 100644
--- a/phosphor-power-supply/psu_manager.cpp
+++ b/phosphor-power-supply/psu_manager.cpp
@@ -154,44 +154,39 @@
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)
+ const std::string* model = std::get_if<std::string>(&(propIt->second));
+ if (model == nullptr)
{
return;
}
- models = *modelsPtr;
- sys_properties sys{0, 0};
+ sys_properties sys;
propIt = properties.find("RedundantCount");
if (propIt != properties.end())
{
const uint64_t* count = std::get_if<uint64_t>(&(propIt->second));
if (count != nullptr)
{
- sys.maxPowerSupplies = *count;
+ sys.powerSupplyCount = *count;
}
}
propIt = properties.find("InputVoltage");
if (propIt != properties.end())
{
- const uint64_t* voltage = std::get_if<uint64_t>(&(propIt->second));
+ const std::vector<uint64_t>* voltage =
+ std::get_if<std::vector<uint64_t>>(&(propIt->second));
if (voltage != nullptr)
{
sys.inputVoltage = *voltage;
}
}
- for (const auto& model : models)
- {
- supportedConfigs.insert(std::make_pair(model, sys));
- }
+ supportedConfigs.emplace(*model, sys);
}
catch (std::exception& e)
{
diff --git a/phosphor-power-supply/psu_manager.hpp b/phosphor-power-supply/psu_manager.hpp
index 9ceeed5..a59b2fc 100644
--- a/phosphor-power-supply/psu_manager.hpp
+++ b/phosphor-power-supply/psu_manager.hpp
@@ -11,8 +11,8 @@
struct sys_properties
{
- int maxPowerSupplies;
- int inputVoltage;
+ int powerSupplyCount;
+ std::vector<uint64_t> inputVoltage;
};
using namespace phosphor::power::psu;
@@ -225,7 +225,7 @@
* @brief Map of supported PSU configurations that include the model name
* and their properties.
*/
- std::multimap<std::string, sys_properties> supportedConfigs;
+ std::map<std::string, sys_properties> supportedConfigs;
/**
* @brief The vector for power supplies.
diff --git a/utility.hpp b/utility.hpp
index 51fe31d..941c909 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -29,8 +29,7 @@
using DbusInterfaceList = std::vector<DbusInterface>;
using DbusSubtree =
std::map<DbusPath, std::map<DbusService, DbusInterfaceList>>;
-using DbusVariant =
- std::variant<uint64_t, std::string, std::vector<std::string>>;
+using DbusVariant = std::variant<uint64_t, std::string, std::vector<uint64_t>>;
using DbusPropertyMap = std::map<DbusProperty, DbusVariant>;
/**
* @brief Get the service name from the mapper for the