Consistently use ManagedObjectType
Some subsystems seem to have invented their own typedefs for this stuff,
move to using the one typedef in dbus::utility so we're consistent, and
we reduce our templates.
Tested: code compiles
This saves a negligible amount (104 bytes compressed) on our binary
size.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I952ea1f960aa703808d0ac80f35dc24cdd8d5027
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index a971325..4853231 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -56,10 +56,8 @@
>;
// clang-format on
-using DBusPropertiesMap =
- boost::container::flat_map<std::string, DbusVariantType>;
-using DBusInteracesMap =
- boost::container::flat_map<std::string, DBusPropertiesMap>;
+using DBusPropertiesMap = std::vector<std::pair<std::string, DbusVariantType>>;
+using DBusInteracesMap = std::vector<std::pair<std::string, DBusPropertiesMap>>;
using ManagedObjectType =
std::vector<std::pair<sdbusplus::message::object_path, DBusInteracesMap>>;
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 7f60575..53d644d 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -71,9 +71,6 @@
std::string,
boost::container::flat_map<std::string, dbus::utility::DbusVariantType>>;
-using ManagedObjectType =
- std::vector<std::pair<sdbusplus::message::object_path, DbusInterfaceType>>;
-
using GetObjectType =
std::vector<std::pair<std::string, std::vector<std::string>>>;
@@ -406,8 +403,9 @@
}
std::string service = resp.begin()->first;
crow::connections::systemBus->async_method_call(
- [callback, ldapType](const boost::system::error_code errorCode,
- const ManagedObjectType& ldapObjects) {
+ [callback, ldapType](
+ const boost::system::error_code errorCode,
+ const dbus::utility::ManagedObjectType& ldapObjects) {
LDAPConfigData confData{};
if (errorCode)
{
@@ -1511,7 +1509,7 @@
crow::connections::systemBus->async_method_call(
[asyncResp, thisUser, effectiveUserPrivileges](
const boost::system::error_code ec,
- const ManagedObjectType& users) {
+ const dbus::utility::ManagedObjectType& users) {
if (ec)
{
messages::internalError(asyncResp->res);
@@ -1708,18 +1706,20 @@
}
crow::connections::systemBus->async_method_call(
- [asyncResp, accountName](const boost::system::error_code ec,
- const ManagedObjectType& users) {
+ [asyncResp,
+ accountName](const boost::system::error_code ec,
+ const dbus::utility::ManagedObjectType& users) {
if (ec)
{
messages::internalError(asyncResp->res);
return;
}
- auto userIt = std::find_if(
+ const auto userIt = std::find_if(
users.begin(), users.end(),
[accountName](
const std::pair<sdbusplus::message::object_path,
- DbusInterfaceType>& user) {
+ dbus::utility::DBusInteracesMap>&
+ user) {
return !accountName.compare(user.first.filename());
});
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 3dca18b..89fad8c 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -840,7 +840,7 @@
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
- const ManagedObjectType& certs) {
+ const dbus::utility::ManagedObjectType& certs) {
if (ec)
{
BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
@@ -942,7 +942,7 @@
<< " Path=" << path << " service= " << service;
crow::connections::systemBus->async_method_call(
[asyncResp, certURL](const boost::system::error_code ec,
- const ManagedObjectType& certs) {
+ const dbus::utility::ManagedObjectType& certs) {
if (ec)
{
BMCWEB_LOG_WARNING
@@ -1026,7 +1026,7 @@
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
- const ManagedObjectType& certs) {
+ const dbus::utility::ManagedObjectType& certs) {
nlohmann::json& members =
asyncResp->res.jsonValue["Members"];
nlohmann::json& count =
@@ -1160,7 +1160,7 @@
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
- const ManagedObjectType& certs) {
+ const dbus::utility::ManagedObjectType& certs) {
if (ec)
{
BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index b726ecc..1097aec 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -37,12 +37,6 @@
using PropertiesMapType =
boost::container::flat_map<std::string, dbus::utility::DbusVariantType>;
-using GetManagedObjects = std::vector<std::pair<
- sdbusplus::message::object_path,
- std::vector<std::pair<std::string,
- boost::container::flat_map<
- std::string, dbus::utility::DbusVariantType>>>>>;
-
enum class LinkType
{
Local,
@@ -196,9 +190,10 @@
return "";
}
-inline bool extractEthernetInterfaceData(const std::string& ethifaceId,
- GetManagedObjects& dbusData,
- EthernetInterfaceData& ethData)
+inline bool
+ extractEthernetInterfaceData(const std::string& ethifaceId,
+ dbus::utility::ManagedObjectType& dbusData,
+ EthernetInterfaceData& ethData)
{
bool idFound = false;
for (auto& objpath : dbusData)
@@ -432,7 +427,7 @@
// Helper function that extracts data for single ethernet ipv6 address
inline void
extractIPV6Data(const std::string& ethifaceId,
- const GetManagedObjects& dbusData,
+ const dbus::utility::ManagedObjectType& dbusData,
boost::container::flat_set<IPv6AddressData>& ipv6Config)
{
const std::string ipv6PathStart =
@@ -510,7 +505,7 @@
// Helper function that extracts data for single ethernet ipv4 address
inline void
extractIPData(const std::string& ethifaceId,
- const GetManagedObjects& dbusData,
+ const dbus::utility::ManagedObjectType& dbusData,
boost::container::flat_set<IPv4AddressData>& ipv4Config)
{
const std::string ipv4PathStart =
@@ -938,7 +933,7 @@
crow::connections::systemBus->async_method_call(
[ethifaceId{std::string{ethifaceId}}, callback{std::move(callback)}](
const boost::system::error_code errorCode,
- GetManagedObjects& resp) {
+ dbus::utility::ManagedObjectType& resp) {
EthernetInterfaceData ethData{};
boost::container::flat_set<IPv4AddressData> ipv4Data;
boost::container::flat_set<IPv6AddressData> ipv6Data;
@@ -989,7 +984,7 @@
crow::connections::systemBus->async_method_call(
[callback{std::move(callback)}](
const boost::system::error_code errorCode,
- GetManagedObjects& resp) {
+ dbus::utility::ManagedObjectType& resp) {
// Callback requires vector<string> to retrieve all available
// ethernet interfaces
boost::container::flat_set<std::string> ifaceList;
diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp
index 41352da..71da99e 100644
--- a/redfish-core/lib/health.hpp
+++ b/redfish-core/lib/health.hpp
@@ -85,41 +85,43 @@
}
if (!isChild)
{
- auto assocIt =
- interfaces.find("xyz.openbmc_project.Association");
- if (assocIt == interfaces.end())
+ for (const auto& [interface, association] : interfaces)
{
- continue;
- }
- auto endpointsIt = assocIt->second.find("endpoints");
- if (endpointsIt == assocIt->second.end())
- {
- BMCWEB_LOG_ERROR << "Illegal association at "
- << path.str;
- continue;
- }
- const std::vector<std::string>* endpoints =
- std::get_if<std::vector<std::string>>(
- &endpointsIt->second);
- if (endpoints == nullptr)
- {
- BMCWEB_LOG_ERROR << "Illegal association at "
- << path.str;
- continue;
- }
- bool containsChild = false;
- for (const std::string& endpoint : *endpoints)
- {
- if (std::find(inventory.begin(), inventory.end(),
- endpoint) != inventory.end())
+ if (interface != "xyz.openbmc_project.Association")
{
- containsChild = true;
- break;
+ continue;
}
- }
- if (!containsChild)
- {
- continue;
+ for (const auto& [name, value] : association)
+ {
+ if (name != "endpoints")
+ {
+ continue;
+ }
+
+ const std::vector<std::string>* endpoints =
+ std::get_if<std::vector<std::string>>(&value);
+ if (endpoints == nullptr)
+ {
+ BMCWEB_LOG_ERROR << "Illegal association at "
+ << path.str;
+ continue;
+ }
+ bool containsChild = false;
+ for (const std::string& endpoint : *endpoints)
+ {
+ if (std::find(inventory.begin(),
+ inventory.end(),
+ endpoint) != inventory.end())
+ {
+ containsChild = true;
+ break;
+ }
+ }
+ if (!containsChild)
+ {
+ continue;
+ }
+ }
}
}
}
diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp
index d308a9a..8faae3f 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -150,7 +150,8 @@
}
inline bool extractHypervisorInterfaceData(
- const std::string& ethIfaceId, const GetManagedObjects& dbusData,
+ const std::string& ethIfaceId,
+ const dbus::utility::ManagedObjectType& dbusData,
EthernetInterfaceData& ethData,
boost::container::flat_set<IPv4AddressData>& ipv4Config)
{
@@ -316,9 +317,9 @@
CallbackFunc&& callback)
{
crow::connections::systemBus->async_method_call(
- [ethIfaceId{std::string{ethIfaceId}},
- callback{std::move(callback)}](const boost::system::error_code error,
- const GetManagedObjects& resp) {
+ [ethIfaceId{std::string{ethIfaceId}}, callback{std::move(callback)}](
+ const boost::system::error_code error,
+ const dbus::utility::ManagedObjectType& resp) {
EthernetInterfaceData ethData{};
boost::container::flat_set<IPv4AddressData> ipv4Data;
if (error)
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index b908da5..0bfd15e 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -106,10 +106,6 @@
using GetManagedPropertyType =
boost::container::flat_map<std::string, dbus::utility::DbusVariantType>;
-using GetManagedObjectsType = boost::container::flat_map<
- sdbusplus::message::object_path,
- boost::container::flat_map<std::string, GetManagedPropertyType>>;
-
inline std::string translateSeverityDbusToRedfish(const std::string& s)
{
if ((s == "xyz.openbmc_project.Logging.Entry.Level.Alert") ||
@@ -396,8 +392,9 @@
}
crow::connections::systemBus->async_method_call(
- [asyncResp, dumpPath, dumpType](const boost::system::error_code ec,
- GetManagedObjectsType& resp) {
+ [asyncResp, dumpPath,
+ dumpType](const boost::system::error_code ec,
+ dbus::utility::ManagedObjectType& resp) {
if (ec)
{
BMCWEB_LOG_ERROR << "DumpEntry resp_handler got error " << ec;
@@ -554,8 +551,9 @@
}
crow::connections::systemBus->async_method_call(
- [asyncResp, entryID, dumpPath, dumpType](
- const boost::system::error_code ec, GetManagedObjectsType& resp) {
+ [asyncResp, entryID, dumpPath,
+ dumpType](const boost::system::error_code ec,
+ dbus::utility::ManagedObjectType& resp) {
if (ec)
{
BMCWEB_LOG_ERROR << "DumpEntry resp_handler got error " << ec;
@@ -1365,7 +1363,7 @@
// Make call to Logging Service to find all log entry objects
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
- GetManagedObjectsType& resp) {
+ dbus::utility::ManagedObjectType& resp) {
if (ec)
{
// TODO Handle for specific error code
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 39b0f88..79ce368 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -314,52 +314,60 @@
{
continue;
}
- auto findName = intfPair.second.find("Name");
- if (findName == intfPair.second.end())
- {
- BMCWEB_LOG_ERROR << "Pid Field missing Name";
- messages::internalError(asyncResp->res);
- return;
- }
- const std::string* namePtr =
- std::get_if<std::string>(&findName->second);
- if (namePtr == nullptr)
- {
- BMCWEB_LOG_ERROR << "Pid Name Field illegal";
- messages::internalError(asyncResp->res);
- return;
- }
- std::string name = *namePtr;
- dbus::utility::escapePathForDbus(name);
+ std::string name;
- auto findProfiles = intfPair.second.find("Profiles");
- if (findProfiles != intfPair.second.end())
+ for (const std::pair<std::string,
+ dbus::utility::DbusVariantType>&
+ propPair : intfPair.second)
{
- const std::vector<std::string>* profiles =
- std::get_if<std::vector<std::string>>(
- &findProfiles->second);
- if (profiles == nullptr)
+ if (propPair.first == "Name")
{
- BMCWEB_LOG_ERROR << "Pid Profiles Field illegal";
- messages::internalError(asyncResp->res);
- return;
+ const std::string* namePtr =
+ std::get_if<std::string>(&propPair.second);
+ if (namePtr == nullptr)
+ {
+ BMCWEB_LOG_ERROR << "Pid Name Field illegal";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ std::string name = *namePtr;
+ dbus::utility::escapePathForDbus(name);
}
- if (std::find(profiles->begin(), profiles->end(),
- currentProfile) == profiles->end())
+ else if (propPair.first == "Profiles")
{
- BMCWEB_LOG_INFO
- << name << " not supported in current profile";
- continue;
+ const std::vector<std::string>* profiles =
+ std::get_if<std::vector<std::string>>(
+ &propPair.second);
+ if (profiles == nullptr)
+ {
+ BMCWEB_LOG_ERROR
+ << "Pid Profiles Field illegal";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (std::find(profiles->begin(), profiles->end(),
+ currentProfile) == profiles->end())
+ {
+ BMCWEB_LOG_INFO
+ << name
+ << " not supported in current profile";
+ continue;
+ }
}
}
nlohmann::json* config = nullptr;
-
const std::string* classPtr = nullptr;
- auto findClass = intfPair.second.find("Class");
- if (findClass != intfPair.second.end())
+
+ for (const std::pair<std::string,
+ dbus::utility::DbusVariantType>&
+ propPair : intfPair.second)
{
- classPtr = std::get_if<std::string>(&findClass->second);
+ if (intfPair.first == "Class")
+ {
+ classPtr =
+ std::get_if<std::string>(&propPair.second);
+ }
}
if (intfPair.first == pidZoneConfigurationIface)
@@ -705,7 +713,7 @@
return true;
}
-inline const dbus::utility::ManagedItem*
+inline const dbus::utility::ManagedObjectType::value_type*
findChassis(const dbus::utility::ManagedObjectType& managedObj,
const std::string& value, std::string& chassis)
{
@@ -785,7 +793,7 @@
return CreatePIDRet::del;
}
- const dbus::utility::ManagedItem* managedItem = nullptr;
+ const dbus::utility::ManagedObjectType::value_type* managedItem = nullptr;
if (!createNewObject)
{
// if we aren't creating a new object, we should be able to find it on
@@ -818,34 +826,47 @@
{
interface = pidConfigurationIface;
}
- auto findConfig = managedItem->second.find(interface);
- if (findConfig == managedItem->second.end())
+ bool ifaceFound = false;
+ for (const auto& iface : managedItem->second)
+ {
+ if (iface.first == interface)
+ {
+ ifaceFound = true;
+ for (const auto& prop : iface.second)
+ {
+ if (prop.first == "Profiles")
+ {
+ const std::vector<std::string>* curProfiles =
+ std::get_if<std::vector<std::string>>(
+ &(prop.second));
+ if (curProfiles == nullptr)
+ {
+ BMCWEB_LOG_ERROR
+ << "Illegal profiles in managed object";
+ messages::internalError(response->res);
+ return CreatePIDRet::fail;
+ }
+ if (std::find(curProfiles->begin(),
+ curProfiles->end(),
+ profile) == curProfiles->end())
+ {
+ std::vector<std::string> newProfiles =
+ *curProfiles;
+ newProfiles.push_back(profile);
+ output["Profiles"] = newProfiles;
+ }
+ }
+ }
+ }
+ }
+
+ if (!ifaceFound)
{
BMCWEB_LOG_ERROR
<< "Failed to find interface in managed object";
messages::internalError(response->res);
return CreatePIDRet::fail;
}
- auto findProfiles = findConfig->second.find("Profiles");
- if (findProfiles != findConfig->second.end())
- {
- const std::vector<std::string>* curProfiles =
- std::get_if<std::vector<std::string>>(
- &(findProfiles->second));
- if (curProfiles == nullptr)
- {
- BMCWEB_LOG_ERROR << "Illegal profiles in managed object";
- messages::internalError(response->res);
- return CreatePIDRet::fail;
- }
- if (std::find(curProfiles->begin(), curProfiles->end(),
- profile) == curProfiles->end())
- {
- std::vector<std::string> newProfiles = *curProfiles;
- newProfiles.push_back(profile);
- output["Profiles"] = newProfiles;
- }
- }
}
}
@@ -1524,6 +1545,7 @@
BMCWEB_LOG_DEBUG << "Found = " << !createNewObject;
std::string iface;
+ /*
if (type == "PidControllers" || type == "FanControllers")
{
iface = pidConfigurationIface;
@@ -1554,7 +1576,7 @@
{
createNewObject = true;
}
- }
+ }*/
if (createNewObject && it.value() == nullptr)
{
@@ -1765,8 +1787,9 @@
// Make sure the image is valid before setting priority
crow::connections::systemBus->async_method_call(
- [aResp, firmwareId, runningFirmwareTarget](
- const boost::system::error_code ec, ManagedObjectType& subtree) {
+ [aResp, firmwareId,
+ runningFirmwareTarget](const boost::system::error_code ec,
+ dbus::utility::ManagedObjectType& subtree) {
if (ec)
{
BMCWEB_LOG_DEBUG << "D-Bus response error getting objects.";
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index a0ecdf9..c19bef5 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -37,10 +37,9 @@
const static std::array<std::pair<std::string, std::string>, 3> protocolToDBus{
{{"SSH", "dropbear"}, {"HTTPS", "bmcweb"}, {"IPMI", "phosphor-ipmi-net"}}};
-inline void
- extractNTPServersAndDomainNamesData(const GetManagedObjects& dbusData,
- std::vector<std::string>& ntpData,
- std::vector<std::string>& dnData)
+inline void extractNTPServersAndDomainNamesData(
+ const dbus::utility::ManagedObjectType& dbusData,
+ std::vector<std::string>& ntpData, std::vector<std::string>& dnData)
{
for (const auto& obj : dbusData)
{
@@ -85,7 +84,7 @@
crow::connections::systemBus->async_method_call(
[callback{std::move(callback)}](
const boost::system::error_code errorCode,
- const GetManagedObjects& dbusData) {
+ const dbus::utility::ManagedObjectType& dbusData) {
std::vector<std::string> ntpServers;
std::vector<std::string> domainNames;
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index b33f912..cdeb4a0 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -77,9 +77,9 @@
});
}
-inline void
- getCpuDataByInterface(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
- const InterfacesProperties& cpuInterfacesProperties)
+inline void getCpuDataByInterface(
+ const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const dbus::utility::DBusInteracesMap& cpuInterfacesProperties)
{
BMCWEB_LOG_DEBUG << "Get CPU resources by interface.";
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 5c86579..de0a828 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -721,13 +721,10 @@
* be nullptr if no associated inventory item was found.
* @return Health value for sensor.
*/
-inline std::string getHealth(
- nlohmann::json& sensorJson,
- const boost::container::flat_map<
- std::string, boost::container::flat_map<
- std::string, dbus::utility::DbusVariantType>>&
- interfacesDict,
- const InventoryItem* inventoryItem)
+inline std::string
+ getHealth(nlohmann::json& sensorJson,
+ const dbus::utility::DBusInteracesMap& interfacesDict,
+ const InventoryItem* inventoryItem)
{
// Get current health value (if any) in the sensor JSON object. Some JSON
// objects contain multiple sensors (such as PowerSupplies). We want to set
@@ -755,36 +752,26 @@
}
// Check if sensor has critical threshold alarm
- auto criticalThresholdIt =
- interfacesDict.find("xyz.openbmc_project.Sensor.Threshold.Critical");
- if (criticalThresholdIt != interfacesDict.end())
+
+ for (auto& [interface, values] : interfacesDict)
{
- auto thresholdHighIt =
- criticalThresholdIt->second.find("CriticalAlarmHigh");
- auto thresholdLowIt =
- criticalThresholdIt->second.find("CriticalAlarmLow");
- if (thresholdHighIt != criticalThresholdIt->second.end())
+ if (interface == "xyz.openbmc_project.Sensor.Threshold.Critical")
{
- const bool* asserted = std::get_if<bool>(&thresholdHighIt->second);
- if (asserted == nullptr)
+ for (auto& [valueName, value] : values)
{
- BMCWEB_LOG_ERROR << "Illegal sensor threshold";
- }
- else if (*asserted)
- {
- return "Critical";
- }
- }
- if (thresholdLowIt != criticalThresholdIt->second.end())
- {
- const bool* asserted = std::get_if<bool>(&thresholdLowIt->second);
- if (asserted == nullptr)
- {
- BMCWEB_LOG_ERROR << "Illegal sensor threshold";
- }
- else if (*asserted)
- {
- return "Critical";
+ if (valueName == "CriticalAlarmHigh" ||
+ valueName == "CriticalAlarmLow")
+ {
+ const bool* asserted = std::get_if<bool>(&value);
+ if (asserted == nullptr)
+ {
+ BMCWEB_LOG_ERROR << "Illegal sensor threshold";
+ }
+ else if (*asserted)
+ {
+ return "Critical";
+ }
+ }
}
}
}
@@ -803,36 +790,25 @@
}
// Check if sensor has warning threshold alarm
- auto warningThresholdIt =
- interfacesDict.find("xyz.openbmc_project.Sensor.Threshold.Warning");
- if (warningThresholdIt != interfacesDict.end())
+ for (auto& [interface, values] : interfacesDict)
{
- auto thresholdHighIt =
- warningThresholdIt->second.find("WarningAlarmHigh");
- auto thresholdLowIt =
- warningThresholdIt->second.find("WarningAlarmLow");
- if (thresholdHighIt != warningThresholdIt->second.end())
+ if (interface == "xyz.openbmc_project.Sensor.Threshold.Warning")
{
- const bool* asserted = std::get_if<bool>(&thresholdHighIt->second);
- if (asserted == nullptr)
+ for (auto& [valueName, value] : values)
{
- BMCWEB_LOG_ERROR << "Illegal sensor threshold";
- }
- else if (*asserted)
- {
- return "Warning";
- }
- }
- if (thresholdLowIt != warningThresholdIt->second.end())
- {
- const bool* asserted = std::get_if<bool>(&thresholdLowIt->second);
- if (asserted == nullptr)
- {
- BMCWEB_LOG_ERROR << "Illegal sensor threshold";
- }
- else if (*asserted)
- {
- return "Warning";
+ if (valueName == "WarningAlarmHigh" ||
+ valueName == "WarningAlarmLow")
+ {
+ const bool* asserted = std::get_if<bool>(&value);
+ if (asserted == nullptr)
+ {
+ BMCWEB_LOG_ERROR << "Illegal sensor threshold";
+ }
+ else if (*asserted)
+ {
+ return "wARNING";
+ }
+ }
}
}
}
@@ -877,31 +853,26 @@
inline void objectInterfacesToJson(
const std::string& sensorName, const std::string& sensorType,
const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
- const boost::container::flat_map<
- std::string, boost::container::flat_map<
- std::string, dbus::utility::DbusVariantType>>&
- interfacesDict,
+ const dbus::utility::DBusInteracesMap& interfacesDict,
nlohmann::json& sensorJson, InventoryItem* inventoryItem)
{
- // We need a value interface before we can do anything with it
- auto valueIt = interfacesDict.find("xyz.openbmc_project.Sensor.Value");
- if (valueIt == interfacesDict.end())
- {
- BMCWEB_LOG_ERROR << "Sensor doesn't have a value interface";
- return;
- }
-
// Assume values exist as is (10^0 == 1) if no scale exists
int64_t scaleMultiplier = 0;
-
- auto scaleIt = valueIt->second.find("Scale");
- // If a scale exists, pull value as int64, and use the scaling.
- if (scaleIt != valueIt->second.end())
+ for (auto& [interface, values] : interfacesDict)
{
- const int64_t* int64Value = std::get_if<int64_t>(&scaleIt->second);
- if (int64Value != nullptr)
+ if (interface == "xyz.openbmc_project.Sensor.Value")
{
- scaleMultiplier = *int64Value;
+ for (auto& [valueName, value] : values)
+ {
+ if (valueName == "Scale")
+ {
+ const int64_t* int64Value = std::get_if<int64_t>(&value);
+ if (int64Value != nullptr)
+ {
+ scaleMultiplier = *int64Value;
+ }
+ }
+ }
}
}
@@ -1079,14 +1050,18 @@
for (const std::tuple<const char*, const char*,
nlohmann::json::json_pointer>& p : properties)
{
- auto interfaceProperties = interfacesDict.find(std::get<0>(p));
- if (interfaceProperties != interfacesDict.end())
+ for (auto& [interface, values] : interfacesDict)
{
- auto thisValueIt = interfaceProperties->second.find(std::get<1>(p));
- if (thisValueIt != interfaceProperties->second.end())
+ if (interface != std::get<0>(p))
{
- const dbus::utility::DbusVariantType& valueVariant =
- thisValueIt->second;
+ continue;
+ }
+ for (auto& [valueName, valueVariant] : values)
+ {
+ if (valueName != std::get<1>(p))
+ {
+ continue;
+ }
// The property we want to set may be nested json, so use
// a json_pointer for easy indexing into the json structure.
@@ -1480,97 +1455,90 @@
*/
inline void storeInventoryItemData(
InventoryItem& inventoryItem,
- const boost::container::flat_map<
- std::string, boost::container::flat_map<
- std::string, dbus::utility::DbusVariantType>>&
- interfacesDict)
+ const dbus::utility::DBusInteracesMap& interfacesDict)
{
// Get properties from Inventory.Item interface
- auto interfaceIt =
- interfacesDict.find("xyz.openbmc_project.Inventory.Item");
- if (interfaceIt != interfacesDict.end())
+
+ for (auto& [interface, values] : interfacesDict)
{
- auto propertyIt = interfaceIt->second.find("Present");
- if (propertyIt != interfaceIt->second.end())
+ if (interface == "xyz.openbmc_project.Inventory.Item")
{
- const bool* value = std::get_if<bool>(&propertyIt->second);
- if (value != nullptr)
+ for (auto& [name, dbusValue] : values)
{
- inventoryItem.isPresent = *value;
+ if (name == "Present")
+ {
+ const bool* value = std::get_if<bool>(&dbusValue);
+ if (value != nullptr)
+ {
+ inventoryItem.isPresent = *value;
+ }
+ }
}
}
- }
+ // Check if Inventory.Item.PowerSupply interface is present
- // Check if Inventory.Item.PowerSupply interface is present
- interfaceIt =
- interfacesDict.find("xyz.openbmc_project.Inventory.Item.PowerSupply");
- if (interfaceIt != interfacesDict.end())
- {
- inventoryItem.isPowerSupply = true;
- }
-
- // Get properties from Inventory.Decorator.Asset interface
- interfaceIt =
- interfacesDict.find("xyz.openbmc_project.Inventory.Decorator.Asset");
- if (interfaceIt != interfacesDict.end())
- {
- auto propertyIt = interfaceIt->second.find("Manufacturer");
- if (propertyIt != interfaceIt->second.end())
+ if (interface == "xyz.openbmc_project.Inventory.Item.PowerSupply")
{
- const std::string* value =
- std::get_if<std::string>(&propertyIt->second);
- if (value != nullptr)
+ inventoryItem.isPowerSupply = true;
+ }
+
+ // Get properties from Inventory.Decorator.Asset interface
+ if (interface == "xyz.openbmc_project.Inventory.Decorator.Asset")
+ {
+ for (auto& [name, dbusValue] : values)
{
- inventoryItem.manufacturer = *value;
+ if (name == "Manufacturer")
+ {
+ const std::string* value =
+ std::get_if<std::string>(&dbusValue);
+ if (value != nullptr)
+ {
+ inventoryItem.manufacturer = *value;
+ }
+ }
+ if (name == "Model")
+ {
+ const std::string* value =
+ std::get_if<std::string>(&dbusValue);
+ if (value != nullptr)
+ {
+ inventoryItem.model = *value;
+ }
+ }
+ if (name == "SerialNumber")
+ {
+ const std::string* value =
+ std::get_if<std::string>(&dbusValue);
+ if (value != nullptr)
+ {
+ inventoryItem.serialNumber = *value;
+ }
+ }
+ if (name == "PartNumber")
+ {
+ const std::string* value =
+ std::get_if<std::string>(&dbusValue);
+ if (value != nullptr)
+ {
+ inventoryItem.partNumber = *value;
+ }
+ }
}
}
- propertyIt = interfaceIt->second.find("Model");
- if (propertyIt != interfaceIt->second.end())
+ if (interface ==
+ "xyz.openbmc_project.State.Decorator.OperationalStatus")
{
- const std::string* value =
- std::get_if<std::string>(&propertyIt->second);
- if (value != nullptr)
+ for (auto& [name, dbusValue] : values)
{
- inventoryItem.model = *value;
- }
- }
-
- propertyIt = interfaceIt->second.find("PartNumber");
- if (propertyIt != interfaceIt->second.end())
- {
- const std::string* value =
- std::get_if<std::string>(&propertyIt->second);
- if (value != nullptr)
- {
- inventoryItem.partNumber = *value;
- }
- }
-
- propertyIt = interfaceIt->second.find("SerialNumber");
- if (propertyIt != interfaceIt->second.end())
- {
- const std::string* value =
- std::get_if<std::string>(&propertyIt->second);
- if (value != nullptr)
- {
- inventoryItem.serialNumber = *value;
- }
- }
- }
-
- // Get properties from State.Decorator.OperationalStatus interface
- interfaceIt = interfacesDict.find(
- "xyz.openbmc_project.State.Decorator.OperationalStatus");
- if (interfaceIt != interfacesDict.end())
- {
- auto propertyIt = interfaceIt->second.find("Functional");
- if (propertyIt != interfaceIt->second.end())
- {
- const bool* value = std::get_if<bool>(&propertyIt->second);
- if (value != nullptr)
- {
- inventoryItem.isFunctional = *value;
+ if (name == "Functional")
+ {
+ const bool* value = std::get_if<bool>(&dbusValue);
+ if (value != nullptr)
+ {
+ inventoryItem.isFunctional = *value;
+ }
+ }
}
}
}
@@ -1637,7 +1605,7 @@
objectMgrPaths, callback{std::move(callback)},
invConnectionsIndex](
const boost::system::error_code ec,
- ManagedObjectsVectorType& resp) {
+ dbus::utility::ManagedObjectType& resp) {
BMCWEB_LOG_DEBUG << "getInventoryItemsData respHandler enter";
if (ec)
{
@@ -1828,10 +1796,6 @@
{
const std::string& objPath =
static_cast<const std::string&>(objDictEntry.first);
- const boost::container::flat_map<
- std::string, boost::container::flat_map<
- std::string, dbus::utility::DbusVariantType>>&
- interfacesDict = objDictEntry.second;
// If path is inventory association for one of the specified sensors
for (const std::string& sensorName : *sensorNames)
@@ -1841,24 +1805,28 @@
if (objPath == sensorAssocPath)
{
// Get Association interface for object path
- auto assocIt =
- interfacesDict.find("xyz.openbmc_project.Association");
- if (assocIt != interfacesDict.end())
+ for (const auto& [interface, values] : objDictEntry.second)
{
- // Get inventory item from end point
- auto endpointsIt = assocIt->second.find("endpoints");
- if (endpointsIt != assocIt->second.end())
+ if (interface == "xyz.openbmc_project.Association")
{
- const std::vector<std::string>* endpoints =
- std::get_if<std::vector<std::string>>(
- &endpointsIt->second);
- if ((endpoints != nullptr) && !endpoints->empty())
+ for (const auto& [valueName, value] : values)
{
- // Add inventory item to vector
- const std::string& invItemPath =
- endpoints->front();
- addInventoryItem(inventoryItems, invItemPath,
- sensorName);
+ if (valueName == "endpoints")
+ {
+ const std::vector<std::string>* endpoints =
+ std::get_if<std::vector<std::string>>(
+ &value);
+ if ((endpoints != nullptr) &&
+ !endpoints->empty())
+ {
+ // Add inventory item to vector
+ const std::string& invItemPath =
+ endpoints->front();
+ addInventoryItem(inventoryItems,
+ invItemPath,
+ sensorName);
+ }
+ }
}
}
}
@@ -1875,10 +1843,6 @@
{
const std::string& objPath =
static_cast<const std::string&>(objDictEntry.first);
- const boost::container::flat_map<
- std::string, boost::container::flat_map<
- std::string, dbus::utility::DbusVariantType>>&
- interfacesDict = objDictEntry.second;
for (InventoryItem& inventoryItem : *inventoryItems)
{
@@ -1886,26 +1850,31 @@
inventoryAssocPath += "/leds";
if (objPath == inventoryAssocPath)
{
- // Get Association interface for object path
- auto assocIt =
- interfacesDict.find("xyz.openbmc_project.Association");
- if (assocIt != interfacesDict.end())
+ for (const auto& [interface, values] : objDictEntry.second)
{
- // Get inventory item from end point
- auto endpointsIt = assocIt->second.find("endpoints");
- if (endpointsIt != assocIt->second.end())
+ if (interface == "xyz.openbmc_project.Association")
{
- const std::vector<std::string>* endpoints =
- std::get_if<std::vector<std::string>>(
- &endpointsIt->second);
- if ((endpoints != nullptr) && !endpoints->empty())
+ for (const auto& [valueName, value] : values)
{
- // Store LED path in inventory item
- const std::string& ledPath = endpoints->front();
- inventoryItem.ledObjectPath = ledPath;
+ if (valueName == "endpoints")
+ {
+ const std::vector<std::string>* endpoints =
+ std::get_if<std::vector<std::string>>(
+ &value);
+ if ((endpoints != nullptr) &&
+ !endpoints->empty())
+ {
+ // Add inventory item to vector
+ // Store LED path in inventory item
+ const std::string& ledPath =
+ endpoints->front();
+ inventoryItem.ledObjectPath = ledPath;
+ }
+ }
}
}
}
+
break;
}
}
@@ -2496,7 +2465,7 @@
auto getManagedObjectsCb = [sensorsAsyncResp, sensorNames,
inventoryItems](
const boost::system::error_code ec,
- ManagedObjectsVectorType& resp) {
+ dbus::utility::ManagedObjectType& resp) {
BMCWEB_LOG_DEBUG << "getManagedObjectsCb enter";
if (ec)
{
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 5f56e35..f820e61 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -331,65 +331,66 @@
{
if (interface.first == "xyz.openbmc_project.Logging.Entry")
{
- BMCWEB_LOG_DEBUG << "Error Match fired";
- const dbus::utility::DBusPropertiesMap& values =
- interface.second;
- auto find = values.find("Message");
- if (find == values.end())
+ for (const std::pair<std::string,
+ dbus::utility::DbusVariantType>&
+ value : interface.second)
{
- return;
- }
- const std::string* type =
- std::get_if<std::string>(&(find->second));
- if (type == nullptr)
- {
- // if this was our message, timeout will cover it
- return;
- }
- fwAvailableTimer = nullptr;
- if (*type ==
- "xyz.openbmc_project.Software.Image.Error.UnTarFailure")
- {
- redfish::messages::invalidUpload(asyncResp->res, url,
- "Invalid archive");
- }
- else if (*type ==
- "xyz.openbmc_project.Software.Image.Error."
- "ManifestFileFailure")
- {
- redfish::messages::invalidUpload(asyncResp->res, url,
- "Invalid manifest");
- }
- else if (
- *type ==
- "xyz.openbmc_project.Software.Image.Error.ImageFailure")
- {
- redfish::messages::invalidUpload(
- asyncResp->res, url, "Invalid image format");
- }
- else if (
- *type ==
- "xyz.openbmc_project.Software.Version.Error.AlreadyExists")
- {
- redfish::messages::invalidUpload(
- asyncResp->res, url,
- "Image version already exists");
+ if (value.first != "Message")
+ {
+ continue;
+ }
+ const std::string* type =
+ std::get_if<std::string>(&value.second);
+ if (type == nullptr)
+ {
+ // if this was our message, timeout will cover it
+ return;
+ }
+ fwAvailableTimer = nullptr;
+ if (*type ==
+ "xyz.openbmc_project.Software.Image.Error.UnTarFailure")
+ {
+ redfish::messages::invalidUpload(
+ asyncResp->res, url, "Invalid archive");
+ }
+ else if (*type ==
+ "xyz.openbmc_project.Software.Image.Error."
+ "ManifestFileFailure")
+ {
+ redfish::messages::invalidUpload(
+ asyncResp->res, url, "Invalid manifest");
+ }
+ else if (
+ *type ==
+ "xyz.openbmc_project.Software.Image.Error.ImageFailure")
+ {
+ redfish::messages::invalidUpload(
+ asyncResp->res, url, "Invalid image format");
+ }
+ else if (
+ *type ==
+ "xyz.openbmc_project.Software.Version.Error.AlreadyExists")
+ {
+ redfish::messages::invalidUpload(
+ asyncResp->res, url,
+ "Image version already exists");
- redfish::messages::resourceAlreadyExists(
- asyncResp->res,
- "UpdateService.v1_5_0.UpdateService", "Version",
- "uploaded version");
- }
- else if (
- *type ==
- "xyz.openbmc_project.Software.Image.Error.BusyFailure")
- {
- redfish::messages::resourceExhaustion(asyncResp->res,
- url);
- }
- else
- {
- redfish::messages::internalError(asyncResp->res);
+ redfish::messages::resourceAlreadyExists(
+ asyncResp->res,
+ "UpdateService.v1_5_0.UpdateService", "Version",
+ "uploaded version");
+ }
+ else if (
+ *type ==
+ "xyz.openbmc_project.Software.Image.Error.BusyFailure")
+ {
+ redfish::messages::resourceExhaustion(
+ asyncResp->res, url);
+ }
+ else
+ {
+ redfish::messages::internalError(asyncResp->res);
+ }
}
}
}
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index 747ca43..844b60d 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -57,71 +57,36 @@
* @brief Read all known properties from VM object interfaces
*/
inline void
- vmParseInterfaceObject(const DbusInterfaceType& interface,
+ vmParseInterfaceObject(const dbus::utility::DBusInteracesMap& interface,
const std::shared_ptr<bmcweb::AsyncResp>& aResp)
{
- const auto mountPointIface =
- interface.find("xyz.openbmc_project.VirtualMedia.MountPoint");
- if (mountPointIface == interface.cend())
+ for (const auto& [interface, values] : interface)
{
- BMCWEB_LOG_DEBUG << "Interface MountPoint not found";
- return;
- }
-
- const auto processIface =
- interface.find("xyz.openbmc_project.VirtualMedia.Process");
- if (processIface == interface.cend())
- {
- BMCWEB_LOG_DEBUG << "Interface Process not found";
- return;
- }
-
- const auto endpointIdProperty = mountPointIface->second.find("EndpointId");
- if (endpointIdProperty == mountPointIface->second.cend())
- {
- BMCWEB_LOG_DEBUG << "Property EndpointId not found";
- return;
- }
-
- const auto activeProperty = processIface->second.find("Active");
- if (activeProperty == processIface->second.cend())
- {
- BMCWEB_LOG_DEBUG << "Property Active not found";
- return;
- }
-
- const bool* activeValue = std::get_if<bool>(&activeProperty->second);
- if (!activeValue)
- {
- BMCWEB_LOG_DEBUG << "Value Active not found";
- return;
- }
-
- const std::string* endpointIdValue =
- std::get_if<std::string>(&endpointIdProperty->second);
- if (endpointIdValue)
- {
- if (!endpointIdValue->empty())
+ if (interface == "xyz.openbmc_project.VirtualMedia.MountPoint")
{
- // Proxy mode
- aResp->res.jsonValue["Oem"]["OpenBMC"]["WebSocketEndpoint"] =
- *endpointIdValue;
- aResp->res.jsonValue["TransferProtocolType"] = "OEM";
- aResp->res.jsonValue["Inserted"] = *activeValue;
- if (*activeValue == true)
+ for (const auto& [property, value] : values)
{
- aResp->res.jsonValue["ConnectedVia"] = "Applet";
- }
- }
- else
- {
- // Legacy mode
- for (const auto& property : mountPointIface->second)
- {
- if (property.first == "ImageURL")
+ if (property == "EndpointId")
+ {
+ const std::string* endpointIdValue =
+ std::get_if<std::string>(&value);
+ if (endpointIdValue == nullptr)
+ {
+ continue;
+ }
+ if (!endpointIdValue->empty())
+ {
+ // Proxy mode
+ aResp->res
+ .jsonValue["Oem"]["OpenBMC"]["WebSocketEndpoint"] =
+ *endpointIdValue;
+ aResp->res.jsonValue["TransferProtocolType"] = "OEM";
+ }
+ }
+ if (property == "ImageURL")
{
const std::string* imageUrlValue =
- std::get_if<std::string>(&property.second);
+ std::get_if<std::string>(&value);
if (imageUrlValue && !imageUrlValue->empty())
{
std::filesystem::path filePath = *imageUrlValue;
@@ -138,20 +103,15 @@
}
aResp->res.jsonValue["Image"] = *imageUrlValue;
- aResp->res.jsonValue["Inserted"] = *activeValue;
aResp->res.jsonValue["TransferProtocolType"] =
getTransferProtocolTypeFromUri(*imageUrlValue);
- if (*activeValue == true)
- {
- aResp->res.jsonValue["ConnectedVia"] = "URI";
- }
+ aResp->res.jsonValue["ConnectedVia"] = "URI";
}
}
- else if (property.first == "WriteProtected")
+ if (property == "WriteProtected")
{
- const bool* writeProtectedValue =
- std::get_if<bool>(&property.second);
+ const bool* writeProtectedValue = std::get_if<bool>(&value);
if (writeProtectedValue)
{
aResp->res.jsonValue["WriteProtected"] =
@@ -160,6 +120,27 @@
}
}
}
+ if (interface == "xyz.openbmc_project.VirtualMedia.Process")
+ {
+ for (const auto& [property, value] : values)
+ {
+ if (property == "Active")
+ {
+ const bool* activeValue = std::get_if<bool>(&value);
+ if (!activeValue)
+ {
+ BMCWEB_LOG_DEBUG << "Value Active not found";
+ return;
+ }
+ aResp->res.jsonValue["Inserted"] = *activeValue;
+
+ if (*activeValue == true)
+ {
+ aResp->res.jsonValue["ConnectedVia"] = "Applet";
+ }
+ }
+ }
+ }
}
}
@@ -198,8 +179,9 @@
{
BMCWEB_LOG_DEBUG << "Get available Virtual Media resources.";
crow::connections::systemBus->async_method_call(
- [name, aResp{std::move(aResp)}](const boost::system::error_code ec,
- ManagedObjectType& subtree) {
+ [name,
+ aResp{std::move(aResp)}](const boost::system::error_code ec,
+ dbus::utility::ManagedObjectType& subtree) {
if (ec)
{
BMCWEB_LOG_DEBUG << "DBUS response error";
@@ -242,7 +224,7 @@
crow::connections::systemBus->async_method_call(
[resName, name, aResp](const boost::system::error_code ec,
- ManagedObjectType& subtree) {
+ dbus::utility::ManagedObjectType& subtree) {
if (ec)
{
BMCWEB_LOG_DEBUG << "DBUS response error";
@@ -849,7 +831,8 @@
crow::connections::systemBus->async_method_call(
[service, resName, actionParams,
asyncResp](const boost::system::error_code ec,
- ManagedObjectType& subtree) mutable {
+ dbus::utility::ManagedObjectType&
+ subtree) mutable {
if (ec)
{
BMCWEB_LOG_DEBUG << "DBUS response error";
@@ -955,7 +938,7 @@
crow::connections::systemBus->async_method_call(
[resName, service, asyncResp{asyncResp}](
const boost::system::error_code ec,
- ManagedObjectType& subtree) {
+ dbus::utility::ManagedObjectType& subtree) {
if (ec)
{
BMCWEB_LOG_DEBUG << "DBUS response error";