summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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