Implement ReleaseAll Locks functionality
- This commit implements the release all locks functionality
as a part of ReleaseLock API.
- The existing ReleaseLock API is modified in such a way that
based on it can do the following things:
1. Release the locks which are corresponding to a set of
transactionID's(provided as input & `Type:Transaction`)
2. Release all the locks which are corrsponding to a particular
session(where `Type:Session`)
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I89f847bcb85912d4d9f85587ffbf782da885393a
diff --git a/include/ibm/management_console_rest.hpp b/include/ibm/management_console_rest.hpp
index 87beb04..9f8f8d2 100644
--- a/include/ibm/management_console_rest.hpp
+++ b/include/ibm/management_console_rest.hpp
@@ -5,6 +5,7 @@
#include <async_resp.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/container/flat_set.hpp>
+#include <error_messages.hpp>
#include <filesystem>
#include <fstream>
#include <ibm/locks.hpp>
@@ -406,6 +407,13 @@
}
}
}
+void handleRelaseAllAPI(const crow::Request &req, crow::Response &res)
+{
+ crow::ibm_mc_lock::Lock::getInstance().releaseLock(req.session->uniqueId);
+ res.result(boost::beast::http::status::ok);
+ res.end();
+ return;
+}
void handleReleaseLockAPI(const crow::Request &req, crow::Response &res,
const std::vector<uint32_t> &listTransactionIds)
@@ -581,19 +589,34 @@
});
BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock")
.requires({"ConfigureComponents", "ConfigureManager"})
- .methods("POST"_method)(
- [](const crow::Request &req, crow::Response &res) {
- std::vector<uint32_t> listTransactionIds;
+ .methods(
+ "POST"_method)([](const crow::Request &req, crow::Response &res) {
+ std::string type;
+ std::vector<uint32_t> listTransactionIds;
- if (!redfish::json_util::readJson(req, res, "TransactionIDs",
- listTransactionIds))
- {
- res.result(boost::beast::http::status::bad_request);
- res.end();
- return;
- }
+ if (!redfish::json_util::readJson(req, res, "Type", type,
+ "TransactionIDs",
+ listTransactionIds))
+ {
+ res.result(boost::beast::http::status::bad_request);
+ res.end();
+ return;
+ }
+ if (type == "Transaction")
+ {
handleReleaseLockAPI(req, res, listTransactionIds);
- });
+ }
+ else if (type == "Session")
+ {
+ handleRelaseAllAPI(req, res);
+ }
+ else
+ {
+ BMCWEB_LOG_DEBUG << " Value of Type : " << type
+ << "is Not a Valid key";
+ redfish::messages::propertyValueNotInList(res, type, "Type");
+ }
+ });
BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.GetLockList")
.requires({"ConfigureComponents", "ConfigureManager"})
.methods("POST"_method)(