Convert variant usage to std interface

This is just a refactoring to use the c++17 std::variant interfaces
instead of the mapbox::variant specific ones. We should be able to use
mapbox::variant and std::variant interchangeably now.

Tested:
    Built against sdbusplus with mapbox::variant and sbusplus using
    std::variant. Both variant compile and test out.

Change-Id: I6fbaad3d12dd34968db6a10f3d74a65e07d0f0cc
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/apphandler.cpp b/apphandler.cpp
index 8c7df7c..fd58218 100644
--- a/apphandler.cpp
+++ b/apphandler.cpp
@@ -23,6 +23,7 @@
 #include <nlohmann/json.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
+#include <sdbusplus/message/types.hpp>
 #include <string>
 #include <tuple>
 #include <vector>
@@ -69,6 +70,7 @@
     sdbusplus::xyz::openbmc_project::Software::server::Activation;
 using BMC = sdbusplus::xyz::openbmc_project::State::server::BMC;
 namespace fs = std::filesystem;
+namespace variant_ns = sdbusplus::message::variant_ns;
 
 // Offset in get device id command.
 typedef struct
@@ -123,12 +125,14 @@
                 auto& redundancyPriorityProps = intfMap.at(redundancyIntf);
                 auto& versionProps = intfMap.at(versionIntf);
                 auto& activationProps = intfMap.at(activationIntf);
-                auto priority =
-                    redundancyPriorityProps.at("Priority").get<uint8_t>();
-                auto purpose = versionProps.at("Purpose").get<std::string>();
-                auto activation =
-                    activationProps.at("Activation").get<std::string>();
-                auto version = versionProps.at("Version").get<std::string>();
+                auto priority = variant_ns::get<uint8_t>(
+                    redundancyPriorityProps.at("Priority"));
+                auto purpose =
+                    variant_ns::get<std::string>(versionProps.at("Purpose"));
+                auto activation = variant_ns::get<std::string>(
+                    activationProps.at("Activation"));
+                auto version =
+                    variant_ns::get<std::string>(versionProps.at("Version"));
                 if ((Version::convertVersionPurposeFromString(purpose) ==
                      Version::VersionPurpose::BMC) &&
                     (Activation::convertActivationsFromString(activation) ==
@@ -169,9 +173,9 @@
         ipmi::getDbusProperty(bus, bmcObject.second, bmcObject.first,
                               bmc_state_interface, bmc_state_property);
 
-    return variant.is<std::string>() &&
-           BMC::convertBMCStateFromString(variant.get<std::string>()) ==
-               BMC::BMCState::Ready;
+    return variant_ns::holds_alternative<std::string>(variant) &&
+           BMC::convertBMCStateFromString(
+               variant_ns::get<std::string>(variant)) == BMC::BMCState::Ready;
 }
 
 ipmi_ret_t ipmi_app_set_acpi_power_state(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
@@ -598,7 +602,7 @@
         auto variant =
             ipmi::getDbusProperty(bus, bmcObject.second, bmcObject.first,
                                   bmc_guid_interface, bmc_guid_property);
-        std::string guidProp = variant.get<std::string>();
+        std::string guidProp = variant_ns::get<std::string>(variant);
 
         // Erase "-" characters from the property value
         guidProp.erase(std::remove(guidProp.begin(), guidProp.end(), '-'),
diff --git a/chassishandler.cpp b/chassishandler.cpp
index d75b3b2..a58eee0 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -23,6 +23,7 @@
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/bus.hpp>
+#include <sdbusplus/message/types.hpp>
 #include <sdbusplus/server/object.hpp>
 #include <sdbusplus/timer.hpp>
 #include <sstream>
@@ -138,6 +139,8 @@
 using namespace phosphor::logging;
 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
 using namespace sdbusplus::xyz::openbmc_project::Control::Boot::server;
+namespace variant_ns = sdbusplus::message::variant_ns;
+
 namespace chassis
 {
 namespace internal
@@ -349,19 +352,19 @@
                                              macObjectInfo.first, MAC_INTERFACE,
                                              "MACAddress");
 
-        auto ipAddress = properties["Address"].get<std::string>();
+        auto ipAddress = variant_ns::get<std::string>(properties["Address"]);
 
-        auto gateway = properties["Gateway"].get<std::string>();
+        auto gateway = variant_ns::get<std::string>(properties["Gateway"]);
 
-        auto prefix = properties["PrefixLength"].get<uint8_t>();
+        auto prefix = variant_ns::get<uint8_t>(properties["PrefixLength"]);
 
         uint8_t isStatic =
-            (properties["Origin"].get<std::string>() ==
+            (variant_ns::get<std::string>(properties["Origin"]) ==
              "xyz.openbmc_project.Network.IP.AddressOrigin.Static")
                 ? 1
                 : 0;
 
-        auto MACAddress = variant.get<std::string>();
+        auto MACAddress = variant_ns::get<std::string>(variant);
 
         // it is expected here that we should get the valid data
         // but we may also get the default values.
@@ -399,10 +402,11 @@
         std::memcpy(respptr->data + ADDRTYPE_OFFSET, &isStatic,
                     sizeof(isStatic));
 
-        uint8_t addressFamily = (properties["Type"].get<std::string>() ==
-                                 "xyz.openbmc_project.Network.IP.Protocol.IPv4")
-                                    ? AF_INET
-                                    : AF_INET6;
+        uint8_t addressFamily =
+            (variant_ns::get<std::string>(properties["Type"]) ==
+             "xyz.openbmc_project.Network.IP.Protocol.IPv4")
+                ? AF_INET
+                : AF_INET6;
 
         addrSize = (addressFamily == AF_INET)
                        ? ipmi::network::IPV4_ADDRESS_SIZE_BYTE
@@ -636,7 +640,7 @@
         ipmi::getDbusProperty(bus, service, chassisStateObj.first,
                               chassisPOHStateIntf, pOHCounterProperty);
 
-    return propValue.get<uint32_t>();
+    return variant_ns::get<uint32_t>(propValue);
 }
 
 ipmi_ret_t ipmi_chassis_wildcard(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
@@ -818,8 +822,8 @@
     }
     sdbusplus::message::variant<std::string> result;
     resp.read(result);
-    auto powerRestore =
-        RestorePolicy::convertPolicyFromString(result.get<std::string>());
+    auto powerRestore = RestorePolicy::convertPolicyFromString(
+        variant_ns::get<std::string>(result));
 
     *data_len = 4;
 
@@ -1365,8 +1369,8 @@
             }
             sdbusplus::message::variant<std::string> result;
             reply.read(result);
-            auto bootSource =
-                Source::convertSourcesFromString(result.get<std::string>());
+            auto bootSource = Source::convertSourcesFromString(
+                variant_ns::get<std::string>(result));
 
             bootSetting = settings::boot::setting(objects, bootModeIntf);
             const auto& bootModeSetting = std::get<settings::Path>(bootSetting);
@@ -1383,8 +1387,8 @@
                 return IPMI_CC_UNSPECIFIED_ERROR;
             }
             reply.read(result);
-            auto bootMode =
-                Mode::convertModesFromString(result.get<std::string>());
+            auto bootMode = Mode::convertModesFromString(
+                variant_ns::get<std::string>(result));
 
             bootOption = sourceDbusToIpmi.at(bootSource);
             if ((Mode::Modes::Regular == bootMode) &&
diff --git a/dcmihandler.cpp b/dcmihandler.cpp
index d01787e..6ea7dd8 100644
--- a/dcmihandler.cpp
+++ b/dcmihandler.cpp
@@ -14,6 +14,7 @@
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/bus.hpp>
+#include <sdbusplus/message/types.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 using namespace phosphor::logging;
@@ -56,6 +57,7 @@
 constexpr auto SENSOR_SCALE_PROP = "Scale";
 
 using namespace phosphor::logging;
+namespace variant_ns = sdbusplus::message::variant_ns;
 
 namespace dcmi
 {
@@ -83,7 +85,7 @@
     sdbusplus::message::variant<uint32_t> pcap;
     reply.read(pcap);
 
-    return pcap.get<uint32_t>();
+    return variant_ns::get<uint32_t>(pcap);
 }
 
 bool getPcapEnabled(sdbusplus::bus::bus& bus)
@@ -104,7 +106,7 @@
     sdbusplus::message::variant<bool> pcapEnabled;
     reply.read(pcapEnabled);
 
-    return pcapEnabled.get<bool>();
+    return variant_ns::get<bool>(pcapEnabled);
 }
 
 void setPcap(sdbusplus::bus::bus& bus, const uint32_t powerCap)
@@ -203,7 +205,7 @@
     sdbusplus::message::variant<std::string> assetTag;
     reply.read(assetTag);
 
-    return assetTag.get<std::string>();
+    return variant_ns::get<std::string>(assetTag);
 }
 
 void writeAssetTag(const std::string& assetTag)
@@ -238,7 +240,7 @@
     auto value = ipmi::getDbusProperty(bus, service, networkConfigObj,
                                        networkConfigIntf, hostNameProp);
 
-    return value.get<std::string>();
+    return variant_ns::get<std::string>(value);
 }
 
 bool getDHCPEnabled()
@@ -253,7 +255,7 @@
     auto value = ipmi::getDbusProperty(bus, service, ethernetObj.first,
                                        ethernetIntf, "DHCPEnabled");
 
-    return value.get<bool>();
+    return variant_ns::get<bool>(value);
 }
 
 bool getDHCPOption(std::string prop)
@@ -263,7 +265,7 @@
     auto service = ipmi::getService(bus, dhcpIntf, dhcpObj);
     auto value = ipmi::getDbusProperty(bus, service, dhcpObj, dhcpIntf, prop);
 
-    return value.get<bool>();
+    return variant_ns::get<bool>(value);
 }
 
 void setDHCPOption(std::string prop, bool value)
@@ -801,10 +803,10 @@
     sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
     auto result = ipmi::getAllDbusProperties(
         bus, dbusService, dbusPath, "xyz.openbmc_project.Sensor.Value");
-    auto temperature = result.at("Value").get<int64_t>();
+    auto temperature = variant_ns::get<int64_t>(result.at("Value"));
     uint64_t absTemp = std::abs(temperature);
 
-    auto factor = result.at("Scale").get<int64_t>();
+    auto factor = variant_ns::get<int64_t>(result.at("Scale"));
     uint64_t scale = std::pow(10, factor); // pow() returns float/double
     unsigned long long tempDegrees = 0;
     // Overflow safe multiplication when the scale is > 0
@@ -1056,8 +1058,8 @@
         // Read the sensor value and scale properties
         auto properties = ipmi::getAllDbusProperties(bus, service, objectPath,
                                                      SENSOR_VALUE_INTF);
-        auto value = properties[SENSOR_VALUE_PROP].get<int64_t>();
-        auto scale = properties[SENSOR_SCALE_PROP].get<int64_t>();
+        auto value = variant_ns::get<int64_t>(properties[SENSOR_VALUE_PROP]);
+        auto scale = variant_ns::get<int64_t>(properties[SENSOR_SCALE_PROP]);
 
         // Power reading needs to be scaled with the Scale value using the
         // formula Value * 10^Scale.
diff --git a/host-cmd-manager.cpp b/host-cmd-manager.cpp
index 2f96661..28bcb70 100644
--- a/host-cmd-manager.cpp
+++ b/host-cmd-manager.cpp
@@ -7,6 +7,7 @@
 #include <chrono>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
+#include <sdbusplus/message/types.hpp>
 #include <sdbusplus/timer.hpp>
 #include <utils.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
@@ -32,6 +33,7 @@
     sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
 
 namespace sdbusRule = sdbusplus::bus::match::rules;
+namespace variant_ns = sdbusplus::message::variant_ns;
 
 Manager::Manager(sdbusplus::bus::bus& bus, sd_event* event) :
     bus(bus), timer(event, std::bind(&Manager::hostTimeout, this)),
@@ -180,7 +182,8 @@
         return;
     }
 
-    auto& requestedState = properties.at(HOST_TRANS_PROP).get<std::string>();
+    auto& requestedState =
+        variant_ns::get<std::string>(properties.at(HOST_TRANS_PROP));
 
     if (server::Host::convertTransitionFromString(requestedState) ==
         server::Host::Transition::On)
diff --git a/ipmid.cpp b/ipmid.cpp
index e19eda0..2d48bfe 100644
--- a/ipmid.cpp
+++ b/ipmid.cpp
@@ -25,12 +25,14 @@
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/bus/match.hpp>
+#include <sdbusplus/message/types.hpp>
 #include <sdbusplus/timer.hpp>
 #include <vector>
 #include <xyz/openbmc_project/Control/Security/RestrictionMode/server.hpp>
 
 using namespace phosphor::logging;
 namespace sdbusRule = sdbusplus::bus::match::rules;
+namespace variant_ns = sdbusplus::message::variant_ns;
 
 sd_bus* bus = NULL;
 sd_bus_slot* ipmid_slot = NULL;
@@ -380,8 +382,8 @@
     }
     sdbusplus::message::variant<std::string> result;
     resp.read(result);
-    auto restrictionMode =
-        RestrictionMode::convertModesFromString(result.get<std::string>());
+    auto restrictionMode = RestrictionMode::convertModesFromString(
+        variant_ns::get<std::string>(result));
     if (RestrictionMode::Modes::Whitelist == restrictionMode)
     {
         restricted_mode = true;
diff --git a/read_fru_data.cpp b/read_fru_data.cpp
index c7ff61b..67bbf9f 100644
--- a/read_fru_data.cpp
+++ b/read_fru_data.cpp
@@ -8,6 +8,7 @@
 
 #include <map>
 #include <phosphor-logging/elog-errors.hpp>
+#include <sdbusplus/message/types.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 extern const FruMap frus;
@@ -15,6 +16,9 @@
 {
 namespace fru
 {
+
+namespace variant_ns = sdbusplus::message::variant_ns;
+
 using namespace phosphor::logging;
 using InternalFailure =
     sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
@@ -143,8 +147,8 @@
                 {
                     data[properties.second.section].emplace(
                         properties.first,
-                        std::move(
-                            allProp[properties.first].get<std::string>()));
+                        std::move(variant_ns::get<std::string>(
+                            allProp[properties.first])));
                 }
             }
         }
diff --git a/sensordatahandler.cpp b/sensordatahandler.cpp
index c973f2e..4f552a3 100644
--- a/sensordatahandler.cpp
+++ b/sensordatahandler.cpp
@@ -5,8 +5,10 @@
 #include "utils.hpp"
 
 #include <bitset>
+#include <optional>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
+#include <sdbusplus/message/types.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 #if __has_include(<filesystem>)
@@ -27,6 +29,8 @@
 namespace sensor
 {
 
+namespace variant_ns = sdbusplus::message::variant_ns;
+
 using namespace phosphor::logging;
 using InternalFailure =
     sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
@@ -260,7 +264,7 @@
 
     for (const auto& property : interface->second)
     {
-        Value tmp{sdbusplus::message::variant_ns::no_init()};
+        std::optional<Value> tmp;
         for (const auto& value : std::get<OffsetValueMap>(property.second))
         {
             if (bothSet.size() <= value.first || !bothSet.test(value.first))
@@ -281,14 +285,14 @@
             }
         }
 
-        if (tmp.valid())
+        if (tmp)
         {
             auto msg = makeDbusMsg("org.freedesktop.DBus.Properties",
                                    sensorInfo.sensorPath, "Set",
                                    sensorInfo.sensorInterface);
             msg.append(interface->first);
             msg.append(property.first);
-            msg.append(tmp);
+            msg.append(*tmp);
 
             auto rc = updateToDbus(msg);
             if (rc)
@@ -348,7 +352,8 @@
                     {
                         return IPMI_CC_OK;
                     }
-                    result = result && value.second.assert.get<bool>();
+                    result =
+                        result && variant_ns::get<bool>(value.second.assert);
                     valid = true;
                 }
                 else if (deassertionSet.test(value.first))
@@ -358,7 +363,8 @@
                     {
                         return IPMI_CC_OK;
                     }
-                    result = result && value.second.deassert.get<bool>();
+                    result =
+                        result && variant_ns::get<bool>(value.second.deassert);
                     valid = true;
                 }
             }
@@ -367,11 +373,13 @@
             {
                 if (assertionSet.test(value.first))
                 {
-                    result = result && value.second.assert.get<bool>();
+                    result =
+                        result && variant_ns::get<bool>(value.second.assert);
                 }
                 else if (deassertionSet.test(value.first))
                 {
-                    result = result && value.second.deassert.get<bool>();
+                    result =
+                        result && variant_ns::get<bool>(value.second.deassert);
                 }
             }
             if (valid)
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index bcb55ff..d56aea8 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -7,12 +7,15 @@
 #include <host-ipmid/ipmid-api.h>
 
 #include <cmath>
+#include <sdbusplus/message/types.hpp>
 
 namespace ipmi
 {
 namespace sensor
 {
 
+namespace variant_ns = sdbusplus::message::variant_ns;
+
 using Assertion = uint16_t;
 using Deassertion = uint16_t;
 using AssertionSet = std::pair<Assertion, Deassertion>;
@@ -164,7 +167,8 @@
         sensorInfo.propertyInterfaces.begin()->first,
         sensorInfo.propertyInterfaces.begin()->second.begin()->first);
 
-    setAssertionBytes(static_cast<uint16_t>(propValue.get<T>()), responseData);
+    setAssertionBytes(static_cast<uint16_t>(variant_ns::get<T>(propValue)),
+                      responseData);
 
     return response;
 }
@@ -194,7 +198,7 @@
         sensorInfo.propertyInterfaces.begin()->first,
         sensorInfo.propertyInterfaces.begin()->second.begin()->first);
 
-    double value = propValue.get<T>() *
+    double value = variant_ns::get<T>(propValue) *
                    std::pow(10, sensorInfo.scale - sensorInfo.exponentR);
 
     auto rawData = static_cast<uint8_t>((value - sensorInfo.scaledOffset) /
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index 08a6325..dca9765 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -14,6 +14,7 @@
 #include <cstring>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
+#include <sdbusplus/message/types.hpp>
 #include <set>
 #include <xyz/openbmc_project/Common/error.hpp>
 #include <xyz/openbmc_project/Sensor/Value/server.hpp>
@@ -453,10 +454,10 @@
     auto warnThresholds = ipmi::getAllDbusProperties(
         bus, service, info.sensorPath, warningThreshIntf);
 
-    double warnLow = variant_ns::apply_visitor(ipmi::VariantToDoubleVisitor(),
-                                               warnThresholds["WarningLow"]);
-    double warnHigh = variant_ns::apply_visitor(ipmi::VariantToDoubleVisitor(),
-                                                warnThresholds["WarningHigh"]);
+    double warnLow = variant_ns::visit(ipmi::VariantToDoubleVisitor(),
+                                       warnThresholds["WarningLow"]);
+    double warnHigh = variant_ns::visit(ipmi::VariantToDoubleVisitor(),
+                                        warnThresholds["WarningHigh"]);
 
     if (warnLow != 0)
     {
@@ -478,10 +479,10 @@
 
     auto critThresholds = ipmi::getAllDbusProperties(
         bus, service, info.sensorPath, criticalThreshIntf);
-    double critLow = variant_ns::apply_visitor(ipmi::VariantToDoubleVisitor(),
-                                               critThresholds["CriticalLow"]);
-    double critHigh = variant_ns::apply_visitor(ipmi::VariantToDoubleVisitor(),
-                                                critThresholds["CriticalHigh"]);
+    double critLow = variant_ns::visit(ipmi::VariantToDoubleVisitor(),
+                                       critThresholds["CriticalLow"]);
+    double critHigh = variant_ns::visit(ipmi::VariantToDoubleVisitor(),
+                                        critThresholds["CriticalHigh"]);
 
     if (critLow != 0)
     {
diff --git a/settings.cpp b/settings.cpp
index 770bde0..0ddd7a6 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -4,6 +4,7 @@
 
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
+#include <sdbusplus/message/types.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 namespace settings
@@ -11,6 +12,7 @@
 
 using namespace phosphor::logging;
 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
+namespace variant_ns = sdbusplus::message::variant_ns;
 
 constexpr auto mapperService = "xyz.openbmc_project.ObjectMapper";
 constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper";
@@ -131,7 +133,7 @@
 
     sdbusplus::message::variant<bool> enabled;
     reply.read(enabled);
-    auto oneTimeEnabled = enabled.get<bool>();
+    auto oneTimeEnabled = variant_ns::get<bool>(enabled);
     const Path& setting = oneTimeEnabled ? oneTimeSetting : regularSetting;
     return std::make_tuple(setting, oneTimeEnabled);
 }
diff --git a/storagehandler.cpp b/storagehandler.cpp
index 0a46b83..5ac116c 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -18,6 +18,7 @@
 #include <cstring>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
+#include <sdbusplus/message/types.hpp>
 #include <sdbusplus/server.hpp>
 #include <string>
 #include <xyz/openbmc_project/Common/error.hpp>
@@ -73,6 +74,8 @@
 
 } // namespace cache
 
+namespace variant_ns = sdbusplus::message::variant_ns;
+
 using InternalFailure =
     sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
 using namespace phosphor::logging;
@@ -501,7 +504,7 @@
             return IPMI_CC_UNSPECIFIED_ERROR;
         }
         reply.read(value);
-        host_time_usec = value.get<uint64_t>();
+        host_time_usec = variant_ns::get<uint64_t>(value);
     }
     catch (InternalFailure& e)
     {
diff --git a/transporthandler.cpp b/transporthandler.cpp
index 9c42887..39b1c9f 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -12,6 +12,7 @@
 #include <fstream>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
+#include <sdbusplus/message/types.hpp>
 #include <sdbusplus/timer.hpp>
 #include <string>
 #include <xyz/openbmc_project/Common/error.hpp>
@@ -47,6 +48,7 @@
 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
 
 namespace fs = std::filesystem;
+namespace variant_ns = sdbusplus::message::variant_ns;
 
 void register_netfn_transport_functions() __attribute__((constructor));
 
@@ -97,7 +99,8 @@
                             bus, ipObjectInfo.second, ipObjectInfo.first,
                             ipmi::network::IP_INTERFACE);
 
-                        ipaddress = properties["Address"].get<std::string>();
+                        ipaddress =
+                            variant_ns::get<std::string>(properties["Address"]);
                     }
                     // ignore the exception, as it is a valid condition that
                     // the system is not configured with any IP.
@@ -171,7 +174,7 @@
                         bus, ipmi::network::SERVICE, networkInterfacePath,
                         ipmi::network::ETHERNET_INTERFACE, "DHCPEnabled");
 
-                    auto dhcpEnabled = variant.get<bool>();
+                    auto dhcpEnabled = variant_ns::get<bool>(variant);
                     // As per IPMI spec 2=>DHCP, 1=STATIC
                     auto ipsrc = dhcpEnabled ? ipmi::network::IPOrigin::DHCP
                                              : ipmi::network::IPOrigin::STATIC;
@@ -201,7 +204,8 @@
                             bus, ipObjectInfo.second, ipObjectInfo.first,
                             ipmi::network::IP_INTERFACE);
 
-                        auto prefix = properties["PrefixLength"].get<uint8_t>();
+                        auto prefix = variant_ns::get<uint8_t>(
+                            properties["PrefixLength"]);
                         mask = ipmi::network::MASK_32_BIT;
                         mask = htonl(mask << (ipmi::network::BITS_32 - prefix));
                     }
@@ -238,8 +242,8 @@
                             bus, systemObject.second, systemObject.first,
                             ipmi::network::SYSTEMCONFIG_INTERFACE);
 
-                        gateway = systemProperties["DefaultGateway"]
-                                      .get<std::string>();
+                        gateway = variant_ns::get<std::string>(
+                            systemProperties["DefaultGateway"]);
                     }
                     // ignore the exception, as it is a valid condition that
                     // the system is not configured with any IP.
@@ -271,7 +275,7 @@
                         bus, macObjectInfo.second, macObjectInfo.first,
                         ipmi::network::MAC_INTERFACE, "MACAddress");
 
-                    macAddress = variant.get<std::string>();
+                    macAddress = variant_ns::get<std::string>(variant);
                 }
                 else if (channelConf->lan_set_in_progress == SET_IN_PROGRESS)
                 {
@@ -777,11 +781,9 @@
             }
 
             // get the configured mode on the system.
-            auto enableDHCP =
-                ipmi::getDbusProperty(
-                    bus, ipmi::network::SERVICE, networkInterfacePath,
-                    ipmi::network::ETHERNET_INTERFACE, "DHCPEnabled")
-                    .get<bool>();
+            auto enableDHCP = variant_ns::get<bool>(ipmi::getDbusProperty(
+                bus, ipmi::network::SERVICE, networkInterfacePath,
+                ipmi::network::ETHERNET_INTERFACE, "DHCPEnabled"));
 
             // if ip address source is not given then get the ip source mode
             // from the system so that it can be applied later.
@@ -824,11 +826,13 @@
                         ipmi::network::IP_INTERFACE);
 
                     ipaddress = channelConf->ipaddr.empty()
-                                    ? properties["Address"].get<std::string>()
+                                    ? variant_ns::get<std::string>(
+                                          properties["Address"])
                                     : channelConf->ipaddr;
 
                     prefix = channelConf->netmask.empty()
-                                 ? properties["PrefixLength"].get<uint8_t>()
+                                 ? variant_ns::get<uint8_t>(
+                                       properties["PrefixLength"])
                                  : ipmi::network::toPrefix(
                                        AF_INET, channelConf->netmask);
                 }
@@ -844,10 +848,10 @@
                     bus, systemObject.second, systemObject.first,
                     ipmi::network::SYSTEMCONFIG_INTERFACE);
 
-                gateway =
-                    channelConf->gateway.empty()
-                        ? systemProperties["DefaultGateway"].get<std::string>()
-                        : channelConf->gateway;
+                gateway = channelConf->gateway.empty()
+                              ? variant_ns::get<std::string>(
+                                    systemProperties["DefaultGateway"])
+                              : channelConf->gateway;
             }
         }
 
diff --git a/utils.cpp b/utils.cpp
index 06c26e8..f6a840a 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -7,6 +7,7 @@
 #include <algorithm>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
+#include <sdbusplus/message/types.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 namespace ipmi
@@ -14,6 +15,7 @@
 
 using namespace phosphor::logging;
 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
+namespace variant_ns = sdbusplus::message::variant_ns;
 
 namespace network
 {
@@ -116,7 +118,7 @@
         objectInfo = std::make_pair(object.first, object.second.begin()->first);
 
         // if LinkLocalIP found look for Non-LinkLocalIP
-        if (ipmi::network::isLinkLocalIP(variant.get<std::string>()))
+        if (ipmi::network::isLinkLocalIP(variant_ns::get<std::string>(variant)))
         {
             continue;
         }