diff options
-rw-r--r-- | include/ibm/locks.hpp | 8 | ||||
-rw-r--r-- | include/ibm/management_console_rest.hpp | 47 |
2 files changed, 39 insertions, 16 deletions
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp index 7b007082ae..66eb926263 100644 --- a/include/ibm/locks.hpp +++ b/include/ibm/locks.hpp @@ -42,7 +42,7 @@ class Lock boost::container::flat_map<uint32_t, LockRequests> lockTable; /* - * This function implements the logic for validating an incomming + * This function implements the logic for validating an incoming * lock request/requests. * * Returns : True (if Valid) @@ -52,7 +52,7 @@ class Lock bool isValidLockRequest(const LockRequest); /* - * This function implements the logic of checking if the incomming + * This function implements the logic of checking if the incoming * multi-lock request is not having conflicting requirements. * * Returns : True (if conflicting) @@ -74,7 +74,7 @@ class Lock /* * This function implements the logic of checking the conflicting - * locks from a incomming single/multi lock requests with the already + * locks from a incoming single/multi lock requests with the already * existing lock request in the lock table. * */ @@ -135,7 +135,7 @@ class Lock public: /* * This function implements the logic for acquiring a lock on a - * resource if the incomming request is legitimate without any + * resource if the incoming request is legitimate without any * conflicting requirements & without any conflicting requirement * with the exsiting locks in the lock table. * diff --git a/include/ibm/management_console_rest.hpp b/include/ibm/management_console_rest.hpp index 87beb049cb..9f8f8d28b5 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 handleAcquireLockAPI(const crow::Request &req, crow::Response &res, } } } +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 @@ template <typename... Middlewares> void requestRoutes(Crow<Middlewares...> &app) }); 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; - - if (!redfish::json_util::readJson(req, res, "TransactionIDs", - listTransactionIds)) - { - res.result(boost::beast::http::status::bad_request); - res.end(); - return; - } + .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, "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)( |