clang-format: re-format for clang-18
clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.
See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.
Change-Id: Iceec1dc95b6c908ec6c21fb40093de9dd18bf11a
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
index 64ce9cb..0db320b 100644
--- a/redfish-core/include/error_messages.hpp
+++ b/redfish-core/include/error_messages.hpp
@@ -86,14 +86,12 @@
* @param[in] arg3 Parameter of message that will replace %3 in its body.
*
* @returns Message ActionParameterValueFormatError formatted to JSON */
-nlohmann::json actionParameterValueFormatError(const nlohmann::json& arg1,
- std::string_view arg2,
- std::string_view arg3);
+nlohmann::json actionParameterValueFormatError(
+ const nlohmann::json& arg1, std::string_view arg2, std::string_view arg3);
-void actionParameterValueFormatError(crow::Response& res,
- const nlohmann::json& arg1,
- std::string_view arg2,
- std::string_view arg3);
+void actionParameterValueFormatError(
+ crow::Response& res, const nlohmann::json& arg1, std::string_view arg2,
+ std::string_view arg3);
/**
* @brief Formats ActionParameterValueNotInList message into JSON
@@ -105,9 +103,8 @@
* @param[in] arg3 Parameter of message that will replace %3 in its body.
*
* @returns Message ActionParameterValueFormatError formatted to JSON */
-nlohmann::json actionParameterValueNotInList(std::string_view arg1,
- std::string_view arg2,
- std::string_view arg3);
+nlohmann::json actionParameterValueNotInList(
+ std::string_view arg1, std::string_view arg2, std::string_view arg3);
void actionParameterValueNotInList(crow::Response& res, std::string_view arg1,
std::string_view arg2,
@@ -211,9 +208,8 @@
* @param[in] arg3 Parameter of message that will replace %3 in its body.
*
* @returns Message ResourceAlreadyExists formatted to JSON */
-nlohmann::json resourceAlreadyExists(std::string_view arg1,
- std::string_view arg2,
- std::string_view arg3);
+nlohmann::json resourceAlreadyExists(
+ std::string_view arg1, std::string_view arg2, std::string_view arg3);
void resourceAlreadyExists(crow::Response& res, std::string_view arg1,
std::string_view arg2, std::string_view arg3);
@@ -461,10 +457,9 @@
* @param[in] arg3 Parameter of message that will replace %3 in its body.
*
* @returns Message PropertyValueResourceConflict to JSON */
-nlohmann::json
- propertyValueResourceConflict(std::string_view arg1,
- const nlohmann::json& arg2,
- const boost::urls::url_view_base& arg3);
+nlohmann::json propertyValueResourceConflict(
+ std::string_view arg1, const nlohmann::json& arg2,
+ const boost::urls::url_view_base& arg3);
void propertyValueResourceConflict(crow::Response& res, std::string_view arg1,
const nlohmann::json& arg2,
@@ -636,9 +631,8 @@
nlohmann::json queryParameterValueTypeError(const nlohmann::json& arg1,
std::string_view arg2);
-void queryParameterValueTypeError(crow::Response& res,
- const nlohmann::json& arg1,
- std::string_view arg2);
+void queryParameterValueTypeError(
+ crow::Response& res, const nlohmann::json& arg1, std::string_view arg2);
/**
* @brief Formats ServiceShuttingDown message into JSON
@@ -690,9 +684,8 @@
* @param[in] arg2 Parameter of message that will replace %2 in its body.
*
* @returns Message SourceDoesNotSupportProtocol formatted to JSON */
-nlohmann::json
- sourceDoesNotSupportProtocol(const boost::urls::url_view_base& arg1,
- std::string_view arg2);
+nlohmann::json sourceDoesNotSupportProtocol(
+ const boost::urls::url_view_base& arg1, std::string_view arg2);
void sourceDoesNotSupportProtocol(crow::Response& res,
const boost::urls::url_view_base& arg1,
@@ -849,14 +842,12 @@
* @param[in] arg3 Parameter of message that will replace %3 in its body.
*
* @returns Message ActionParameterValueTypeError formatted to JSON */
-nlohmann::json actionParameterValueTypeError(const nlohmann::json& arg1,
- std::string_view arg2,
- std::string_view arg3);
+nlohmann::json actionParameterValueTypeError(
+ const nlohmann::json& arg1, std::string_view arg2, std::string_view arg3);
-void actionParameterValueTypeError(crow::Response& res,
- const nlohmann::json& arg1,
- std::string_view arg2,
- std::string_view arg3);
+void actionParameterValueTypeError(
+ crow::Response& res, const nlohmann::json& arg1, std::string_view arg2,
+ std::string_view arg3);
/**
* @brief Formats ActionParameterValueError message into JSON
@@ -1009,9 +1000,8 @@
nlohmann::json queryParameterValueFormatError(const nlohmann::json& arg1,
std::string_view arg2);
-void queryParameterValueFormatError(crow::Response& res,
- const nlohmann::json& arg1,
- std::string_view arg2);
+void queryParameterValueFormatError(
+ crow::Response& res, const nlohmann::json& arg1, std::string_view arg2);
/**
* @brief Formats PropertyMissing message into JSON
@@ -1057,9 +1047,8 @@
* @param[in] arg3 Parameter of message that will replace %3 in its body.
*
* @returns Message QueryParameterOutOfRange formatted to JSON */
-nlohmann::json queryParameterOutOfRange(std::string_view arg1,
- std::string_view arg2,
- std::string_view arg3);
+nlohmann::json queryParameterOutOfRange(
+ std::string_view arg1, std::string_view arg2, std::string_view arg3);
void queryParameterOutOfRange(crow::Response& res, std::string_view arg1,
std::string_view arg2, std::string_view arg3);
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 517910c..b004bde 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -89,8 +89,8 @@
{
std::span<const MessageEntry>::iterator messageIt = std::ranges::find_if(
registry, [&messageKey](const MessageEntry& messageEntry) {
- return messageKey == messageEntry.first;
- });
+ return messageKey == messageEntry.first;
+ });
if (messageIt != registry.end())
{
return &messageIt->second;
@@ -215,12 +215,10 @@
}
}
-inline int formatEventLogEntry(const std::string& logEntryID,
- const std::string& messageID,
- const std::span<std::string_view> messageArgs,
- std::string timestamp,
- const std::string& customText,
- nlohmann::json::object_t& logEntryJson)
+inline int formatEventLogEntry(
+ const std::string& logEntryID, const std::string& messageID,
+ const std::span<std::string_view> messageArgs, std::string timestamp,
+ const std::string& customText, nlohmann::json::object_t& logEntryJson)
{
// Get the Message from the MessageRegistry
const registries::Message* message = registries::formatMessage(messageID);
@@ -230,8 +228,8 @@
return -1;
}
- std::string msg = redfish::registries::fillMessageArgs(messageArgs,
- message->message);
+ std::string msg =
+ redfish::registries::fillMessageArgs(messageArgs, message->message);
if (msg.empty())
{
return -1;
@@ -321,8 +319,8 @@
// Search the resourceTypes list for the subscription.
auto resourceTypeIndex = std::ranges::find_if(
resourceTypes, [resType](const std::string& rtEntry) {
- return rtEntry == resType;
- });
+ return rtEntry == resType;
+ });
if (resourceTypeIndex == resourceTypes.end())
{
BMCWEB_LOG_DEBUG("Not subscribed to this resource");
@@ -393,8 +391,8 @@
msg["Name"] = "Event Log";
msg["Events"] = logEntryArray;
- std::string strMsg = msg.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string strMsg =
+ msg.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
return sendEvent(std::move(strMsg));
}
@@ -435,8 +433,8 @@
msg["Id"] = std::to_string(eventSeqNum);
msg["Name"] = "Event Log";
msg["Events"] = std::move(logEntryArray);
- std::string strMsg = msg.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string strMsg =
+ msg.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
sendEvent(std::move(strMsg));
eventSeqNum++;
}
@@ -474,8 +472,8 @@
msg["Context"] = customText;
}
- std::string strMsg = msg.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string strMsg =
+ msg.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
sendEvent(std::move(strMsg));
}
@@ -927,8 +925,8 @@
boost::circular_buffer<Event>::iterator lastEvent =
std::find_if(messages.begin(), messages.end(),
[&lastEventId](const Event& event) {
- return event.id == lastEventId;
- });
+ return event.id == lastEventId;
+ });
// Can't find a matching ID
if (lastEvent == messages.end())
{
@@ -1012,8 +1010,8 @@
subscriptionsMap,
[](const std::pair<std::string, std::shared_ptr<Subscription>>&
entry) {
- return (entry.second->subscriptionType == subscriptionTypeSSE);
- });
+ return (entry.second->subscriptionType == subscriptionTypeSSE);
+ });
return static_cast<size_t>(size);
}
@@ -1184,94 +1182,95 @@
static std::array<char, 1024> readBuffer;
- inotifyConn->async_read_some(boost::asio::buffer(readBuffer),
- [&](const boost::system::error_code& ec,
- const std::size_t& bytesTransferred) {
- if (ec == boost::asio::error::operation_aborted)
- {
- BMCWEB_LOG_DEBUG("Inotify was canceled (shutdown?)");
- return;
- }
- if (ec)
- {
- BMCWEB_LOG_ERROR("Callback Error: {}", ec.message());
- return;
- }
- std::size_t index = 0;
- while ((index + iEventSize) <= bytesTransferred)
- {
- struct inotify_event event
- {};
- std::memcpy(&event, &readBuffer[index], iEventSize);
- if (event.wd == dirWatchDesc)
+ inotifyConn->async_read_some(
+ boost::asio::buffer(readBuffer),
+ [&](const boost::system::error_code& ec,
+ const std::size_t& bytesTransferred) {
+ if (ec == boost::asio::error::operation_aborted)
{
- if ((event.len == 0) ||
- (index + iEventSize + event.len > bytesTransferred))
- {
- index += (iEventSize + event.len);
- continue;
- }
-
- std::string fileName(&readBuffer[index + iEventSize]);
- if (fileName != "redfish")
- {
- index += (iEventSize + event.len);
- continue;
- }
-
- BMCWEB_LOG_DEBUG(
- "Redfish log file created/deleted. event.name: {}",
- fileName);
- if (event.mask == IN_CREATE)
- {
- if (fileWatchDesc != -1)
- {
- BMCWEB_LOG_DEBUG(
- "Remove and Add inotify watcher on "
- "redfish event log file");
- // Remove existing inotify watcher and add
- // with new redfish event log file.
- inotify_rm_watch(inotifyFd, fileWatchDesc);
- fileWatchDesc = -1;
- }
-
- fileWatchDesc = inotify_add_watch(
- inotifyFd, redfishEventLogFile, IN_MODIFY);
- if (fileWatchDesc == -1)
- {
- BMCWEB_LOG_ERROR("inotify_add_watch failed for "
- "redfish log file.");
- return;
- }
-
- EventServiceManager::getInstance()
- .resetRedfishFilePosition();
- EventServiceManager::getInstance()
- .readEventLogsFromFile();
- }
- else if ((event.mask == IN_DELETE) ||
- (event.mask == IN_MOVED_TO))
- {
- if (fileWatchDesc != -1)
- {
- inotify_rm_watch(inotifyFd, fileWatchDesc);
- fileWatchDesc = -1;
- }
- }
+ BMCWEB_LOG_DEBUG("Inotify was canceled (shutdown?)");
+ return;
}
- else if (event.wd == fileWatchDesc)
+ if (ec)
{
- if (event.mask == IN_MODIFY)
- {
- EventServiceManager::getInstance()
- .readEventLogsFromFile();
- }
+ BMCWEB_LOG_ERROR("Callback Error: {}", ec.message());
+ return;
}
- index += (iEventSize + event.len);
- }
+ std::size_t index = 0;
+ while ((index + iEventSize) <= bytesTransferred)
+ {
+ struct inotify_event event
+ {};
+ std::memcpy(&event, &readBuffer[index], iEventSize);
+ if (event.wd == dirWatchDesc)
+ {
+ if ((event.len == 0) ||
+ (index + iEventSize + event.len > bytesTransferred))
+ {
+ index += (iEventSize + event.len);
+ continue;
+ }
- watchRedfishEventLogFile();
- });
+ std::string fileName(&readBuffer[index + iEventSize]);
+ if (fileName != "redfish")
+ {
+ index += (iEventSize + event.len);
+ continue;
+ }
+
+ BMCWEB_LOG_DEBUG(
+ "Redfish log file created/deleted. event.name: {}",
+ fileName);
+ if (event.mask == IN_CREATE)
+ {
+ if (fileWatchDesc != -1)
+ {
+ BMCWEB_LOG_DEBUG(
+ "Remove and Add inotify watcher on "
+ "redfish event log file");
+ // Remove existing inotify watcher and add
+ // with new redfish event log file.
+ inotify_rm_watch(inotifyFd, fileWatchDesc);
+ fileWatchDesc = -1;
+ }
+
+ fileWatchDesc = inotify_add_watch(
+ inotifyFd, redfishEventLogFile, IN_MODIFY);
+ if (fileWatchDesc == -1)
+ {
+ BMCWEB_LOG_ERROR("inotify_add_watch failed for "
+ "redfish log file.");
+ return;
+ }
+
+ EventServiceManager::getInstance()
+ .resetRedfishFilePosition();
+ EventServiceManager::getInstance()
+ .readEventLogsFromFile();
+ }
+ else if ((event.mask == IN_DELETE) ||
+ (event.mask == IN_MOVED_TO))
+ {
+ if (fileWatchDesc != -1)
+ {
+ inotify_rm_watch(inotifyFd, fileWatchDesc);
+ fileWatchDesc = -1;
+ }
+ }
+ }
+ else if (event.wd == fileWatchDesc)
+ {
+ if (event.mask == IN_MODIFY)
+ {
+ EventServiceManager::getInstance()
+ .readEventLogsFromFile();
+ }
+ }
+ index += (iEventSize + event.len);
+ }
+
+ watchRedfishEventLogFile();
+ });
}
static int startEventLogMonitor(boost::asio::io_context& ioc)
@@ -1296,8 +1295,8 @@
}
// Watch redfish event log file for modifications.
- fileWatchDesc = inotify_add_watch(inotifyFd, redfishEventLogFile,
- IN_MODIFY);
+ fileWatchDesc =
+ inotify_add_watch(inotifyFd, redfishEventLogFile, IN_MODIFY);
if (fileWatchDesc == -1)
{
BMCWEB_LOG_ERROR("inotify_add_watch failed for redfish log file.");
@@ -1338,8 +1337,9 @@
std::vector<std::string> invalidProps;
msg.read(interface, props, invalidProps);
- auto found = std::ranges::find_if(
- props, [](const auto& x) { return x.first == "Readings"; });
+ auto found = std::ranges::find_if(props, [](const auto& x) {
+ return x.first == "Readings";
+ });
if (found == props.end())
{
BMCWEB_LOG_INFO("Failed to get Readings from Report properties");
diff --git a/redfish-core/include/filter_expr_parser_grammar.hpp b/redfish-core/include/filter_expr_parser_grammar.hpp
index 1b422ff..939a683 100644
--- a/redfish-core/include/filter_expr_parser_grammar.hpp
+++ b/redfish-core/include/filter_expr_parser_grammar.hpp
@@ -50,8 +50,8 @@
///// BEGIN GRAMMAR
// Two types of strings.
-const auto quotedString_def = '\'' >> lexeme[*('\\' >> char_ | ~char_('\''))] >>
- '\'';
+const auto quotedString_def =
+ '\'' >> lexeme[*('\\' >> char_ | ~char_('\''))] >> '\'';
const auto unquotedString_def = char_("a-zA-Z") >> *(char_("a-zA-Z0-9[]/"));
// Make sure we only parse true floating points as doubles
diff --git a/redfish-core/include/gzfile.hpp b/redfish-core/include/gzfile.hpp
index 3fa1e49..fd8ddd0 100644
--- a/redfish-core/include/gzfile.hpp
+++ b/redfish-core/include/gzfile.hpp
@@ -97,8 +97,8 @@
while (pos != std::string::npos)
{
- std::string logEntry = bufferStr.substr(initialPos,
- pos - initialPos);
+ std::string logEntry =
+ bufferStr.substr(initialPos, pos - initialPos);
// Since there might be consecutive delimiters like "\r\n", we need
// to filter empty strings.
if (!logEntry.empty())
diff --git a/redfish-core/include/query.hpp b/redfish-core/include/query.hpp
index 2d280cb..a46bd4a 100644
--- a/redfish-core/include/query.hpp
+++ b/redfish-core/include/query.hpp
@@ -153,8 +153,9 @@
if constexpr (BMCWEB_REDFISH_AGGREGATION)
{
- needToCallHandlers = RedfishAggregator::beginAggregation(
- req, asyncResp) == Result::LocalHandle;
+ needToCallHandlers =
+ RedfishAggregator::beginAggregation(req, asyncResp) ==
+ Result::LocalHandle;
// If the request should be forwarded to a satellite BMC then we don't
// want to write anything to the asyncResp since it will get overwritten
@@ -174,8 +175,8 @@
asyncResp->res.setCompleteRequestHandler(
[&app, handler(std::move(handler)), query{std::move(*queryOpt)},
delegated{delegated}](crow::Response& resIn) mutable {
- processAllParams(app, query, delegated, handler, resIn);
- });
+ processAllParams(app, query, delegated, handler, resIn);
+ });
return needToCallHandlers;
}
diff --git a/redfish-core/include/redfish_aggregator.hpp b/redfish-core/include/redfish_aggregator.hpp
index 5ccfd2f..8477b18 100644
--- a/redfish-core/include/redfish_aggregator.hpp
+++ b/redfish-core/include/redfish_aggregator.hpp
@@ -291,8 +291,8 @@
}
// Fix HTTP headers which appear in responses from Task resources among others
-static inline void addPrefixToHeadersInResp(nlohmann::json& json,
- std::string_view prefix)
+static inline void
+ addPrefixToHeadersInResp(nlohmann::json& json, std::string_view prefix)
{
// The passed in "HttpHeaders" should be an array of headers
nlohmann::json::array_t* array = json.get_ptr<nlohmann::json::array_t*>();
@@ -827,33 +827,33 @@
[handler{std::move(handler)}](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& objects) {
- std::unordered_map<std::string, boost::urls::url> satelliteInfo;
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error {}, {}", ec.value(),
- ec.message());
+ std::unordered_map<std::string, boost::urls::url> satelliteInfo;
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error {}, {}", ec.value(),
+ ec.message());
+ handler(ec, satelliteInfo);
+ return;
+ }
+
+ // Maps a chosen alias representing a satellite BMC to a url
+ // containing the information required to create a http
+ // connection to the satellite
+ findSatelliteConfigs(objects, satelliteInfo);
+
+ if (!satelliteInfo.empty())
+ {
+ BMCWEB_LOG_DEBUG(
+ "Redfish Aggregation enabled with {} satellite BMCs",
+ std::to_string(satelliteInfo.size()));
+ }
+ else
+ {
+ BMCWEB_LOG_DEBUG(
+ "No satellite BMCs detected. Redfish Aggregation not enabled");
+ }
handler(ec, satelliteInfo);
- return;
- }
-
- // Maps a chosen alias representing a satellite BMC to a url
- // containing the information required to create a http
- // connection to the satellite
- findSatelliteConfigs(objects, satelliteInfo);
-
- if (!satelliteInfo.empty())
- {
- BMCWEB_LOG_DEBUG(
- "Redfish Aggregation enabled with {} satellite BMCs",
- std::to_string(satelliteInfo.size()));
- }
- else
- {
- BMCWEB_LOG_DEBUG(
- "No satellite BMCs detected. Redfish Aggregation not enabled");
- }
- handler(ec, satelliteInfo);
- });
+ });
}
// Processes the response returned by a satellite BMC and loads its
@@ -877,8 +877,8 @@
// We need to create a json from resp's stringResponse
if (isJsonContentType(resp.getHeaderValue("Content-Type")))
{
- nlohmann::json jsonVal = nlohmann::json::parse(*resp.body(),
- nullptr, false);
+ nlohmann::json jsonVal =
+ nlohmann::json::parse(*resp.body(), nullptr, false);
if (jsonVal.is_discarded())
{
BMCWEB_LOG_ERROR("Error parsing satellite response as JSON");
@@ -939,8 +939,8 @@
// We need to create a json from resp's stringResponse
if (isJsonContentType(resp.getHeaderValue("Content-Type")))
{
- nlohmann::json jsonVal = nlohmann::json::parse(*resp.body(),
- nullptr, false);
+ nlohmann::json jsonVal =
+ nlohmann::json::parse(*resp.body(), nullptr, false);
if (jsonVal.is_discarded())
{
BMCWEB_LOG_ERROR("Error parsing satellite response as JSON");
@@ -1072,8 +1072,8 @@
if (isJsonContentType(resp.getHeaderValue("Content-Type")))
{
bool addedLinks = false;
- nlohmann::json jsonVal = nlohmann::json::parse(*resp.body(),
- nullptr, false);
+ nlohmann::json jsonVal =
+ nlohmann::json::parse(*resp.body(), nullptr, false);
if (jsonVal.is_discarded())
{
BMCWEB_LOG_ERROR("Error parsing satellite response as JSON");
diff --git a/redfish-core/include/registries.hpp b/redfish-core/include/registries.hpp
index b0ddb68..3d572c2 100644
--- a/redfish-core/include/registries.hpp
+++ b/redfish-core/include/registries.hpp
@@ -54,9 +54,8 @@
};
using MessageEntry = std::pair<const char*, const Message>;
-inline std::string
- fillMessageArgs(const std::span<const std::string_view> messageArgs,
- std::string_view msg)
+inline std::string fillMessageArgs(
+ const std::span<const std::string_view> messageArgs, std::string_view msg)
{
std::string ret;
size_t reserve = msg.size();
@@ -90,10 +89,9 @@
return ret;
}
-inline nlohmann::json::object_t
- getLogFromRegistry(const Header& header,
- std::span<const MessageEntry> registry, size_t index,
- std::span<const std::string_view> args)
+inline nlohmann::json::object_t getLogFromRegistry(
+ const Header& header, std::span<const MessageEntry> registry, size_t index,
+ std::span<const std::string_view> args)
{
const redfish::registries::MessageEntry& entry = registry[index];
// Intentionally make a copy of the string, so we can append in the
diff --git a/redfish-core/include/snmp_trap_event_clients.hpp b/redfish-core/include/snmp_trap_event_clients.hpp
index 8e0692a..d71d59f 100644
--- a/redfish-core/include/snmp_trap_event_clients.hpp
+++ b/redfish-core/include/snmp_trap_event_clients.hpp
@@ -86,48 +86,47 @@
objectPath, "xyz.openbmc_project.Network.Client",
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
- afterGetSnmpTrapClientdata(asyncResp, ec, properties);
- });
+ afterGetSnmpTrapClientdata(asyncResp, ec, properties);
+ });
}
-inline void
- getSnmpTrapClient(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& id)
+inline void getSnmpTrapClient(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& id)
{
crow::connections::systemBus->async_method_call(
[asyncResp, id](const boost::system::error_code& ec,
dbus::utility::ManagedObjectType& resp) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("D-Bus response error on GetManagedObjects {}",
- ec);
- messages::internalError(asyncResp->res);
- return;
- }
-
- for (const auto& objpath : resp)
- {
- sdbusplus::message::object_path path(objpath.first);
- const std::string snmpId = path.filename();
- if (snmpId.empty())
+ if (ec)
{
- BMCWEB_LOG_ERROR("The SNMP client ID is wrong");
+ BMCWEB_LOG_ERROR("D-Bus response error on GetManagedObjects {}",
+ ec);
messages::internalError(asyncResp->res);
return;
}
- const std::string subscriptionId = "snmp" + snmpId;
- if (id != subscriptionId)
+
+ for (const auto& objpath : resp)
{
- continue;
+ sdbusplus::message::object_path path(objpath.first);
+ const std::string snmpId = path.filename();
+ if (snmpId.empty())
+ {
+ BMCWEB_LOG_ERROR("The SNMP client ID is wrong");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ const std::string subscriptionId = "snmp" + snmpId;
+ if (id != subscriptionId)
+ {
+ continue;
+ }
+
+ getSnmpTrapClientdata(asyncResp, id, objpath.first);
+ return;
}
- getSnmpTrapClientdata(asyncResp, id, objpath.first);
- return;
- }
-
- messages::resourceNotFound(asyncResp->res, "Subscriptions", id);
- EventServiceManager::getInstance().deleteSubscription(id);
- },
+ messages::resourceNotFound(asyncResp->res, "Subscriptions", id);
+ EventServiceManager::getInstance().deleteSubscription(id);
+ },
"xyz.openbmc_project.Network.SNMP",
"/xyz/openbmc_project/network/snmp/manager",
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
@@ -183,21 +182,20 @@
const std::string& host, uint16_t snmpTrapPort)
{
crow::connections::systemBus->async_method_call(
- [asyncResp, host](const boost::system::error_code& ec,
- const sdbusplus::message_t& msg,
- const std::string& dbusSNMPid) {
- afterSnmpClientCreate(asyncResp, ec, msg, host, dbusSNMPid);
- },
+ [asyncResp,
+ host](const boost::system::error_code& ec,
+ const sdbusplus::message_t& msg, const std::string& dbusSNMPid) {
+ afterSnmpClientCreate(asyncResp, ec, msg, host, dbusSNMPid);
+ },
"xyz.openbmc_project.Network.SNMP",
"/xyz/openbmc_project/network/snmp/manager",
"xyz.openbmc_project.Network.Client.Create", "Client", host,
snmpTrapPort);
}
-inline void
- getSnmpSubscriptionList(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& snmpId,
- nlohmann::json& memberArray)
+inline void getSnmpSubscriptionList(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& snmpId, nlohmann::json& memberArray)
{
const std::string subscriptionId = "snmp" + snmpId;
@@ -227,20 +225,20 @@
crow::connections::systemBus->async_method_call(
[asyncResp, param](const boost::system::error_code& ec) {
- if (ec)
- {
- // The snmp trap id is incorrect
- if (ec.value() == EBADR)
+ if (ec)
{
- messages::resourceNotFound(asyncResp->res, "Subscription",
- param);
+ // The snmp trap id is incorrect
+ if (ec.value() == EBADR)
+ {
+ messages::resourceNotFound(asyncResp->res, "Subscription",
+ param);
+ return;
+ }
+ messages::internalError(asyncResp->res);
return;
}
- messages::internalError(asyncResp->res);
- return;
- }
- messages::success(asyncResp->res);
- },
+ messages::success(asyncResp->res);
+ },
"xyz.openbmc_project.Network.SNMP", static_cast<std::string>(snmpPath),
"xyz.openbmc_project.Object.Delete", "Delete");
}
diff --git a/redfish-core/include/utils/chassis_utils.hpp b/redfish-core/include/utils/chassis_utils.hpp
index 410a289..889b6f7 100644
--- a/redfish-core/include/utils/chassis_utils.hpp
+++ b/redfish-core/include/utils/chassis_utils.hpp
@@ -33,33 +33,33 @@
chassisId](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse&
chassisPaths) mutable {
- BMCWEB_LOG_DEBUG("getValidChassisPath respHandler enter");
- if (ec)
- {
- BMCWEB_LOG_ERROR("getValidChassisPath respHandler DBUS error: {}",
- ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ BMCWEB_LOG_DEBUG("getValidChassisPath respHandler enter");
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR(
+ "getValidChassisPath respHandler DBUS error: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- std::optional<std::string> chassisPath;
- for (const std::string& chassis : chassisPaths)
- {
- sdbusplus::message::object_path path(chassis);
- std::string chassisName = path.filename();
- if (chassisName.empty())
+ std::optional<std::string> chassisPath;
+ for (const std::string& chassis : chassisPaths)
{
- BMCWEB_LOG_ERROR("Failed to find '/' in {}", chassis);
- continue;
+ sdbusplus::message::object_path path(chassis);
+ std::string chassisName = path.filename();
+ if (chassisName.empty())
+ {
+ BMCWEB_LOG_ERROR("Failed to find '/' in {}", chassis);
+ continue;
+ }
+ if (chassisName == chassisId)
+ {
+ chassisPath = chassis;
+ break;
+ }
}
- if (chassisName == chassisId)
- {
- chassisPath = chassis;
- break;
- }
- }
- callback(chassisPath);
- });
+ callback(chassisPath);
+ });
BMCWEB_LOG_DEBUG("checkChassisId exit");
}
diff --git a/redfish-core/include/utils/collection.hpp b/redfish-core/include/utils/collection.hpp
index 9efa7d3..6528a98 100644
--- a/redfish-core/include/utils/collection.hpp
+++ b/redfish-core/include/utils/collection.hpp
@@ -92,24 +92,22 @@
*
* @return void
*/
-inline void
- getCollectionToKey(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const boost::urls::url& collectionPath,
- std::span<const std::string_view> interfaces,
- const std::string& subtree,
- const nlohmann::json::json_pointer& jsonKeyName)
+inline void getCollectionToKey(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const boost::urls::url& collectionPath,
+ std::span<const std::string_view> interfaces, const std::string& subtree,
+ const nlohmann::json::json_pointer& jsonKeyName)
{
BMCWEB_LOG_DEBUG("Get collection members for: {}", collectionPath.buffer());
- dbus::utility::getSubTreePaths(subtree, 0, interfaces,
- std::bind_front(handleCollectionMembers,
- asyncResp, collectionPath,
- jsonKeyName));
+ dbus::utility::getSubTreePaths(
+ subtree, 0, interfaces,
+ std::bind_front(handleCollectionMembers, asyncResp, collectionPath,
+ jsonKeyName));
}
-inline void
- getCollectionMembers(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const boost::urls::url& collectionPath,
- std::span<const std::string_view> interfaces,
- const std::string& subtree)
+inline void getCollectionMembers(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const boost::urls::url& collectionPath,
+ std::span<const std::string_view> interfaces, const std::string& subtree)
{
getCollectionToKey(asyncResp, collectionPath, interfaces, subtree,
nlohmann::json::json_pointer("/Members"));
diff --git a/redfish-core/include/utils/dbus_utils.hpp b/redfish-core/include/utils/dbus_utils.hpp
index dbb6fd1..3fcd2c7 100644
--- a/redfish-core/include/utils/dbus_utils.hpp
+++ b/redfish-core/include/utils/dbus_utils.hpp
@@ -34,11 +34,10 @@
namespace details
{
-void afterSetProperty(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& redfishPropertyName,
- const nlohmann::json& propertyValue,
- const boost::system::error_code& ec,
- const sdbusplus::message_t& msg);
+void afterSetProperty(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& redfishPropertyName, const nlohmann::json& propertyValue,
+ const boost::system::error_code& ec, const sdbusplus::message_t& msg);
void afterSetPropertyAction(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& redfishActionName,
@@ -48,12 +47,11 @@
} // namespace details
template <typename PropertyType>
-void setDbusProperty(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- std::string_view redfishPropertyName,
- std::string_view processName,
- const sdbusplus::message::object_path& path,
- std::string_view interface, std::string_view dbusProperty,
- const PropertyType& prop)
+void setDbusProperty(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ std::string_view redfishPropertyName, std::string_view processName,
+ const sdbusplus::message::object_path& path, std::string_view interface,
+ std::string_view dbusProperty, const PropertyType& prop)
{
std::string processNameStr(processName);
std::string interfaceStr(interface);
@@ -65,20 +63,18 @@
[asyncResp, redfishPropertyNameStr = std::string{redfishPropertyName},
jsonProp = nlohmann::json(prop)](const boost::system::error_code& ec,
const sdbusplus::message_t& msg) {
- details::afterSetProperty(asyncResp, redfishPropertyNameStr, jsonProp,
- ec, msg);
- });
+ details::afterSetProperty(asyncResp, redfishPropertyNameStr,
+ jsonProp, ec, msg);
+ });
}
template <typename DbusPropertyType>
-void setDbusPropertyAction(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- std::string_view processName,
- const sdbusplus::message::object_path& path,
- std::string_view interface,
- std::string_view dbusProperty,
- std::string_view redfishActionParameterName,
- std::string_view redfishActionName,
- const DbusPropertyType& prop)
+void setDbusPropertyAction(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ std::string_view processName, const sdbusplus::message::object_path& path,
+ std::string_view interface, std::string_view dbusProperty,
+ std::string_view redfishActionParameterName,
+ std::string_view redfishActionName, const DbusPropertyType& prop)
{
std::string processNameStr(processName);
std::string interfaceStr(interface);
@@ -93,9 +89,10 @@
redfishActionNameStr = std::string{redfishActionName}](
const boost::system::error_code& ec,
const sdbusplus::message_t& msg) {
- details::afterSetPropertyAction(asyncResp, redfishActionNameStr,
- redfishActionParameterName, ec, msg);
- });
+ details::afterSetPropertyAction(asyncResp, redfishActionNameStr,
+ redfishActionParameterName, ec,
+ msg);
+ });
}
} // namespace redfish
diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp
index f6ac70b..bc1a69a 100644
--- a/redfish-core/include/utils/json_utils.hpp
+++ b/redfish-core/include/utils/json_utils.hpp
@@ -209,8 +209,8 @@
value = static_cast<Type>(*jsonPtr);
}
- else if constexpr ((std::is_unsigned_v<Type>)&&(
- !std::is_same_v<bool, Type>))
+ else if constexpr ((std::is_unsigned_v<Type>) &&
+ (!std::is_same_v<bool, Type>))
{
uint64_t* jsonPtr = jsonValue.get_ptr<uint64_t*>();
if (jsonPtr == nullptr)
@@ -560,15 +560,16 @@
break;
}
- result = std::visit(
- [&item, &unpackSpec, &res](auto&& val) {
- using ContainedT =
- std::remove_pointer_t<std::decay_t<decltype(val)>>;
- return details::unpackValue<ContainedT>(
- item.second, unpackSpec.key, res, *val);
- },
- unpackSpec.value) &&
- result;
+ result =
+ std::visit(
+ [&item, &unpackSpec, &res](auto&& val) {
+ using ContainedT =
+ std::remove_pointer_t<std::decay_t<decltype(val)>>;
+ return details::unpackValue<ContainedT>(
+ item.second, unpackSpec.key, res, *val);
+ },
+ unpackSpec.value) &&
+ result;
unpackSpec.complete = true;
break;
@@ -587,10 +588,10 @@
{
bool isOptional = std::visit(
[](auto&& val) {
- using ContainedType =
- std::remove_pointer_t<std::decay_t<decltype(val)>>;
- return details::IsOptional<ContainedType>::value;
- },
+ using ContainedType =
+ std::remove_pointer_t<std::decay_t<decltype(val)>>;
+ return details::IsOptional<ContainedType>::value;
+ },
perUnpack.value);
if (isOptional)
{
@@ -679,8 +680,8 @@
}
std::erase_if(*object,
[](const std::pair<std::string, nlohmann::json>& item) {
- return item.first.starts_with("@odata.");
- });
+ return item.first.starts_with("@odata.");
+ });
if (object->empty())
{
// If the update request only contains OData annotations, the service
diff --git a/redfish-core/include/utils/query_param.hpp b/redfish-core/include/utils/query_param.hpp
index 3ec4dc3..5de3967 100644
--- a/redfish-core/include/utils/query_param.hpp
+++ b/redfish-core/include/utils/query_param.hpp
@@ -310,8 +310,8 @@
inline QueryError getNumericParam(std::string_view value, size_t& param)
{
- std::from_chars_result r = std::from_chars(value.begin(), value.end(),
- param);
+ std::from_chars_result r =
+ std::from_chars(value.begin(), value.end(), param);
// If the number wasn't representable in the type, it's out of range
if (r.ec == std::errc::result_out_of_range)
@@ -387,8 +387,8 @@
return query.filter.has_value();
}
-inline std::optional<Query> parseParameters(boost::urls::params_view urlParams,
- crow::Response& res)
+inline std::optional<Query>
+ parseParameters(boost::urls::params_view urlParams, crow::Response& res)
{
Query ret{};
for (const boost::urls::params_view::value_type& it : urlParams)
@@ -698,9 +698,8 @@
// Isn't a concern until https://gerrit.openbmc.org/c/openbmc/bmcweb/+/60556
// lands. May want to avoid forwarding query params when request is uptree from
// a top level collection.
-inline std::vector<ExpandNode>
- findNavigationReferences(ExpandType eType, int depth, int skipDepth,
- nlohmann::json& jsonResponse)
+inline std::vector<ExpandNode> findNavigationReferences(
+ ExpandType eType, int depth, int skipDepth, nlohmann::json& jsonResponse)
{
std::vector<ExpandNode> ret;
const nlohmann::json::json_pointer root = nlohmann::json::json_pointer("");
@@ -790,8 +789,9 @@
if (finalCodeIndex != std::numeric_limits<size_t>::max() &&
subResponseCodeIndex != std::numeric_limits<size_t>::max())
{
- return finalCodeIndex <= subResponseCodeIndex ? finalCode
- : subResponseCode;
+ return finalCodeIndex <= subResponseCodeIndex
+ ? finalCode
+ : subResponseCode;
}
if (subResponseCode == 500 || finalCode == 500)
{
@@ -832,8 +832,7 @@
// class manages the final "merge" of the json resources.
MultiAsyncResp(crow::App& appIn,
std::shared_ptr<bmcweb::AsyncResp> finalResIn) :
- app(appIn),
- finalRes(std::move(finalResIn))
+ app(appIn), finalRes(std::move(finalResIn))
{}
void addAwaitingResponse(
diff --git a/redfish-core/include/utils/sw_utils.hpp b/redfish-core/include/utils/sw_utils.hpp
index 8455145..fc15783 100644
--- a/redfish-core/include/utils/sw_utils.hpp
+++ b/redfish-core/include/utils/sw_utils.hpp
@@ -99,178 +99,193 @@
populateLinkToImages](
const boost::system::error_code& ec,
const dbus::utility::MapperEndPoints& functionalSw) {
- BMCWEB_LOG_DEBUG("populateSoftwareInformation enter");
- if (ec)
- {
- BMCWEB_LOG_ERROR("error_code = {}", ec);
- BMCWEB_LOG_ERROR("error msg = {}", ec.message());
- messages::internalError(asyncResp->res);
- return;
- }
-
- if (functionalSw.empty())
- {
- // Could keep going and try to populate SoftwareImages but
- // something is seriously wrong, so just fail
- BMCWEB_LOG_ERROR("Zero functional software in system");
- messages::internalError(asyncResp->res);
- return;
- }
-
- std::vector<std::string> functionalSwIds;
- // example functionalSw:
- // v as 2 "/xyz/openbmc_project/software/ace821ef"
- // "/xyz/openbmc_project/software/230fb078"
- for (const auto& sw : functionalSw)
- {
- sdbusplus::message::object_path path(sw);
- std::string leaf = path.filename();
- if (leaf.empty())
+ BMCWEB_LOG_DEBUG("populateSoftwareInformation enter");
+ if (ec)
{
- continue;
- }
-
- functionalSwIds.push_back(leaf);
- }
-
- constexpr std::array<std::string_view, 1> interfaces = {
- "xyz.openbmc_project.Software.Version"};
- dbus::utility::getSubTree(
- "/xyz/openbmc_project/software", 0, interfaces,
- [asyncResp, swVersionPurpose, activeVersionPropName,
- populateLinkToImages, functionalSwIds](
- const boost::system::error_code& ec2,
- const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec2)
- {
- BMCWEB_LOG_ERROR("error_code = {}", ec2);
- BMCWEB_LOG_ERROR("error msg = {}", ec2.message());
+ BMCWEB_LOG_ERROR("error_code = {}", ec);
+ BMCWEB_LOG_ERROR("error msg = {}", ec.message());
messages::internalError(asyncResp->res);
return;
}
- BMCWEB_LOG_DEBUG("Found {} images", subtree.size());
-
- for (const std::pair<std::string,
- std::vector<std::pair<
- std::string, std::vector<std::string>>>>&
- obj : subtree)
+ if (functionalSw.empty())
{
- sdbusplus::message::object_path path(obj.first);
- std::string swId = path.filename();
- if (swId.empty())
- {
- messages::internalError(asyncResp->res);
- BMCWEB_LOG_ERROR("Invalid software ID");
+ // Could keep going and try to populate SoftwareImages but
+ // something is seriously wrong, so just fail
+ BMCWEB_LOG_ERROR("Zero functional software in system");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- return;
+ std::vector<std::string> functionalSwIds;
+ // example functionalSw:
+ // v as 2 "/xyz/openbmc_project/software/ace821ef"
+ // "/xyz/openbmc_project/software/230fb078"
+ for (const auto& sw : functionalSw)
+ {
+ sdbusplus::message::object_path path(sw);
+ std::string leaf = path.filename();
+ if (leaf.empty())
+ {
+ continue;
}
- bool runningImage = false;
- // Look at Ids from
- // /xyz/openbmc_project/software/functional
- // to determine if this is a running image
- if (std::ranges::find(functionalSwIds, swId) !=
- functionalSwIds.end())
- {
- runningImage = true;
- }
+ functionalSwIds.push_back(leaf);
+ }
- // Now grab its version info
- sdbusplus::asio::getAllProperties(
- *crow::connections::systemBus, obj.second[0].first,
- obj.first, "xyz.openbmc_project.Software.Version",
- [asyncResp, swId, runningImage, swVersionPurpose,
- activeVersionPropName, populateLinkToImages](
- const boost::system::error_code& ec3,
- const dbus::utility::DBusPropertiesMap&
- propertiesList) {
- if (ec3)
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Software.Version"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/software", 0, interfaces,
+ [asyncResp, swVersionPurpose, activeVersionPropName,
+ populateLinkToImages, functionalSwIds](
+ const boost::system::error_code& ec2,
+ const dbus::utility::MapperGetSubTreeResponse& subtree) {
+ if (ec2)
{
- BMCWEB_LOG_ERROR("error_code = {}", ec3);
- BMCWEB_LOG_ERROR("error msg = {}", ec3.message());
- // Have seen the code update app delete the D-Bus
- // object, during code update, between the call to
- // mapper and here. Just leave these properties off if
- // resource not found.
- if (ec3.value() == EBADR)
+ BMCWEB_LOG_ERROR("error_code = {}", ec2);
+ BMCWEB_LOG_ERROR("error msg = {}", ec2.message());
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ BMCWEB_LOG_DEBUG("Found {} images", subtree.size());
+
+ for (const std::pair<
+ std::string,
+ std::vector<std::pair<
+ std::string, std::vector<std::string>>>>& obj :
+ subtree)
+ {
+ sdbusplus::message::object_path path(obj.first);
+ std::string swId = path.filename();
+ if (swId.empty())
{
+ messages::internalError(asyncResp->res);
+ BMCWEB_LOG_ERROR("Invalid software ID");
+
return;
}
- messages::internalError(asyncResp->res);
- return;
- }
- // example propertiesList
- // a{sv} 2 "Version" s
- // "IBM-witherspoon-OP9-v2.0.10-2.22" "Purpose"
- // s
- // "xyz.openbmc_project.Software.Version.VersionPurpose.Host"
- const std::string* version = nullptr;
- const std::string* swInvPurpose = nullptr;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), propertiesList,
- "Purpose", swInvPurpose, "Version", version);
-
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- if (version == nullptr || version->empty())
- {
- messages::internalError(asyncResp->res);
- return;
- }
- if (swInvPurpose == nullptr ||
- *swInvPurpose != swVersionPurpose)
- {
- // Not purpose we're looking for
- return;
- }
-
- BMCWEB_LOG_DEBUG("Image ID: {}", swId);
- BMCWEB_LOG_DEBUG("Running image: {}", runningImage);
- BMCWEB_LOG_DEBUG("Image purpose: {}", *swInvPurpose);
-
- if (populateLinkToImages)
- {
- nlohmann::json& softwareImageMembers =
- asyncResp->res.jsonValue["Links"]["SoftwareImages"];
- // Firmware images are at
- // /redfish/v1/UpdateService/FirmwareInventory/<Id>
- // e.g. .../FirmwareInventory/82d3ec86
- nlohmann::json::object_t member;
- member["@odata.id"] = boost::urls::format(
- "/redfish/v1/UpdateService/FirmwareInventory/{}",
- swId);
- softwareImageMembers.emplace_back(std::move(member));
- asyncResp->res
- .jsonValue["Links"]["SoftwareImages@odata.count"] =
- softwareImageMembers.size();
-
- if (runningImage)
+ bool runningImage = false;
+ // Look at Ids from
+ // /xyz/openbmc_project/software/functional
+ // to determine if this is a running image
+ if (std::ranges::find(functionalSwIds, swId) !=
+ functionalSwIds.end())
{
- nlohmann::json::object_t runningMember;
- runningMember["@odata.id"] = boost::urls::format(
- "/redfish/v1/UpdateService/FirmwareInventory/{}",
- swId);
- // Create the link to the running image
- asyncResp->res
- .jsonValue["Links"]["ActiveSoftwareImage"] =
- std::move(runningMember);
+ runningImage = true;
}
- }
- if (!activeVersionPropName.empty() && runningImage)
- {
- asyncResp->res.jsonValue[activeVersionPropName] =
- *version;
+
+ // Now grab its version info
+ sdbusplus::asio::getAllProperties(
+ *crow::connections::systemBus, obj.second[0].first,
+ obj.first, "xyz.openbmc_project.Software.Version",
+ [asyncResp, swId, runningImage, swVersionPurpose,
+ activeVersionPropName, populateLinkToImages](
+ const boost::system::error_code& ec3,
+ const dbus::utility::DBusPropertiesMap&
+ propertiesList) {
+ if (ec3)
+ {
+ BMCWEB_LOG_ERROR("error_code = {}", ec3);
+ BMCWEB_LOG_ERROR("error msg = {}",
+ ec3.message());
+ // Have seen the code update app delete the
+ // D-Bus object, during code update, between
+ // the call to mapper and here. Just leave
+ // these properties off if resource not
+ // found.
+ if (ec3.value() == EBADR)
+ {
+ return;
+ }
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ // example propertiesList
+ // a{sv} 2 "Version" s
+ // "IBM-witherspoon-OP9-v2.0.10-2.22" "Purpose"
+ // s
+ // "xyz.openbmc_project.Software.Version.VersionPurpose.Host"
+ const std::string* version = nullptr;
+ const std::string* swInvPurpose = nullptr;
+
+ const bool success =
+ sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(),
+ propertiesList, "Purpose", swInvPurpose,
+ "Version", version);
+
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ if (version == nullptr || version->empty())
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (swInvPurpose == nullptr ||
+ *swInvPurpose != swVersionPurpose)
+ {
+ // Not purpose we're looking for
+ return;
+ }
+
+ BMCWEB_LOG_DEBUG("Image ID: {}", swId);
+ BMCWEB_LOG_DEBUG("Running image: {}",
+ runningImage);
+ BMCWEB_LOG_DEBUG("Image purpose: {}",
+ *swInvPurpose);
+
+ if (populateLinkToImages)
+ {
+ nlohmann::json& softwareImageMembers =
+ asyncResp->res
+ .jsonValue["Links"]
+ ["SoftwareImages"];
+ // Firmware images are at
+ // /redfish/v1/UpdateService/FirmwareInventory/<Id>
+ // e.g. .../FirmwareInventory/82d3ec86
+ nlohmann::json::object_t member;
+ member["@odata.id"] = boost::urls::format(
+ "/redfish/v1/UpdateService/FirmwareInventory/{}",
+ swId);
+ softwareImageMembers.emplace_back(
+ std::move(member));
+ asyncResp->res.jsonValue
+ ["Links"]
+ ["SoftwareImages@odata.count"] =
+ softwareImageMembers.size();
+
+ if (runningImage)
+ {
+ nlohmann::json::object_t runningMember;
+ runningMember["@odata.id"] =
+ boost::urls::format(
+ "/redfish/v1/UpdateService/FirmwareInventory/{}",
+ swId);
+ // Create the link to the running image
+ asyncResp->res
+ .jsonValue["Links"]
+ ["ActiveSoftwareImage"] =
+ std::move(runningMember);
+ }
+ }
+ if (!activeVersionPropName.empty() &&
+ runningImage)
+ {
+ asyncResp->res
+ .jsonValue[activeVersionPropName] =
+ *version;
+ }
+ });
}
});
- }
});
- });
}
/**
@@ -351,38 +366,38 @@
[asyncResp,
swId](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& propertiesList) {
- if (ec)
- {
- // not all swtypes are updateable, this is ok
+ if (ec)
+ {
+ // not all swtypes are updateable, this is ok
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Enabled;
+ return;
+ }
+
+ const std::string* swInvActivation = nullptr;
+
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), propertiesList, "Activation",
+ swInvActivation);
+
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ if (swInvActivation == nullptr)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ BMCWEB_LOG_DEBUG("getSwStatus: Activation {}", *swInvActivation);
asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Enabled;
- return;
- }
-
- const std::string* swInvActivation = nullptr;
-
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), propertiesList, "Activation",
- swInvActivation);
-
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- if (swInvActivation == nullptr)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- BMCWEB_LOG_DEBUG("getSwStatus: Activation {}", *swInvActivation);
- asyncResp->res.jsonValue["Status"]["State"] =
- getRedfishSwState(*swInvActivation);
- asyncResp->res.jsonValue["Status"]["Health"] =
- getRedfishSwHealth(*swInvActivation);
- });
+ getRedfishSwState(*swInvActivation);
+ asyncResp->res.jsonValue["Status"]["Health"] =
+ getRedfishSwHealth(*swInvActivation);
+ });
}
inline void handleUpdateableEndpoints(