diff options
Diffstat (limited to 'redfish-core/lib/update_service.hpp')
-rw-r--r-- | redfish-core/lib/update_service.hpp | 96 |
1 files changed, 46 insertions, 50 deletions
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp index 357c04770b..3e75425ee5 100644 --- a/redfish-core/lib/update_service.hpp +++ b/redfish-core/lib/update_service.hpp @@ -63,7 +63,7 @@ inline static void cleanUp() inline static void activateImage(const std::string& objPath, const std::string& service) { - BMCWEB_LOG_DEBUG << "Activate image for " << objPath << " " << service; + BMCWEB_LOG_DEBUG("Activate image for {} {}", objPath, service); sdbusplus::asio::setProperty( *crow::connections::systemBus, service, objPath, "xyz.openbmc_project.Software.Activation", "RequestedActivation", @@ -71,8 +71,8 @@ inline static void activateImage(const std::string& objPath, [](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "error_code = " << ec; - BMCWEB_LOG_DEBUG << "error msg = " << ec.message(); + BMCWEB_LOG_DEBUG("error_code = {}", ec); + BMCWEB_LOG_DEBUG("error msg = {}", ec.message()); } }); } @@ -89,10 +89,10 @@ static void m.read(objPath, interfacesProperties); - BMCWEB_LOG_DEBUG << "obj path = " << objPath.str; + BMCWEB_LOG_DEBUG("obj path = {}", objPath.str); for (const auto& interface : interfacesProperties) { - BMCWEB_LOG_DEBUG << "interface = " << interface.first; + BMCWEB_LOG_DEBUG("interface = {}", interface.first); if (interface.first == "xyz.openbmc_project.Software.Activation") { @@ -108,8 +108,8 @@ static void objInfo) mutable { if (ec) { - BMCWEB_LOG_DEBUG << "error_code = " << ec; - BMCWEB_LOG_DEBUG << "error msg = " << ec.message(); + BMCWEB_LOG_DEBUG("error_code = {}", ec); + BMCWEB_LOG_DEBUG("error msg = {}", ec.message()); if (asyncResp) { messages::internalError(asyncResp->res); @@ -120,8 +120,7 @@ static void // Ensure we only got one service back if (objInfo.size() != 1) { - BMCWEB_LOG_ERROR << "Invalid Object Size " - << objInfo.size(); + BMCWEB_LOG_ERROR("Invalid Object Size {}", objInfo.size()); if (asyncResp) { messages::internalError(asyncResp->res); @@ -295,12 +294,11 @@ static void monitorForSoftwareAvailable( // expected, we were canceled before the timer completed. return; } - BMCWEB_LOG_ERROR - << "Timed out waiting for firmware object being created"; - BMCWEB_LOG_ERROR << "FW image may has already been uploaded to server"; + BMCWEB_LOG_ERROR("Timed out waiting for firmware object being created"); + BMCWEB_LOG_ERROR("FW image may has already been uploaded to server"); if (ec) { - BMCWEB_LOG_ERROR << "Async_wait failed" << ec; + BMCWEB_LOG_ERROR("Async_wait failed{}", ec); return; } if (asyncResp) @@ -310,7 +308,7 @@ static void monitorForSoftwareAvailable( }); task::Payload payload(req); auto callback = [asyncResp, payload](sdbusplus::message_t& m) mutable { - BMCWEB_LOG_DEBUG << "Match fired"; + BMCWEB_LOG_DEBUG("Match fired"); softwareInterfaceAdded(asyncResp, m, std::move(payload)); }; @@ -332,7 +330,7 @@ static void monitorForSoftwareAvailable( interfacesProperties; sdbusplus::message::object_path objPath; m.read(objPath, interfacesProperties); - BMCWEB_LOG_DEBUG << "obj path = " << objPath.str; + BMCWEB_LOG_DEBUG("obj path = {}", objPath.str); for (const std::pair<std::string, dbus::utility::DBusPropertiesMap>& interface : interfacesProperties) { @@ -423,7 +421,7 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) std::optional<std::string> transferProtocol; std::string imageURI; - BMCWEB_LOG_DEBUG << "Enter UpdateService.SimpleUpdate doPost"; + BMCWEB_LOG_DEBUG("Enter UpdateService.SimpleUpdate doPost"); // User can pass in both TransferProtocol and ImageURI parameters or // they can pass in just the ImageURI with the transfer protocol @@ -434,8 +432,7 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) if (!json_util::readJsonAction(req, asyncResp->res, "TransferProtocol", transferProtocol, "ImageURI", imageURI)) { - BMCWEB_LOG_DEBUG - << "Missing TransferProtocol or ImageURI parameter"; + BMCWEB_LOG_DEBUG("Missing TransferProtocol or ImageURI parameter"); return; } if (!transferProtocol) @@ -449,22 +446,21 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) messages::actionParameterValueTypeError( asyncResp->res, imageURI, "ImageURI", "UpdateService.SimpleUpdate"); - BMCWEB_LOG_ERROR << "ImageURI missing transfer protocol: " - << imageURI; + BMCWEB_LOG_ERROR("ImageURI missing transfer protocol: {}", + imageURI); return; } transferProtocol = imageURI.substr(0, separator); // Ensure protocol is upper case for a common comparison path // below boost::to_upper(*transferProtocol); - BMCWEB_LOG_DEBUG << "Encoded transfer protocol " - << *transferProtocol; + BMCWEB_LOG_DEBUG("Encoded transfer protocol {}", *transferProtocol); // Adjust imageURI to not have the protocol on it for parsing // below // ex. tftp://1.1.1.1/myfile.bin -> 1.1.1.1/myfile.bin imageURI = imageURI.substr(separator + 3); - BMCWEB_LOG_DEBUG << "Adjusted imageUri " << imageURI; + BMCWEB_LOG_DEBUG("Adjusted imageUri {}", imageURI); } // OpenBMC currently only supports TFTP @@ -473,8 +469,8 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) messages::actionParameterNotSupported(asyncResp->res, "TransferProtocol", "UpdateService.SimpleUpdate"); - BMCWEB_LOG_ERROR << "Request incorrect protocol parameter: " - << *transferProtocol; + BMCWEB_LOG_ERROR("Request incorrect protocol parameter: {}", + *transferProtocol); return; } @@ -486,13 +482,13 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) messages::actionParameterValueTypeError( asyncResp->res, imageURI, "ImageURI", "UpdateService.SimpleUpdate"); - BMCWEB_LOG_ERROR << "Invalid ImageURI: " << imageURI; + BMCWEB_LOG_ERROR("Invalid ImageURI: {}", imageURI); return; } std::string tftpServer = imageURI.substr(0, separator); std::string fwFile = imageURI.substr(separator + 1); - BMCWEB_LOG_DEBUG << "Server: " << tftpServer + " File: " << fwFile; + BMCWEB_LOG_DEBUG("Server: {}{}", tftpServer + " File: ", fwFile); // Setup callback for when new software detected // Give TFTP 10 minutes to complete @@ -514,19 +510,19 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) { // messages::internalError(asyncResp->res); cleanUp(); - BMCWEB_LOG_DEBUG << "error_code = " << ec; - BMCWEB_LOG_DEBUG << "error msg = " << ec.message(); + BMCWEB_LOG_DEBUG("error_code = {}", ec); + BMCWEB_LOG_DEBUG("error msg = {}", ec.message()); } else { - BMCWEB_LOG_DEBUG << "Call to DownloaViaTFTP Success"; + BMCWEB_LOG_DEBUG("Call to DownloaViaTFTP Success"); } }, "xyz.openbmc_project.Software.Download", "/xyz/openbmc_project/software", "xyz.openbmc_project.Common.TFTP", "DownloadViaTFTP", fwFile, tftpServer); - BMCWEB_LOG_DEBUG << "Exit UpdateService.SimpleUpdate doPost"; + BMCWEB_LOG_DEBUG("Exit UpdateService.SimpleUpdate doPost"); }); } @@ -534,7 +530,7 @@ inline void uploadImageFile(crow::Response& res, std::string_view body) { std::filesystem::path filepath("/tmp/images/" + bmcweb::getRandomUUID()); - BMCWEB_LOG_DEBUG << "Writing file to " << filepath; + BMCWEB_LOG_DEBUG("Writing file to {}", filepath.string()); std::ofstream out(filepath, std::ofstream::out | std::ofstream::binary | std::ofstream::trunc); // set the permission of the file to 640 @@ -566,8 +562,8 @@ inline void setApplyTime(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, } else { - BMCWEB_LOG_INFO - << "ApplyTime value is not in the list of acceptable values"; + BMCWEB_LOG_INFO( + "ApplyTime value is not in the list of acceptable values"); messages::propertyValueNotInList(asyncResp->res, applyTime, "ApplyTime"); return; @@ -581,7 +577,7 @@ inline void setApplyTime(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, applyTimeNewVal, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -602,10 +598,10 @@ inline void formpart.fields.find("Content-Disposition"); if (it == formpart.fields.end()) { - BMCWEB_LOG_ERROR << "Couldn't find Content-Disposition"; + BMCWEB_LOG_ERROR("Couldn't find Content-Disposition"); return; } - BMCWEB_LOG_INFO << "Parsing value " << it->value(); + BMCWEB_LOG_INFO("Parsing value {}", it->value()); // The construction parameters of param_list must start with `;` size_t index = it->value().find(';'); @@ -656,7 +652,7 @@ inline void if (uploadData == nullptr) { - BMCWEB_LOG_ERROR << "Upload data is NULL"; + BMCWEB_LOG_ERROR("Upload data is NULL"); messages::propertyMissing(asyncResp->res, "UpdateFile"); return; } @@ -681,7 +677,7 @@ inline void } std::string_view contentType = req.getHeaderValue("Content-Type"); - BMCWEB_LOG_DEBUG << "doPost: contentType=" << contentType; + BMCWEB_LOG_DEBUG("doPost: contentType={}", contentType); // Make sure that content type is application/octet-stream or // multipart/form-data @@ -705,8 +701,8 @@ inline void if (ec != ParserError::PARSER_SUCCESS) { // handle error - BMCWEB_LOG_ERROR << "MIME parse failed, ec : " - << static_cast<int>(ec); + BMCWEB_LOG_ERROR("MIME parse failed, ec : {}", + static_cast<int>(ec)); messages::internalError(asyncResp->res); return; } @@ -714,7 +710,7 @@ inline void } else { - BMCWEB_LOG_DEBUG << "Bad content type specified:" << contentType; + BMCWEB_LOG_DEBUG("Bad content type specified:{}", contentType); asyncResp->res.result(boost::beast::http::status::bad_request); } } @@ -768,7 +764,7 @@ inline void requestRoutesUpdateService(App& app) const std::string& applyTime) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } @@ -799,7 +795,7 @@ inline void requestRoutesUpdateService(App& app) { return; } - BMCWEB_LOG_DEBUG << "doPatch..."; + BMCWEB_LOG_DEBUG("doPatch..."); std::optional<nlohmann::json> pushUriOptions; if (!json_util::readJsonPatch(req, asyncResp->res, "HttpPushUriOptions", @@ -890,7 +886,7 @@ inline static void } else { - BMCWEB_LOG_ERROR << "Unknown software purpose " << purpose; + BMCWEB_LOG_ERROR("Unknown software purpose {}", purpose); } } @@ -926,16 +922,16 @@ inline void if (swInvPurpose == nullptr) { - BMCWEB_LOG_DEBUG << "Can't find property \"Purpose\"!"; + BMCWEB_LOG_DEBUG("Can't find property \"Purpose\"!"); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "swInvPurpose = " << *swInvPurpose; + BMCWEB_LOG_DEBUG("swInvPurpose = {}", *swInvPurpose); if (version == nullptr) { - BMCWEB_LOG_DEBUG << "Can't find property \"Version\"!"; + BMCWEB_LOG_DEBUG("Can't find property \"Version\"!"); messages::internalError(asyncResp->res); @@ -991,7 +987,7 @@ inline void requestRoutesSoftwareInventory(App& app) [asyncResp, swId](const boost::system::error_code& ec, const dbus::utility::MapperGetSubTreeResponse& subtree) { - BMCWEB_LOG_DEBUG << "doGet callback..."; + BMCWEB_LOG_DEBUG("doGet callback..."); if (ec) { messages::internalError(asyncResp->res); @@ -1022,7 +1018,7 @@ inline void requestRoutesSoftwareInventory(App& app) } if (!found) { - BMCWEB_LOG_WARNING << "Input swID " << *swId << " not found!"; + BMCWEB_LOG_WARNING("Input swID {} not found!", *swId); messages::resourceMissingAtURI( asyncResp->res, boost::urls::format( |