Ratan Gupta | 453fed0 | 2019-12-14 09:39:47 +0530 | [diff] [blame] | 1 | #pragma once |
Ratan Gupta | 453fed0 | 2019-12-14 09:39:47 +0530 | [diff] [blame] | 2 | #include <tinyxml2.h> |
| 3 | |
Ed Tanous | 04e438c | 2020-10-03 08:06:26 -0700 | [diff] [blame] | 4 | #include <app.hpp> |
Ratan Gupta | 453fed0 | 2019-12-14 09:39:47 +0530 | [diff] [blame] | 5 | #include <async_resp.hpp> |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 6 | #include <boost/algorithm/string.hpp> |
| 7 | #include <boost/container/flat_set.hpp> |
Manojkiran Eda | 5bb0ece | 2020-01-20 20:22:36 +0530 | [diff] [blame] | 8 | #include <error_messages.hpp> |
Sunitha Harish | 96330b9 | 2020-06-26 05:42:14 -0500 | [diff] [blame] | 9 | #include <event_service_manager.hpp> |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 10 | #include <ibm/locks.hpp> |
| 11 | #include <nlohmann/json.hpp> |
Sunitha Harish | 96330b9 | 2020-06-26 05:42:14 -0500 | [diff] [blame] | 12 | #include <resource_messages.hpp> |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 13 | #include <sdbusplus/message/types.hpp> |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 14 | #include <utils/json_utils.hpp> |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 15 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 16 | #include <filesystem> |
| 17 | #include <fstream> |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 18 | |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 19 | using SType = std::string; |
| 20 | using SegmentFlags = std::vector<std::pair<std::string, uint32_t>>; |
| 21 | using LockRequest = std::tuple<SType, SType, SType, uint64_t, SegmentFlags>; |
| 22 | using LockRequests = std::vector<LockRequest>; |
| 23 | using Rc = std::pair<bool, std::variant<uint32_t, LockRequest>>; |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 24 | using RcGetLockList = |
| 25 | std::variant<std::string, std::vector<std::pair<uint32_t, LockRequests>>>; |
| 26 | using ListOfSessionIds = std::vector<std::string>; |
Ratan Gupta | 453fed0 | 2019-12-14 09:39:47 +0530 | [diff] [blame] | 27 | namespace crow |
| 28 | { |
| 29 | namespace ibm_mc |
| 30 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 31 | constexpr const char* methodNotAllowedMsg = "Method Not Allowed"; |
| 32 | constexpr const char* resourceNotFoundMsg = "Resource Not Found"; |
| 33 | constexpr const char* contentNotAcceptableMsg = "Content Not Acceptable"; |
| 34 | constexpr const char* internalServerError = "Internal Server Error"; |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 35 | |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 36 | constexpr size_t maxSaveareaDirSize = |
| 37 | 10000000; // Allow save area dir size to be max 10MB |
| 38 | constexpr size_t minSaveareaFileSize = |
| 39 | 100; // Allow save area file size of minimum 100B |
Asmitha Karunanithi | 5738de5 | 2020-07-17 02:03:31 -0500 | [diff] [blame] | 40 | constexpr size_t maxSaveareaFileSize = |
| 41 | 500000; // Allow save area file size upto 500KB |
| 42 | constexpr size_t maxBroadcastMsgSize = |
| 43 | 1000; // Allow Broadcast message size upto 1KB |
| 44 | |
Ed Tanous | 02379d3 | 2020-09-15 21:15:44 -0700 | [diff] [blame] | 45 | inline bool createSaveAreaPath(crow::Response& res) |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 46 | { |
| 47 | // The path /var/lib/obmc will be created by initrdscripts |
| 48 | // Create the directories for the save-area files, when we get |
| 49 | // first file upload request |
| 50 | std::error_code ec; |
| 51 | if (!std::filesystem::is_directory("/var/lib/obmc/bmc-console-mgmt", ec)) |
| 52 | { |
| 53 | std::filesystem::create_directory("/var/lib/obmc/bmc-console-mgmt", ec); |
| 54 | } |
| 55 | if (ec) |
| 56 | { |
| 57 | res.result(boost::beast::http::status::internal_server_error); |
| 58 | res.jsonValue["Description"] = internalServerError; |
| 59 | BMCWEB_LOG_DEBUG |
| 60 | << "handleIbmPost: Failed to prepare save-area directory. ec : " |
| 61 | << ec; |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | if (!std::filesystem::is_directory( |
| 66 | "/var/lib/obmc/bmc-console-mgmt/save-area", ec)) |
| 67 | { |
| 68 | std::filesystem::create_directory( |
| 69 | "/var/lib/obmc/bmc-console-mgmt/save-area", ec); |
| 70 | } |
| 71 | if (ec) |
| 72 | { |
| 73 | res.result(boost::beast::http::status::internal_server_error); |
| 74 | res.jsonValue["Description"] = internalServerError; |
| 75 | BMCWEB_LOG_DEBUG |
| 76 | << "handleIbmPost: Failed to prepare save-area directory. ec : " |
| 77 | << ec; |
| 78 | return false; |
| 79 | } |
| 80 | return true; |
| 81 | } |
Ed Tanous | 02379d3 | 2020-09-15 21:15:44 -0700 | [diff] [blame] | 82 | |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 83 | inline void handleFilePut(const crow::Request& req, |
| 84 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
Ed Tanous | 02379d3 | 2020-09-15 21:15:44 -0700 | [diff] [blame] | 85 | const std::string& fileID) |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 86 | { |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 87 | std::error_code ec; |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 88 | // Check the content-type of the request |
| 89 | std::string_view contentType = req.getHeaderValue("content-type"); |
| 90 | if (boost::starts_with(contentType, "multipart/form-data")) |
| 91 | { |
| 92 | BMCWEB_LOG_DEBUG |
| 93 | << "This is multipart/form-data. Invalid content for PUT"; |
| 94 | |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 95 | asyncResp->res.result(boost::beast::http::status::not_acceptable); |
| 96 | asyncResp->res.jsonValue["Description"] = contentNotAcceptableMsg; |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 97 | return; |
| 98 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 99 | BMCWEB_LOG_DEBUG << "Not a multipart/form-data. Continue.."; |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 100 | |
| 101 | BMCWEB_LOG_DEBUG |
| 102 | << "handleIbmPut: Request to create/update the save-area file"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 103 | if (!createSaveAreaPath(asyncResp->res)) |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 104 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 105 | asyncResp->res.result(boost::beast::http::status::not_found); |
| 106 | asyncResp->res.jsonValue["Description"] = resourceNotFoundMsg; |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 107 | return; |
| 108 | } |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 109 | |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 110 | std::ofstream file; |
| 111 | std::filesystem::path loc("/var/lib/obmc/bmc-console-mgmt/save-area"); |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 112 | |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 113 | // Get the current size of the savearea directory |
| 114 | std::filesystem::recursive_directory_iterator iter(loc, ec); |
| 115 | if (ec) |
| 116 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 117 | asyncResp->res.result( |
| 118 | boost::beast::http::status::internal_server_error); |
| 119 | asyncResp->res.jsonValue["Description"] = internalServerError; |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 120 | BMCWEB_LOG_DEBUG << "handleIbmPut: Failed to prepare save-area " |
| 121 | "directory iterator. ec : " |
| 122 | << ec; |
| 123 | return; |
| 124 | } |
| 125 | std::uintmax_t saveAreaDirSize = 0; |
| 126 | for (auto& it : iter) |
| 127 | { |
| 128 | if (!std::filesystem::is_directory(it, ec)) |
| 129 | { |
| 130 | if (ec) |
| 131 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 132 | asyncResp->res.result( |
| 133 | boost::beast::http::status::internal_server_error); |
| 134 | asyncResp->res.jsonValue["Description"] = internalServerError; |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 135 | BMCWEB_LOG_DEBUG << "handleIbmPut: Failed to find save-area " |
| 136 | "directory . ec : " |
| 137 | << ec; |
| 138 | return; |
| 139 | } |
| 140 | std::uintmax_t fileSize = std::filesystem::file_size(it, ec); |
| 141 | if (ec) |
| 142 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 143 | asyncResp->res.result( |
| 144 | boost::beast::http::status::internal_server_error); |
| 145 | asyncResp->res.jsonValue["Description"] = internalServerError; |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 146 | BMCWEB_LOG_DEBUG << "handleIbmPut: Failed to find save-area " |
| 147 | "file size inside the directory . ec : " |
| 148 | << ec; |
| 149 | return; |
| 150 | } |
| 151 | saveAreaDirSize += fileSize; |
| 152 | } |
| 153 | } |
| 154 | BMCWEB_LOG_DEBUG << "saveAreaDirSize: " << saveAreaDirSize; |
| 155 | |
| 156 | // Get the file size getting uploaded |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 157 | const std::string& data = req.body; |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 158 | BMCWEB_LOG_DEBUG << "data length: " << data.length(); |
| 159 | |
| 160 | if (data.length() < minSaveareaFileSize) |
| 161 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 162 | asyncResp->res.result(boost::beast::http::status::bad_request); |
| 163 | asyncResp->res.jsonValue["Description"] = |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 164 | "File size is less than minimum allowed size[100B]"; |
| 165 | return; |
| 166 | } |
| 167 | if (data.length() > maxSaveareaFileSize) |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 168 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 169 | asyncResp->res.result(boost::beast::http::status::bad_request); |
| 170 | asyncResp->res.jsonValue["Description"] = |
Ratan Gupta | e46946a | 2020-05-11 13:22:59 +0530 | [diff] [blame] | 171 | "File size exceeds maximum allowed size[500KB]"; |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 172 | return; |
| 173 | } |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 174 | |
| 175 | // Form the file path |
| 176 | loc /= fileID; |
Asmitha Karunanithi | 10693fa | 2020-07-27 02:27:49 -0500 | [diff] [blame] | 177 | BMCWEB_LOG_DEBUG << "Writing to the file: " << loc; |
| 178 | |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 179 | // Check if the same file exists in the directory |
| 180 | bool fileExists = std::filesystem::exists(loc, ec); |
| 181 | if (ec) |
Asmitha Karunanithi | 10693fa | 2020-07-27 02:27:49 -0500 | [diff] [blame] | 182 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 183 | asyncResp->res.result( |
| 184 | boost::beast::http::status::internal_server_error); |
| 185 | asyncResp->res.jsonValue["Description"] = internalServerError; |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 186 | BMCWEB_LOG_DEBUG << "handleIbmPut: Failed to find if file exists. ec : " |
| 187 | << ec; |
| 188 | return; |
Asmitha Karunanithi | 10693fa | 2020-07-27 02:27:49 -0500 | [diff] [blame] | 189 | } |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 190 | |
| 191 | std::uintmax_t newSizeToWrite = 0; |
| 192 | if (fileExists) |
| 193 | { |
| 194 | // File exists. Get the current file size |
| 195 | std::uintmax_t currentFileSize = std::filesystem::file_size(loc, ec); |
| 196 | if (ec) |
| 197 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 198 | asyncResp->res.result( |
| 199 | boost::beast::http::status::internal_server_error); |
| 200 | asyncResp->res.jsonValue["Description"] = internalServerError; |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 201 | BMCWEB_LOG_DEBUG << "handleIbmPut: Failed to find file size. ec : " |
| 202 | << ec; |
| 203 | return; |
| 204 | } |
| 205 | // Calculate the difference in the file size. |
| 206 | // If the data.length is greater than the existing file size, then |
| 207 | // calculate the difference. Else consider the delta size as zero - |
| 208 | // because there is no increase in the total directory size. |
| 209 | // We need to add the diff only if the incoming data is larger than the |
| 210 | // existing filesize |
| 211 | if (data.length() > currentFileSize) |
| 212 | { |
| 213 | newSizeToWrite = data.length() - currentFileSize; |
| 214 | } |
| 215 | BMCWEB_LOG_DEBUG << "newSizeToWrite: " << newSizeToWrite; |
| 216 | } |
| 217 | else |
| 218 | { |
| 219 | // This is a new file upload |
| 220 | newSizeToWrite = data.length(); |
| 221 | } |
| 222 | |
| 223 | // Calculate the total dir size before writing the new file |
| 224 | BMCWEB_LOG_DEBUG << "total new size: " << saveAreaDirSize + newSizeToWrite; |
| 225 | |
| 226 | if ((saveAreaDirSize + newSizeToWrite) > maxSaveareaDirSize) |
| 227 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 228 | asyncResp->res.result(boost::beast::http::status::bad_request); |
| 229 | asyncResp->res.jsonValue["Description"] = |
| 230 | "File size does not fit in the savearea " |
| 231 | "directory maximum allowed size[10MB]"; |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 232 | return; |
| 233 | } |
| 234 | |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 235 | file.open(loc, std::ofstream::out); |
| 236 | if (file.fail()) |
| 237 | { |
| 238 | BMCWEB_LOG_DEBUG << "Error while opening the file for writing"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 239 | asyncResp->res.result( |
| 240 | boost::beast::http::status::internal_server_error); |
| 241 | asyncResp->res.jsonValue["Description"] = |
| 242 | "Error while creating the file"; |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 243 | return; |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 244 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 245 | file << data; |
| 246 | std::string origin = "/ibm/v1/Host/ConfigFiles/" + fileID; |
| 247 | // Push an event |
| 248 | if (fileExists) |
| 249 | { |
| 250 | BMCWEB_LOG_DEBUG << "config file is updated"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 251 | asyncResp->res.jsonValue["Description"] = "File Updated"; |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 252 | |
| 253 | redfish::EventServiceManager::getInstance().sendEvent( |
| 254 | redfish::messages::resourceChanged(), origin, "IBMConfigFile"); |
| 255 | } |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 256 | else |
| 257 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 258 | BMCWEB_LOG_DEBUG << "config file is created"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 259 | asyncResp->res.jsonValue["Description"] = "File Created"; |
Asmitha Karunanithi | 10693fa | 2020-07-27 02:27:49 -0500 | [diff] [blame] | 260 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 261 | redfish::EventServiceManager::getInstance().sendEvent( |
| 262 | redfish::messages::resourceCreated(), origin, "IBMConfigFile"); |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 263 | } |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 264 | } |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 265 | |
Ed Tanous | 02379d3 | 2020-09-15 21:15:44 -0700 | [diff] [blame] | 266 | inline void handleConfigFileList(crow::Response& res) |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 267 | { |
| 268 | std::vector<std::string> pathObjList; |
| 269 | std::filesystem::path loc("/var/lib/obmc/bmc-console-mgmt/save-area"); |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 270 | std::shared_ptr<bmcweb::AsyncResp> asyncResp = |
| 271 | std::make_shared<bmcweb::AsyncResp>(res); |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 272 | if (std::filesystem::exists(loc) && std::filesystem::is_directory(loc)) |
| 273 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 274 | for (const auto& file : std::filesystem::directory_iterator(loc)) |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 275 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 276 | const std::filesystem::path& pathObj = file.path(); |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 277 | pathObjList.push_back("/ibm/v1/Host/ConfigFiles/" + |
| 278 | pathObj.filename().string()); |
| 279 | } |
| 280 | } |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 281 | asyncResp->res.jsonValue["@odata.type"] = |
| 282 | "#IBMConfigFile.v1_0_0.IBMConfigFile"; |
| 283 | asyncResp->res.jsonValue["@odata.id"] = "/ibm/v1/Host/ConfigFiles/"; |
| 284 | asyncResp->res.jsonValue["Id"] = "ConfigFiles"; |
| 285 | asyncResp->res.jsonValue["Name"] = "ConfigFiles"; |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 286 | |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 287 | asyncResp->res.jsonValue["Members"] = std::move(pathObjList); |
| 288 | asyncResp->res.jsonValue["Actions"]["#IBMConfigFiles.DeleteAll"] = { |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 289 | {"target", |
Sunitha Harish | e56f254 | 2020-07-22 02:38:59 -0500 | [diff] [blame] | 290 | "/ibm/v1/Host/ConfigFiles/Actions/IBMConfigFiles.DeleteAll"}}; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 291 | return; |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 292 | } |
| 293 | |
Ed Tanous | 02379d3 | 2020-09-15 21:15:44 -0700 | [diff] [blame] | 294 | inline void deleteConfigFiles(crow::Response& res) |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 295 | { |
| 296 | std::vector<std::string> pathObjList; |
| 297 | std::error_code ec; |
| 298 | std::filesystem::path loc("/var/lib/obmc/bmc-console-mgmt/save-area"); |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 299 | std::shared_ptr<bmcweb::AsyncResp> asyncResp = |
| 300 | std::make_shared<bmcweb::AsyncResp>(res); |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 301 | if (std::filesystem::exists(loc) && std::filesystem::is_directory(loc)) |
| 302 | { |
| 303 | std::filesystem::remove_all(loc, ec); |
| 304 | if (ec) |
| 305 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 306 | asyncResp->res.result( |
| 307 | boost::beast::http::status::internal_server_error); |
| 308 | asyncResp->res.jsonValue["Description"] = internalServerError; |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 309 | BMCWEB_LOG_DEBUG << "deleteConfigFiles: Failed to delete the " |
| 310 | "config files directory. ec : " |
| 311 | << ec; |
| 312 | } |
| 313 | } |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 314 | return; |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 315 | } |
| 316 | |
Ed Tanous | 02379d3 | 2020-09-15 21:15:44 -0700 | [diff] [blame] | 317 | inline void getLockServiceData(crow::Response& res) |
Ratan Gupta | 734a1c3 | 2019-12-14 11:53:48 +0530 | [diff] [blame] | 318 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 319 | std::shared_ptr<bmcweb::AsyncResp> asyncResp = |
| 320 | std::make_shared<bmcweb::AsyncResp>(res); |
| 321 | asyncResp->res.jsonValue["@odata.type"] = "#LockService.v1_0_0.LockService"; |
| 322 | asyncResp->res.jsonValue["@odata.id"] = "/ibm/v1/HMC/LockService/"; |
| 323 | asyncResp->res.jsonValue["Id"] = "LockService"; |
| 324 | asyncResp->res.jsonValue["Name"] = "LockService"; |
Ratan Gupta | 734a1c3 | 2019-12-14 11:53:48 +0530 | [diff] [blame] | 325 | |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 326 | asyncResp->res.jsonValue["Actions"]["#LockService.AcquireLock"] = { |
Ratan Gupta | 734a1c3 | 2019-12-14 11:53:48 +0530 | [diff] [blame] | 327 | {"target", "/ibm/v1/HMC/LockService/Actions/LockService.AcquireLock"}}; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 328 | asyncResp->res.jsonValue["Actions"]["#LockService.ReleaseLock"] = { |
Ratan Gupta | 734a1c3 | 2019-12-14 11:53:48 +0530 | [diff] [blame] | 329 | {"target", "/ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock"}}; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 330 | asyncResp->res.jsonValue["Actions"]["#LockService.GetLockList"] = { |
Ratan Gupta | 734a1c3 | 2019-12-14 11:53:48 +0530 | [diff] [blame] | 331 | {"target", "/ibm/v1/HMC/LockService/Actions/LockService.GetLockList"}}; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 332 | return; |
Ratan Gupta | 734a1c3 | 2019-12-14 11:53:48 +0530 | [diff] [blame] | 333 | } |
| 334 | |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 335 | inline void handleFileGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 336 | const std::string& fileID) |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 337 | { |
| 338 | BMCWEB_LOG_DEBUG << "HandleGet on SaveArea files on path: " << fileID; |
| 339 | std::filesystem::path loc("/var/lib/obmc/bmc-console-mgmt/save-area/" + |
| 340 | fileID); |
| 341 | if (!std::filesystem::exists(loc)) |
| 342 | { |
| 343 | BMCWEB_LOG_ERROR << loc << "Not found"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 344 | asyncResp->res.result(boost::beast::http::status::not_found); |
| 345 | asyncResp->res.jsonValue["Description"] = resourceNotFoundMsg; |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 346 | return; |
| 347 | } |
| 348 | |
| 349 | std::ifstream readfile(loc.string()); |
| 350 | if (!readfile) |
| 351 | { |
| 352 | BMCWEB_LOG_ERROR << loc.string() << "Not found"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 353 | asyncResp->res.result(boost::beast::http::status::not_found); |
| 354 | asyncResp->res.jsonValue["Description"] = resourceNotFoundMsg; |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 355 | return; |
| 356 | } |
| 357 | |
| 358 | std::string contentDispositionParam = |
| 359 | "attachment; filename=\"" + fileID + "\""; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 360 | asyncResp->res.addHeader("Content-Disposition", contentDispositionParam); |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 361 | std::string fileData; |
| 362 | fileData = {std::istreambuf_iterator<char>(readfile), |
| 363 | std::istreambuf_iterator<char>()}; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 364 | asyncResp->res.jsonValue["Data"] = fileData; |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 365 | return; |
| 366 | } |
| 367 | |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 368 | inline void |
| 369 | handleFileDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 370 | const std::string& fileID) |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 371 | { |
| 372 | std::string filePath("/var/lib/obmc/bmc-console-mgmt/save-area/" + fileID); |
| 373 | BMCWEB_LOG_DEBUG << "Removing the file : " << filePath << "\n"; |
Ed Tanous | 2c70f80 | 2020-09-28 14:29:23 -0700 | [diff] [blame] | 374 | std::ifstream fileOpen(filePath.c_str()); |
| 375 | if (static_cast<bool>(fileOpen)) |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 376 | { |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 377 | if (remove(filePath.c_str()) == 0) |
| 378 | { |
| 379 | BMCWEB_LOG_DEBUG << "File removed!\n"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 380 | asyncResp->res.jsonValue["Description"] = "File Deleted"; |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 381 | } |
| 382 | else |
| 383 | { |
| 384 | BMCWEB_LOG_ERROR << "File not removed!\n"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 385 | asyncResp->res.result( |
| 386 | boost::beast::http::status::internal_server_error); |
| 387 | asyncResp->res.jsonValue["Description"] = internalServerError; |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 388 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 389 | } |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 390 | else |
| 391 | { |
| 392 | BMCWEB_LOG_ERROR << "File not found!\n"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 393 | asyncResp->res.result(boost::beast::http::status::not_found); |
| 394 | asyncResp->res.jsonValue["Description"] = resourceNotFoundMsg; |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 395 | } |
| 396 | return; |
| 397 | } |
| 398 | |
Asmitha Karunanithi | 5738de5 | 2020-07-17 02:03:31 -0500 | [diff] [blame] | 399 | inline void handleBroadcastService(const crow::Request& req, |
| 400 | crow::Response& res) |
| 401 | { |
| 402 | std::string broadcastMsg; |
| 403 | |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 404 | std::shared_ptr<bmcweb::AsyncResp> asyncResp = |
| 405 | std::make_shared<bmcweb::AsyncResp>(res); |
| 406 | |
Asmitha Karunanithi | 5738de5 | 2020-07-17 02:03:31 -0500 | [diff] [blame] | 407 | if (!redfish::json_util::readJson(req, res, "Message", broadcastMsg)) |
| 408 | { |
| 409 | BMCWEB_LOG_DEBUG << "Not a Valid JSON"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 410 | asyncResp->res.result(boost::beast::http::status::bad_request); |
Asmitha Karunanithi | 5738de5 | 2020-07-17 02:03:31 -0500 | [diff] [blame] | 411 | return; |
| 412 | } |
| 413 | if (broadcastMsg.size() > maxBroadcastMsgSize) |
| 414 | { |
| 415 | BMCWEB_LOG_ERROR << "Message size exceeds maximum allowed size[1KB]"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 416 | asyncResp->res.result(boost::beast::http::status::bad_request); |
Asmitha Karunanithi | 5738de5 | 2020-07-17 02:03:31 -0500 | [diff] [blame] | 417 | return; |
| 418 | } |
| 419 | redfish::EventServiceManager::getInstance().sendBroadcastMsg(broadcastMsg); |
Asmitha Karunanithi | 5738de5 | 2020-07-17 02:03:31 -0500 | [diff] [blame] | 420 | return; |
| 421 | } |
| 422 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 423 | inline void handleFileUrl(const crow::Request& req, crow::Response& res, |
| 424 | const std::string& fileID) |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 425 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 426 | std::shared_ptr<bmcweb::AsyncResp> asyncResp = |
| 427 | std::make_shared<bmcweb::AsyncResp>(res); |
| 428 | |
Ed Tanous | b41187f | 2019-10-24 16:30:02 -0700 | [diff] [blame] | 429 | if (req.method() == boost::beast::http::verb::put) |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 430 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 431 | handleFilePut(req, asyncResp, fileID); |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 432 | return; |
| 433 | } |
Ed Tanous | b41187f | 2019-10-24 16:30:02 -0700 | [diff] [blame] | 434 | if (req.method() == boost::beast::http::verb::get) |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 435 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 436 | handleFileGet(asyncResp, fileID); |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 437 | return; |
| 438 | } |
Ed Tanous | b41187f | 2019-10-24 16:30:02 -0700 | [diff] [blame] | 439 | if (req.method() == boost::beast::http::verb::delete_) |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 440 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 441 | handleFileDelete(asyncResp, fileID); |
asmithakarun | 1c7b07c | 2019-09-09 03:42:59 -0500 | [diff] [blame] | 442 | return; |
| 443 | } |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 444 | } |
Ratan Gupta | 453fed0 | 2019-12-14 09:39:47 +0530 | [diff] [blame] | 445 | |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 446 | inline void |
| 447 | handleAcquireLockAPI(const crow::Request& req, |
| 448 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 449 | std::vector<nlohmann::json> body) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 450 | { |
| 451 | LockRequests lockRequestStructure; |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 452 | for (auto& element : body) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 453 | { |
| 454 | std::string lockType; |
| 455 | uint64_t resourceId; |
| 456 | |
| 457 | SegmentFlags segInfo; |
| 458 | std::vector<nlohmann::json> segmentFlags; |
| 459 | |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 460 | if (!redfish::json_util::readJson(element, asyncResp->res, "LockType", |
| 461 | lockType, "ResourceID", resourceId, |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 462 | "SegmentFlags", segmentFlags)) |
| 463 | { |
| 464 | BMCWEB_LOG_DEBUG << "Not a Valid JSON"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 465 | asyncResp->res.result(boost::beast::http::status::bad_request); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 466 | return; |
| 467 | } |
| 468 | BMCWEB_LOG_DEBUG << lockType; |
| 469 | BMCWEB_LOG_DEBUG << resourceId; |
| 470 | |
| 471 | BMCWEB_LOG_DEBUG << "Segment Flags are present"; |
| 472 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 473 | for (auto& e : segmentFlags) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 474 | { |
| 475 | std::string lockFlags; |
| 476 | uint32_t segmentLength; |
| 477 | |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 478 | if (!redfish::json_util::readJson(e, asyncResp->res, "LockFlag", |
| 479 | lockFlags, "SegmentLength", |
| 480 | segmentLength)) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 481 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 482 | asyncResp->res.result(boost::beast::http::status::bad_request); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 483 | return; |
| 484 | } |
| 485 | |
| 486 | BMCWEB_LOG_DEBUG << "Lockflag : " << lockFlags; |
| 487 | BMCWEB_LOG_DEBUG << "SegmentLength : " << segmentLength; |
| 488 | |
| 489 | segInfo.push_back(std::make_pair(lockFlags, segmentLength)); |
| 490 | } |
Manojkiran Eda | 566329e | 2020-05-22 12:36:17 +0530 | [diff] [blame] | 491 | lockRequestStructure.push_back( |
| 492 | make_tuple(req.session->uniqueId, req.session->clientId, lockType, |
| 493 | resourceId, segInfo)); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | // print lock request into journal |
| 497 | |
Ed Tanous | 4e08751 | 2020-09-28 18:41:25 -0700 | [diff] [blame] | 498 | for (auto& i : lockRequestStructure) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 499 | { |
Ed Tanous | 4e08751 | 2020-09-28 18:41:25 -0700 | [diff] [blame] | 500 | BMCWEB_LOG_DEBUG << std::get<0>(i); |
| 501 | BMCWEB_LOG_DEBUG << std::get<1>(i); |
| 502 | BMCWEB_LOG_DEBUG << std::get<2>(i); |
| 503 | BMCWEB_LOG_DEBUG << std::get<3>(i); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 504 | |
Ed Tanous | 4e08751 | 2020-09-28 18:41:25 -0700 | [diff] [blame] | 505 | for (const auto& p : std::get<4>(i)) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 506 | { |
| 507 | BMCWEB_LOG_DEBUG << p.first << ", " << p.second; |
| 508 | } |
| 509 | } |
| 510 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 511 | const LockRequests& t = lockRequestStructure; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 512 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 513 | auto varAcquireLock = crow::ibm_mc_lock::Lock::getInstance().acquireLock(t); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 514 | |
| 515 | if (varAcquireLock.first) |
| 516 | { |
| 517 | // Either validity failure of there is a conflict with itself |
| 518 | |
| 519 | auto validityStatus = |
| 520 | std::get<std::pair<bool, int>>(varAcquireLock.second); |
| 521 | |
| 522 | if ((!validityStatus.first) && (validityStatus.second == 0)) |
| 523 | { |
| 524 | BMCWEB_LOG_DEBUG << "Not a Valid record"; |
| 525 | BMCWEB_LOG_DEBUG << "Bad json in request"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 526 | asyncResp->res.result(boost::beast::http::status::bad_request); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 527 | return; |
| 528 | } |
| 529 | if (validityStatus.first && (validityStatus.second == 1)) |
| 530 | { |
| 531 | BMCWEB_LOG_DEBUG << "There is a conflict within itself"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 532 | asyncResp->res.result(boost::beast::http::status::bad_request); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 533 | return; |
| 534 | } |
| 535 | } |
| 536 | else |
| 537 | { |
| 538 | auto conflictStatus = |
| 539 | std::get<crow::ibm_mc_lock::Rc>(varAcquireLock.second); |
| 540 | if (!conflictStatus.first) |
| 541 | { |
| 542 | BMCWEB_LOG_DEBUG << "There is no conflict with the locktable"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 543 | asyncResp->res.result(boost::beast::http::status::ok); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 544 | |
| 545 | auto var = std::get<uint32_t>(conflictStatus.second); |
| 546 | nlohmann::json returnJson; |
| 547 | returnJson["id"] = var; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 548 | asyncResp->res.jsonValue["TransactionID"] = var; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 549 | return; |
| 550 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 551 | BMCWEB_LOG_DEBUG << "There is a conflict with the lock table"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 552 | asyncResp->res.result(boost::beast::http::status::conflict); |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 553 | auto var = |
| 554 | std::get<std::pair<uint32_t, LockRequest>>(conflictStatus.second); |
| 555 | nlohmann::json returnJson, segments; |
| 556 | nlohmann::json myarray = nlohmann::json::array(); |
| 557 | returnJson["TransactionID"] = var.first; |
| 558 | returnJson["SessionID"] = std::get<0>(var.second); |
| 559 | returnJson["HMCID"] = std::get<1>(var.second); |
| 560 | returnJson["LockType"] = std::get<2>(var.second); |
| 561 | returnJson["ResourceID"] = std::get<3>(var.second); |
| 562 | |
| 563 | for (auto& i : std::get<4>(var.second)) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 564 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 565 | segments["LockFlag"] = i.first; |
| 566 | segments["SegmentLength"] = i.second; |
| 567 | myarray.push_back(segments); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 568 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 569 | |
| 570 | returnJson["SegmentFlags"] = myarray; |
| 571 | |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 572 | asyncResp->res.jsonValue["Record"] = returnJson; |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 573 | return; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 574 | } |
| 575 | } |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 576 | inline void |
| 577 | handleRelaseAllAPI(const crow::Request& req, |
| 578 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
Manojkiran Eda | 5bb0ece | 2020-01-20 20:22:36 +0530 | [diff] [blame] | 579 | { |
| 580 | crow::ibm_mc_lock::Lock::getInstance().releaseLock(req.session->uniqueId); |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 581 | asyncResp->res.result(boost::beast::http::status::ok); |
Manojkiran Eda | 5bb0ece | 2020-01-20 20:22:36 +0530 | [diff] [blame] | 582 | return; |
| 583 | } |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 584 | |
Ed Tanous | 02379d3 | 2020-09-15 21:15:44 -0700 | [diff] [blame] | 585 | inline void |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 586 | handleReleaseLockAPI(const crow::Request& req, |
| 587 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
Ed Tanous | 02379d3 | 2020-09-15 21:15:44 -0700 | [diff] [blame] | 588 | const std::vector<uint32_t>& listTransactionIds) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 589 | { |
| 590 | BMCWEB_LOG_DEBUG << listTransactionIds.size(); |
| 591 | BMCWEB_LOG_DEBUG << "Data is present"; |
Ed Tanous | 4e08751 | 2020-09-28 18:41:25 -0700 | [diff] [blame] | 592 | for (unsigned int listTransactionId : listTransactionIds) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 593 | { |
Ed Tanous | 4e08751 | 2020-09-28 18:41:25 -0700 | [diff] [blame] | 594 | BMCWEB_LOG_DEBUG << listTransactionId; |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 595 | } |
| 596 | |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 597 | // validate the request ids |
| 598 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 599 | auto varReleaselock = crow::ibm_mc_lock::Lock::getInstance().releaseLock( |
Manojkiran Eda | 566329e | 2020-05-22 12:36:17 +0530 | [diff] [blame] | 600 | listTransactionIds, |
| 601 | std::make_pair(req.session->clientId, req.session->uniqueId)); |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 602 | |
| 603 | if (!varReleaselock.first) |
| 604 | { |
| 605 | // validation Failed |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 606 | asyncResp->res.result(boost::beast::http::status::bad_request); |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 607 | return; |
| 608 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 609 | auto statusRelease = |
| 610 | std::get<crow::ibm_mc_lock::RcRelaseLock>(varReleaselock.second); |
| 611 | if (statusRelease.first) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 612 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 613 | // The current hmc owns all the locks, so we already released |
| 614 | // them |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 615 | return; |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 616 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 617 | |
| 618 | // valid rid, but the current hmc does not own all the locks |
| 619 | BMCWEB_LOG_DEBUG << "Current HMC does not own all the locks"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 620 | asyncResp->res.result(boost::beast::http::status::unauthorized); |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 621 | |
| 622 | auto var = statusRelease.second; |
| 623 | nlohmann::json returnJson, segments; |
| 624 | nlohmann::json myArray = nlohmann::json::array(); |
| 625 | returnJson["TransactionID"] = var.first; |
| 626 | returnJson["SessionID"] = std::get<0>(var.second); |
| 627 | returnJson["HMCID"] = std::get<1>(var.second); |
| 628 | returnJson["LockType"] = std::get<2>(var.second); |
| 629 | returnJson["ResourceID"] = std::get<3>(var.second); |
| 630 | |
| 631 | for (auto& i : std::get<4>(var.second)) |
| 632 | { |
| 633 | segments["LockFlag"] = i.first; |
| 634 | segments["SegmentLength"] = i.second; |
| 635 | myArray.push_back(segments); |
| 636 | } |
| 637 | |
| 638 | returnJson["SegmentFlags"] = myArray; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 639 | asyncResp->res.jsonValue["Record"] = returnJson; |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 640 | return; |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 641 | } |
| 642 | |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 643 | inline void |
| 644 | handleGetLockListAPI(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 645 | const ListOfSessionIds& listSessionIds) |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 646 | { |
| 647 | BMCWEB_LOG_DEBUG << listSessionIds.size(); |
| 648 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 649 | auto status = |
| 650 | crow::ibm_mc_lock::Lock::getInstance().getLockList(listSessionIds); |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 651 | auto var = std::get<std::vector<std::pair<uint32_t, LockRequests>>>(status); |
| 652 | |
| 653 | nlohmann::json lockRecords = nlohmann::json::array(); |
| 654 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 655 | for (const auto& transactionId : var) |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 656 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 657 | for (const auto& lockRecord : transactionId.second) |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 658 | { |
| 659 | nlohmann::json returnJson; |
| 660 | |
| 661 | returnJson["TransactionID"] = transactionId.first; |
| 662 | returnJson["SessionID"] = std::get<0>(lockRecord); |
| 663 | returnJson["HMCID"] = std::get<1>(lockRecord); |
| 664 | returnJson["LockType"] = std::get<2>(lockRecord); |
| 665 | returnJson["ResourceID"] = std::get<3>(lockRecord); |
| 666 | |
| 667 | nlohmann::json segments; |
| 668 | nlohmann::json segmentInfoArray = nlohmann::json::array(); |
| 669 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 670 | for (const auto& segment : std::get<4>(lockRecord)) |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 671 | { |
| 672 | segments["LockFlag"] = segment.first; |
| 673 | segments["SegmentLength"] = segment.second; |
| 674 | segmentInfoArray.push_back(segments); |
| 675 | } |
| 676 | |
| 677 | returnJson["SegmentFlags"] = segmentInfoArray; |
| 678 | lockRecords.push_back(returnJson); |
| 679 | } |
| 680 | } |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 681 | asyncResp->res.result(boost::beast::http::status::ok); |
| 682 | asyncResp->res.jsonValue["Records"] = lockRecords; |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 683 | } |
| 684 | |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 685 | inline bool isValidConfigFileName(const std::string& fileName, |
| 686 | crow::Response& res) |
| 687 | { |
| 688 | if (fileName.empty()) |
| 689 | { |
| 690 | BMCWEB_LOG_ERROR << "Empty filename"; |
| 691 | res.jsonValue["Description"] = "Empty file path in the url"; |
| 692 | return false; |
| 693 | } |
| 694 | |
| 695 | // ConfigFile name is allowed to take upper and lowercase letters, |
| 696 | // numbers and hyphen |
| 697 | std::size_t found = fileName.find_first_not_of( |
| 698 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-"); |
| 699 | if (found != std::string::npos) |
| 700 | { |
| 701 | BMCWEB_LOG_ERROR << "Unsupported character in filename: " << fileName; |
| 702 | res.jsonValue["Description"] = "Unsupported character in filename"; |
| 703 | return false; |
| 704 | } |
| 705 | |
| 706 | // Check the filename length |
| 707 | if (fileName.length() > 20) |
| 708 | { |
| 709 | BMCWEB_LOG_ERROR << "Name must be maximum 20 characters. " |
| 710 | "Input filename length is: " |
| 711 | << fileName.length(); |
| 712 | res.jsonValue["Description"] = "Filename must be maximum 20 characters"; |
| 713 | return false; |
| 714 | } |
| 715 | |
| 716 | return true; |
| 717 | } |
| 718 | |
Ed Tanous | 02379d3 | 2020-09-15 21:15:44 -0700 | [diff] [blame] | 719 | inline void requestRoutes(App& app) |
Ratan Gupta | 453fed0 | 2019-12-14 09:39:47 +0530 | [diff] [blame] | 720 | { |
| 721 | |
| 722 | // allowed only for admin |
| 723 | BMCWEB_ROUTE(app, "/ibm/v1/") |
Ed Tanous | 23a21a1 | 2020-07-25 04:45:05 +0000 | [diff] [blame] | 724 | .privileges({"ConfigureComponents", "ConfigureManager"}) |
Ed Tanous | b41187f | 2019-10-24 16:30:02 -0700 | [diff] [blame] | 725 | .methods(boost::beast::http::verb::get)( |
Ed Tanous | cb13a39 | 2020-07-25 19:02:03 +0000 | [diff] [blame] | 726 | [](const crow::Request&, crow::Response& res) { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 727 | std::shared_ptr<bmcweb::AsyncResp> asyncResp = |
| 728 | std::make_shared<bmcweb::AsyncResp>(res); |
| 729 | |
| 730 | asyncResp->res.jsonValue["@odata.type"] = |
Ratan Gupta | 453fed0 | 2019-12-14 09:39:47 +0530 | [diff] [blame] | 731 | "#ibmServiceRoot.v1_0_0.ibmServiceRoot"; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 732 | asyncResp->res.jsonValue["@odata.id"] = "/ibm/v1/"; |
| 733 | asyncResp->res.jsonValue["Id"] = "IBM Rest RootService"; |
| 734 | asyncResp->res.jsonValue["Name"] = "IBM Service Root"; |
| 735 | asyncResp->res.jsonValue["ConfigFiles"] = { |
Ratan Gupta | 453fed0 | 2019-12-14 09:39:47 +0530 | [diff] [blame] | 736 | {"@odata.id", "/ibm/v1/Host/ConfigFiles"}}; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 737 | asyncResp->res.jsonValue["LockService"] = { |
Ratan Gupta | 453fed0 | 2019-12-14 09:39:47 +0530 | [diff] [blame] | 738 | {"@odata.id", "/ibm/v1/HMC/LockService"}}; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 739 | asyncResp->res.jsonValue["BroadcastService"] = { |
Asmitha Karunanithi | 5738de5 | 2020-07-17 02:03:31 -0500 | [diff] [blame] | 740 | {"@odata.id", "/ibm/v1/HMC/BroadcastService"}}; |
Ratan Gupta | 453fed0 | 2019-12-14 09:39:47 +0530 | [diff] [blame] | 741 | }); |
Sunitha Harish | 97b0e43 | 2019-11-21 04:59:29 -0600 | [diff] [blame] | 742 | |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 743 | BMCWEB_ROUTE(app, "/ibm/v1/Host/ConfigFiles") |
Ed Tanous | 23a21a1 | 2020-07-25 04:45:05 +0000 | [diff] [blame] | 744 | .privileges({"ConfigureComponents", "ConfigureManager"}) |
Ed Tanous | b41187f | 2019-10-24 16:30:02 -0700 | [diff] [blame] | 745 | .methods(boost::beast::http::verb::get)( |
Ed Tanous | cb13a39 | 2020-07-25 19:02:03 +0000 | [diff] [blame] | 746 | [](const crow::Request&, crow::Response& res) { |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 747 | handleConfigFileList(res); |
| 748 | }); |
| 749 | |
| 750 | BMCWEB_ROUTE(app, |
Sunitha Harish | e56f254 | 2020-07-22 02:38:59 -0500 | [diff] [blame] | 751 | "/ibm/v1/Host/ConfigFiles/Actions/IBMConfigFiles.DeleteAll") |
Ed Tanous | 23a21a1 | 2020-07-25 04:45:05 +0000 | [diff] [blame] | 752 | .privileges({"ConfigureComponents", "ConfigureManager"}) |
Ed Tanous | b41187f | 2019-10-24 16:30:02 -0700 | [diff] [blame] | 753 | .methods(boost::beast::http::verb::post)( |
Ed Tanous | cb13a39 | 2020-07-25 19:02:03 +0000 | [diff] [blame] | 754 | [](const crow::Request&, crow::Response& res) { |
Ratan Gupta | d3630cb | 2019-12-14 11:21:35 +0530 | [diff] [blame] | 755 | deleteConfigFiles(res); |
| 756 | }); |
| 757 | |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 758 | BMCWEB_ROUTE(app, "/ibm/v1/Host/ConfigFiles/<str>") |
Ed Tanous | 23a21a1 | 2020-07-25 04:45:05 +0000 | [diff] [blame] | 759 | .privileges({"ConfigureComponents", "ConfigureManager"}) |
Sunitha Harish | 7c0bbe7 | 2020-07-30 08:25:28 -0500 | [diff] [blame] | 760 | .methods( |
| 761 | boost::beast::http::verb::put, boost::beast::http::verb::get, |
| 762 | boost::beast::http::verb::delete_)([](const crow::Request& req, |
| 763 | crow::Response& res, |
| 764 | const std::string& fileName) { |
| 765 | std::shared_ptr<bmcweb::AsyncResp> asyncResp = |
| 766 | std::make_shared<bmcweb::AsyncResp>(res); |
| 767 | BMCWEB_LOG_DEBUG << "ConfigFile : " << fileName; |
| 768 | // Validate the incoming fileName |
| 769 | if (!isValidConfigFileName(fileName, res)) |
| 770 | { |
| 771 | asyncResp->res.result(boost::beast::http::status::bad_request); |
| 772 | return; |
| 773 | } |
| 774 | handleFileUrl(req, res, fileName); |
| 775 | }); |
Ratan Gupta | 734a1c3 | 2019-12-14 11:53:48 +0530 | [diff] [blame] | 776 | |
| 777 | BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService") |
Ed Tanous | 23a21a1 | 2020-07-25 04:45:05 +0000 | [diff] [blame] | 778 | .privileges({"ConfigureComponents", "ConfigureManager"}) |
Ed Tanous | b41187f | 2019-10-24 16:30:02 -0700 | [diff] [blame] | 779 | .methods(boost::beast::http::verb::get)( |
Ed Tanous | cb13a39 | 2020-07-25 19:02:03 +0000 | [diff] [blame] | 780 | [](const crow::Request&, crow::Response& res) { |
Ratan Gupta | 734a1c3 | 2019-12-14 11:53:48 +0530 | [diff] [blame] | 781 | getLockServiceData(res); |
| 782 | }); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 783 | |
| 784 | BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.AcquireLock") |
Ed Tanous | 23a21a1 | 2020-07-25 04:45:05 +0000 | [diff] [blame] | 785 | .privileges({"ConfigureComponents", "ConfigureManager"}) |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 786 | .methods(boost::beast::http::verb::post)([](const crow::Request& req, |
| 787 | crow::Response& res) { |
| 788 | std::shared_ptr<bmcweb::AsyncResp> asyncResp = |
| 789 | std::make_shared<bmcweb::AsyncResp>(res); |
| 790 | |
| 791 | std::vector<nlohmann::json> body; |
| 792 | if (!redfish::json_util::readJson(req, res, "Request", body)) |
| 793 | { |
| 794 | BMCWEB_LOG_DEBUG << "Not a Valid JSON"; |
| 795 | asyncResp->res.result(boost::beast::http::status::bad_request); |
| 796 | return; |
| 797 | } |
| 798 | handleAcquireLockAPI(req, asyncResp, body); |
| 799 | }); |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 800 | BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock") |
Ed Tanous | 23a21a1 | 2020-07-25 04:45:05 +0000 | [diff] [blame] | 801 | .privileges({"ConfigureComponents", "ConfigureManager"}) |
Ed Tanous | b41187f | 2019-10-24 16:30:02 -0700 | [diff] [blame] | 802 | .methods(boost::beast::http::verb::post)([](const crow::Request& req, |
| 803 | crow::Response& res) { |
Manojkiran Eda | 5bb0ece | 2020-01-20 20:22:36 +0530 | [diff] [blame] | 804 | std::string type; |
| 805 | std::vector<uint32_t> listTransactionIds; |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 806 | std::shared_ptr<bmcweb::AsyncResp> asyncResp = |
| 807 | std::make_shared<bmcweb::AsyncResp>(res); |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 808 | |
Manojkiran Eda | 5bb0ece | 2020-01-20 20:22:36 +0530 | [diff] [blame] | 809 | if (!redfish::json_util::readJson(req, res, "Type", type, |
| 810 | "TransactionIDs", |
| 811 | listTransactionIds)) |
| 812 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 813 | asyncResp->res.result(boost::beast::http::status::bad_request); |
Manojkiran Eda | 5bb0ece | 2020-01-20 20:22:36 +0530 | [diff] [blame] | 814 | return; |
| 815 | } |
| 816 | if (type == "Transaction") |
| 817 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 818 | handleReleaseLockAPI(req, asyncResp, listTransactionIds); |
Manojkiran Eda | 5bb0ece | 2020-01-20 20:22:36 +0530 | [diff] [blame] | 819 | } |
| 820 | else if (type == "Session") |
| 821 | { |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 822 | handleRelaseAllAPI(req, asyncResp); |
Manojkiran Eda | 5bb0ece | 2020-01-20 20:22:36 +0530 | [diff] [blame] | 823 | } |
| 824 | else |
| 825 | { |
| 826 | BMCWEB_LOG_DEBUG << " Value of Type : " << type |
| 827 | << "is Not a Valid key"; |
| 828 | redfish::messages::propertyValueNotInList(res, type, "Type"); |
| 829 | } |
| 830 | }); |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 831 | BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.GetLockList") |
Ed Tanous | 23a21a1 | 2020-07-25 04:45:05 +0000 | [diff] [blame] | 832 | .privileges({"ConfigureComponents", "ConfigureManager"}) |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 833 | .methods(boost::beast::http::verb::post)([](const crow::Request& req, |
| 834 | crow::Response& res) { |
| 835 | ListOfSessionIds listSessionIds; |
| 836 | std::shared_ptr<bmcweb::AsyncResp> asyncResp = |
| 837 | std::make_shared<bmcweb::AsyncResp>(res); |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 838 | |
Sunitha Harish | db81c07 | 2021-01-21 23:33:21 -0600 | [diff] [blame^] | 839 | if (!redfish::json_util::readJson(req, res, "SessionIDs", |
| 840 | listSessionIds)) |
| 841 | { |
| 842 | asyncResp->res.result(boost::beast::http::status::bad_request); |
| 843 | return; |
| 844 | } |
| 845 | handleGetLockListAPI(asyncResp, listSessionIds); |
| 846 | }); |
Asmitha Karunanithi | 5738de5 | 2020-07-17 02:03:31 -0500 | [diff] [blame] | 847 | |
| 848 | BMCWEB_ROUTE(app, "/ibm/v1/HMC/BroadcastService") |
Ed Tanous | 23a21a1 | 2020-07-25 04:45:05 +0000 | [diff] [blame] | 849 | .privileges({"ConfigureComponents", "ConfigureManager"}) |
Asmitha Karunanithi | 5738de5 | 2020-07-17 02:03:31 -0500 | [diff] [blame] | 850 | .methods(boost::beast::http::verb::post)( |
| 851 | [](const crow::Request& req, crow::Response& res) { |
| 852 | handleBroadcastService(req, res); |
| 853 | }); |
Ratan Gupta | 453fed0 | 2019-12-14 09:39:47 +0530 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | } // namespace ibm_mc |
| 857 | } // namespace crow |