bmcweb: move variant usage to std namespace
Change-Id: I9d7069668f91f2ac72d2f4a440f63e0e85dd5269
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 8958290..d9388cf 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -19,6 +19,7 @@
#include <error_messages.hpp>
#include <openbmc_dbus_rest.hpp>
#include <utils/json_utils.hpp>
+#include <variant>
namespace redfish
{
@@ -26,9 +27,8 @@
using ManagedObjectType = std::vector<std::pair<
sdbusplus::message::object_path,
boost::container::flat_map<
- std::string,
- boost::container::flat_map<
- std::string, sdbusplus::message::variant<bool, std::string>>>>>;
+ std::string, boost::container::flat_map<
+ std::string, std::variant<bool, std::string>>>>>;
inline std::string getPrivilegeFromRoleId(boost::beast::string_view role)
{
@@ -110,8 +110,7 @@
[asyncResp](
const boost::system::error_code ec,
const std::vector<std::pair<
- std::string,
- sdbusplus::message::variant<uint32_t, uint16_t, uint8_t>>>&
+ std::string, std::variant<uint32_t, uint16_t, uint8_t>>>&
propertiesList) {
if (ec)
{
@@ -121,15 +120,13 @@
BMCWEB_LOG_DEBUG << "Got " << propertiesList.size()
<< "properties for AccountService";
for (const std::pair<std::string,
- sdbusplus::message::variant<
- uint32_t, uint16_t, uint8_t>>&
+ std::variant<uint32_t, uint16_t, uint8_t>>&
property : propertiesList)
{
if (property.first == "MinPasswordLength")
{
const uint8_t* value =
- sdbusplus::message::variant_ns::get_if<uint8_t>(
- &property.second);
+ std::get_if<uint8_t>(&property.second);
if (value != nullptr)
{
asyncResp->res.jsonValue["MinPasswordLength"] =
@@ -139,8 +136,7 @@
if (property.first == "AccountUnlockTimeout")
{
const uint32_t* value =
- sdbusplus::message::variant_ns::get_if<uint32_t>(
- &property.second);
+ std::get_if<uint32_t>(&property.second);
if (value != nullptr)
{
asyncResp->res.jsonValue["AccountLockoutDuration"] =
@@ -150,8 +146,7 @@
if (property.first == "MaxLoginAttemptBeforeLockout")
{
const uint16_t* value =
- sdbusplus::message::variant_ns::get_if<uint16_t>(
- &property.second);
+ std::get_if<uint16_t>(&property.second);
if (value != nullptr)
{
asyncResp->res
@@ -190,8 +185,7 @@
"xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.User.AccountPolicy",
- "AccountUnlockTimeout",
- sdbusplus::message::variant<uint32_t>(*unlockTimeout));
+ "AccountUnlockTimeout", std::variant<uint32_t>(*unlockTimeout));
}
if (lockoutThreshold)
{
@@ -207,7 +201,7 @@
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.User.AccountPolicy",
"MaxLoginAttemptBeforeLockout",
- sdbusplus::message::variant<uint16_t>(*lockoutThreshold));
+ std::variant<uint16_t>(*lockoutThreshold));
}
}
};
@@ -435,8 +429,7 @@
if (property.first == "UserEnabled")
{
const bool* userEnabled =
- sdbusplus::message::variant_ns::get_if<
- bool>(&property.second);
+ std::get_if<bool>(&property.second);
if (userEnabled == nullptr)
{
BMCWEB_LOG_ERROR
@@ -451,8 +444,7 @@
"UserLockedForFailedAttempt")
{
const bool* userLocked =
- sdbusplus::message::variant_ns::get_if<
- bool>(&property.second);
+ std::get_if<bool>(&property.second);
if (userLocked == nullptr)
{
BMCWEB_LOG_ERROR << "UserLockedForF"
@@ -467,8 +459,7 @@
else if (property.first == "UserPrivilege")
{
const std::string* userRolePtr =
- sdbusplus::message::variant_ns::get_if<
- std::string>(&property.second);
+ std::get_if<std::string>(&property.second);
if (userRolePtr == nullptr)
{
BMCWEB_LOG_ERROR
@@ -594,7 +585,7 @@
"/xyz/openbmc_project/user/" + username,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.User.Attributes", "UserEnabled",
- sdbusplus::message::variant<bool>{*enabled});
+ std::variant<bool>{*enabled});
}
if (roleId)
@@ -621,7 +612,7 @@
"/xyz/openbmc_project/user/" + username,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.User.Attributes", "UserPrivilege",
- sdbusplus::message::variant<std::string>{priv});
+ std::variant<std::string>{priv});
}
}
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index fe6cdef..fd03c8f 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -18,6 +18,7 @@
#include "node.hpp"
#include <boost/container/flat_map.hpp>
+#include <variant>
namespace redfish
{
@@ -29,7 +30,7 @@
// Note, this is not a very useful Variant, but because it isn't used to get
// values, it should be as simple as possible
// TODO(ed) invent a nullvariant type
-using VariantType = sdbusplus::message::variant<bool, std::string, uint64_t>;
+using VariantType = std::variant<bool, std::string, uint64_t>;
using ManagedObjectsType = std::vector<std::pair<
sdbusplus::message::object_path,
std::vector<std::pair<std::string,
@@ -201,8 +202,7 @@
&property : propertiesList)
{
const std::string *value =
- sdbusplus::message::variant_ns::get_if<
- std::string>(&property.second);
+ std::get_if<std::string>(&property.second);
if (value != nullptr)
{
asyncResp->res.jsonValue[property.first] =
diff --git a/redfish-core/lib/cpudimm.hpp b/redfish-core/lib/cpudimm.hpp
index c57394a..1719fc8 100644
--- a/redfish-core/lib/cpudimm.hpp
+++ b/redfish-core/lib/cpudimm.hpp
@@ -18,6 +18,7 @@
#include <boost/container/flat_map.hpp>
#include <node.hpp>
#include <utils/json_utils.hpp>
+#include <variant>
namespace redfish
{
@@ -72,8 +73,7 @@
[name, cpuId, aResp{std::move(aResp)}](
const boost::system::error_code ec,
const boost::container::flat_map<
- std::string,
- sdbusplus::message::variant<std::string, uint32_t, uint16_t>>
+ std::string, std::variant<std::string, uint32_t, uint16_t>>
&properties) {
if (ec)
{
@@ -89,8 +89,7 @@
if (coresCountProperty != properties.end())
{
const uint16_t *coresCount =
- sdbusplus::message::variant_ns::get_if<uint16_t>(
- &coresCountProperty->second);
+ std::get_if<uint16_t>(&coresCountProperty->second);
if (coresCount == nullptr)
{
// Important property not in desired type
@@ -122,8 +121,7 @@
{
aResp->res.jsonValue["Manufacturer"] = property.second;
const std::string *value =
- sdbusplus::message::variant_ns::get_if<std::string>(
- &property.second);
+ std::get_if<std::string>(&property.second);
if (value != nullptr)
{
// Otherwise would be unexpected.
@@ -208,8 +206,7 @@
[name, dimmId, aResp{std::move(aResp)}](
const boost::system::error_code ec,
const boost::container::flat_map<
- std::string,
- sdbusplus::message::variant<std::string, uint32_t, uint16_t>>
+ std::string, std::variant<std::string, uint32_t, uint16_t>>
&properties) {
if (ec)
{
@@ -225,8 +222,7 @@
if (memorySizeProperty != properties.end())
{
const uint32_t *memorySize =
- sdbusplus::message::variant_ns::get_if<uint32_t>(
- &memorySizeProperty->second);
+ std::get_if<uint32_t>(&memorySizeProperty->second);
if (memorySize == nullptr)
{
// Important property not in desired type
@@ -256,8 +252,7 @@
else if (property.first == "MemoryType")
{
const auto *value =
- sdbusplus::message::variant_ns::get_if<std::string>(
- &property.second);
+ std::get_if<std::string>(&property.second);
if (value != nullptr)
{
aResp->res.jsonValue["MemoryDeviceType"] = *value;
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index e861fb8..9147585 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -22,6 +22,7 @@
#include <node.hpp>
#include <optional>
#include <utils/json_utils.hpp>
+#include <variant>
namespace redfish
{
@@ -31,18 +32,17 @@
* TODO(Pawel) consider move this to separate file into boost::dbus
*/
using PropertiesMapType = boost::container::flat_map<
- std::string,
- sdbusplus::message::variant<std::string, bool, uint8_t, int16_t, uint16_t,
- int32_t, uint32_t, int64_t, uint64_t, double>>;
+ std::string, std::variant<std::string, bool, uint8_t, int16_t, uint16_t,
+ int32_t, uint32_t, int64_t, uint64_t, double>>;
using GetManagedObjects = std::vector<std::pair<
sdbusplus::message::object_path,
std::vector<std::pair<
std::string,
boost::container::flat_map<
- std::string, sdbusplus::message::variant<
- std::string, bool, uint8_t, int16_t, uint16_t,
- int32_t, uint32_t, int64_t, uint64_t, double>>>>>>;
+ std::string,
+ std::variant<std::string, bool, uint8_t, int16_t, uint16_t, int32_t,
+ uint32_t, int64_t, uint64_t, double>>>>>>;
enum class LinkType
{
@@ -171,8 +171,7 @@
if (propertyPair.first == "MACAddress")
{
const std::string *mac =
- sdbusplus::message::variant_ns::get_if<
- std::string>(&propertyPair.second);
+ std::get_if<std::string>(&propertyPair.second);
if (mac != nullptr)
{
ethData.mac_address = *mac;
@@ -187,8 +186,7 @@
if (propertyPair.first == "Id")
{
const uint32_t *id =
- sdbusplus::message::variant_ns::get_if<
- uint32_t>(&propertyPair.second);
+ std::get_if<uint32_t>(&propertyPair.second);
if (id != nullptr)
{
ethData.vlan_id = *id;
@@ -204,8 +202,7 @@
if (propertyPair.first == "AutoNeg")
{
const bool *auto_neg =
- sdbusplus::message::variant_ns::get_if<bool>(
- &propertyPair.second);
+ std::get_if<bool>(&propertyPair.second);
if (auto_neg != nullptr)
{
ethData.auto_neg = *auto_neg;
@@ -214,8 +211,7 @@
else if (propertyPair.first == "Speed")
{
const uint32_t *speed =
- sdbusplus::message::variant_ns::get_if<
- uint32_t>(&propertyPair.second);
+ std::get_if<uint32_t>(&propertyPair.second);
if (speed != nullptr)
{
ethData.speed = *speed;
@@ -231,8 +227,7 @@
if (propertyPair.first == "HostName")
{
const std::string *hostname =
- sdbusplus::message::variant_ns::get_if<
- std::string>(&propertyPair.second);
+ std::get_if<std::string>(&propertyPair.second);
if (hostname != nullptr)
{
ethData.hostname = *hostname;
@@ -241,8 +236,7 @@
else if (propertyPair.first == "DefaultGateway")
{
const std::string *defaultGateway =
- sdbusplus::message::variant_ns::get_if<
- std::string>(&propertyPair.second);
+ std::get_if<std::string>(&propertyPair.second);
if (defaultGateway != nullptr)
{
ethData.default_gateway = *defaultGateway;
@@ -288,8 +282,7 @@
if (property.first == "Address")
{
const std::string *address =
- sdbusplus::message::variant_ns::get_if<
- std::string>(&property.second);
+ std::get_if<std::string>(&property.second);
if (address != nullptr)
{
ipv4_address.address = *address;
@@ -298,8 +291,7 @@
else if (property.first == "Gateway")
{
const std::string *gateway =
- sdbusplus::message::variant_ns::get_if<
- std::string>(&property.second);
+ std::get_if<std::string>(&property.second);
if (gateway != nullptr)
{
ipv4_address.gateway = *gateway;
@@ -308,8 +300,7 @@
else if (property.first == "Origin")
{
const std::string *origin =
- sdbusplus::message::variant_ns::get_if<
- std::string>(&property.second);
+ std::get_if<std::string>(&property.second);
if (origin != nullptr)
{
ipv4_address.origin =
@@ -320,8 +311,7 @@
else if (property.first == "PrefixLength")
{
const uint8_t *mask =
- sdbusplus::message::variant_ns::get_if<uint8_t>(
- &property.second);
+ std::get_if<uint8_t>(&property.second);
if (mask != nullptr)
{
// convert it to the string
@@ -364,7 +354,7 @@
std::string("/xyz/openbmc_project/network/") + ifaceId,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.VLAN", "Id",
- sdbusplus::message::variant<uint32_t>(inputVlanId));
+ std::variant<uint32_t>(inputVlanId));
}
/**
@@ -496,7 +486,7 @@
"/xyz/openbmc_project/network/" + ifaceId + "/ipv4/" + ipHash,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.IP", name,
- sdbusplus::message::variant<std::string>(newValue));
+ std::variant<std::string>(newValue));
}
/**
@@ -537,7 +527,7 @@
"/xyz/openbmc_project/network/" + ifaceId + "/ipv4/" + ipHash,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.IP", "Origin",
- sdbusplus::message::variant<std::string>(newValueDbus));
+ std::variant<std::string>(newValueDbus));
}
/**
@@ -577,7 +567,7 @@
"/xyz/openbmc_project/network/" + ifaceId + "/ipv4/" + ipHash,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.IP", "PrefixLength",
- sdbusplus::message::variant<uint8_t>(newValue));
+ std::variant<uint8_t>(newValue));
}
/**
@@ -865,7 +855,7 @@
"/xyz/openbmc_project/network/" + ifaceId,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.VLAN", "Id",
- sdbusplus::message::variant<uint32_t>(vlanId));
+ std::variant<uint32_t>(vlanId));
}
else
{
@@ -901,7 +891,7 @@
"/xyz/openbmc_project/network/config",
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.SystemConfiguration", "HostName",
- sdbusplus::message::variant<std::string>(hostname));
+ std::variant<std::string>(hostname));
}
void handleIPv4Patch(
@@ -1090,8 +1080,7 @@
"/ipv4/" + thisData->id,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.IP", "Address",
- sdbusplus::message::variant<std::string>(
- *addressField));
+ std::variant<std::string>(*addressField));
}
if (prefixLength && subnetField != nullptr)
@@ -1132,8 +1121,7 @@
"/ipv4/" + thisData->id,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.IP", "Gateway",
- sdbusplus::message::variant<std::string>(
- *gatewayField));
+ std::variant<std::string>(*gatewayField));
}
}
thisData++;
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 5e64ec0..ce5b97f 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -22,6 +22,7 @@
#include <boost/container/flat_map.hpp>
#include <boost/utility/string_view.hpp>
+#include <variant>
namespace redfish
{
@@ -1090,45 +1091,41 @@
return;
}
const uint8_t logId = std::atoi(params[0].c_str());
- auto getStoredLogCallback =
- [asyncResp,
- logId](const boost::system::error_code ec,
- const sdbusplus::message::variant<std::string> &resp) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG << "failed to get log ec: "
- << ec.message();
- messages::internalError(asyncResp->res);
- return;
- }
- const std::string *log =
- sdbusplus::message::variant_ns::get_if<std::string>(&resp);
- if (log == nullptr)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- nlohmann::json j = nlohmann::json::parse(*log, nullptr, false);
- if (j.is_discarded())
- {
- messages::internalError(asyncResp->res);
- return;
- }
- std::string t = getLogCreatedTime(j);
- asyncResp->res.jsonValue = {
- {"@odata.type", "#LogEntry.v1_3_0.LogEntry"},
- {"@odata.context",
- "/redfish/v1/$metadata#LogEntry.LogEntry"},
- {"@odata.id",
- "/redfish/v1/Managers/bmc/LogServices/CpuLog/Entries/" +
- std::to_string(logId)},
- {"Name", "CPU Debug Log"},
- {"Id", logId},
- {"EntryType", "Oem"},
- {"OemRecordFormat", "Intel CPU Log"},
- {"Oem", {{"Intel", std::move(j)}}},
- {"Created", std::move(t)}};
- };
+ auto getStoredLogCallback = [asyncResp, logId](
+ const boost::system::error_code ec,
+ const std::variant<std::string> &resp) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << "failed to get log ec: " << ec.message();
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ const std::string *log = std::get_if<std::string>(&resp);
+ if (log == nullptr)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ nlohmann::json j = nlohmann::json::parse(*log, nullptr, false);
+ if (j.is_discarded())
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ std::string t = getLogCreatedTime(j);
+ asyncResp->res.jsonValue = {
+ {"@odata.type", "#LogEntry.v1_3_0.LogEntry"},
+ {"@odata.context", "/redfish/v1/$metadata#LogEntry.LogEntry"},
+ {"@odata.id",
+ "/redfish/v1/Managers/bmc/LogServices/CpuLog/Entries/" +
+ std::to_string(logId)},
+ {"Name", "CPU Debug Log"},
+ {"Id", logId},
+ {"EntryType", "Oem"},
+ {"OemRecordFormat", "Intel CPU Log"},
+ {"Oem", {{"Intel", std::move(j)}}},
+ {"Created", std::move(t)}};
+ };
crow::connections::systemBus->async_method_call(
std::move(getStoredLogCallback), cpuLogObject,
cpuLogPath + std::string("/") + std::to_string(logId),
@@ -1199,14 +1196,12 @@
}
sdbusplus::message::object_path objPath;
boost::container::flat_map<
- std::string,
- boost::container::flat_map<
- std::string, sdbusplus::message::variant<std::string>>>
+ std::string, boost::container::flat_map<
+ std::string, std::variant<std::string>>>
interfacesAdded;
m.read(objPath, interfacesAdded);
- const std::string *log =
- sdbusplus::message::variant_ns::get_if<std::string>(
- &interfacesAdded[cpuLogInterface]["Log"]);
+ const std::string *log = std::get_if<std::string>(
+ &interfacesAdded[cpuLogInterface]["Log"]);
if (log == nullptr)
{
messages::internalError(asyncResp->res);
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index d0b2cc8..33ac72c 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -19,6 +19,7 @@
#include <boost/algorithm/string/replace.hpp>
#include <dbus_utility.hpp>
+#include <variant>
namespace redfish
{
@@ -184,8 +185,7 @@
return;
}
const std::string* namePtr =
- sdbusplus::message::variant_ns::get_if<std::string>(
- &findName->second);
+ std::get_if<std::string>(&findName->second);
if (namePtr == nullptr)
{
BMCWEB_LOG_ERROR << "Pid Name Field illegal";
@@ -240,8 +240,8 @@
auto findClass = intfPair.second.find("Class");
if (findClass != intfPair.second.end())
{
- classPtr = sdbusplus::message::variant_ns::get_if<
- std::string>(&findClass->second);
+ classPtr =
+ std::get_if<std::string>(&findClass->second);
}
if (classPtr == nullptr)
{
@@ -303,8 +303,7 @@
if (intfPair.first == pidZoneConfigurationIface)
{
const double* ptr =
- sdbusplus::message::variant_ns::get_if<double>(
- &propertyPair.second);
+ std::get_if<double>(&propertyPair.second);
if (ptr == nullptr)
{
BMCWEB_LOG_ERROR << "Field Illegal "
@@ -321,8 +320,7 @@
propertyPair.first == "Output")
{
const std::vector<double>* ptr =
- sdbusplus::message::variant_ns::get_if<
- std::vector<double>>(
+ std::get_if<std::vector<double>>(
&propertyPair.second);
if (ptr == nullptr)
@@ -365,8 +363,7 @@
propertyPair.first == "PositiveHysteresis")
{
const double* ptr =
- sdbusplus::message::variant_ns::get_if<
- double>(&propertyPair.second);
+ std::get_if<double>(&propertyPair.second);
if (ptr == nullptr)
{
BMCWEB_LOG_ERROR << "Field Illegal "
@@ -386,8 +383,7 @@
if (propertyPair.first == "Zones")
{
const std::vector<std::string>* inputs =
- sdbusplus::message::variant_ns::get_if<
- std::vector<std::string>>(
+ std::get_if<std::vector<std::string>>(
&propertyPair.second);
if (inputs == nullptr)
@@ -421,8 +417,7 @@
{
auto& data = (*config)[propertyPair.first];
const std::vector<std::string>* inputs =
- sdbusplus::message::variant_ns::get_if<
- std::vector<std::string>>(
+ std::get_if<std::vector<std::string>>(
&propertyPair.second);
if (inputs == nullptr)
@@ -448,8 +443,7 @@
propertyPair.first == "SlewPos")
{
const double* ptr =
- sdbusplus::message::variant_ns::get_if<
- double>(&propertyPair.second);
+ std::get_if<double>(&propertyPair.second);
if (ptr == nullptr)
{
BMCWEB_LOG_ERROR << "Field Illegal "
@@ -945,8 +939,8 @@
if (property.first == "Version")
{
const std::string* value =
- sdbusplus::message::variant_ns::get_if<
- std::string>(&property.second);
+ std::get_if<std::string>(
+ &property.second);
if (value == nullptr)
{
continue;
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 90f12dd..044d8d0 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -18,6 +18,8 @@
#include "error_messages.hpp"
#include "node.hpp"
+#include <variant>
+
namespace redfish
{
@@ -156,19 +158,17 @@
[asyncResp, service{std::string(service)},
socketPath](
const boost::system::error_code ec,
- const sdbusplus::message::variant<std::vector<
- std::tuple<std::string, std::string>>>&
- resp) {
+ const std::variant<std::vector<std::tuple<
+ std::string, std::string>>>& resp) {
if (ec)
{
messages::internalError(asyncResp->res);
return;
}
- const std::vector<std::tuple<
- std::string, std::string>>* responsePtr =
- sdbusplus::message::variant_ns::get_if<
- std::vector<std::tuple<std::string,
- std::string>>>(
+ const std::vector<
+ std::tuple<std::string, std::string>>*
+ responsePtr = std::get_if<std::vector<
+ std::tuple<std::string, std::string>>>(
&resp);
if (responsePtr == nullptr ||
responsePtr->size() < 1)
diff --git a/redfish-core/lib/roles.hpp b/redfish-core/lib/roles.hpp
index 0f33b04..d07208e 100644
--- a/redfish-core/lib/roles.hpp
+++ b/redfish-core/lib/roles.hpp
@@ -17,6 +17,8 @@
#include "node.hpp"
+#include <variant>
+
namespace redfish
{
@@ -145,10 +147,8 @@
{"Description", "BMC User Roles"}};
crow::connections::systemBus->async_method_call(
- [asyncResp](
- const boost::system::error_code ec,
- const sdbusplus::message::variant<std::vector<std::string>>&
- resp) {
+ [asyncResp](const boost::system::error_code ec,
+ const std::variant<std::vector<std::string>>& resp) {
if (ec)
{
messages::internalError(asyncResp->res);
@@ -158,8 +158,7 @@
asyncResp->res.jsonValue["Members"];
memberArray = nlohmann::json::array();
const std::vector<std::string>* privList =
- sdbusplus::message::variant_ns::get_if<
- std::vector<std::string>>(&resp);
+ std::get_if<std::vector<std::string>>(&resp);
for (const std::string& priv : *privList)
{
std::string role = getRoleFromPrivileges(priv);
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index f866e5d..28dc358 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -22,6 +22,7 @@
#include <boost/container/flat_map.hpp>
#include <boost/range/algorithm/replace_copy_if.hpp>
#include <dbus_singleton.hpp>
+#include <variant>
namespace redfish
{
@@ -32,7 +33,7 @@
std::pair<std::string,
std::vector<std::pair<std::string, std::vector<std::string>>>>>;
-using SensorVariant = sdbusplus::message::variant<int64_t, double>;
+using SensorVariant = std::variant<int64_t, double>;
using ManagedObjectsVectorType = std::vector<std::pair<
sdbusplus::message::object_path,
@@ -272,8 +273,7 @@
// If a scale exists, pull value as int64, and use the scaling.
if (scaleIt != valueIt->second.end())
{
- const int64_t* int64Value =
- sdbusplus::message::variant_ns::get_if<int64_t>(&scaleIt->second);
+ const int64_t* int64Value = std::get_if<int64_t>(&scaleIt->second);
if (int64Value != nullptr)
{
scaleMultiplier = *int64Value;
@@ -369,13 +369,9 @@
const SensorVariant& valueVariant = valueIt->second;
nlohmann::json& valueIt = sensor_json[std::get<2>(p)];
// Attempt to pull the int64 directly
- const int64_t* int64Value =
- sdbusplus::message::variant_ns::get_if<int64_t>(
- &valueVariant);
+ const int64_t* int64Value = std::get_if<int64_t>(&valueVariant);
- const double* doubleValue =
- sdbusplus::message::variant_ns::get_if<double>(
- &valueVariant);
+ const double* doubleValue = std::get_if<double>(&valueVariant);
double temp = 0.0;
if (int64Value != nullptr)
{
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 3d7c931..e24a077 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -18,6 +18,7 @@
#include <boost/container/flat_map.hpp>
#include <node.hpp>
#include <utils/json_utils.hpp>
+#include <variant>
namespace redfish
{
@@ -87,8 +88,7 @@
&property : propertiesList)
{
const std::string *value =
- sdbusplus::message::variant_ns::get_if<
- std::string>(&property.second);
+ std::get_if<std::string>(&property.second);
if (value != nullptr)
{
aResp->res.jsonValue[property.first] =
@@ -355,8 +355,7 @@
if (property.first == "Asserted")
{
const bool *asserted =
- sdbusplus::message::variant_ns::get_if<
- bool>(&property.second);
+ std::get_if<bool>(&property.second);
if (nullptr != asserted)
{
callback(*asserted, aResp);
@@ -399,8 +398,7 @@
if (property.first == "State")
{
const std::string *s =
- sdbusplus::message::variant_ns::get_if<std::string>(
- &property.second);
+ std::get_if<std::string>(&property.second);
if (nullptr != s)
{
BMCWEB_LOG_DEBUG << "Identify Led State: " << *s;
@@ -444,9 +442,8 @@
{
BMCWEB_LOG_DEBUG << "Get host information.";
crow::connections::systemBus->async_method_call(
- [aResp{std::move(aResp)}](
- const boost::system::error_code ec,
- const sdbusplus::message::variant<std::string> &hostState) {
+ [aResp{std::move(aResp)}](const boost::system::error_code ec,
+ const std::variant<std::string> &hostState) {
if (ec)
{
BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
@@ -454,8 +451,7 @@
return;
}
- const std::string *s =
- sdbusplus::message::variant_ns::get_if<std::string>(&hostState);
+ const std::string *s = std::get_if<std::string>(&hostState);
BMCWEB_LOG_DEBUG << "Host state: " << *s;
if (s != nullptr)
{
@@ -598,7 +594,7 @@
"/xyz/openbmc_project/state/chassis0",
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.State.Chassis", "RequestedPowerTransition",
- sdbusplus::message::variant<std::string>{
+ std::variant<std::string>{
"xyz.openbmc_project.State.Chassis.Transition.Off"});
return;
}
@@ -640,7 +636,7 @@
"/xyz/openbmc_project/state/host0",
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.State.Host", "RequestedHostTransition",
- sdbusplus::message::variant<std::string>{command});
+ std::variant<std::string>{command});
}
};
@@ -813,7 +809,7 @@
"/xyz/openbmc_project/led/groups/enclosure_identify",
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Led.Group", "Asserted",
- sdbusplus::message::variant<bool>(
+ std::variant<bool>(
(dbusLedState ==
"xyz.openbmc_project.Led.Physical.Action.Off"
? false
@@ -836,7 +832,7 @@
"/xyz/openbmc_project/led/physical/identify",
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Led.Physical", "State",
- sdbusplus::message::variant<std::string>(dbusLedState));
+ std::variant<std::string>(dbusLedState));
}
}
};
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index d5ecf24..5d5b3ea 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -18,6 +18,7 @@
#include "node.hpp"
#include <boost/container/flat_map.hpp>
+#include <variant>
namespace redfish
{
@@ -69,7 +70,7 @@
"xyz.openbmc_project.Software.BMC.Updater", objPath,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Software.Activation", "RequestedActivation",
- sdbusplus::message::variant<std::string>(
+ std::variant<std::string>(
"xyz.openbmc_project.Software.Activation.RequestedActivations."
"Active"));
}
@@ -125,8 +126,7 @@
}
std::vector<std::pair<
std::string,
- std::vector<std::pair<
- std::string, sdbusplus::message::variant<std::string>>>>>
+ std::vector<std::pair<std::string, std::variant<std::string>>>>>
interfacesProperties;
sdbusplus::message::object_path objPath;
@@ -260,8 +260,7 @@
}
const std::string *swActivationStatus =
- sdbusplus::message::variant_ns::get_if<
- std::string>(&activation);
+ std::get_if<std::string>(&activation);
if (swActivationStatus == nullptr)
{
messages::internalError(asyncResp->res);
@@ -401,8 +400,7 @@
return;
}
const std::string *swInvPurpose =
- sdbusplus::message::variant_ns::get_if<
- std::string>(&it->second);
+ std::get_if<std::string>(&it->second);
if (swInvPurpose == nullptr)
{
BMCWEB_LOG_DEBUG
@@ -427,8 +425,7 @@
BMCWEB_LOG_DEBUG << "Version found!";
const std::string *version =
- sdbusplus::message::variant_ns::get_if<
- std::string>(&it->second);
+ std::get_if<std::string>(&it->second);
if (version == nullptr)
{