summaryrefslogtreecommitdiff
path: root/redfish-core/lib
diff options
context:
space:
mode:
authorJiaqing Zhao <jiaqing.zhao@intel.com>2023-03-09 06:14:44 +0300
committerEd Tanous <edtanous@google.com>2023-06-09 00:52:14 +0300
commite7caf25097d911dc290567e2a68ee6c4682e6890 (patch)
tree063079cd9e63c09971d0f574588fdf8d431ed26c /redfish-core/lib
parent7857cb8d830209fdf82db6250f5bd36c5ff01837 (diff)
downloadbmcweb-e7caf25097d911dc290567e2a68ee6c4682e6890.tar.xz
Implement DELETE EthernetInterface for VLAN
After using EthernetInterface to represent a VLAN interface, DELETE handler is required for deleting VLAN interfaces. Tested: * VLAN interfaces can be deleted successfully via DELETE request. * Deleting a physical interface returns ResourceCannotBeDeleted error. * Deleting a non-existent interface returns ResourceNotFound error. Change-Id: Ib22063eb3ddea0614c390ba83d4e6af29d007165 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com> Signed-off-by: Ed Tanous <edtanous@google.com>
Diffstat (limited to 'redfish-core/lib')
-rw-r--r--redfish-core/lib/ethernet.hpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index a5e397f1e8..74f544c9c8 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -1716,6 +1716,39 @@ inline void
}
}
+inline void afterDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& ifaceId,
+ const boost::system::error_code& ec,
+ const sdbusplus::message_t& m)
+{
+ if (!ec)
+ {
+ return;
+ }
+ const sd_bus_error* dbusError = m.get_error();
+ if (dbusError == nullptr)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ BMCWEB_LOG_DEBUG << "DBus error: " << dbusError->name;
+
+ if (std::string_view("org.freedesktop.DBus.Error.UnknownObject") ==
+ dbusError->name)
+ {
+ messages::resourceNotFound(asyncResp->res, "EthernetInterface",
+ ifaceId);
+ return;
+ }
+ if (std::string_view("org.freedesktop.DBus.Error.UnknownMethod") ==
+ dbusError->name)
+ {
+ messages::resourceCannotBeDeleted(asyncResp->res);
+ return;
+ }
+ messages::internalError(asyncResp->res);
+}
+
inline void requestEthernetInterfacesRoutes(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/EthernetInterfaces/")
@@ -1949,6 +1982,27 @@ inline void requestEthernetInterfacesRoutes(App& app)
}
});
});
+
+ BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/EthernetInterfaces/<str>/")
+ .privileges(redfish::privileges::deleteEthernetInterface)
+ .methods(boost::beast::http::verb::delete_)(
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& ifaceId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+
+ crow::connections::systemBus->async_method_call(
+ [asyncResp, ifaceId](const boost::system::error_code& ec,
+ const sdbusplus::message_t& m) {
+ afterDelete(asyncResp, ifaceId, ec, m);
+ },
+ "xyz.openbmc_project.Network",
+ std::string("/xyz/openbmc_project/network/") + ifaceId,
+ "xyz.openbmc_project.Object.Delete", "Delete");
+ });
}
} // namespace redfish