diff options
author | Jiaqing Zhao <jiaqing.zhao@intel.com> | 2022-09-13 04:38:25 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-10-05 23:04:30 +0300 |
commit | 23a063171f6a6baf935303e2124a6725dca2e8a0 (patch) | |
tree | 674d5febd137e53b9896ab654fd1d32b41e17e2c | |
parent | 22872ff355e9f3fdf5530be5979e2f0f98a7edc0 (diff) | |
download | bmcweb-23a063171f6a6baf935303e2124a6725dca2e8a0.tar.xz |
ethernet: Change the behavior of setting VLANEnable
In current implementation, setting VLANEnable to true does nothing
while setting to false will essentially delete the VLAN from system,
which is not a reasonable behavior for Redfish. PATCH requests should
never delete a resource. This patch changes the behavior to changing
the NICEnabled property of VLAN interface, which essentially enables/
disables the VLAN interface.
Tested:
Verified PATCH {"VLANEnable": false} no longer deletes the interface
and the NICEnabled property on DBus is successfully changed.
Change-Id: I8c47f6f2987fed576ba36c215f29bc03c6e9182b
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
-rw-r--r-- | redfish-core/lib/ethernet.hpp | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index 00f993007a..804d8aa407 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -2009,7 +2009,7 @@ inline void requestEthernetInterfacesRoutes(App& app) "/redfish/v1/Managers/bmc/EthernetInterfaces/" + parentIfaceId + "/VLANs/" + ifaceId; - asyncResp->res.jsonValue["VLANEnable"] = true; + asyncResp->res.jsonValue["VLANEnable"] = ethData.nicEnabled; asyncResp->res.jsonValue["VLANId"] = *ethData.vlanId; } else @@ -2067,23 +2067,22 @@ inline void requestEthernetInterfacesRoutes(App& app) const boost::container::flat_set<IPv6AddressData>&) { if (success && ethData.vlanId) { - auto callback = - [asyncResp](const boost::system::error_code ec) { - if (ec) - { - messages::internalError(asyncResp->res); - return; - } - }; - - if (vlanEnable && !(*vlanEnable)) + if (vlanEnable) { - BMCWEB_LOG_DEBUG << "vlanEnable is false. Deleting the " - "vlan interface"; crow::connections::systemBus->async_method_call( - std::move(callback), "xyz.openbmc_project.Network", - std::string("/xyz/openbmc_project/network/") + ifaceId, - "xyz.openbmc_project.Object.Delete", "Delete"); + [asyncResp](const boost::system::error_code ec) { + if (ec) + { + messages::internalError(asyncResp->res); + return; + } + }, + "xyz.openbmc_project.Network", + "/xyz/openbmc_project/network/" + ifaceId, + "org.freedesktop.DBus.Properties", "Set", + "xyz.openbmc_project.Network.EthernetInterface", + "NICEnabled", + dbus::utility::DbusVariantType(*vlanEnable)); } } else |