summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorAsmitha Karunanithi <asmitk01@in.ibm.com>2024-03-27 06:03:48 +0300
committerAsmitha Karunanithi <asmitk01@in.ibm.com>2024-03-28 22:50:50 +0300
commit1847f2a0c517df6a7439b9bd491afbf6b2302a92 (patch)
treebcd546e5c951540b5a6f53570eabdfa1f84cc765 /redfish-core
parentd02aad3988620c648d6e696b67d6c542857f5bfc (diff)
downloadbmcweb-1847f2a0c517df6a7439b9bd491afbf6b2302a92.tar.xz
ethernet: Move to setProperty dbus utility method
This commit changes sdbusplus setProperty calls in ethernet.hpp file to "setDbusProperty" method in Redfish namespace that handles all DBus errors in a consistent manner. Tested By: Tested a few PATCH operations on the redfish endpoints defined in this file and verified that bmcweb returns appropriate Redfish errors. Change-Id: Ie456db75d59dc247cdce5dd5cc0b2f6894f5265f Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com>
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/lib/ethernet.hpp51
1 files changed, 16 insertions, 35 deletions
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index b73da3e737..dd3473db8a 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -1347,29 +1347,24 @@ inline void setDHCPConfig(const std::string& propertyName, const bool& value,
const std::string& ethifaceId, NetworkType type)
{
BMCWEB_LOG_DEBUG("{} = {}", propertyName, value);
+ std::string redfishPropertyName;
sdbusplus::message::object_path path("/xyz/openbmc_project/network/");
path /= ethifaceId;
if (type == NetworkType::dhcp4)
{
path /= "dhcp4";
+ redfishPropertyName = "DHCPv4";
}
else
{
path /= "dhcp6";
+ redfishPropertyName = "DHCPv6";
}
- sdbusplus::asio::setProperty(
- *crow::connections::systemBus, "xyz.openbmc_project.Network", path,
- "xyz.openbmc_project.Network.DHCPConfiguration", propertyName, value,
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- });
+ setDbusProperty(asyncResp, "xyz.openbmc_project.Network", path,
+ "xyz.openbmc_project.Network.DHCPConfiguration",
+ propertyName, redfishPropertyName, value);
}
inline void handleSLAACAutoConfigPatch(
@@ -1378,19 +1373,11 @@ inline void handleSLAACAutoConfigPatch(
{
sdbusplus::message::object_path path("/xyz/openbmc_project/network");
path /= ifaceId;
- sdbusplus::asio::setProperty(
- *crow::connections::systemBus, "xyz.openbmc_project.Network", path,
- "xyz.openbmc_project.Network.EthernetInterface", "IPv6AcceptRA",
- ipv6AutoConfigEnabled,
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- messages::success(asyncResp->res);
- });
+ setDbusProperty(asyncResp, "xyz.openbmc_project.Network", path,
+ "xyz.openbmc_project.Network.EthernetInterface",
+ "IPv6AcceptRA",
+ "StatelessAddressAutoConfig/IPv6AutoConfigEnabled",
+ ipv6AutoConfigEnabled);
}
inline void handleDHCPPatch(const std::string& ifaceId,
@@ -1663,18 +1650,12 @@ inline void handleStaticNameServersPatch(
const std::vector<std::string>& updatedStaticNameServers,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
- sdbusplus::asio::setProperty(
- *crow::connections::systemBus, "xyz.openbmc_project.Network",
- "/xyz/openbmc_project/network/" + ifaceId,
+ setDbusProperty(
+ asyncResp, "xyz.openbmc_project.Network",
+ sdbusplus::message::object_path("/xyz/openbmc_project/network") /
+ ifaceId,
"xyz.openbmc_project.Network.EthernetInterface", "StaticNameServers",
- updatedStaticNameServers,
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- });
+ "StaticNameServers", updatedStaticNameServers);
}
inline void handleIPv6StaticAddressesPatch(