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(
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index aa06782..2cc6976 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -176,10 +176,9 @@
*
* @return true if Account Types mapped to User Groups, false otherwise.
*/
-inline bool
- getUserGroupFromAccountType(crow::Response& res,
- const std::vector<std::string>& accountTypes,
- std::vector<std::string>& userGroups)
+inline bool getUserGroupFromAccountType(
+ crow::Response& res, const std::vector<std::string>& accountTypes,
+ std::vector<std::string>& userGroups)
{
// Need both Redfish and WebUI Account Types to map to 'redfish' User Group
bool redfishType = false;
@@ -384,24 +383,25 @@
crow::connections::systemBus->async_method_call(
[asyncResp, roleMapObjData, serverType,
index](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue[serverType]["RemoteRoleMapping"]
- [index] = nullptr;
- },
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res
+ .jsonValue[serverType]["RemoteRoleMapping"][index] =
+ nullptr;
+ },
ldapDbusService, roleMapObjData[index].first,
"xyz.openbmc_project.Object.Delete", "Delete");
}
else
{
BMCWEB_LOG_ERROR("Can't delete the object");
- messages::propertyValueTypeError(asyncResp->res, "null",
- "RemoteRoleMapping/" +
- std::to_string(index));
+ messages::propertyValueTypeError(
+ asyncResp->res, "null",
+ "RemoteRoleMapping/" + std::to_string(index));
return;
}
}
@@ -462,8 +462,8 @@
{
BMCWEB_LOG_DEBUG(
"setRoleMappingProperties: Creating new Object");
- std::string pathString = "RemoteRoleMapping/" +
- std::to_string(index);
+ std::string pathString =
+ "RemoteRoleMapping/" + std::to_string(index);
if (!localRole)
{
@@ -494,20 +494,20 @@
crow::connections::systemBus->async_method_call(
[asyncResp, serverType, localRole,
remoteGroup](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- nlohmann::json& remoteRoleJson =
- asyncResp->res
- .jsonValue[serverType]["RemoteRoleMapping"];
- nlohmann::json::object_t roleMapEntry;
- roleMapEntry["LocalRole"] = *localRole;
- roleMapEntry["RemoteGroup"] = *remoteGroup;
- remoteRoleJson.emplace_back(std::move(roleMapEntry));
- },
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ nlohmann::json& remoteRoleJson =
+ asyncResp->res
+ .jsonValue[serverType]["RemoteRoleMapping"];
+ nlohmann::json::object_t roleMapEntry;
+ roleMapEntry["LocalRole"] = *localRole;
+ roleMapEntry["RemoteGroup"] = *remoteGroup;
+ remoteRoleJson.emplace_back(std::move(roleMapEntry));
+ },
ldapDbusService, dbusObjectPath, ldapPrivMapperInterface,
"Create", *remoteGroup,
getPrivilegeFromRoleId(std::move(*localRole)));
@@ -521,8 +521,8 @@
* into JSON
*/
template <typename CallbackFunc>
-inline void getLDAPConfigData(const std::string& ldapType,
- CallbackFunc&& callback)
+inline void
+ getLDAPConfigData(const std::string& ldapType, CallbackFunc&& callback)
{
constexpr std::array<std::string_view, 2> interfaces = {
ldapEnableInterface, ldapConfigInterface};
@@ -532,156 +532,165 @@
[callback = std::forward<CallbackFunc>(callback),
ldapType](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& resp) mutable {
- if (ec || resp.empty())
- {
- BMCWEB_LOG_WARNING(
- "DBUS response error during getting of service name: {}", ec);
- LDAPConfigData empty{};
- callback(false, empty, ldapType);
- return;
- }
- std::string service = resp.begin()->first;
- sdbusplus::message::object_path path(ldapRootObject);
- dbus::utility::getManagedObjects(
- service, path,
- [callback, ldapType](
- const boost::system::error_code& ec2,
- const dbus::utility::ManagedObjectType& ldapObjects) mutable {
- LDAPConfigData confData{};
- if (ec2)
+ if (ec || resp.empty())
{
- callback(false, confData, ldapType);
- BMCWEB_LOG_WARNING("D-Bus responses error: {}", ec2);
+ BMCWEB_LOG_WARNING(
+ "DBUS response error during getting of service name: {}",
+ ec);
+ LDAPConfigData empty{};
+ callback(false, empty, ldapType);
return;
}
-
- std::string ldapDbusType;
- std::string searchString;
-
- if (ldapType == "LDAP")
- {
- ldapDbusType =
- "xyz.openbmc_project.User.Ldap.Config.Type.OpenLdap";
- searchString = "openldap";
- }
- else if (ldapType == "ActiveDirectory")
- {
- ldapDbusType =
- "xyz.openbmc_project.User.Ldap.Config.Type.ActiveDirectory";
- searchString = "active_directory";
- }
- else
- {
- BMCWEB_LOG_ERROR("Can't get the DbusType for the given type={}",
- ldapType);
- callback(false, confData, ldapType);
- return;
- }
-
- std::string ldapEnableInterfaceStr = ldapEnableInterface;
- std::string ldapConfigInterfaceStr = ldapConfigInterface;
-
- for (const auto& object : ldapObjects)
- {
- // let's find the object whose ldap type is equal to the
- // given type
- if (object.first.str.find(searchString) == std::string::npos)
- {
- continue;
- }
-
- for (const auto& interface : object.second)
- {
- if (interface.first == ldapEnableInterfaceStr)
+ std::string service = resp.begin()->first;
+ sdbusplus::message::object_path path(ldapRootObject);
+ dbus::utility::getManagedObjects(
+ service, path,
+ [callback, ldapType](const boost::system::error_code& ec2,
+ const dbus::utility::ManagedObjectType&
+ ldapObjects) mutable {
+ LDAPConfigData confData{};
+ if (ec2)
{
- // rest of the properties are string.
- for (const auto& property : interface.second)
+ callback(false, confData, ldapType);
+ BMCWEB_LOG_WARNING("D-Bus responses error: {}", ec2);
+ return;
+ }
+
+ std::string ldapDbusType;
+ std::string searchString;
+
+ if (ldapType == "LDAP")
+ {
+ ldapDbusType =
+ "xyz.openbmc_project.User.Ldap.Config.Type.OpenLdap";
+ searchString = "openldap";
+ }
+ else if (ldapType == "ActiveDirectory")
+ {
+ ldapDbusType =
+ "xyz.openbmc_project.User.Ldap.Config.Type.ActiveDirectory";
+ searchString = "active_directory";
+ }
+ else
+ {
+ BMCWEB_LOG_ERROR(
+ "Can't get the DbusType for the given type={}",
+ ldapType);
+ callback(false, confData, ldapType);
+ return;
+ }
+
+ std::string ldapEnableInterfaceStr = ldapEnableInterface;
+ std::string ldapConfigInterfaceStr = ldapConfigInterface;
+
+ for (const auto& object : ldapObjects)
+ {
+ // let's find the object whose ldap type is equal to the
+ // given type
+ if (object.first.str.find(searchString) ==
+ std::string::npos)
{
- if (property.first == "Enabled")
+ continue;
+ }
+
+ for (const auto& interface : object.second)
+ {
+ if (interface.first == ldapEnableInterfaceStr)
{
- const bool* value =
- std::get_if<bool>(&property.second);
- if (value == nullptr)
+ // rest of the properties are string.
+ for (const auto& property : interface.second)
{
- continue;
+ if (property.first == "Enabled")
+ {
+ const bool* value =
+ std::get_if<bool>(&property.second);
+ if (value == nullptr)
+ {
+ continue;
+ }
+ confData.serviceEnabled = *value;
+ break;
+ }
}
- confData.serviceEnabled = *value;
- break;
+ }
+ else if (interface.first == ldapConfigInterfaceStr)
+ {
+ for (const auto& property : interface.second)
+ {
+ const std::string* strValue =
+ std::get_if<std::string>(
+ &property.second);
+ if (strValue == nullptr)
+ {
+ continue;
+ }
+ if (property.first == "LDAPServerURI")
+ {
+ confData.uri = *strValue;
+ }
+ else if (property.first == "LDAPBindDN")
+ {
+ confData.bindDN = *strValue;
+ }
+ else if (property.first == "LDAPBaseDN")
+ {
+ confData.baseDN = *strValue;
+ }
+ else if (property.first ==
+ "LDAPSearchScope")
+ {
+ confData.searchScope = *strValue;
+ }
+ else if (property.first ==
+ "GroupNameAttribute")
+ {
+ confData.groupAttribute = *strValue;
+ }
+ else if (property.first ==
+ "UserNameAttribute")
+ {
+ confData.userNameAttribute = *strValue;
+ }
+ else if (property.first == "LDAPType")
+ {
+ confData.serverType = *strValue;
+ }
+ }
+ }
+ else if (
+ interface.first ==
+ "xyz.openbmc_project.User.PrivilegeMapperEntry")
+ {
+ LDAPRoleMapData roleMapData{};
+ for (const auto& property : interface.second)
+ {
+ const std::string* strValue =
+ std::get_if<std::string>(
+ &property.second);
+
+ if (strValue == nullptr)
+ {
+ continue;
+ }
+
+ if (property.first == "GroupName")
+ {
+ roleMapData.groupName = *strValue;
+ }
+ else if (property.first == "Privilege")
+ {
+ roleMapData.privilege = *strValue;
+ }
+ }
+
+ confData.groupRoleList.emplace_back(
+ object.first.str, roleMapData);
}
}
}
- else if (interface.first == ldapConfigInterfaceStr)
- {
- for (const auto& property : interface.second)
- {
- const std::string* strValue =
- std::get_if<std::string>(&property.second);
- if (strValue == nullptr)
- {
- continue;
- }
- if (property.first == "LDAPServerURI")
- {
- confData.uri = *strValue;
- }
- else if (property.first == "LDAPBindDN")
- {
- confData.bindDN = *strValue;
- }
- else if (property.first == "LDAPBaseDN")
- {
- confData.baseDN = *strValue;
- }
- else if (property.first == "LDAPSearchScope")
- {
- confData.searchScope = *strValue;
- }
- else if (property.first == "GroupNameAttribute")
- {
- confData.groupAttribute = *strValue;
- }
- else if (property.first == "UserNameAttribute")
- {
- confData.userNameAttribute = *strValue;
- }
- else if (property.first == "LDAPType")
- {
- confData.serverType = *strValue;
- }
- }
- }
- else if (interface.first ==
- "xyz.openbmc_project.User.PrivilegeMapperEntry")
- {
- LDAPRoleMapData roleMapData{};
- for (const auto& property : interface.second)
- {
- const std::string* strValue =
- std::get_if<std::string>(&property.second);
-
- if (strValue == nullptr)
- {
- continue;
- }
-
- if (property.first == "GroupName")
- {
- roleMapData.groupName = *strValue;
- }
- else if (property.first == "Privilege")
- {
- roleMapData.privilege = *strValue;
- }
- }
-
- confData.groupRoleList.emplace_back(object.first.str,
- roleMapData);
- }
- }
- }
- callback(true, confData, ldapType);
+ callback(true, confData, ldapType);
+ });
});
- });
}
/**
@@ -774,17 +783,17 @@
server(openLDAP/ActiveDirectory)
*/
-inline void
- handleUserNameAttrPatch(const std::string& userNameAttribute,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& ldapServerElementName,
- const std::string& ldapConfigObject)
+inline void handleUserNameAttrPatch(
+ const std::string& userNameAttribute,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& ldapServerElementName,
+ const std::string& ldapConfigObject)
{
- setDbusProperty(asyncResp,
- ldapServerElementName +
- "LDAPService/SearchSettings/UsernameAttribute",
- ldapDbusService, ldapConfigObject, ldapConfigInterface,
- "UserNameAttribute", userNameAttribute);
+ setDbusProperty(
+ asyncResp,
+ ldapServerElementName + "LDAPService/SearchSettings/UsernameAttribute",
+ ldapDbusService, ldapConfigObject, ldapConfigInterface,
+ "UserNameAttribute", userNameAttribute);
}
/**
* @brief updates the LDAP group attribute and updates the
@@ -801,11 +810,11 @@
const std::string& ldapServerElementName,
const std::string& ldapConfigObject)
{
- setDbusProperty(asyncResp,
- ldapServerElementName +
- "/LDAPService/SearchSettings/GroupsAttribute",
- ldapDbusService, ldapConfigObject, ldapConfigInterface,
- "GroupNameAttribute", groupsAttribute);
+ setDbusProperty(
+ asyncResp,
+ ldapServerElementName + "/LDAPService/SearchSettings/GroupsAttribute",
+ ldapDbusService, ldapConfigObject, ldapConfigInterface,
+ "GroupNameAttribute", groupsAttribute);
}
/**
* @brief updates the LDAP service enable and updates the
@@ -1001,11 +1010,11 @@
// Get the existing resource first then keep modifying
// whenever any property gets updated.
- getLDAPConfigData(serverType,
- [asyncResp, input = std::move(input),
- dbusObjectPath = std::move(dbusObjectPath)](
- bool success, const LDAPConfigData& confData,
- const std::string& serverT) mutable {
+ getLDAPConfigData(serverType, [asyncResp, input = std::move(input),
+ dbusObjectPath = std::move(dbusObjectPath)](
+ bool success,
+ const LDAPConfigData& confData,
+ const std::string& serverT) mutable {
if (!success)
{
messages::internalError(asyncResp->res);
@@ -1095,89 +1104,91 @@
[dbusObjectPath, username, password, roleId, enabled, locked,
accountTypes(std::move(accountTypes)), userSelf, session,
asyncResp{std::move(asyncResp)}](int rc) {
- if (rc <= 0)
- {
- messages::resourceNotFound(asyncResp->res, "ManagerAccount",
- username);
- return;
- }
-
- if (password)
- {
- int retval = pamUpdatePassword(username, *password);
-
- if (retval == PAM_USER_UNKNOWN)
+ if (rc <= 0)
{
messages::resourceNotFound(asyncResp->res, "ManagerAccount",
username);
- }
- else if (retval == PAM_AUTHTOK_ERR)
- {
- // If password is invalid
- messages::propertyValueFormatError(asyncResp->res, nullptr,
- "Password");
- BMCWEB_LOG_ERROR("pamUpdatePassword Failed");
- }
- else if (retval != PAM_SUCCESS)
- {
- messages::internalError(asyncResp->res);
return;
}
- else
+
+ if (password)
{
- // Remove existing sessions of the user when password changed
- persistent_data::SessionStore::getInstance()
- .removeSessionsByUsernameExceptSession(username, session);
- messages::success(asyncResp->res);
+ int retval = pamUpdatePassword(username, *password);
+
+ if (retval == PAM_USER_UNKNOWN)
+ {
+ messages::resourceNotFound(asyncResp->res, "ManagerAccount",
+ username);
+ }
+ else if (retval == PAM_AUTHTOK_ERR)
+ {
+ // If password is invalid
+ messages::propertyValueFormatError(asyncResp->res, nullptr,
+ "Password");
+ BMCWEB_LOG_ERROR("pamUpdatePassword Failed");
+ }
+ else if (retval != PAM_SUCCESS)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ else
+ {
+ // Remove existing sessions of the user when password
+ // changed
+ persistent_data::SessionStore::getInstance()
+ .removeSessionsByUsernameExceptSession(username,
+ session);
+ messages::success(asyncResp->res);
+ }
}
- }
- if (enabled)
- {
- setDbusProperty(asyncResp, "Enabled",
- "xyz.openbmc_project.User.Manager", dbusObjectPath,
- "xyz.openbmc_project.User.Attributes",
- "UserEnabled", *enabled);
- }
-
- if (roleId)
- {
- std::string priv = getPrivilegeFromRoleId(*roleId);
- if (priv.empty())
+ if (enabled)
{
- messages::propertyValueNotInList(asyncResp->res, true,
- "Locked");
- return;
+ setDbusProperty(
+ asyncResp, "Enabled", "xyz.openbmc_project.User.Manager",
+ dbusObjectPath, "xyz.openbmc_project.User.Attributes",
+ "UserEnabled", *enabled);
}
- setDbusProperty(asyncResp, "RoleId",
- "xyz.openbmc_project.User.Manager", dbusObjectPath,
- "xyz.openbmc_project.User.Attributes",
- "UserPrivilege", priv);
- }
- if (locked)
- {
- // admin can unlock the account which is locked by
- // successive authentication failures but admin should
- // not be allowed to lock an account.
- if (*locked)
+ if (roleId)
{
- messages::propertyValueNotInList(asyncResp->res, "true",
- "Locked");
- return;
+ std::string priv = getPrivilegeFromRoleId(*roleId);
+ if (priv.empty())
+ {
+ messages::propertyValueNotInList(asyncResp->res, true,
+ "Locked");
+ return;
+ }
+ setDbusProperty(
+ asyncResp, "RoleId", "xyz.openbmc_project.User.Manager",
+ dbusObjectPath, "xyz.openbmc_project.User.Attributes",
+ "UserPrivilege", priv);
}
- setDbusProperty(asyncResp, "Locked",
- "xyz.openbmc_project.User.Manager", dbusObjectPath,
- "xyz.openbmc_project.User.Attributes",
- "UserLockedForFailedAttempt", *locked);
- }
- if (accountTypes)
- {
- patchAccountTypes(*accountTypes, asyncResp, dbusObjectPath,
- userSelf);
- }
- });
+ if (locked)
+ {
+ // admin can unlock the account which is locked by
+ // successive authentication failures but admin should
+ // not be allowed to lock an account.
+ if (*locked)
+ {
+ messages::propertyValueNotInList(asyncResp->res, "true",
+ "Locked");
+ return;
+ }
+ setDbusProperty(
+ asyncResp, "Locked", "xyz.openbmc_project.User.Manager",
+ dbusObjectPath, "xyz.openbmc_project.User.Attributes",
+ "UserLockedForFailedAttempt", *locked);
+ }
+
+ if (accountTypes)
+ {
+ patchAccountTypes(*accountTypes, asyncResp, dbusObjectPath,
+ userSelf);
+ }
+ });
}
inline void handleAccountServiceHead(
@@ -1405,48 +1416,49 @@
"/xyz/openbmc_project/user", "xyz.openbmc_project.User.AccountPolicy",
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& propertiesList) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- BMCWEB_LOG_DEBUG("Got {} properties for AccountService",
- propertiesList.size());
+ BMCWEB_LOG_DEBUG("Got {} properties for AccountService",
+ propertiesList.size());
- const uint8_t* minPasswordLength = nullptr;
- const uint32_t* accountUnlockTimeout = nullptr;
- const uint16_t* maxLoginAttemptBeforeLockout = nullptr;
+ const uint8_t* minPasswordLength = nullptr;
+ const uint32_t* accountUnlockTimeout = nullptr;
+ const uint16_t* maxLoginAttemptBeforeLockout = nullptr;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), propertiesList,
- "MinPasswordLength", minPasswordLength, "AccountUnlockTimeout",
- accountUnlockTimeout, "MaxLoginAttemptBeforeLockout",
- maxLoginAttemptBeforeLockout);
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), propertiesList,
+ "MinPasswordLength", minPasswordLength, "AccountUnlockTimeout",
+ accountUnlockTimeout, "MaxLoginAttemptBeforeLockout",
+ maxLoginAttemptBeforeLockout);
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (minPasswordLength != nullptr)
- {
- asyncResp->res.jsonValue["MinPasswordLength"] = *minPasswordLength;
- }
+ if (minPasswordLength != nullptr)
+ {
+ asyncResp->res.jsonValue["MinPasswordLength"] =
+ *minPasswordLength;
+ }
- if (accountUnlockTimeout != nullptr)
- {
- asyncResp->res.jsonValue["AccountLockoutDuration"] =
- *accountUnlockTimeout;
- }
+ if (accountUnlockTimeout != nullptr)
+ {
+ asyncResp->res.jsonValue["AccountLockoutDuration"] =
+ *accountUnlockTimeout;
+ }
- if (maxLoginAttemptBeforeLockout != nullptr)
- {
- asyncResp->res.jsonValue["AccountLockoutThreshold"] =
- *maxLoginAttemptBeforeLockout;
- }
- });
+ if (maxLoginAttemptBeforeLockout != nullptr)
+ {
+ asyncResp->res.jsonValue["AccountLockoutThreshold"] =
+ *maxLoginAttemptBeforeLockout;
+ }
+ });
auto callback = [asyncResp](bool success, const LDAPConfigData& confData,
const std::string& ldapType) {
@@ -1461,9 +1473,8 @@
getLDAPConfigData("ActiveDirectory", callback);
}
-inline void
- handleCertificateMappingAttributePatch(crow::Response& res,
- const std::string& certMapAttribute)
+inline void handleCertificateMappingAttributePatch(
+ crow::Response& res, const std::string& certMapAttribute)
{
MTLSCommonNameParseMode parseMode =
persistent_data::getMTLSCommonNameParseMode(certMapAttribute);
@@ -1690,47 +1701,49 @@
[asyncResp, thisUser, effectiveUserPrivileges](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& users) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- bool userCanSeeAllAccounts =
- effectiveUserPrivileges.isSupersetOf({"ConfigureUsers"});
-
- bool userCanSeeSelf =
- effectiveUserPrivileges.isSupersetOf({"ConfigureSelf"});
-
- nlohmann::json& memberArray = asyncResp->res.jsonValue["Members"];
- memberArray = nlohmann::json::array();
-
- for (const auto& userpath : users)
- {
- std::string user = userpath.first.filename();
- if (user.empty())
+ if (ec)
{
messages::internalError(asyncResp->res);
- BMCWEB_LOG_ERROR("Invalid firmware ID");
-
return;
}
- // As clarified by Redfish here:
- // https://redfishforum.com/thread/281/manageraccountcollection-change-allows-account-enumeration
- // Users without ConfigureUsers, only see their own
- // account. Users with ConfigureUsers, see all
- // accounts.
- if (userCanSeeAllAccounts || (thisUser == user && userCanSeeSelf))
+ bool userCanSeeAllAccounts =
+ effectiveUserPrivileges.isSupersetOf({"ConfigureUsers"});
+
+ bool userCanSeeSelf =
+ effectiveUserPrivileges.isSupersetOf({"ConfigureSelf"});
+
+ nlohmann::json& memberArray = asyncResp->res.jsonValue["Members"];
+ memberArray = nlohmann::json::array();
+
+ for (const auto& userpath : users)
{
- nlohmann::json::object_t member;
- member["@odata.id"] = boost::urls::format(
- "/redfish/v1/AccountService/Accounts/{}", user);
- memberArray.emplace_back(std::move(member));
+ std::string user = userpath.first.filename();
+ if (user.empty())
+ {
+ messages::internalError(asyncResp->res);
+ BMCWEB_LOG_ERROR("Invalid firmware ID");
+
+ return;
+ }
+
+ // As clarified by Redfish here:
+ // https://redfishforum.com/thread/281/manageraccountcollection-change-allows-account-enumeration
+ // Users without ConfigureUsers, only see their own
+ // account. Users with ConfigureUsers, see all
+ // accounts.
+ if (userCanSeeAllAccounts ||
+ (thisUser == user && userCanSeeSelf))
+ {
+ nlohmann::json::object_t member;
+ member["@odata.id"] = boost::urls::format(
+ "/redfish/v1/AccountService/Accounts/{}", user);
+ memberArray.emplace_back(std::move(member));
+ }
}
- }
- asyncResp->res.jsonValue["Members@odata.count"] = memberArray.size();
- });
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ memberArray.size();
+ });
}
inline void processAfterCreateUser(
@@ -1756,16 +1769,16 @@
crow::connections::systemBus->async_method_call(
[asyncResp, password](const boost::system::error_code& ec3) {
- if (ec3)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec3)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- // If password is invalid
- messages::propertyValueFormatError(asyncResp->res, nullptr,
- "Password");
- },
+ // If password is invalid
+ messages::propertyValueFormatError(asyncResp->res, nullptr,
+ "Password");
+ },
"xyz.openbmc_project.User.Manager", userPath,
"xyz.openbmc_project.Object.Delete", "Delete");
@@ -1849,8 +1862,8 @@
crow::connections::systemBus->async_method_call(
[asyncResp, username, password](const boost::system::error_code& ec2,
sdbusplus::message_t& m) {
- processAfterCreateUser(asyncResp, username, password, ec2, m);
- },
+ processAfterCreateUser(asyncResp, username, password, ec2, m);
+ },
"xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
"xyz.openbmc_project.User.Manager", "CreateUser", username, userGroups,
roleId, enabled);
@@ -1869,10 +1882,10 @@
std::optional<std::string> roleIdJson;
std::optional<bool> enabledJson;
std::optional<std::vector<std::string>> accountTypes;
- if (!json_util::readJsonPatch(req, asyncResp->res, "UserName", username,
- "Password", password, "RoleId", roleIdJson,
- "Enabled", enabledJson, "AccountTypes",
- accountTypes))
+ if (!json_util::readJsonPatch(
+ req, asyncResp->res, "UserName", username, "Password", password,
+ "RoleId", roleIdJson, "Enabled", enabledJson, "AccountTypes",
+ accountTypes))
{
return;
}
@@ -1896,22 +1909,22 @@
[asyncResp, username, password{std::move(password)}, roleId, enabled,
accountTypes](const boost::system::error_code& ec,
const std::vector<std::string>& allGroupsList) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("ERROR with async_method_call");
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("ERROR with async_method_call");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (allGroupsList.empty())
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (allGroupsList.empty())
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- processAfterGetAllGroups(asyncResp, username, password, roleId, enabled,
- accountTypes, allGroupsList);
- });
+ processAfterGetAllGroups(asyncResp, username, password, roleId,
+ enabled, accountTypes, allGroupsList);
+ });
}
inline void
@@ -1979,138 +1992,140 @@
[asyncResp,
accountName](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& users) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- const auto userIt = std::ranges::find_if(
- users,
- [accountName](
- const std::pair<sdbusplus::message::object_path,
- dbus::utility::DBusInterfacesMap>& user) {
- return accountName == user.first.filename();
- });
-
- if (userIt == users.end())
- {
- messages::resourceNotFound(asyncResp->res, "ManagerAccount",
- accountName);
- return;
- }
-
- asyncResp->res.jsonValue["@odata.type"] =
- "#ManagerAccount.v1_7_0.ManagerAccount";
- asyncResp->res.jsonValue["Name"] = "User Account";
- asyncResp->res.jsonValue["Description"] = "User Account";
- asyncResp->res.jsonValue["Password"] = nullptr;
- asyncResp->res.jsonValue["StrictAccountTypes"] = true;
-
- for (const auto& interface : userIt->second)
- {
- if (interface.first == "xyz.openbmc_project.User.Attributes")
+ if (ec)
{
- for (const auto& property : interface.second)
- {
- if (property.first == "UserEnabled")
- {
- const bool* userEnabled =
- std::get_if<bool>(&property.second);
- if (userEnabled == nullptr)
- {
- BMCWEB_LOG_ERROR("UserEnabled wasn't a bool");
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["Enabled"] = *userEnabled;
- }
- else if (property.first == "UserLockedForFailedAttempt")
- {
- const bool* userLocked =
- std::get_if<bool>(&property.second);
- if (userLocked == nullptr)
- {
- BMCWEB_LOG_ERROR("UserLockedForF"
- "ailedAttempt "
- "wasn't a bool");
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["Locked"] = *userLocked;
- nlohmann::json::array_t allowed;
- // can only unlock accounts
- allowed.emplace_back("false");
- asyncResp->res
- .jsonValue["Locked@Redfish.AllowableValues"] =
- std::move(allowed);
- }
- else if (property.first == "UserPrivilege")
- {
- const std::string* userPrivPtr =
- std::get_if<std::string>(&property.second);
- if (userPrivPtr == nullptr)
- {
- BMCWEB_LOG_ERROR("UserPrivilege wasn't a "
- "string");
- messages::internalError(asyncResp->res);
- return;
- }
- std::string role = getRoleIdFromPrivilege(*userPrivPtr);
- if (role.empty())
- {
- BMCWEB_LOG_ERROR("Invalid user role");
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["RoleId"] = role;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ const auto userIt = std::ranges::find_if(
+ users,
+ [accountName](
+ const std::pair<sdbusplus::message::object_path,
+ dbus::utility::DBusInterfacesMap>& user) {
+ return accountName == user.first.filename();
+ });
- nlohmann::json& roleEntry =
- asyncResp->res.jsonValue["Links"]["Role"];
- roleEntry["@odata.id"] = boost::urls::format(
- "/redfish/v1/AccountService/Roles/{}", role);
- }
- else if (property.first == "UserPasswordExpired")
+ if (userIt == users.end())
+ {
+ messages::resourceNotFound(asyncResp->res, "ManagerAccount",
+ accountName);
+ return;
+ }
+
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ManagerAccount.v1_7_0.ManagerAccount";
+ asyncResp->res.jsonValue["Name"] = "User Account";
+ asyncResp->res.jsonValue["Description"] = "User Account";
+ asyncResp->res.jsonValue["Password"] = nullptr;
+ asyncResp->res.jsonValue["StrictAccountTypes"] = true;
+
+ for (const auto& interface : userIt->second)
+ {
+ if (interface.first == "xyz.openbmc_project.User.Attributes")
+ {
+ for (const auto& property : interface.second)
{
- const bool* userPasswordExpired =
- std::get_if<bool>(&property.second);
- if (userPasswordExpired == nullptr)
+ if (property.first == "UserEnabled")
{
- BMCWEB_LOG_ERROR(
- "UserPasswordExpired wasn't a bool");
- messages::internalError(asyncResp->res);
- return;
+ const bool* userEnabled =
+ std::get_if<bool>(&property.second);
+ if (userEnabled == nullptr)
+ {
+ BMCWEB_LOG_ERROR("UserEnabled wasn't a bool");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["Enabled"] = *userEnabled;
}
- asyncResp->res.jsonValue["PasswordChangeRequired"] =
- *userPasswordExpired;
- }
- else if (property.first == "UserGroups")
- {
- const std::vector<std::string>* userGroups =
- std::get_if<std::vector<std::string>>(
- &property.second);
- if (userGroups == nullptr)
+ else if (property.first == "UserLockedForFailedAttempt")
{
- BMCWEB_LOG_ERROR(
- "userGroups wasn't a string vector");
- messages::internalError(asyncResp->res);
- return;
+ const bool* userLocked =
+ std::get_if<bool>(&property.second);
+ if (userLocked == nullptr)
+ {
+ BMCWEB_LOG_ERROR("UserLockedForF"
+ "ailedAttempt "
+ "wasn't a bool");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["Locked"] = *userLocked;
+ nlohmann::json::array_t allowed;
+ // can only unlock accounts
+ allowed.emplace_back("false");
+ asyncResp->res
+ .jsonValue["Locked@Redfish.AllowableValues"] =
+ std::move(allowed);
}
- if (!translateUserGroup(*userGroups, asyncResp->res))
+ else if (property.first == "UserPrivilege")
{
- BMCWEB_LOG_ERROR("userGroups mapping failed");
- messages::internalError(asyncResp->res);
- return;
+ const std::string* userPrivPtr =
+ std::get_if<std::string>(&property.second);
+ if (userPrivPtr == nullptr)
+ {
+ BMCWEB_LOG_ERROR("UserPrivilege wasn't a "
+ "string");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ std::string role =
+ getRoleIdFromPrivilege(*userPrivPtr);
+ if (role.empty())
+ {
+ BMCWEB_LOG_ERROR("Invalid user role");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["RoleId"] = role;
+
+ nlohmann::json& roleEntry =
+ asyncResp->res.jsonValue["Links"]["Role"];
+ roleEntry["@odata.id"] = boost::urls::format(
+ "/redfish/v1/AccountService/Roles/{}", role);
+ }
+ else if (property.first == "UserPasswordExpired")
+ {
+ const bool* userPasswordExpired =
+ std::get_if<bool>(&property.second);
+ if (userPasswordExpired == nullptr)
+ {
+ BMCWEB_LOG_ERROR(
+ "UserPasswordExpired wasn't a bool");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["PasswordChangeRequired"] =
+ *userPasswordExpired;
+ }
+ else if (property.first == "UserGroups")
+ {
+ const std::vector<std::string>* userGroups =
+ std::get_if<std::vector<std::string>>(
+ &property.second);
+ if (userGroups == nullptr)
+ {
+ BMCWEB_LOG_ERROR(
+ "userGroups wasn't a string vector");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (!translateUserGroup(*userGroups,
+ asyncResp->res))
+ {
+ BMCWEB_LOG_ERROR("userGroups mapping failed");
+ messages::internalError(asyncResp->res);
+ return;
+ }
}
}
}
}
- }
- asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/AccountService/Accounts/{}", accountName);
- asyncResp->res.jsonValue["Id"] = accountName;
- asyncResp->res.jsonValue["UserName"] = accountName;
- });
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/AccountService/Accounts/{}", accountName);
+ asyncResp->res.jsonValue["Id"] = accountName;
+ asyncResp->res.jsonValue["UserName"] = accountName;
+ });
}
inline void
@@ -2135,15 +2150,15 @@
crow::connections::systemBus->async_method_call(
[asyncResp, username](const boost::system::error_code& ec) {
- if (ec)
- {
- messages::resourceNotFound(asyncResp->res, "ManagerAccount",
- username);
- return;
- }
+ if (ec)
+ {
+ messages::resourceNotFound(asyncResp->res, "ManagerAccount",
+ username);
+ return;
+ }
- messages::accountRemoved(asyncResp->res);
- },
+ messages::accountRemoved(asyncResp->res);
+ },
"xyz.openbmc_project.User.Manager", userPath,
"xyz.openbmc_project.Object.Delete", "Delete");
}
@@ -2227,16 +2242,16 @@
roleId(std::move(roleId)), enabled, newUser{std::string(*newUserName)},
locked, userSelf, req, accountTypes(std::move(accountTypes))](
const boost::system::error_code& ec, sdbusplus::message_t& m) {
- if (ec)
- {
- userErrorMessageHandler(m.get_error(), asyncResp, newUser,
- username);
- return;
- }
+ if (ec)
+ {
+ userErrorMessageHandler(m.get_error(), asyncResp, newUser,
+ username);
+ return;
+ }
- updateUserProperties(asyncResp, newUser, password, enabled, roleId,
- locked, accountTypes, userSelf, req.session);
- },
+ updateUserProperties(asyncResp, newUser, password, enabled, roleId,
+ locked, accountTypes, userSelf, req.session);
+ },
"xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
"xyz.openbmc_project.User.Manager", "RenameUser", username,
*newUserName);
diff --git a/redfish-core/lib/bios.hpp b/redfish-core/lib/bios.hpp
index 1ec967b..ee922af 100644
--- a/redfish-core/lib/bios.hpp
+++ b/redfish-core/lib/bios.hpp
@@ -91,13 +91,13 @@
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Failed to reset bios: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- },
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("Failed to reset bios: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ },
"org.open_power.Software.Host.Updater", "/xyz/openbmc_project/software",
"xyz.openbmc_project.Common.FactoryReset", "Reset");
}
diff --git a/redfish-core/lib/cable.hpp b/redfish-core/lib/cable.hpp
index 41a5588..27ee276 100644
--- a/redfish-core/lib/cable.hpp
+++ b/redfish-core/lib/cable.hpp
@@ -24,10 +24,9 @@
* @param[in] ec Error code corresponding to Async method call.
* @param[in] properties List of Cable Properties key/value pairs.
*/
-inline void
- fillCableProperties(crow::Response& resp,
- const boost::system::error_code& ec,
- const dbus::utility::DBusPropertiesMap& properties)
+inline void fillCableProperties(
+ crow::Response& resp, const boost::system::error_code& ec,
+ const dbus::utility::DBusPropertiesMap& properties)
{
if (ec)
{
@@ -98,8 +97,8 @@
[asyncResp](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
- fillCableProperties(asyncResp->res, ec, properties);
- });
+ fillCableProperties(asyncResp->res, ec, properties);
+ });
}
else if (interface == "xyz.openbmc_project.Inventory.Item")
{
@@ -108,24 +107,24 @@
interface, "Present",
[asyncResp, cableObjectPath](
const boost::system::error_code& ec, bool present) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG(
- "get presence failed for Cable {} with error {}",
- cableObjectPath, ec);
- if (ec.value() != EBADR)
+ if (ec)
{
- messages::internalError(asyncResp->res);
+ BMCWEB_LOG_DEBUG(
+ "get presence failed for Cable {} with error {}",
+ cableObjectPath, ec);
+ if (ec.value() != EBADR)
+ {
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- if (!present)
- {
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Absent;
- }
- });
+ if (!present)
+ {
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Absent;
+ }
+ });
}
}
}
@@ -142,53 +141,59 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& cableId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- BMCWEB_LOG_DEBUG("Cable Id: {}", cableId);
- constexpr std::array<std::string_view, 1> interfaces = {
- "xyz.openbmc_project.Inventory.Item.Cable"};
- dbus::utility::getSubTree(
- "/xyz/openbmc_project/inventory", 0, interfaces,
- [asyncResp,
- cableId](const boost::system::error_code& ec,
- const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec.value() == EBADR)
- {
- messages::resourceNotFound(asyncResp->res, "Cable", cableId);
- return;
- }
-
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
-
- for (const auto& [objectPath, serviceMap] : subtree)
- {
- sdbusplus::message::object_path path(objectPath);
- if (path.filename() != cableId)
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
- continue;
+ return;
}
+ BMCWEB_LOG_DEBUG("Cable Id: {}", cableId);
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.Cable"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
+ [asyncResp,
+ cableId](const boost::system::error_code& ec,
+ const dbus::utility::MapperGetSubTreeResponse&
+ subtree) {
+ if (ec.value() == EBADR)
+ {
+ messages::resourceNotFound(asyncResp->res, "Cable",
+ cableId);
+ return;
+ }
- asyncResp->res.jsonValue["@odata.type"] = "#Cable.v1_0_0.Cable";
- asyncResp->res.jsonValue["@odata.id"] =
- boost::urls::format("/redfish/v1/Cables/{}", cableId);
- asyncResp->res.jsonValue["Id"] = cableId;
- asyncResp->res.jsonValue["Name"] = "Cable";
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Enabled;
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- getCableProperties(asyncResp, objectPath, serviceMap);
- return;
- }
- messages::resourceNotFound(asyncResp->res, "Cable", cableId);
- });
- });
+ for (const auto& [objectPath, serviceMap] : subtree)
+ {
+ sdbusplus::message::object_path path(objectPath);
+ if (path.filename() != cableId)
+ {
+ continue;
+ }
+
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#Cable.v1_0_0.Cable";
+ asyncResp->res.jsonValue["@odata.id"] =
+ boost::urls::format("/redfish/v1/Cables/{}",
+ cableId);
+ asyncResp->res.jsonValue["Id"] = cableId;
+ asyncResp->res.jsonValue["Name"] = "Cable";
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Enabled;
+
+ getCableProperties(asyncResp, objectPath,
+ serviceMap);
+ return;
+ }
+ messages::resourceNotFound(asyncResp->res, "Cable",
+ cableId);
+ });
+ });
}
/**
@@ -201,21 +206,22 @@
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- asyncResp->res.jsonValue["@odata.type"] =
- "#CableCollection.CableCollection";
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Cables";
- asyncResp->res.jsonValue["Name"] = "Cable Collection";
- asyncResp->res.jsonValue["Description"] = "Collection of Cable Entries";
- constexpr std::array<std::string_view, 1> interfaces{
- "xyz.openbmc_project.Inventory.Item.Cable"};
- collection_util::getCollectionMembers(
- asyncResp, boost::urls::url("/redfish/v1/Cables"), interfaces,
- "/xyz/openbmc_project/inventory");
- });
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#CableCollection.CableCollection";
+ asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Cables";
+ asyncResp->res.jsonValue["Name"] = "Cable Collection";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of Cable Entries";
+ constexpr std::array<std::string_view, 1> interfaces{
+ "xyz.openbmc_project.Inventory.Item.Cable"};
+ collection_util::getCollectionMembers(
+ asyncResp, boost::urls::url("/redfish/v1/Cables"),
+ interfaces, "/xyz/openbmc_project/inventory");
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index af35450..e90f749 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -106,9 +106,9 @@
{
certDirectory = tempDirectory;
certificateFile = certDirectory / "cert.pem";
- std::ofstream out(certificateFile, std::ofstream::out |
- std::ofstream::binary |
- std::ofstream::trunc);
+ std::ofstream out(certificateFile,
+ std::ofstream::out | std::ofstream::binary |
+ std::ofstream::trunc);
out << certString;
out.close();
BMCWEB_LOG_DEBUG("Creating certificate file{}",
@@ -213,11 +213,10 @@
* @param[in] countPtr Json pointer to the count in asyncResp
* @return None
*/
-static void
- getCertificateList(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& basePath,
- const nlohmann::json::json_pointer& listPtr,
- const nlohmann::json::json_pointer& countPtr)
+static void getCertificateList(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& basePath, const nlohmann::json::json_pointer& listPtr,
+ const nlohmann::json::json_pointer& countPtr)
{
constexpr std::array<std::string_view, 1> interfaces = {
certs::certPropIntf};
@@ -226,55 +225,57 @@
[asyncResp, listPtr, countPtr](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse& certPaths) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Certificate collection query failed: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
-
- nlohmann::json& links = asyncResp->res.jsonValue[listPtr];
- links = nlohmann::json::array();
- for (const auto& certPath : certPaths)
- {
- sdbusplus::message::object_path objPath(certPath);
- std::string certId = objPath.filename();
- if (certId.empty())
+ if (ec)
{
- BMCWEB_LOG_ERROR("Invalid certificate objPath {}", certPath);
- continue;
+ BMCWEB_LOG_ERROR("Certificate collection query failed: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
}
- boost::urls::url certURL;
- if (objPath.parent_path() == certs::httpsObjectPath)
+ nlohmann::json& links = asyncResp->res.jsonValue[listPtr];
+ links = nlohmann::json::array();
+ for (const auto& certPath : certPaths)
{
- certURL = boost::urls::format(
- "/redfish/v1/Managers/{}/NetworkProtocol/HTTPS/Certificates/{}",
- BMCWEB_REDFISH_MANAGER_URI_NAME, certId);
- }
- else if (objPath.parent_path() == certs::ldapObjectPath)
- {
- certURL = boost::urls::format(
- "/redfish/v1/AccountService/LDAP/Certificates/{}", certId);
- }
- else if (objPath.parent_path() == certs::authorityObjectPath)
- {
- certURL = boost::urls::format(
- "/redfish/v1/Managers/{}/Truststore/Certificates/{}",
- BMCWEB_REDFISH_MANAGER_URI_NAME, certId);
- }
- else
- {
- continue;
+ sdbusplus::message::object_path objPath(certPath);
+ std::string certId = objPath.filename();
+ if (certId.empty())
+ {
+ BMCWEB_LOG_ERROR("Invalid certificate objPath {}",
+ certPath);
+ continue;
+ }
+
+ boost::urls::url certURL;
+ if (objPath.parent_path() == certs::httpsObjectPath)
+ {
+ certURL = boost::urls::format(
+ "/redfish/v1/Managers/{}/NetworkProtocol/HTTPS/Certificates/{}",
+ BMCWEB_REDFISH_MANAGER_URI_NAME, certId);
+ }
+ else if (objPath.parent_path() == certs::ldapObjectPath)
+ {
+ certURL = boost::urls::format(
+ "/redfish/v1/AccountService/LDAP/Certificates/{}",
+ certId);
+ }
+ else if (objPath.parent_path() == certs::authorityObjectPath)
+ {
+ certURL = boost::urls::format(
+ "/redfish/v1/Managers/{}/Truststore/Certificates/{}",
+ BMCWEB_REDFISH_MANAGER_URI_NAME, certId);
+ }
+ else
+ {
+ continue;
+ }
+
+ nlohmann::json::object_t link;
+ link["@odata.id"] = certURL;
+ links.emplace_back(std::move(link));
}
- nlohmann::json::object_t link;
- link["@odata.id"] = certURL;
- links.emplace_back(std::move(link));
- }
-
- asyncResp->res.jsonValue[countPtr] = links.size();
- });
+ asyncResp->res.jsonValue[countPtr] = links.size();
+ });
}
/**
@@ -301,79 +302,81 @@
[asyncResp, certURL, certId,
name](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
- messages::resourceNotFound(asyncResp->res, "Certificate", certId);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
+ messages::resourceNotFound(asyncResp->res, "Certificate",
+ certId);
+ return;
+ }
- const std::string* certificateString = nullptr;
- const std::vector<std::string>* keyUsage = nullptr;
- const std::string* issuer = nullptr;
- const std::string* subject = nullptr;
- const uint64_t* validNotAfter = nullptr;
- const uint64_t* validNotBefore = nullptr;
+ const std::string* certificateString = nullptr;
+ const std::vector<std::string>* keyUsage = nullptr;
+ const std::string* issuer = nullptr;
+ const std::string* subject = nullptr;
+ const uint64_t* validNotAfter = nullptr;
+ const uint64_t* validNotBefore = nullptr;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), properties, "CertificateString",
- certificateString, "KeyUsage", keyUsage, "Issuer", issuer,
- "Subject", subject, "ValidNotAfter", validNotAfter,
- "ValidNotBefore", validNotBefore);
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), properties,
+ "CertificateString", certificateString, "KeyUsage", keyUsage,
+ "Issuer", issuer, "Subject", subject, "ValidNotAfter",
+ validNotAfter, "ValidNotBefore", validNotBefore);
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- asyncResp->res.jsonValue["@odata.id"] = certURL;
- asyncResp->res.jsonValue["@odata.type"] =
- "#Certificate.v1_0_0.Certificate";
- asyncResp->res.jsonValue["Id"] = certId;
- asyncResp->res.jsonValue["Name"] = name;
- asyncResp->res.jsonValue["Description"] = name;
- asyncResp->res.jsonValue["CertificateString"] = "";
- asyncResp->res.jsonValue["KeyUsage"] = nlohmann::json::array();
+ asyncResp->res.jsonValue["@odata.id"] = certURL;
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#Certificate.v1_0_0.Certificate";
+ asyncResp->res.jsonValue["Id"] = certId;
+ asyncResp->res.jsonValue["Name"] = name;
+ asyncResp->res.jsonValue["Description"] = name;
+ asyncResp->res.jsonValue["CertificateString"] = "";
+ asyncResp->res.jsonValue["KeyUsage"] = nlohmann::json::array();
- if (certificateString != nullptr)
- {
- asyncResp->res.jsonValue["CertificateString"] = *certificateString;
- }
+ if (certificateString != nullptr)
+ {
+ asyncResp->res.jsonValue["CertificateString"] =
+ *certificateString;
+ }
- if (keyUsage != nullptr)
- {
- asyncResp->res.jsonValue["KeyUsage"] = *keyUsage;
- }
+ if (keyUsage != nullptr)
+ {
+ asyncResp->res.jsonValue["KeyUsage"] = *keyUsage;
+ }
- if (issuer != nullptr)
- {
- updateCertIssuerOrSubject(asyncResp->res.jsonValue["Issuer"],
- *issuer);
- }
+ if (issuer != nullptr)
+ {
+ updateCertIssuerOrSubject(asyncResp->res.jsonValue["Issuer"],
+ *issuer);
+ }
- if (subject != nullptr)
- {
- updateCertIssuerOrSubject(asyncResp->res.jsonValue["Subject"],
- *subject);
- }
+ if (subject != nullptr)
+ {
+ updateCertIssuerOrSubject(asyncResp->res.jsonValue["Subject"],
+ *subject);
+ }
- if (validNotAfter != nullptr)
- {
- asyncResp->res.jsonValue["ValidNotAfter"] =
- redfish::time_utils::getDateTimeUint(*validNotAfter);
- }
+ if (validNotAfter != nullptr)
+ {
+ asyncResp->res.jsonValue["ValidNotAfter"] =
+ redfish::time_utils::getDateTimeUint(*validNotAfter);
+ }
- if (validNotBefore != nullptr)
- {
- asyncResp->res.jsonValue["ValidNotBefore"] =
- redfish::time_utils::getDateTimeUint(*validNotBefore);
- }
+ if (validNotBefore != nullptr)
+ {
+ asyncResp->res.jsonValue["ValidNotBefore"] =
+ redfish::time_utils::getDateTimeUint(*validNotBefore);
+ }
- asyncResp->res.addHeader(
- boost::beast::http::field::location,
- std::string_view(certURL.data(), certURL.size()));
- });
+ asyncResp->res.addHeader(
+ boost::beast::http::field::location,
+ std::string_view(certURL.data(), certURL.size()));
+ });
}
static void
@@ -384,14 +387,14 @@
crow::connections::systemBus->async_method_call(
[asyncResp,
id{objectPath.filename()}](const boost::system::error_code& ec) {
- if (ec)
- {
- messages::resourceNotFound(asyncResp->res, "Certificate", id);
- return;
- }
- BMCWEB_LOG_INFO("Certificate deleted");
- asyncResp->res.result(boost::beast::http::status::no_content);
- },
+ if (ec)
+ {
+ messages::resourceNotFound(asyncResp->res, "Certificate", id);
+ return;
+ }
+ BMCWEB_LOG_INFO("Certificate deleted");
+ asyncResp->res.result(boost::beast::http::status::no_content);
+ },
service, objectPath, certs::objDeleteIntf, "Delete");
}
@@ -548,22 +551,24 @@
crow::connections::systemBus->async_method_call(
[asyncResp, certFile, objectPath, service, url{*parsedUrl}, id,
name](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
- if (ec.value() ==
- boost::system::linux_error::bad_request_descriptor)
+ if (ec)
{
- messages::resourceNotFound(asyncResp->res, "Certificate", id);
+ BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
+ if (ec.value() ==
+ boost::system::linux_error::bad_request_descriptor)
+ {
+ messages::resourceNotFound(asyncResp->res, "Certificate",
+ id);
+ return;
+ }
+ messages::internalError(asyncResp->res);
return;
}
- messages::internalError(asyncResp->res);
- return;
- }
- getCertificateProperties(asyncResp, objectPath, service, id, url, name);
- BMCWEB_LOG_DEBUG("HTTPS certificate install file={}",
- certFile->getCertFilePath());
- },
+ getCertificateProperties(asyncResp, objectPath, service, id, url,
+ name);
+ BMCWEB_LOG_DEBUG("HTTPS certificate install file={}",
+ certFile->getCertFilePath());
+ },
service, objectPath, certs::certReplaceIntf, "Replace",
certFile->getCertFilePath());
}
@@ -588,24 +593,24 @@
BMCWEB_LOG_DEBUG("getCSR CertObjectPath{} CSRObjectPath={} service={}",
certObjPath, csrObjPath, service);
crow::connections::systemBus->async_method_call(
- [asyncResp, certURI](const boost::system::error_code& ec,
- const std::string& csr) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- if (csr.empty())
- {
- BMCWEB_LOG_ERROR("CSR read is empty");
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["CSRString"] = csr;
- asyncResp->res.jsonValue["CertificateCollection"]["@odata.id"] =
- certURI;
- },
+ [asyncResp,
+ certURI](const boost::system::error_code& ec, const std::string& csr) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (csr.empty())
+ {
+ BMCWEB_LOG_ERROR("CSR read is empty");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["CSRString"] = csr;
+ asyncResp->res.jsonValue["CertificateCollection"]["@odata.id"] =
+ certURI;
+ },
service, csrObjPath, "xyz.openbmc_project.Certs.CSR", "CSR");
}
@@ -804,38 +809,38 @@
csrMatcher = std::make_unique<sdbusplus::bus::match_t>(
*crow::connections::systemBus, match,
[asyncResp, service, objectPath, certURI](sdbusplus::message_t& m) {
- timeout.cancel();
- if (m.is_method_error())
- {
- BMCWEB_LOG_ERROR("Dbus method error!!!");
- messages::internalError(asyncResp->res);
- return;
- }
-
- dbus::utility::DBusInterfacesMap interfacesProperties;
-
- sdbusplus::message::object_path csrObjectPath;
- m.read(csrObjectPath, interfacesProperties);
- BMCWEB_LOG_DEBUG("CSR object added{}", csrObjectPath.str);
- for (const auto& interface : interfacesProperties)
- {
- if (interface.first == "xyz.openbmc_project.Certs.CSR")
+ timeout.cancel();
+ if (m.is_method_error())
{
- getCSR(asyncResp, certURI, service, objectPath,
- csrObjectPath.str);
- break;
+ BMCWEB_LOG_ERROR("Dbus method error!!!");
+ messages::internalError(asyncResp->res);
+ return;
}
- }
- });
+
+ dbus::utility::DBusInterfacesMap interfacesProperties;
+
+ sdbusplus::message::object_path csrObjectPath;
+ m.read(csrObjectPath, interfacesProperties);
+ BMCWEB_LOG_DEBUG("CSR object added{}", csrObjectPath.str);
+ for (const auto& interface : interfacesProperties)
+ {
+ if (interface.first == "xyz.openbmc_project.Certs.CSR")
+ {
+ getCSR(asyncResp, certURI, service, objectPath,
+ csrObjectPath.str);
+ break;
+ }
+ }
+ });
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code& ec, const std::string&) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error: {}", ec.message());
- messages::internalError(asyncResp->res);
- return;
- }
- },
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error: {}", ec.message());
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ },
service, objectPath, "xyz.openbmc_project.Certs.CSR.Create",
"GenerateCSR", *optAlternativeNames, *optChallengePassword, city,
commonName, *optContactPerson, country, *optEmail, *optGivenName,
@@ -937,23 +942,24 @@
crow::connections::systemBus->async_method_call(
[asyncResp, certFile](const boost::system::error_code& ec,
const std::string& objectPath) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- sdbusplus::message::object_path path(objectPath);
- std::string certId = path.filename();
- const boost::urls::url certURL = boost::urls::format(
- "/redfish/v1/Managers/{}/NetworkProtocol/HTTPS/Certificates/{}",
- BMCWEB_REDFISH_MANAGER_URI_NAME, certId);
- getCertificateProperties(asyncResp, objectPath, certs::httpsServiceName,
- certId, certURL, "HTTPS Certificate");
- BMCWEB_LOG_DEBUG("HTTPS certificate install file={}",
- certFile->getCertFilePath());
- },
+ sdbusplus::message::object_path path(objectPath);
+ std::string certId = path.filename();
+ const boost::urls::url certURL = boost::urls::format(
+ "/redfish/v1/Managers/{}/NetworkProtocol/HTTPS/Certificates/{}",
+ BMCWEB_REDFISH_MANAGER_URI_NAME, certId);
+ getCertificateProperties(asyncResp, objectPath,
+ certs::httpsServiceName, certId, certURL,
+ "HTTPS Certificate");
+ BMCWEB_LOG_DEBUG("HTTPS certificate install file={}",
+ certFile->getCertFilePath());
+ },
certs::httpsServiceName, certs::httpsObjectPath, certs::certInstallIntf,
"Install", certFile->getCertFilePath());
}
@@ -1051,22 +1057,23 @@
crow::connections::systemBus->async_method_call(
[asyncResp, certFile](const boost::system::error_code& ec,
const std::string& objectPath) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- sdbusplus::message::object_path path(objectPath);
- std::string certId = path.filename();
- const boost::urls::url certURL = boost::urls::format(
- "/redfish/v1/AccountService/LDAP/Certificates/{}", certId);
- getCertificateProperties(asyncResp, objectPath, certs::ldapServiceName,
- certId, certURL, "LDAP Certificate");
- BMCWEB_LOG_DEBUG("LDAP certificate install file={}",
- certFile->getCertFilePath());
- },
+ sdbusplus::message::object_path path(objectPath);
+ std::string certId = path.filename();
+ const boost::urls::url certURL = boost::urls::format(
+ "/redfish/v1/AccountService/LDAP/Certificates/{}", certId);
+ getCertificateProperties(asyncResp, objectPath,
+ certs::ldapServiceName, certId, certURL,
+ "LDAP Certificate");
+ BMCWEB_LOG_DEBUG("LDAP certificate install file={}",
+ certFile->getCertFilePath());
+ },
certs::ldapServiceName, certs::ldapObjectPath, certs::certInstallIntf,
"Install", certFile->getCertFilePath());
}
@@ -1188,24 +1195,24 @@
crow::connections::systemBus->async_method_call(
[asyncResp, certFile](const boost::system::error_code& ec,
const std::string& objectPath) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- sdbusplus::message::object_path path(objectPath);
- std::string certId = path.filename();
- const boost::urls::url certURL = boost::urls::format(
- "/redfish/v1/Managers/{}/Truststore/Certificates/{}",
- BMCWEB_REDFISH_MANAGER_URI_NAME, certId);
- getCertificateProperties(asyncResp, objectPath,
- certs::authorityServiceName, certId, certURL,
- "TrustStore Certificate");
- BMCWEB_LOG_DEBUG("TrustStore certificate install file={}",
- certFile->getCertFilePath());
- },
+ sdbusplus::message::object_path path(objectPath);
+ std::string certId = path.filename();
+ const boost::urls::url certURL = boost::urls::format(
+ "/redfish/v1/Managers/{}/Truststore/Certificates/{}",
+ BMCWEB_REDFISH_MANAGER_URI_NAME, certId);
+ getCertificateProperties(asyncResp, objectPath,
+ certs::authorityServiceName, certId,
+ certURL, "TrustStore Certificate");
+ BMCWEB_LOG_DEBUG("TrustStore certificate install file={}",
+ certFile->getCertFilePath());
+ },
certs::authorityServiceName, certs::authorityObjectPath,
certs::certInstallIntf, "Install", certFile->getCertFilePath());
}
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index d6438d0..35bed99 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -62,32 +62,32 @@
(path / "storage").str, "xyz.openbmc_project.Association", "endpoints",
[asyncResp](const boost::system::error_code& ec,
const std::vector<std::string>& storageList) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("getStorageLink got DBUS response error");
- return;
- }
-
- nlohmann::json::array_t storages;
- for (const std::string& storagePath : storageList)
- {
- std::string id =
- sdbusplus::message::object_path(storagePath).filename();
- if (id.empty())
+ if (ec)
{
- continue;
+ BMCWEB_LOG_DEBUG("getStorageLink got DBUS response error");
+ return;
}
- nlohmann::json::object_t storage;
- storage["@odata.id"] =
- boost::urls::format("/redfish/v1/Systems/{}/Storage/{}",
- BMCWEB_REDFISH_SYSTEM_URI_NAME, id);
- storages.emplace_back(std::move(storage));
- }
- asyncResp->res.jsonValue["Links"]["Storage@odata.count"] =
- storages.size();
- asyncResp->res.jsonValue["Links"]["Storage"] = std::move(storages);
- });
+ nlohmann::json::array_t storages;
+ for (const std::string& storagePath : storageList)
+ {
+ std::string id =
+ sdbusplus::message::object_path(storagePath).filename();
+ if (id.empty())
+ {
+ continue;
+ }
+
+ nlohmann::json::object_t storage;
+ storage["@odata.id"] =
+ boost::urls::format("/redfish/v1/Systems/{}/Storage/{}",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, id);
+ storages.emplace_back(std::move(storage));
+ }
+ asyncResp->res.jsonValue["Links"]["Storage@odata.count"] =
+ storages.size();
+ asyncResp->res.jsonValue["Links"]["Storage"] = std::move(storages);
+ });
}
/**
@@ -106,36 +106,39 @@
"xyz.openbmc_project.State.Chassis", "CurrentPowerState",
[asyncResp{std::move(asyncResp)}](const boost::system::error_code& ec,
const std::string& chassisState) {
- if (ec)
- {
- if (ec == boost::system::errc::host_unreachable)
+ if (ec)
{
- // Service not available, no error, just don't return
- // chassis state info
- BMCWEB_LOG_DEBUG("Service not available {}", ec);
+ if (ec == boost::system::errc::host_unreachable)
+ {
+ // Service not available, no error, just don't return
+ // chassis state info
+ BMCWEB_LOG_DEBUG("Service not available {}", ec);
+ return;
+ }
+ BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
+ messages::internalError(asyncResp->res);
return;
}
- BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- BMCWEB_LOG_DEBUG("Chassis state: {}", chassisState);
- // Verify Chassis State
- if (chassisState == "xyz.openbmc_project.State.Chassis.PowerState.On")
- {
- asyncResp->res.jsonValue["PowerState"] = resource::PowerState::On;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Enabled;
- }
- else if (chassisState ==
- "xyz.openbmc_project.State.Chassis.PowerState.Off")
- {
- asyncResp->res.jsonValue["PowerState"] = resource::PowerState::Off;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::StandbyOffline;
- }
- });
+ BMCWEB_LOG_DEBUG("Chassis state: {}", chassisState);
+ // Verify Chassis State
+ if (chassisState ==
+ "xyz.openbmc_project.State.Chassis.PowerState.On")
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::On;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Enabled;
+ }
+ else if (chassisState ==
+ "xyz.openbmc_project.State.Chassis.PowerState.Off")
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::Off;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::StandbyOffline;
+ }
+ });
}
/**
@@ -167,19 +170,20 @@
"xyz.openbmc_project.Chassis.Intrusion", "Status",
[asyncResp](const boost::system::error_code& ec1,
const std::string& value) {
- if (ec1)
- {
- // do not add err msg in redfish response, because this is
- // not
- // mandatory property
- BMCWEB_LOG_ERROR("DBUS response error {}", ec1);
- return;
- }
- asyncResp->res
- .jsonValue["PhysicalSecurity"]["IntrusionSensorNumber"] = 1;
- asyncResp->res
- .jsonValue["PhysicalSecurity"]["IntrusionSensor"] = value;
- });
+ if (ec1)
+ {
+ // do not add err msg in redfish response, because this
+ // is not
+ // mandatory property
+ BMCWEB_LOG_ERROR("DBUS response error {}", ec1);
+ return;
+ }
+ asyncResp->res.jsonValue["PhysicalSecurity"]
+ ["IntrusionSensorNumber"] = 1;
+ asyncResp->res
+ .jsonValue["PhysicalSecurity"]["IntrusionSensor"] =
+ value;
+ });
return;
}
@@ -281,17 +285,16 @@
continue;
}
nlohmann::json link;
- link["@odata.id"] = boost::urls::format("/redfish/v1/Chassis/{}",
- downstreamChassis);
+ link["@odata.id"] =
+ boost::urls::format("/redfish/v1/Chassis/{}", downstreamChassis);
jValue.push_back(std::move(link));
}
asyncResp->res.jsonValue["Links"]["Contains@odata.count"] = jValue.size();
}
-inline void
- getChassisConnectivity(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& chassisId,
- const std::string& chassisPath)
+inline void getChassisConnectivity(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisId, const std::string& chassisPath)
{
BMCWEB_LOG_DEBUG("Get chassis connectivity");
@@ -323,26 +326,26 @@
std::bind_front(handleChassisCollectionGet, std::ref(app)));
}
-inline void
- getChassisLocationCode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& connectionName,
- const std::string& path)
+inline void getChassisLocationCode(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& connectionName, const std::string& path)
{
sdbusplus::asio::getProperty<std::string>(
*crow::connections::systemBus, connectionName, path,
"xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
[asyncResp](const boost::system::error_code& ec,
const std::string& property) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error for Location");
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for Location");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- asyncResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
- property;
- });
+ asyncResp->res
+ .jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
+ property;
+ });
}
inline void getChassisUUID(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -354,14 +357,14 @@
"xyz.openbmc_project.Common.UUID", "UUID",
[asyncResp](const boost::system::error_code& ec,
const std::string& chassisUUID) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error for UUID");
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["UUID"] = chassisUUID;
- });
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for UUID");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["UUID"] = chassisUUID;
+ });
}
inline void handleDecoratorAssetProperties(
@@ -444,8 +447,8 @@
nlohmann::json::array_t computerSystems;
nlohmann::json::object_t system;
- system["@odata.id"] = std::format("/redfish/v1/Systems/{}",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ system["@odata.id"] =
+ std::format("/redfish/v1/Systems/{}", BMCWEB_REDFISH_SYSTEM_URI_NAME);
computerSystems.emplace_back(std::move(system));
asyncResp->res.jsonValue["Links"]["ComputerSystems"] =
std::move(computerSystems);
@@ -512,16 +515,16 @@
path + "/drive",
[asyncResp, chassisId](const boost::system::error_code& ec3,
const dbus::utility::MapperEndPoints& resp) {
- if (ec3 || resp.empty())
- {
- return; // no drives = no failures
- }
+ if (ec3 || resp.empty())
+ {
+ return; // no drives = no failures
+ }
- nlohmann::json reference;
- reference["@odata.id"] =
- boost::urls::format("/redfish/v1/Chassis/{}/Drives", chassisId);
- asyncResp->res.jsonValue["Drives"] = std::move(reference);
- });
+ nlohmann::json reference;
+ reference["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Chassis/{}/Drives", chassisId);
+ asyncResp->res.jsonValue["Drives"] = std::move(reference);
+ });
const std::string& connectionName = connectionNames[0].first;
@@ -546,15 +549,15 @@
assetTagInterface, "AssetTag",
[asyncResp, chassisId](const boost::system::error_code& ec2,
const std::string& property) {
- if (ec2)
- {
- BMCWEB_LOG_ERROR("DBus response error for AssetTag: {}",
- ec2);
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["AssetTag"] = property;
- });
+ if (ec2)
+ {
+ BMCWEB_LOG_ERROR(
+ "DBus response error for AssetTag: {}", ec2);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["AssetTag"] = property;
+ });
}
else if (interface == replaceableInterface)
{
@@ -563,15 +566,16 @@
replaceableInterface, "HotPluggable",
[asyncResp, chassisId](const boost::system::error_code& ec2,
const bool property) {
- if (ec2)
- {
- BMCWEB_LOG_ERROR(
- "DBus response error for HotPluggable: {}", ec2);
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["HotPluggable"] = property;
- });
+ if (ec2)
+ {
+ BMCWEB_LOG_ERROR(
+ "DBus response error for HotPluggable: {}",
+ ec2);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["HotPluggable"] = property;
+ });
}
else if (interface == revisionInterface)
{
@@ -580,15 +584,15 @@
revisionInterface, "Version",
[asyncResp, chassisId](const boost::system::error_code& ec2,
const std::string& property) {
- if (ec2)
- {
- BMCWEB_LOG_ERROR("DBus response error for Version: {}",
- ec2);
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["Version"] = property;
- });
+ if (ec2)
+ {
+ BMCWEB_LOG_ERROR(
+ "DBus response error for Version: {}", ec2);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["Version"] = property;
+ });
}
}
@@ -608,9 +612,9 @@
[asyncResp, chassisId,
path](const boost::system::error_code&,
const dbus::utility::DBusPropertiesMap& propertiesList) {
- handleDecoratorAssetProperties(asyncResp, chassisId, path,
- propertiesList);
- });
+ handleDecoratorAssetProperties(asyncResp, chassisId, path,
+ propertiesList);
+ });
for (const auto& interface : interfaces2)
{
@@ -704,81 +708,83 @@
[asyncResp, chassisId, locationIndicatorActive,
indicatorLed](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
-
- // Iterate over all retrieved ObjectPaths.
- for (const std::pair<
- std::string,
- std::vector<std::pair<std::string, std::vector<std::string>>>>&
- object : subtree)
- {
- const std::string& path = object.first;
- const std::vector<std::pair<std::string, std::vector<std::string>>>&
- connectionNames = object.second;
-
- sdbusplus::message::object_path objPath(path);
- if (objPath.filename() != chassisId)
+ if (ec)
{
- continue;
+ BMCWEB_LOG_ERROR("DBUS response error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
}
- if (connectionNames.empty())
+ // Iterate over all retrieved ObjectPaths.
+ for (const std::pair<std::string,
+ std::vector<std::pair<
+ std::string, std::vector<std::string>>>>&
+ object : subtree)
{
- BMCWEB_LOG_ERROR("Got 0 Connection names");
- continue;
+ const std::string& path = object.first;
+ const std::vector<
+ std::pair<std::string, std::vector<std::string>>>&
+ connectionNames = object.second;
+
+ sdbusplus::message::object_path objPath(path);
+ if (objPath.filename() != chassisId)
+ {
+ continue;
+ }
+
+ if (connectionNames.empty())
+ {
+ BMCWEB_LOG_ERROR("Got 0 Connection names");
+ continue;
+ }
+
+ const std::vector<std::string>& interfaces3 =
+ connectionNames[0].second;
+
+ const std::array<const char*, 3> hasIndicatorLed = {
+ "xyz.openbmc_project.Inventory.Item.Chassis",
+ "xyz.openbmc_project.Inventory.Item.Panel",
+ "xyz.openbmc_project.Inventory.Item.Board.Motherboard"};
+ bool indicatorChassis = false;
+ for (const char* interface : hasIndicatorLed)
+ {
+ if (std::ranges::find(interfaces3, interface) !=
+ interfaces3.end())
+ {
+ indicatorChassis = true;
+ break;
+ }
+ }
+ if (locationIndicatorActive)
+ {
+ if (indicatorChassis)
+ {
+ setSystemLocationIndicatorActive(
+ asyncResp, *locationIndicatorActive);
+ }
+ else
+ {
+ messages::propertyUnknown(asyncResp->res,
+ "LocationIndicatorActive");
+ }
+ }
+ if (indicatorLed)
+ {
+ if (indicatorChassis)
+ {
+ setIndicatorLedState(asyncResp, *indicatorLed);
+ }
+ else
+ {
+ messages::propertyUnknown(asyncResp->res,
+ "IndicatorLED");
+ }
+ }
+ return;
}
- const std::vector<std::string>& interfaces3 =
- connectionNames[0].second;
-
- const std::array<const char*, 3> hasIndicatorLed = {
- "xyz.openbmc_project.Inventory.Item.Chassis",
- "xyz.openbmc_project.Inventory.Item.Panel",
- "xyz.openbmc_project.Inventory.Item.Board.Motherboard"};
- bool indicatorChassis = false;
- for (const char* interface : hasIndicatorLed)
- {
- if (std::ranges::find(interfaces3, interface) !=
- interfaces3.end())
- {
- indicatorChassis = true;
- break;
- }
- }
- if (locationIndicatorActive)
- {
- if (indicatorChassis)
- {
- setSystemLocationIndicatorActive(asyncResp,
- *locationIndicatorActive);
- }
- else
- {
- messages::propertyUnknown(asyncResp->res,
- "LocationIndicatorActive");
- }
- }
- if (indicatorLed)
- {
- if (indicatorChassis)
- {
- setIndicatorLedState(asyncResp, *indicatorLed);
- }
- else
- {
- messages::propertyUnknown(asyncResp->res, "IndicatorLED");
- }
- }
- return;
- }
-
- messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
- });
+ messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
+ });
}
/**
@@ -810,32 +816,34 @@
[asyncResp](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse& chassisList) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("[mapper] Bad D-Bus request error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("[mapper] Bad D-Bus request error: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- const char* processName = "xyz.openbmc_project.State.Chassis";
- const char* interfaceName = "xyz.openbmc_project.State.Chassis";
- const char* destProperty = "RequestedPowerTransition";
- const std::string propertyValue =
- "xyz.openbmc_project.State.Chassis.Transition.PowerCycle";
- std::string objectPath = "/xyz/openbmc_project/state/chassis_system0";
+ const char* processName = "xyz.openbmc_project.State.Chassis";
+ const char* interfaceName = "xyz.openbmc_project.State.Chassis";
+ const char* destProperty = "RequestedPowerTransition";
+ const std::string propertyValue =
+ "xyz.openbmc_project.State.Chassis.Transition.PowerCycle";
+ std::string objectPath =
+ "/xyz/openbmc_project/state/chassis_system0";
- /* Look for system reset chassis path */
- if ((std::ranges::find(chassisList, objectPath)) == chassisList.end())
- {
- /* We prefer to reset the full chassis_system, but if it doesn't
- * exist on some platforms, fall back to a host-only power reset
- */
- objectPath = "/xyz/openbmc_project/state/chassis0";
- }
+ /* Look for system reset chassis path */
+ if ((std::ranges::find(chassisList, objectPath)) ==
+ chassisList.end())
+ {
+ /* We prefer to reset the full chassis_system, but if it doesn't
+ * exist on some platforms, fall back to a host-only power reset
+ */
+ objectPath = "/xyz/openbmc_project/state/chassis0";
+ }
- setDbusProperty(asyncResp, "ResetType", processName, objectPath,
- interfaceName, destProperty, propertyValue);
- });
+ setDbusProperty(asyncResp, "ResetType", processName, objectPath,
+ interfaceName, destProperty, propertyValue);
+ });
}
inline void handleChassisResetActionInfoPost(
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 3e97869..34e7215 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -180,9 +180,8 @@
return "xyz.openbmc_project.Network.EthernetInterface.DHCPConf.none";
}
-inline std::string
- translateAddressOriginDbusToRedfish(const std::string& inputOrigin,
- bool isIPv4)
+inline std::string translateAddressOriginDbusToRedfish(
+ const std::string& inputOrigin, bool isIPv4)
{
if (inputOrigin == "xyz.openbmc_project.Network.IP.AddressOrigin.Static")
{
@@ -395,8 +394,8 @@
sdbusplus::message::object_path path(
"/xyz/openbmc_project/network");
- sdbusplus::message::object_path dhcp4Path = path / ethifaceId /
- "dhcp4";
+ sdbusplus::message::object_path dhcp4Path =
+ path / ethifaceId / "dhcp4";
if (sdbusplus::message::object_path(objpath.first) == dhcp4Path)
{
@@ -445,8 +444,8 @@
}
}
- sdbusplus::message::object_path dhcp6Path = path / ethifaceId /
- "dhcp6";
+ sdbusplus::message::object_path dhcp6Path =
+ path / ethifaceId / "dhcp6";
if (sdbusplus::message::object_path(objpath.first) == dhcp6Path)
{
@@ -522,8 +521,8 @@
const dbus::utility::ManagedObjectType& dbusData,
std::vector<IPv6AddressData>& ipv6Config)
{
- const std::string ipPathStart = "/xyz/openbmc_project/network/" +
- ethifaceId;
+ const std::string ipPathStart =
+ "/xyz/openbmc_project/network/" + ethifaceId;
// Since there might be several IPv6 configurations aligned with
// single ethernet interface, loop over all of them
@@ -536,10 +535,10 @@
{
if (interface.first == "xyz.openbmc_project.Network.IP")
{
- auto type = std::ranges::find_if(interface.second,
- [](const auto& property) {
- return property.first == "Type";
- });
+ auto type = std::ranges::find_if(
+ interface.second, [](const auto& property) {
+ return property.first == "Type";
+ });
if (type == interface.second.end())
{
continue;
@@ -614,8 +613,8 @@
const dbus::utility::ManagedObjectType& dbusData,
std::vector<IPv4AddressData>& ipv4Config)
{
- const std::string ipPathStart = "/xyz/openbmc_project/network/" +
- ethifaceId;
+ const std::string ipPathStart =
+ "/xyz/openbmc_project/network/" + ethifaceId;
// Since there might be several IPv4 configurations aligned with
// single ethernet interface, loop over all of them
@@ -628,10 +627,10 @@
{
if (interface.first == "xyz.openbmc_project.Network.IP")
{
- auto type = std::ranges::find_if(interface.second,
- [](const auto& property) {
- return property.first == "Type";
- });
+ auto type = std::ranges::find_if(
+ interface.second, [](const auto& property) {
+ return property.first == "Type";
+ });
if (type == interface.second.end())
{
continue;
@@ -745,11 +744,11 @@
{
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- }
- },
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ }
+ },
"xyz.openbmc_project.Network",
"/xyz/openbmc_project/network/" + ifaceId + ipHash,
"xyz.openbmc_project.Object.Delete", "Delete");
@@ -770,14 +769,14 @@
const std::string& gateway, const std::string& address,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
- auto createIpHandler = [asyncResp, ifaceId,
- gateway](const boost::system::error_code& ec) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- };
+ auto createIpHandler =
+ [asyncResp, ifaceId, gateway](const boost::system::error_code& ec) {
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ };
crow::connections::systemBus->async_method_call(
std::move(createIpHandler), "xyz.openbmc_project.Network",
@@ -810,24 +809,24 @@
crow::connections::systemBus->async_method_call(
[asyncResp, version, ifaceId, address, prefixLength,
gateway](const boost::system::error_code& ec) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- }
- std::string protocol = "xyz.openbmc_project.Network.IP.Protocol.";
- protocol += version == IpVersion::IpV4 ? "IPv4" : "IPv6";
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec2) {
- if (ec2)
+ if (ec)
{
messages::internalError(asyncResp->res);
}
+ std::string protocol = "xyz.openbmc_project.Network.IP.Protocol.";
+ protocol += version == IpVersion::IpV4 ? "IPv4" : "IPv6";
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code& ec2) {
+ if (ec2)
+ {
+ messages::internalError(asyncResp->res);
+ }
+ },
+ "xyz.openbmc_project.Network",
+ "/xyz/openbmc_project/network/" + ifaceId,
+ "xyz.openbmc_project.Network.IP.Create", "IP", protocol,
+ address, prefixLength, gateway);
},
- "xyz.openbmc_project.Network",
- "/xyz/openbmc_project/network/" + ifaceId,
- "xyz.openbmc_project.Network.IP.Create", "IP", protocol, address,
- prefixLength, gateway);
- },
"xyz.openbmc_project.Network",
"/xyz/openbmc_project/network/" + ifaceId + id,
"xyz.openbmc_project.Object.Delete", "Delete");
@@ -889,21 +888,21 @@
sdbusplus::message::object_path path("/xyz/openbmc_project/network");
path /= ifaceId;
- auto createIpHandler = [asyncResp,
- address](const boost::system::error_code& ec) {
- if (ec)
- {
- if (ec == boost::system::errc::io_error)
+ auto createIpHandler =
+ [asyncResp, address](const boost::system::error_code& ec) {
+ if (ec)
{
- messages::propertyValueFormatError(asyncResp->res, address,
- "Address");
+ if (ec == boost::system::errc::io_error)
+ {
+ messages::propertyValueFormatError(asyncResp->res, address,
+ "Address");
+ }
+ else
+ {
+ messages::internalError(asyncResp->res);
+ }
}
- else
- {
- messages::internalError(asyncResp->res);
- }
- }
- };
+ };
// Passing null for gateway, as per redfish spec IPv6StaticAddresses
// object does not have associated gateway property
crow::connections::systemBus->async_method_call(
@@ -930,11 +929,11 @@
path /= gatewayId;
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- }
- },
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ }
+ },
"xyz.openbmc_project.Network", path,
"xyz.openbmc_project.Object.Delete", "Delete");
}
@@ -989,13 +988,13 @@
crow::connections::systemBus->async_method_call(
[asyncResp, ifaceId, gateway,
prefixLength](const boost::system::error_code& ec) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- createIPv6DefaultGateway(ifaceId, prefixLength, gateway, asyncResp);
- },
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ createIPv6DefaultGateway(ifaceId, prefixLength, gateway, asyncResp);
+ },
"xyz.openbmc_project.Network", path,
"xyz.openbmc_project.Object.Delete", "Delete");
}
@@ -1034,8 +1033,8 @@
}
staticGatewayEntry++;
}
- std::string pathString = "IPv6StaticDefaultGateways/" +
- std::to_string(entryIdx);
+ std::string pathString =
+ "IPv6StaticDefaultGateways/" + std::to_string(entryIdx);
nlohmann::json::object_t* obj =
std::get_if<nlohmann::json::object_t>(&thisJson);
if (obj == nullptr)
@@ -1128,44 +1127,46 @@
callback = std::forward<CallbackFunc>(callback)](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) mutable {
- EthernetInterfaceData ethData{};
- std::vector<IPv4AddressData> ipv4Data;
- std::vector<IPv6AddressData> ipv6Data;
- std::vector<StaticGatewayData> ipv6GatewayData;
+ EthernetInterfaceData ethData{};
+ std::vector<IPv4AddressData> ipv4Data;
+ std::vector<IPv6AddressData> ipv6Data;
+ std::vector<StaticGatewayData> ipv6GatewayData;
- if (ec)
- {
- callback(false, ethData, ipv4Data, ipv6Data, ipv6GatewayData);
- return;
- }
-
- bool found = extractEthernetInterfaceData(ethifaceId, resp, ethData);
- if (!found)
- {
- callback(false, ethData, ipv4Data, ipv6Data, ipv6GatewayData);
- return;
- }
-
- extractIPData(ethifaceId, resp, ipv4Data);
- // Fix global GW
- for (IPv4AddressData& ipv4 : ipv4Data)
- {
- if (((ipv4.linktype == LinkType::Global) &&
- (ipv4.gateway == "0.0.0.0")) ||
- (ipv4.origin == "DHCP") || (ipv4.origin == "Static"))
+ if (ec)
{
- ipv4.gateway = ethData.defaultGateway;
+ callback(false, ethData, ipv4Data, ipv6Data, ipv6GatewayData);
+ return;
}
- }
- extractIPV6Data(ethifaceId, resp, ipv6Data);
- if (!extractIPv6DefaultGatewayData(ethifaceId, resp, ipv6GatewayData))
- {
- callback(false, ethData, ipv4Data, ipv6Data, ipv6GatewayData);
- }
- // Finally make a callback with useful data
- callback(true, ethData, ipv4Data, ipv6Data, ipv6GatewayData);
- });
+ bool found =
+ extractEthernetInterfaceData(ethifaceId, resp, ethData);
+ if (!found)
+ {
+ callback(false, ethData, ipv4Data, ipv6Data, ipv6GatewayData);
+ return;
+ }
+
+ extractIPData(ethifaceId, resp, ipv4Data);
+ // Fix global GW
+ for (IPv4AddressData& ipv4 : ipv4Data)
+ {
+ if (((ipv4.linktype == LinkType::Global) &&
+ (ipv4.gateway == "0.0.0.0")) ||
+ (ipv4.origin == "DHCP") || (ipv4.origin == "Static"))
+ {
+ ipv4.gateway = ethData.defaultGateway;
+ }
+ }
+
+ extractIPV6Data(ethifaceId, resp, ipv6Data);
+ if (!extractIPv6DefaultGatewayData(ethifaceId, resp,
+ ipv6GatewayData))
+ {
+ callback(false, ethData, ipv4Data, ipv6Data, ipv6GatewayData);
+ }
+ // Finally make a callback with useful data
+ callback(true, ethData, ipv4Data, ipv6Data, ipv6GatewayData);
+ });
}
/**
@@ -1183,44 +1184,44 @@
[callback = std::forward<CallbackFunc>(callback)](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) {
- // Callback requires vector<string> to retrieve all available
- // ethernet interfaces
- std::vector<std::string> ifaceList;
- ifaceList.reserve(resp.size());
- if (ec)
- {
- callback(false, ifaceList);
- return;
- }
-
- // Iterate over all retrieved ObjectPaths.
- for (const auto& objpath : resp)
- {
- // And all interfaces available for certain ObjectPath.
- for (const auto& interface : objpath.second)
+ // Callback requires vector<string> to retrieve all available
+ // ethernet interfaces
+ std::vector<std::string> ifaceList;
+ ifaceList.reserve(resp.size());
+ if (ec)
{
- // If interface is
- // xyz.openbmc_project.Network.EthernetInterface, this is
- // what we're looking for.
- if (interface.first ==
- "xyz.openbmc_project.Network.EthernetInterface")
+ callback(false, ifaceList);
+ return;
+ }
+
+ // Iterate over all retrieved ObjectPaths.
+ for (const auto& objpath : resp)
+ {
+ // And all interfaces available for certain ObjectPath.
+ for (const auto& interface : objpath.second)
{
- std::string ifaceId = objpath.first.filename();
- if (ifaceId.empty())
+ // If interface is
+ // xyz.openbmc_project.Network.EthernetInterface, this is
+ // what we're looking for.
+ if (interface.first ==
+ "xyz.openbmc_project.Network.EthernetInterface")
{
- continue;
+ std::string ifaceId = objpath.first.filename();
+ if (ifaceId.empty())
+ {
+ continue;
+ }
+ // and put it into output vector.
+ ifaceList.emplace_back(ifaceId);
}
- // and put it into output vector.
- ifaceList.emplace_back(ifaceId);
}
}
- }
- std::ranges::sort(ifaceList, AlphanumLess<std::string>());
+ std::ranges::sort(ifaceList, AlphanumLess<std::string>());
- // Finally make a callback with useful data
- callback(true, ifaceList);
- });
+ // Finally make a callback with useful data
+ callback(true, ifaceList);
+ });
}
inline void
@@ -1252,10 +1253,9 @@
"MTU", mtuSize);
}
-inline void
- handleDomainnamePatch(const std::string& ifaceId,
- const std::string& domainname,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
+inline void handleDomainnamePatch(
+ const std::string& ifaceId, const std::string& domainname,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
std::vector<std::string> vectorDomainname = {domainname};
setDbusProperty(
@@ -1325,10 +1325,9 @@
handleDomainnamePatch(ifaceId, domainname, asyncResp);
}
-inline void
- handleMACAddressPatch(const std::string& ifaceId,
- const std::string& macAddress,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
+inline void handleMACAddressPatch(
+ const std::string& ifaceId, const std::string& macAddress,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
setDbusProperty(
asyncResp, "MACAddress", "xyz.openbmc_project.Network",
@@ -1394,11 +1393,10 @@
"IPv6AcceptRA", ipv6AutoConfigEnabled);
}
-inline void handleDHCPPatch(const std::string& ifaceId,
- const EthernetInterfaceData& ethData,
- const DHCPParameters& v4dhcpParms,
- const DHCPParameters& v6dhcpParms,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
+inline void handleDHCPPatch(
+ const std::string& ifaceId, const EthernetInterfaceData& ethData,
+ const DHCPParameters& v4dhcpParms, const DHCPParameters& v6dhcpParms,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
bool ipv4Active = translateDhcpEnabledToBool(ethData.dhcpEnabled, true);
bool ipv6Active = translateDhcpEnabledToBool(ethData.dhcpEnabled, false);
@@ -1534,8 +1532,8 @@
for (std::variant<nlohmann::json::object_t, std::nullptr_t>& thisJson :
input)
{
- std::string pathString = "IPv4StaticAddresses/" +
- std::to_string(entryIdx);
+ std::string pathString =
+ "IPv4StaticAddresses/" + std::to_string(entryIdx);
nlohmann::json::object_t* obj =
std::get_if<nlohmann::json::object_t>(&thisJson);
if (obj == nullptr)
@@ -1543,8 +1541,8 @@
if (nicIpEntry != ipv4Data.cend())
{
deleteIPAddress(ifaceId, nicIpEntry->id, asyncResp);
- nicIpEntry = getNextStaticIpEntry(++nicIpEntry,
- ipv4Data.cend());
+ nicIpEntry =
+ getNextStaticIpEntry(++nicIpEntry, ipv4Data.cend());
if (!preserveGateway && (nicIpEntry == ipv4Data.cend()))
{
// All entries have been processed, and this last has
@@ -1680,8 +1678,8 @@
deleteAndCreateIPAddress(IpVersion::IpV4, ifaceId,
nicIpEntry->id, prefixLength, *address,
*gateway, asyncResp);
- nicIpEntry = getNextStaticIpEntry(++nicIpEntry,
- ipv4Data.cend());
+ nicIpEntry =
+ getNextStaticIpEntry(++nicIpEntry, ipv4Data.cend());
preserveGateway = true;
}
else
@@ -1697,8 +1695,8 @@
// Received {}, do not modify this address
if (nicIpEntry != ipv4Data.cend())
{
- nicIpEntry = getNextStaticIpEntry(++nicIpEntry,
- ipv4Data.cend());
+ nicIpEntry =
+ getNextStaticIpEntry(++nicIpEntry, ipv4Data.cend());
preserveGateway = true;
entryIdx++;
}
@@ -1739,8 +1737,8 @@
for (std::variant<nlohmann::json::object_t, std::nullptr_t>& thisJson :
input)
{
- std::string pathString = "IPv6StaticAddresses/" +
- std::to_string(entryIdx);
+ std::string pathString =
+ "IPv6StaticAddresses/" + std::to_string(entryIdx);
nlohmann::json::object_t* obj =
std::get_if<nlohmann::json::object_t>(&thisJson);
if (obj != nullptr && !obj->empty())
@@ -1788,8 +1786,8 @@
deleteAndCreateIPAddress(IpVersion::IpV6, ifaceId,
nicIpEntry->id, *prefixLength,
*address, "", asyncResp);
- nicIpEntry = getNextStaticIpEntry(++nicIpEntry,
- ipv6Data.cend());
+ nicIpEntry =
+ getNextStaticIpEntry(++nicIpEntry, ipv6Data.cend());
}
else
{
@@ -1820,8 +1818,8 @@
}
if (nicIpEntry != ipv6Data.cend())
{
- nicIpEntry = getNextStaticIpEntry(++nicIpEntry,
- ipv6Data.cend());
+ nicIpEntry =
+ getNextStaticIpEntry(++nicIpEntry, ipv6Data.cend());
}
entryIdx++;
}
@@ -1834,13 +1832,12 @@
return ifaceId.substr(0, pos);
}
-inline void
- parseInterfaceData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& ifaceId,
- const EthernetInterfaceData& ethData,
- const std::vector<IPv4AddressData>& ipv4Data,
- const std::vector<IPv6AddressData>& ipv6Data,
- const std::vector<StaticGatewayData>& ipv6GatewayData)
+inline void parseInterfaceData(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& ifaceId, const EthernetInterfaceData& ethData,
+ const std::vector<IPv4AddressData>& ipv4Data,
+ const std::vector<IPv6AddressData>& ipv6Data,
+ const std::vector<StaticGatewayData>& ipv6GatewayData)
{
nlohmann::json& jsonResponse = asyncResp->res.jsonValue;
jsonResponse["Id"] = ifaceId;
@@ -1871,8 +1868,9 @@
jsonResponse["DHCPv4"]["UseDNSServers"] = ethData.dnsv4Enabled;
jsonResponse["DHCPv4"]["UseDomainName"] = ethData.domainv4Enabled;
jsonResponse["DHCPv6"]["OperatingMode"] =
- translateDhcpEnabledToBool(ethData.dhcpEnabled, false) ? "Enabled"
- : "Disabled";
+ translateDhcpEnabledToBool(ethData.dhcpEnabled, false)
+ ? "Enabled"
+ : "Disabled";
jsonResponse["DHCPv6"]["UseNTPServers"] = ethData.ntpv6Enabled;
jsonResponse["DHCPv6"]["UseDNSServers"] = ethData.dnsv6Enabled;
jsonResponse["DHCPv6"]["UseDomainName"] = ethData.domainv6Enabled;
@@ -2022,11 +2020,10 @@
messages::internalError(asyncResp->res);
}
-inline void afterVlanCreate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& parentInterfaceUri,
- const std::string& vlanInterface,
- const boost::system::error_code& ec,
- const sdbusplus::message_t& m
+inline void afterVlanCreate(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& parentInterfaceUri, const std::string& vlanInterface,
+ const boost::system::error_code& ec, const sdbusplus::message_t& m
)
{
@@ -2075,55 +2072,59 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& managerId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "Manager", managerId);
- return;
- }
+ if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "Manager",
+ managerId);
+ return;
+ }
- asyncResp->res.jsonValue["@odata.type"] =
- "#EthernetInterfaceCollection.EthernetInterfaceCollection";
- asyncResp->res.jsonValue["@odata.id"] =
- boost::urls::format("/redfish/v1/Managers/{}/EthernetInterfaces",
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#EthernetInterfaceCollection.EthernetInterfaceCollection";
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}/EthernetInterfaces",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+ asyncResp->res.jsonValue["Name"] =
+ "Ethernet Network Interface Collection";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of EthernetInterfaces for this Manager";
+
+ // Get eth interface list, and call the below callback for JSON
+ // preparation
+ getEthernetIfaceList(
+ [asyncResp](const bool& success,
+ const std::vector<std::string>& ifaceList) {
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ nlohmann::json& ifaceArray =
+ asyncResp->res.jsonValue["Members"];
+ ifaceArray = nlohmann::json::array();
+ for (const std::string& ifaceItem : ifaceList)
+ {
+ nlohmann::json::object_t iface;
+ iface["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}/EthernetInterfaces/{}",
+ BMCWEB_REDFISH_MANAGER_URI_NAME, ifaceItem);
+ ifaceArray.push_back(std::move(iface));
+ }
+
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ ifaceArray.size();
+ asyncResp->res.jsonValue["@odata.id"] =
+ boost::urls::format(
+ "/redfish/v1/Managers/{}/EthernetInterfaces",
BMCWEB_REDFISH_MANAGER_URI_NAME);
- asyncResp->res.jsonValue["Name"] =
- "Ethernet Network Interface Collection";
- asyncResp->res.jsonValue["Description"] =
- "Collection of EthernetInterfaces for this Manager";
-
- // Get eth interface list, and call the below callback for JSON
- // preparation
- getEthernetIfaceList(
- [asyncResp](const bool& success,
- const std::vector<std::string>& ifaceList) {
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- nlohmann::json& ifaceArray = asyncResp->res.jsonValue["Members"];
- ifaceArray = nlohmann::json::array();
- for (const std::string& ifaceItem : ifaceList)
- {
- nlohmann::json::object_t iface;
- iface["@odata.id"] = boost::urls::format(
- "/redfish/v1/Managers/{}/EthernetInterfaces/{}",
- BMCWEB_REDFISH_MANAGER_URI_NAME, ifaceItem);
- ifaceArray.push_back(std::move(iface));
- }
-
- asyncResp->res.jsonValue["Members@odata.count"] = ifaceArray.size();
- asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/Managers/{}/EthernetInterfaces",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
- });
- });
+ });
+ });
BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/EthernetInterfaces/")
.privileges(redfish::privileges::postEthernetInterfaceCollection)
@@ -2131,90 +2132,93 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& managerId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "Manager", managerId);
- return;
- }
+ if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "Manager",
+ managerId);
+ return;
+ }
- bool vlanEnable = false;
- uint32_t vlanId = 0;
- std::vector<nlohmann::json::object_t> relatedInterfaces;
+ bool vlanEnable = false;
+ uint32_t vlanId = 0;
+ std::vector<nlohmann::json::object_t> relatedInterfaces;
- if (!json_util::readJsonPatch(req, asyncResp->res, "VLAN/VLANEnable",
- vlanEnable, "VLAN/VLANId", vlanId,
- "Links/RelatedInterfaces",
- relatedInterfaces))
- {
- return;
- }
+ if (!json_util::readJsonPatch(
+ req, asyncResp->res, "VLAN/VLANEnable", vlanEnable,
+ "VLAN/VLANId", vlanId, "Links/RelatedInterfaces",
+ relatedInterfaces))
+ {
+ return;
+ }
- if (relatedInterfaces.size() != 1)
- {
- messages::arraySizeTooLong(asyncResp->res,
- "Links/RelatedInterfaces",
- relatedInterfaces.size());
- return;
- }
+ if (relatedInterfaces.size() != 1)
+ {
+ messages::arraySizeTooLong(asyncResp->res,
+ "Links/RelatedInterfaces",
+ relatedInterfaces.size());
+ return;
+ }
- std::string parentInterfaceUri;
- if (!json_util::readJsonObject(relatedInterfaces[0], asyncResp->res,
- "@odata.id", parentInterfaceUri))
- {
- messages::propertyMissing(asyncResp->res,
- "Links/RelatedInterfaces/0/@odata.id");
- return;
- }
- BMCWEB_LOG_INFO("Parent Interface URI: {}", parentInterfaceUri);
+ std::string parentInterfaceUri;
+ if (!json_util::readJsonObject(relatedInterfaces[0],
+ asyncResp->res, "@odata.id",
+ parentInterfaceUri))
+ {
+ messages::propertyMissing(
+ asyncResp->res, "Links/RelatedInterfaces/0/@odata.id");
+ return;
+ }
+ BMCWEB_LOG_INFO("Parent Interface URI: {}", parentInterfaceUri);
- boost::system::result<boost::urls::url_view> parsedUri =
- boost::urls::parse_relative_ref(parentInterfaceUri);
- if (!parsedUri)
- {
- messages::propertyValueFormatError(
- asyncResp->res, parentInterfaceUri,
- "Links/RelatedInterfaces/0/@odata.id");
- return;
- }
+ boost::system::result<boost::urls::url_view> parsedUri =
+ boost::urls::parse_relative_ref(parentInterfaceUri);
+ if (!parsedUri)
+ {
+ messages::propertyValueFormatError(
+ asyncResp->res, parentInterfaceUri,
+ "Links/RelatedInterfaces/0/@odata.id");
+ return;
+ }
- std::string parentInterface;
- if (!crow::utility::readUrlSegments(
- *parsedUri, "redfish", "v1", "Managers", "bmc",
- "EthernetInterfaces", std::ref(parentInterface)))
- {
- messages::propertyValueNotInList(
- asyncResp->res, parentInterfaceUri,
- "Links/RelatedInterfaces/0/@odata.id");
- return;
- }
+ std::string parentInterface;
+ if (!crow::utility::readUrlSegments(
+ *parsedUri, "redfish", "v1", "Managers", "bmc",
+ "EthernetInterfaces", std::ref(parentInterface)))
+ {
+ messages::propertyValueNotInList(
+ asyncResp->res, parentInterfaceUri,
+ "Links/RelatedInterfaces/0/@odata.id");
+ return;
+ }
- if (!vlanEnable)
- {
- // In OpenBMC implementation, VLANEnable cannot be false on
- // create
- messages::propertyValueIncorrect(asyncResp->res, "VLAN/VLANEnable",
- "false");
- return;
- }
+ if (!vlanEnable)
+ {
+ // In OpenBMC implementation, VLANEnable cannot be false on
+ // create
+ messages::propertyValueIncorrect(
+ asyncResp->res, "VLAN/VLANEnable", "false");
+ return;
+ }
- std::string vlanInterface = parentInterface + "_" +
- std::to_string(vlanId);
- crow::connections::systemBus->async_method_call(
- [asyncResp, parentInterfaceUri,
- vlanInterface](const boost::system::error_code& ec,
- const sdbusplus::message_t& m) {
- afterVlanCreate(asyncResp, parentInterfaceUri, vlanInterface, ec,
- m);
- },
- "xyz.openbmc_project.Network", "/xyz/openbmc_project/network",
- "xyz.openbmc_project.Network.VLAN.Create", "VLAN", parentInterface,
- vlanId);
- });
+ std::string vlanInterface =
+ parentInterface + "_" + std::to_string(vlanId);
+ crow::connections::systemBus->async_method_call(
+ [asyncResp, parentInterfaceUri,
+ vlanInterface](const boost::system::error_code& ec,
+ const sdbusplus::message_t& m) {
+ afterVlanCreate(asyncResp, parentInterfaceUri,
+ vlanInterface, ec, m);
+ },
+ "xyz.openbmc_project.Network",
+ "/xyz/openbmc_project/network",
+ "xyz.openbmc_project.Network.VLAN.Create", "VLAN",
+ parentInterface, vlanId);
+ });
BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/EthernetInterfaces/<str>/")
.privileges(redfish::privileges::getEthernetInterface)
@@ -2222,43 +2226,46 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& managerId, const std::string& ifaceId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "Manager", managerId);
- return;
- }
+ if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "Manager",
+ managerId);
+ return;
+ }
- getEthernetIfaceData(
- ifaceId,
- [asyncResp,
- ifaceId](const bool& success, const EthernetInterfaceData& ethData,
- const std::vector<IPv4AddressData>& ipv4Data,
- const std::vector<IPv6AddressData>& ipv6Data,
- const std::vector<StaticGatewayData>& ipv6GatewayData) {
- if (!success)
- {
- // TODO(Pawel)consider distinguish between non
- // existing object, and other errors
- messages::resourceNotFound(asyncResp->res, "EthernetInterface",
- ifaceId);
- return;
- }
+ getEthernetIfaceData(
+ ifaceId,
+ [asyncResp, ifaceId](
+ const bool& success,
+ const EthernetInterfaceData& ethData,
+ const std::vector<IPv4AddressData>& ipv4Data,
+ const std::vector<IPv6AddressData>& ipv6Data,
+ const std::vector<StaticGatewayData>& ipv6GatewayData) {
+ if (!success)
+ {
+ // TODO(Pawel)consider distinguish between non
+ // existing object, and other errors
+ messages::resourceNotFound(
+ asyncResp->res, "EthernetInterface", ifaceId);
+ return;
+ }
- asyncResp->res.jsonValue["@odata.type"] =
- "#EthernetInterface.v1_9_0.EthernetInterface";
- asyncResp->res.jsonValue["Name"] = "Manager Ethernet Interface";
- asyncResp->res.jsonValue["Description"] =
- "Management Network Interface";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#EthernetInterface.v1_9_0.EthernetInterface";
+ asyncResp->res.jsonValue["Name"] =
+ "Manager Ethernet Interface";
+ asyncResp->res.jsonValue["Description"] =
+ "Management Network Interface";
- parseInterfaceData(asyncResp, ifaceId, ethData, ipv4Data, ipv6Data,
- ipv6GatewayData);
- });
- });
+ parseInterfaceData(asyncResp, ifaceId, ethData,
+ ipv4Data, ipv6Data, ipv6GatewayData);
+ });
+ });
BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/EthernetInterfaces/<str>/")
.privileges(redfish::privileges::patchEthernetInterface)
@@ -2266,37 +2273,38 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& managerId, const std::string& ifaceId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "Manager", managerId);
- return;
- }
+ if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "Manager",
+ managerId);
+ return;
+ }
- std::optional<std::string> hostname;
- std::optional<std::string> fqdn;
- std::optional<std::string> macAddress;
- std::optional<std::string> ipv6DefaultGateway;
- std::optional<
- std::vector<std::variant<nlohmann::json::object_t, std::nullptr_t>>>
- ipv4StaticAddresses;
- std::optional<
- std::vector<std::variant<nlohmann::json::object_t, std::nullptr_t>>>
- ipv6StaticAddresses;
- std::optional<
- std::vector<std::variant<nlohmann::json::object_t, std::nullptr_t>>>
- ipv6StaticDefaultGateways;
- std::optional<std::vector<std::string>> staticNameServers;
- std::optional<bool> ipv6AutoConfigEnabled;
- std::optional<bool> interfaceEnabled;
- std::optional<size_t> mtuSize;
- DHCPParameters v4dhcpParms;
- DHCPParameters v6dhcpParms;
- // clang-format off
+ std::optional<std::string> hostname;
+ std::optional<std::string> fqdn;
+ std::optional<std::string> macAddress;
+ std::optional<std::string> ipv6DefaultGateway;
+ std::optional<std::vector<
+ std::variant<nlohmann::json::object_t, std::nullptr_t>>>
+ ipv4StaticAddresses;
+ std::optional<std::vector<
+ std::variant<nlohmann::json::object_t, std::nullptr_t>>>
+ ipv6StaticAddresses;
+ std::optional<std::vector<
+ std::variant<nlohmann::json::object_t, std::nullptr_t>>>
+ ipv6StaticDefaultGateways;
+ std::optional<std::vector<std::string>> staticNameServers;
+ std::optional<bool> ipv6AutoConfigEnabled;
+ std::optional<bool> interfaceEnabled;
+ std::optional<size_t> mtuSize;
+ DHCPParameters v4dhcpParms;
+ DHCPParameters v6dhcpParms;
+ // clang-format off
if (!json_util::readJsonPatch(req, asyncResp->res,
"DHCPv4/DHCPEnabled", v4dhcpParms.dhcpv4Enabled,
"DHCPv4/UseDNSServers", v4dhcpParms.useDnsServers,
@@ -2322,106 +2330,114 @@
{
return;
}
- // clang-format on
+ // clang-format on
- // Get single eth interface data, and call the below callback
- // for JSON preparation
- getEthernetIfaceData(
- ifaceId,
- [asyncResp, ifaceId, hostname = std::move(hostname),
- fqdn = std::move(fqdn), macAddress = std::move(macAddress),
- ipv4StaticAddresses = std::move(ipv4StaticAddresses),
- ipv6DefaultGateway = std::move(ipv6DefaultGateway),
- ipv6StaticAddresses = std::move(ipv6StaticAddresses),
- ipv6StaticDefaultGateway = std::move(ipv6StaticDefaultGateways),
- staticNameServers = std::move(staticNameServers), mtuSize,
- ipv6AutoConfigEnabled, v4dhcpParms = std::move(v4dhcpParms),
- v6dhcpParms = std::move(v6dhcpParms), interfaceEnabled](
- const bool success, const EthernetInterfaceData& ethData,
- const std::vector<IPv4AddressData>& ipv4Data,
- const std::vector<IPv6AddressData>& ipv6Data,
- const std::vector<StaticGatewayData>& ipv6GatewayData) mutable {
- if (!success)
- {
- // ... otherwise return error
- // TODO(Pawel)consider distinguish between non
- // existing object, and other errors
- messages::resourceNotFound(asyncResp->res, "EthernetInterface",
- ifaceId);
- return;
- }
+ // Get single eth interface data, and call the below callback
+ // for JSON preparation
+ getEthernetIfaceData(
+ ifaceId,
+ [asyncResp, ifaceId, hostname = std::move(hostname),
+ fqdn = std::move(fqdn), macAddress = std::move(macAddress),
+ ipv4StaticAddresses = std::move(ipv4StaticAddresses),
+ ipv6DefaultGateway = std::move(ipv6DefaultGateway),
+ ipv6StaticAddresses = std::move(ipv6StaticAddresses),
+ ipv6StaticDefaultGateway =
+ std::move(ipv6StaticDefaultGateways),
+ staticNameServers = std::move(staticNameServers), mtuSize,
+ ipv6AutoConfigEnabled,
+ v4dhcpParms = std::move(v4dhcpParms),
+ v6dhcpParms = std::move(v6dhcpParms), interfaceEnabled](
+ const bool success,
+ const EthernetInterfaceData& ethData,
+ const std::vector<IPv4AddressData>& ipv4Data,
+ const std::vector<IPv6AddressData>& ipv6Data,
+ const std::vector<StaticGatewayData>&
+ ipv6GatewayData) mutable {
+ if (!success)
+ {
+ // ... otherwise return error
+ // TODO(Pawel)consider distinguish between non
+ // existing object, and other errors
+ messages::resourceNotFound(
+ asyncResp->res, "EthernetInterface", ifaceId);
+ return;
+ }
- handleDHCPPatch(ifaceId, ethData, v4dhcpParms, v6dhcpParms,
- asyncResp);
+ handleDHCPPatch(ifaceId, ethData, v4dhcpParms,
+ v6dhcpParms, asyncResp);
- if (hostname)
- {
- handleHostnamePatch(*hostname, asyncResp);
- }
+ if (hostname)
+ {
+ handleHostnamePatch(*hostname, asyncResp);
+ }
- if (ipv6AutoConfigEnabled)
- {
- handleSLAACAutoConfigPatch(ifaceId, *ipv6AutoConfigEnabled,
- asyncResp);
- }
+ if (ipv6AutoConfigEnabled)
+ {
+ handleSLAACAutoConfigPatch(
+ ifaceId, *ipv6AutoConfigEnabled, asyncResp);
+ }
- if (fqdn)
- {
- handleFqdnPatch(ifaceId, *fqdn, asyncResp);
- }
+ if (fqdn)
+ {
+ handleFqdnPatch(ifaceId, *fqdn, asyncResp);
+ }
- if (macAddress)
- {
- handleMACAddressPatch(ifaceId, *macAddress, asyncResp);
- }
+ if (macAddress)
+ {
+ handleMACAddressPatch(ifaceId, *macAddress,
+ asyncResp);
+ }
- if (ipv4StaticAddresses)
- {
- handleIPv4StaticPatch(ifaceId, *ipv4StaticAddresses, ethData,
- ipv4Data, asyncResp);
- }
+ if (ipv4StaticAddresses)
+ {
+ handleIPv4StaticPatch(ifaceId, *ipv4StaticAddresses,
+ ethData, ipv4Data, asyncResp);
+ }
- if (staticNameServers)
- {
- handleStaticNameServersPatch(ifaceId, *staticNameServers,
- asyncResp);
- }
+ if (staticNameServers)
+ {
+ handleStaticNameServersPatch(
+ ifaceId, *staticNameServers, asyncResp);
+ }
- if (ipv6DefaultGateway)
- {
- messages::propertyNotWritable(asyncResp->res,
- "IPv6DefaultGateway");
- }
+ if (ipv6DefaultGateway)
+ {
+ messages::propertyNotWritable(asyncResp->res,
+ "IPv6DefaultGateway");
+ }
- if (ipv6StaticAddresses)
- {
- handleIPv6StaticAddressesPatch(ifaceId, *ipv6StaticAddresses,
- ipv6Data, asyncResp);
- }
+ if (ipv6StaticAddresses)
+ {
+ handleIPv6StaticAddressesPatch(ifaceId,
+ *ipv6StaticAddresses,
+ ipv6Data, asyncResp);
+ }
- if (ipv6StaticDefaultGateway)
- {
- handleIPv6DefaultGateway(ifaceId, *ipv6StaticDefaultGateway,
- ipv6GatewayData, asyncResp);
- }
+ if (ipv6StaticDefaultGateway)
+ {
+ handleIPv6DefaultGateway(
+ ifaceId, *ipv6StaticDefaultGateway,
+ ipv6GatewayData, asyncResp);
+ }
- if (interfaceEnabled)
- {
- setDbusProperty(asyncResp, "InterfaceEnabled",
+ if (interfaceEnabled)
+ {
+ setDbusProperty(
+ asyncResp, "InterfaceEnabled",
"xyz.openbmc_project.Network",
sdbusplus::message::object_path(
"/xyz/openbmc_project/network") /
ifaceId,
"xyz.openbmc_project.Network.EthernetInterface",
"NICEnabled", *interfaceEnabled);
- }
+ }
- if (mtuSize)
- {
- handleMTUSizePatch(ifaceId, *mtuSize, asyncResp);
- }
- });
- });
+ if (mtuSize)
+ {
+ handleMTUSizePatch(ifaceId, *mtuSize, asyncResp);
+ }
+ });
+ });
BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/EthernetInterfaces/<str>/")
.privileges(redfish::privileges::deleteEthernetInterface)
@@ -2429,26 +2445,27 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& managerId, const std::string& ifaceId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "Manager", managerId);
- return;
- }
+ if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "Manager",
+ managerId);
+ return;
+ }
- crow::connections::systemBus->async_method_call(
- [asyncResp, ifaceId](const boost::system::error_code& ec,
- const sdbusplus::message_t& m) {
- afterDelete(asyncResp, ifaceId, ec, m);
- },
- "xyz.openbmc_project.Network",
- std::string("/xyz/openbmc_project/network/") + ifaceId,
- "xyz.openbmc_project.Object.Delete", "Delete");
- });
+ crow::connections::systemBus->async_method_call(
+ [asyncResp, ifaceId](const boost::system::error_code& ec,
+ const sdbusplus::message_t& m) {
+ afterDelete(asyncResp, ifaceId, ec, m);
+ },
+ "xyz.openbmc_project.Network",
+ std::string("/xyz/openbmc_project/network/") + ifaceId,
+ "xyz.openbmc_project.Object.Delete", "Delete");
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index 0b6dce6..ff3de82 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -52,118 +52,123 @@
{
BMCWEB_ROUTE(app, "/redfish/v1/EventService/")
.privileges(redfish::privileges::getEventService)
- .methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/EventService";
- asyncResp->res.jsonValue["@odata.type"] =
- "#EventService.v1_5_0.EventService";
- asyncResp->res.jsonValue["Id"] = "EventService";
- asyncResp->res.jsonValue["Name"] = "Event Service";
- asyncResp->res.jsonValue["ServerSentEventUri"] =
- "/redfish/v1/EventService/SSE";
+ asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/EventService";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#EventService.v1_5_0.EventService";
+ asyncResp->res.jsonValue["Id"] = "EventService";
+ asyncResp->res.jsonValue["Name"] = "Event Service";
+ asyncResp->res.jsonValue["ServerSentEventUri"] =
+ "/redfish/v1/EventService/SSE";
- asyncResp->res.jsonValue["Subscriptions"]["@odata.id"] =
- "/redfish/v1/EventService/Subscriptions";
- asyncResp->res
- .jsonValue["Actions"]["#EventService.SubmitTestEvent"]["target"] =
- "/redfish/v1/EventService/Actions/EventService.SubmitTestEvent";
+ asyncResp->res.jsonValue["Subscriptions"]["@odata.id"] =
+ "/redfish/v1/EventService/Subscriptions";
+ asyncResp->res.jsonValue["Actions"]["#EventService.SubmitTestEvent"]
+ ["target"] =
+ "/redfish/v1/EventService/Actions/EventService.SubmitTestEvent";
- const persistent_data::EventServiceConfig eventServiceConfig =
- persistent_data::EventServiceStore::getInstance()
- .getEventServiceConfig();
+ const persistent_data::EventServiceConfig eventServiceConfig =
+ persistent_data::EventServiceStore::getInstance()
+ .getEventServiceConfig();
- asyncResp->res.jsonValue["Status"]["State"] =
- (eventServiceConfig.enabled ? "Enabled" : "Disabled");
- asyncResp->res.jsonValue["ServiceEnabled"] = eventServiceConfig.enabled;
- asyncResp->res.jsonValue["DeliveryRetryAttempts"] =
- eventServiceConfig.retryAttempts;
- asyncResp->res.jsonValue["DeliveryRetryIntervalSeconds"] =
- eventServiceConfig.retryTimeoutInterval;
- asyncResp->res.jsonValue["EventFormatTypes"] = supportedEvtFormatTypes;
- asyncResp->res.jsonValue["RegistryPrefixes"] = supportedRegPrefixes;
- asyncResp->res.jsonValue["ResourceTypes"] = supportedResourceTypes;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ (eventServiceConfig.enabled ? "Enabled" : "Disabled");
+ asyncResp->res.jsonValue["ServiceEnabled"] =
+ eventServiceConfig.enabled;
+ asyncResp->res.jsonValue["DeliveryRetryAttempts"] =
+ eventServiceConfig.retryAttempts;
+ asyncResp->res.jsonValue["DeliveryRetryIntervalSeconds"] =
+ eventServiceConfig.retryTimeoutInterval;
+ asyncResp->res.jsonValue["EventFormatTypes"] =
+ supportedEvtFormatTypes;
+ asyncResp->res.jsonValue["RegistryPrefixes"] = supportedRegPrefixes;
+ asyncResp->res.jsonValue["ResourceTypes"] = supportedResourceTypes;
- nlohmann::json::object_t supportedSSEFilters;
- supportedSSEFilters["EventFormatType"] = true;
- supportedSSEFilters["MessageId"] = true;
- supportedSSEFilters["MetricReportDefinition"] = true;
- supportedSSEFilters["RegistryPrefix"] = true;
- supportedSSEFilters["OriginResource"] = false;
- supportedSSEFilters["ResourceType"] = false;
+ nlohmann::json::object_t supportedSSEFilters;
+ supportedSSEFilters["EventFormatType"] = true;
+ supportedSSEFilters["MessageId"] = true;
+ supportedSSEFilters["MetricReportDefinition"] = true;
+ supportedSSEFilters["RegistryPrefix"] = true;
+ supportedSSEFilters["OriginResource"] = false;
+ supportedSSEFilters["ResourceType"] = false;
- asyncResp->res.jsonValue["SSEFilterPropertiesSupported"] =
- std::move(supportedSSEFilters);
- });
+ asyncResp->res.jsonValue["SSEFilterPropertiesSupported"] =
+ std::move(supportedSSEFilters);
+ });
BMCWEB_ROUTE(app, "/redfish/v1/EventService/")
.privileges(redfish::privileges::patchEventService)
.methods(boost::beast::http::verb::patch)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- std::optional<bool> serviceEnabled;
- std::optional<uint32_t> retryAttemps;
- std::optional<uint32_t> retryInterval;
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ std::optional<bool> serviceEnabled;
+ std::optional<uint32_t> retryAttemps;
+ std::optional<uint32_t> retryInterval;
- if (!json_util::readJsonPatch(
- req, asyncResp->res, "ServiceEnabled", serviceEnabled,
- "DeliveryRetryAttempts", retryAttemps,
- "DeliveryRetryIntervalSeconds", retryInterval))
- {
- return;
- }
+ if (!json_util::readJsonPatch(
+ req, asyncResp->res, "ServiceEnabled", serviceEnabled,
+ "DeliveryRetryAttempts", retryAttemps,
+ "DeliveryRetryIntervalSeconds", retryInterval))
+ {
+ return;
+ }
- persistent_data::EventServiceConfig eventServiceConfig =
- persistent_data::EventServiceStore::getInstance()
- .getEventServiceConfig();
+ persistent_data::EventServiceConfig eventServiceConfig =
+ persistent_data::EventServiceStore::getInstance()
+ .getEventServiceConfig();
- if (serviceEnabled)
- {
- eventServiceConfig.enabled = *serviceEnabled;
- }
+ if (serviceEnabled)
+ {
+ eventServiceConfig.enabled = *serviceEnabled;
+ }
- if (retryAttemps)
- {
- // Supported range [1-3]
- if ((*retryAttemps < 1) || (*retryAttemps > 3))
- {
- messages::queryParameterOutOfRange(
- asyncResp->res, std::to_string(*retryAttemps),
- "DeliveryRetryAttempts", "[1-3]");
- }
- else
- {
- eventServiceConfig.retryAttempts = *retryAttemps;
- }
- }
+ if (retryAttemps)
+ {
+ // Supported range [1-3]
+ if ((*retryAttemps < 1) || (*retryAttemps > 3))
+ {
+ messages::queryParameterOutOfRange(
+ asyncResp->res, std::to_string(*retryAttemps),
+ "DeliveryRetryAttempts", "[1-3]");
+ }
+ else
+ {
+ eventServiceConfig.retryAttempts = *retryAttemps;
+ }
+ }
- if (retryInterval)
- {
- // Supported range [5 - 180]
- if ((*retryInterval < 5) || (*retryInterval > 180))
- {
- messages::queryParameterOutOfRange(
- asyncResp->res, std::to_string(*retryInterval),
- "DeliveryRetryIntervalSeconds", "[5-180]");
- }
- else
- {
- eventServiceConfig.retryTimeoutInterval = *retryInterval;
- }
- }
+ if (retryInterval)
+ {
+ // Supported range [5 - 180]
+ if ((*retryInterval < 5) || (*retryInterval > 180))
+ {
+ messages::queryParameterOutOfRange(
+ asyncResp->res, std::to_string(*retryInterval),
+ "DeliveryRetryIntervalSeconds", "[5-180]");
+ }
+ else
+ {
+ eventServiceConfig.retryTimeoutInterval =
+ *retryInterval;
+ }
+ }
- EventServiceManager::getInstance().setEventServiceConfig(
- eventServiceConfig);
- });
+ EventServiceManager::getInstance().setEventServiceConfig(
+ eventServiceConfig);
+ });
}
inline void requestRoutesSubmitTestEvent(App& app)
@@ -174,18 +179,18 @@
.methods(boost::beast::http::verb::post)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if (!EventServiceManager::getInstance().sendTestEventLog())
- {
- messages::serviceDisabled(asyncResp->res,
- "/redfish/v1/EventService/");
- return;
- }
- asyncResp->res.result(boost::beast::http::status::no_content);
- });
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if (!EventServiceManager::getInstance().sendTestEventLog())
+ {
+ messages::serviceDisabled(asyncResp->res,
+ "/redfish/v1/EventService/");
+ return;
+ }
+ asyncResp->res.result(boost::beast::http::status::no_content);
+ });
}
inline void doSubscriptionCollection(
@@ -228,409 +233,417 @@
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- asyncResp->res.jsonValue["@odata.type"] =
- "#EventDestinationCollection.EventDestinationCollection";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/EventService/Subscriptions";
- asyncResp->res.jsonValue["Name"] = "Event Destination Collections";
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#EventDestinationCollection.EventDestinationCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/EventService/Subscriptions";
+ asyncResp->res.jsonValue["Name"] =
+ "Event Destination Collections";
- nlohmann::json& memberArray = asyncResp->res.jsonValue["Members"];
+ nlohmann::json& memberArray =
+ asyncResp->res.jsonValue["Members"];
- std::vector<std::string> subscripIds =
- EventServiceManager::getInstance().getAllIDs();
- memberArray = nlohmann::json::array();
- asyncResp->res.jsonValue["Members@odata.count"] = subscripIds.size();
+ std::vector<std::string> subscripIds =
+ EventServiceManager::getInstance().getAllIDs();
+ memberArray = nlohmann::json::array();
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ subscripIds.size();
- for (const std::string& id : subscripIds)
- {
- nlohmann::json::object_t member;
- member["@odata.id"] = boost::urls::format(
- "/redfish/v1/EventService/Subscriptions/{}" + id);
- memberArray.emplace_back(std::move(member));
- }
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec,
- const dbus::utility::ManagedObjectType& resp) {
- doSubscriptionCollection(ec, asyncResp, resp);
- },
- "xyz.openbmc_project.Network.SNMP",
- "/xyz/openbmc_project/network/snmp/manager",
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
- });
+ for (const std::string& id : subscripIds)
+ {
+ nlohmann::json::object_t member;
+ member["@odata.id"] = boost::urls::format(
+ "/redfish/v1/EventService/Subscriptions/{}" + id);
+ memberArray.emplace_back(std::move(member));
+ }
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code& ec,
+ const dbus::utility::ManagedObjectType& resp) {
+ doSubscriptionCollection(ec, asyncResp, resp);
+ },
+ "xyz.openbmc_project.Network.SNMP",
+ "/xyz/openbmc_project/network/snmp/manager",
+ "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+ });
BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/")
.privileges(redfish::privileges::postEventDestinationCollection)
- .methods(boost::beast::http::verb::post)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if (EventServiceManager::getInstance().getNumberOfSubscriptions() >=
- maxNoOfSubscriptions)
- {
- messages::eventSubscriptionLimitExceeded(asyncResp->res);
- return;
- }
- std::string destUrl;
- std::string protocol;
- std::optional<bool> verifyCertificate;
- std::optional<std::string> context;
- std::optional<std::string> subscriptionType;
- std::optional<std::string> eventFormatType2;
- std::optional<std::string> retryPolicy;
- std::optional<std::vector<std::string>> msgIds;
- std::optional<std::vector<std::string>> regPrefixes;
- std::optional<std::vector<std::string>> resTypes;
- std::optional<std::vector<nlohmann::json::object_t>> headers;
- std::optional<std::vector<nlohmann::json::object_t>> mrdJsonArray;
+ .methods(
+ boost::beast::http::verb::
+ post)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if (EventServiceManager::getInstance().getNumberOfSubscriptions() >=
+ maxNoOfSubscriptions)
+ {
+ messages::eventSubscriptionLimitExceeded(asyncResp->res);
+ return;
+ }
+ std::string destUrl;
+ std::string protocol;
+ std::optional<bool> verifyCertificate;
+ std::optional<std::string> context;
+ std::optional<std::string> subscriptionType;
+ std::optional<std::string> eventFormatType2;
+ std::optional<std::string> retryPolicy;
+ std::optional<std::vector<std::string>> msgIds;
+ std::optional<std::vector<std::string>> regPrefixes;
+ std::optional<std::vector<std::string>> resTypes;
+ std::optional<std::vector<nlohmann::json::object_t>> headers;
+ std::optional<std::vector<nlohmann::json::object_t>> mrdJsonArray;
- if (!json_util::readJsonPatch(
- req, asyncResp->res, "Destination", destUrl, "Context", context,
- "Protocol", protocol, "SubscriptionType", subscriptionType,
- "EventFormatType", eventFormatType2, "HttpHeaders", headers,
- "RegistryPrefixes", regPrefixes, "MessageIds", msgIds,
- "DeliveryRetryPolicy", retryPolicy, "MetricReportDefinitions",
- mrdJsonArray, "ResourceTypes", resTypes, "VerifyCertificate",
- verifyCertificate))
- {
- return;
- }
-
- // https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
- static constexpr const uint16_t maxDestinationSize = 2000;
- if (destUrl.size() > maxDestinationSize)
- {
- messages::stringValueTooLong(asyncResp->res, "Destination",
- maxDestinationSize);
- return;
- }
-
- if (regPrefixes && msgIds)
- {
- if (!regPrefixes->empty() && !msgIds->empty())
+ if (!json_util::readJsonPatch(
+ req, asyncResp->res, "Destination", destUrl, "Context",
+ context, "Protocol", protocol, "SubscriptionType",
+ subscriptionType, "EventFormatType", eventFormatType2,
+ "HttpHeaders", headers, "RegistryPrefixes", regPrefixes,
+ "MessageIds", msgIds, "DeliveryRetryPolicy", retryPolicy,
+ "MetricReportDefinitions", mrdJsonArray, "ResourceTypes",
+ resTypes, "VerifyCertificate", verifyCertificate))
{
- messages::propertyValueConflict(asyncResp->res, "MessageIds",
- "RegistryPrefixes");
- return;
- }
- }
-
- boost::system::result<boost::urls::url> url =
- boost::urls::parse_absolute_uri(destUrl);
- if (!url)
- {
- BMCWEB_LOG_WARNING("Failed to validate and split destination url");
- messages::propertyValueFormatError(asyncResp->res, destUrl,
- "Destination");
- return;
- }
- url->normalize();
- crow::utility::setProtocolDefaults(*url, protocol);
- crow::utility::setPortDefaults(*url);
-
- if (url->path().empty())
- {
- url->set_path("/");
- }
-
- if (url->has_userinfo())
- {
- messages::propertyValueFormatError(asyncResp->res, destUrl,
- "Destination");
- return;
- }
-
- if (protocol == "SNMPv2c")
- {
- if (context)
- {
- messages::propertyValueConflict(asyncResp->res, "Context",
- "Protocol");
- return;
- }
- if (eventFormatType2)
- {
- messages::propertyValueConflict(asyncResp->res,
- "EventFormatType", "Protocol");
- return;
- }
- if (retryPolicy)
- {
- messages::propertyValueConflict(asyncResp->res, "RetryPolicy",
- "Protocol");
- return;
- }
- if (msgIds)
- {
- messages::propertyValueConflict(asyncResp->res, "MessageIds",
- "Protocol");
- return;
- }
- if (regPrefixes)
- {
- messages::propertyValueConflict(asyncResp->res,
- "RegistryPrefixes", "Protocol");
- return;
- }
- if (resTypes)
- {
- messages::propertyValueConflict(asyncResp->res, "ResourceTypes",
- "Protocol");
- return;
- }
- if (headers)
- {
- messages::propertyValueConflict(asyncResp->res, "HttpHeaders",
- "Protocol");
- return;
- }
- if (mrdJsonArray)
- {
- messages::propertyValueConflict(
- asyncResp->res, "MetricReportDefinitions", "Protocol");
- return;
- }
- if (url->scheme() != "snmp")
- {
- messages::propertyValueConflict(asyncResp->res, "Destination",
- "Protocol");
return;
}
- addSnmpTrapClient(asyncResp, url->host_address(),
- url->port_number());
- return;
- }
-
- std::shared_ptr<Subscription> subValue =
- std::make_shared<Subscription>(*url, app.ioContext());
-
- subValue->destinationUrl = std::move(*url);
-
- if (subscriptionType)
- {
- if (*subscriptionType != "RedfishEvent")
+ // https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
+ static constexpr const uint16_t maxDestinationSize = 2000;
+ if (destUrl.size() > maxDestinationSize)
{
- messages::propertyValueNotInList(
- asyncResp->res, *subscriptionType, "SubscriptionType");
+ messages::stringValueTooLong(asyncResp->res, "Destination",
+ maxDestinationSize);
return;
}
- subValue->subscriptionType = *subscriptionType;
- }
- else
- {
- subValue->subscriptionType = "RedfishEvent"; // Default
- }
- if (protocol != "Redfish")
- {
- messages::propertyValueNotInList(asyncResp->res, protocol,
- "Protocol");
- return;
- }
- subValue->protocol = protocol;
-
- if (verifyCertificate)
- {
- subValue->verifyCertificate = *verifyCertificate;
- }
-
- if (eventFormatType2)
- {
- if (std::ranges::find(supportedEvtFormatTypes, *eventFormatType2) ==
- supportedEvtFormatTypes.end())
+ if (regPrefixes && msgIds)
{
- messages::propertyValueNotInList(
- asyncResp->res, *eventFormatType2, "EventFormatType");
- return;
- }
- subValue->eventFormatType = *eventFormatType2;
- }
- else
- {
- // If not specified, use default "Event"
- subValue->eventFormatType = "Event";
- }
-
- if (context)
- {
- // This value is selected arbitrarily.
- constexpr const size_t maxContextSize = 256;
- if (context->size() > maxContextSize)
- {
- messages::stringValueTooLong(asyncResp->res, "Context",
- maxContextSize);
- return;
- }
- subValue->customText = *context;
- }
-
- if (headers)
- {
- size_t cumulativeLen = 0;
-
- for (const nlohmann::json::object_t& headerChunk : *headers)
- {
- for (const auto& item : headerChunk)
+ if (!regPrefixes->empty() && !msgIds->empty())
{
- const std::string* value =
- item.second.get_ptr<const std::string*>();
- if (value == nullptr)
- {
- messages::propertyValueFormatError(
- asyncResp->res, item.second,
- "HttpHeaders/" + item.first);
- return;
- }
- // Adding a new json value is the size of the key, +
- // the size of the value + 2 * 2 quotes for each, +
- // the colon and space between. example:
- // "key": "value"
- cumulativeLen += item.first.size() + value->size() + 6;
- // This value is selected to mirror http_connection.hpp
- constexpr const uint16_t maxHeaderSizeED = 8096;
- if (cumulativeLen > maxHeaderSizeED)
- {
- messages::arraySizeTooLong(
- asyncResp->res, "HttpHeaders", maxHeaderSizeED);
- return;
- }
- subValue->httpHeaders.set(item.first, *value);
- }
- }
- }
-
- if (regPrefixes)
- {
- for (const std::string& it : *regPrefixes)
- {
- if (std::ranges::find(supportedRegPrefixes, it) ==
- supportedRegPrefixes.end())
- {
- messages::propertyValueNotInList(asyncResp->res, it,
- "RegistryPrefixes");
+ messages::propertyValueConflict(
+ asyncResp->res, "MessageIds", "RegistryPrefixes");
return;
}
}
- subValue->registryPrefixes = *regPrefixes;
- }
- if (resTypes)
- {
- for (const std::string& it : *resTypes)
+ boost::system::result<boost::urls::url> url =
+ boost::urls::parse_absolute_uri(destUrl);
+ if (!url)
{
- if (std::ranges::find(supportedResourceTypes, it) ==
- supportedResourceTypes.end())
+ BMCWEB_LOG_WARNING(
+ "Failed to validate and split destination url");
+ messages::propertyValueFormatError(asyncResp->res, destUrl,
+ "Destination");
+ return;
+ }
+ url->normalize();
+ crow::utility::setProtocolDefaults(*url, protocol);
+ crow::utility::setPortDefaults(*url);
+
+ if (url->path().empty())
+ {
+ url->set_path("/");
+ }
+
+ if (url->has_userinfo())
+ {
+ messages::propertyValueFormatError(asyncResp->res, destUrl,
+ "Destination");
+ return;
+ }
+
+ if (protocol == "SNMPv2c")
+ {
+ if (context)
{
- messages::propertyValueNotInList(asyncResp->res, it,
- "ResourceTypes");
+ messages::propertyValueConflict(asyncResp->res, "Context",
+ "Protocol");
return;
}
+ if (eventFormatType2)
+ {
+ messages::propertyValueConflict(
+ asyncResp->res, "EventFormatType", "Protocol");
+ return;
+ }
+ if (retryPolicy)
+ {
+ messages::propertyValueConflict(asyncResp->res,
+ "RetryPolicy", "Protocol");
+ return;
+ }
+ if (msgIds)
+ {
+ messages::propertyValueConflict(asyncResp->res,
+ "MessageIds", "Protocol");
+ return;
+ }
+ if (regPrefixes)
+ {
+ messages::propertyValueConflict(
+ asyncResp->res, "RegistryPrefixes", "Protocol");
+ return;
+ }
+ if (resTypes)
+ {
+ messages::propertyValueConflict(
+ asyncResp->res, "ResourceTypes", "Protocol");
+ return;
+ }
+ if (headers)
+ {
+ messages::propertyValueConflict(asyncResp->res,
+ "HttpHeaders", "Protocol");
+ return;
+ }
+ if (mrdJsonArray)
+ {
+ messages::propertyValueConflict(
+ asyncResp->res, "MetricReportDefinitions", "Protocol");
+ return;
+ }
+ if (url->scheme() != "snmp")
+ {
+ messages::propertyValueConflict(asyncResp->res,
+ "Destination", "Protocol");
+ return;
+ }
+
+ addSnmpTrapClient(asyncResp, url->host_address(),
+ url->port_number());
+ return;
}
- subValue->resourceTypes = *resTypes;
- }
- if (msgIds)
- {
- std::vector<std::string> registryPrefix;
+ std::shared_ptr<Subscription> subValue =
+ std::make_shared<Subscription>(*url, app.ioContext());
- // If no registry prefixes are mentioned, consider all
- // supported prefixes
- if (subValue->registryPrefixes.empty())
+ subValue->destinationUrl = std::move(*url);
+
+ if (subscriptionType)
{
- registryPrefix.assign(supportedRegPrefixes.begin(),
- supportedRegPrefixes.end());
+ if (*subscriptionType != "RedfishEvent")
+ {
+ messages::propertyValueNotInList(
+ asyncResp->res, *subscriptionType, "SubscriptionType");
+ return;
+ }
+ subValue->subscriptionType = *subscriptionType;
}
else
{
- registryPrefix = subValue->registryPrefixes;
+ subValue->subscriptionType = "RedfishEvent"; // Default
}
- for (const std::string& id : *msgIds)
+ if (protocol != "Redfish")
{
- bool validId = false;
+ messages::propertyValueNotInList(asyncResp->res, protocol,
+ "Protocol");
+ return;
+ }
+ subValue->protocol = protocol;
- // Check for Message ID in each of the selected Registry
- for (const std::string& it : registryPrefix)
+ if (verifyCertificate)
+ {
+ subValue->verifyCertificate = *verifyCertificate;
+ }
+
+ if (eventFormatType2)
+ {
+ if (std::ranges::find(supportedEvtFormatTypes,
+ *eventFormatType2) ==
+ supportedEvtFormatTypes.end())
{
- const std::span<const redfish::registries::MessageEntry>
- registry =
- redfish::registries::getRegistryFromPrefix(it);
+ messages::propertyValueNotInList(
+ asyncResp->res, *eventFormatType2, "EventFormatType");
+ return;
+ }
+ subValue->eventFormatType = *eventFormatType2;
+ }
+ else
+ {
+ // If not specified, use default "Event"
+ subValue->eventFormatType = "Event";
+ }
- if (std::ranges::any_of(
- registry,
- [&id](const redfish::registries::MessageEntry&
- messageEntry) {
- return id == messageEntry.first;
- }))
+ if (context)
+ {
+ // This value is selected arbitrarily.
+ constexpr const size_t maxContextSize = 256;
+ if (context->size() > maxContextSize)
+ {
+ messages::stringValueTooLong(asyncResp->res, "Context",
+ maxContextSize);
+ return;
+ }
+ subValue->customText = *context;
+ }
+
+ if (headers)
+ {
+ size_t cumulativeLen = 0;
+
+ for (const nlohmann::json::object_t& headerChunk : *headers)
+ {
+ for (const auto& item : headerChunk)
{
- validId = true;
- break;
+ const std::string* value =
+ item.second.get_ptr<const std::string*>();
+ if (value == nullptr)
+ {
+ messages::propertyValueFormatError(
+ asyncResp->res, item.second,
+ "HttpHeaders/" + item.first);
+ return;
+ }
+ // Adding a new json value is the size of the key, +
+ // the size of the value + 2 * 2 quotes for each, +
+ // the colon and space between. example:
+ // "key": "value"
+ cumulativeLen += item.first.size() + value->size() + 6;
+ // This value is selected to mirror http_connection.hpp
+ constexpr const uint16_t maxHeaderSizeED = 8096;
+ if (cumulativeLen > maxHeaderSizeED)
+ {
+ messages::arraySizeTooLong(
+ asyncResp->res, "HttpHeaders", maxHeaderSizeED);
+ return;
+ }
+ subValue->httpHeaders.set(item.first, *value);
+ }
+ }
+ }
+
+ if (regPrefixes)
+ {
+ for (const std::string& it : *regPrefixes)
+ {
+ if (std::ranges::find(supportedRegPrefixes, it) ==
+ supportedRegPrefixes.end())
+ {
+ messages::propertyValueNotInList(asyncResp->res, it,
+ "RegistryPrefixes");
+ return;
+ }
+ }
+ subValue->registryPrefixes = *regPrefixes;
+ }
+
+ if (resTypes)
+ {
+ for (const std::string& it : *resTypes)
+ {
+ if (std::ranges::find(supportedResourceTypes, it) ==
+ supportedResourceTypes.end())
+ {
+ messages::propertyValueNotInList(asyncResp->res, it,
+ "ResourceTypes");
+ return;
+ }
+ }
+ subValue->resourceTypes = *resTypes;
+ }
+
+ if (msgIds)
+ {
+ std::vector<std::string> registryPrefix;
+
+ // If no registry prefixes are mentioned, consider all
+ // supported prefixes
+ if (subValue->registryPrefixes.empty())
+ {
+ registryPrefix.assign(supportedRegPrefixes.begin(),
+ supportedRegPrefixes.end());
+ }
+ else
+ {
+ registryPrefix = subValue->registryPrefixes;
+ }
+
+ for (const std::string& id : *msgIds)
+ {
+ bool validId = false;
+
+ // Check for Message ID in each of the selected Registry
+ for (const std::string& it : registryPrefix)
+ {
+ const std::span<const redfish::registries::MessageEntry>
+ registry =
+ redfish::registries::getRegistryFromPrefix(it);
+
+ if (std::ranges::any_of(
+ registry,
+ [&id](const redfish::registries::MessageEntry&
+ messageEntry) {
+ return id == messageEntry.first;
+ }))
+ {
+ validId = true;
+ break;
+ }
+ }
+
+ if (!validId)
+ {
+ messages::propertyValueNotInList(asyncResp->res, id,
+ "MessageIds");
+ return;
}
}
- if (!validId)
+ subValue->registryMsgIds = *msgIds;
+ }
+
+ if (retryPolicy)
+ {
+ if (std::ranges::find(supportedRetryPolicies, *retryPolicy) ==
+ supportedRetryPolicies.end())
{
- messages::propertyValueNotInList(asyncResp->res, id,
- "MessageIds");
+ messages::propertyValueNotInList(
+ asyncResp->res, *retryPolicy, "DeliveryRetryPolicy");
return;
}
+ subValue->retryPolicy = *retryPolicy;
+ }
+ else
+ {
+ // Default "TerminateAfterRetries"
+ subValue->retryPolicy = "TerminateAfterRetries";
+ }
+
+ if (mrdJsonArray)
+ {
+ for (nlohmann::json::object_t& mrdObj : *mrdJsonArray)
+ {
+ std::string mrdUri;
+
+ if (!json_util::readJsonObject(mrdObj, asyncResp->res,
+ "@odata.id", mrdUri))
+
+ {
+ return;
+ }
+ subValue->metricReportDefinitions.emplace_back(mrdUri);
+ }
}
- subValue->registryMsgIds = *msgIds;
- }
-
- if (retryPolicy)
- {
- if (std::ranges::find(supportedRetryPolicies, *retryPolicy) ==
- supportedRetryPolicies.end())
+ std::string id =
+ EventServiceManager::getInstance().addPushSubscription(
+ subValue);
+ if (id.empty())
{
- messages::propertyValueNotInList(asyncResp->res, *retryPolicy,
- "DeliveryRetryPolicy");
+ messages::internalError(asyncResp->res);
return;
}
- subValue->retryPolicy = *retryPolicy;
- }
- else
- {
- // Default "TerminateAfterRetries"
- subValue->retryPolicy = "TerminateAfterRetries";
- }
- if (mrdJsonArray)
- {
- for (nlohmann::json::object_t& mrdObj : *mrdJsonArray)
- {
- std::string mrdUri;
-
- if (!json_util::readJsonObject(mrdObj, asyncResp->res,
- "@odata.id", mrdUri))
-
- {
- return;
- }
- subValue->metricReportDefinitions.emplace_back(mrdUri);
- }
- }
-
- std::string id =
- EventServiceManager::getInstance().addPushSubscription(subValue);
- if (id.empty())
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- messages::created(asyncResp->res);
- asyncResp->res.addHeader(
- "Location", "/redfish/v1/EventService/Subscriptions/" + id);
- });
+ messages::created(asyncResp->res);
+ asyncResp->res.addHeader(
+ "Location", "/redfish/v1/EventService/Subscriptions/" + id);
+ });
}
inline void requestRoutesEventDestination(App& app)
@@ -641,58 +654,66 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& param) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- if (param.starts_with("snmp"))
- {
- getSnmpTrapClient(asyncResp, param);
- return;
- }
+ if (param.starts_with("snmp"))
+ {
+ getSnmpTrapClient(asyncResp, param);
+ return;
+ }
- std::shared_ptr<Subscription> subValue =
- EventServiceManager::getInstance().getSubscription(param);
- if (subValue == nullptr)
- {
- asyncResp->res.result(boost::beast::http::status::not_found);
- return;
- }
- const std::string& id = param;
+ std::shared_ptr<Subscription> subValue =
+ EventServiceManager::getInstance().getSubscription(param);
+ if (subValue == nullptr)
+ {
+ asyncResp->res.result(
+ boost::beast::http::status::not_found);
+ return;
+ }
+ const std::string& id = param;
- asyncResp->res.jsonValue["@odata.type"] =
- "#EventDestination.v1_8_0.EventDestination";
- asyncResp->res.jsonValue["Protocol"] =
- event_destination::EventDestinationProtocol::Redfish;
- asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/EventService/Subscriptions/{}", id);
- asyncResp->res.jsonValue["Id"] = id;
- asyncResp->res.jsonValue["Name"] = "Event Destination " + id;
- asyncResp->res.jsonValue["Destination"] = subValue->destinationUrl;
- asyncResp->res.jsonValue["Context"] = subValue->customText;
- asyncResp->res.jsonValue["SubscriptionType"] =
- subValue->subscriptionType;
- asyncResp->res.jsonValue["HttpHeaders"] = nlohmann::json::array();
- asyncResp->res.jsonValue["EventFormatType"] = subValue->eventFormatType;
- asyncResp->res.jsonValue["RegistryPrefixes"] =
- subValue->registryPrefixes;
- asyncResp->res.jsonValue["ResourceTypes"] = subValue->resourceTypes;
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#EventDestination.v1_8_0.EventDestination";
+ asyncResp->res.jsonValue["Protocol"] =
+ event_destination::EventDestinationProtocol::Redfish;
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/EventService/Subscriptions/{}", id);
+ asyncResp->res.jsonValue["Id"] = id;
+ asyncResp->res.jsonValue["Name"] = "Event Destination " + id;
+ asyncResp->res.jsonValue["Destination"] =
+ subValue->destinationUrl;
+ asyncResp->res.jsonValue["Context"] = subValue->customText;
+ asyncResp->res.jsonValue["SubscriptionType"] =
+ subValue->subscriptionType;
+ asyncResp->res.jsonValue["HttpHeaders"] =
+ nlohmann::json::array();
+ asyncResp->res.jsonValue["EventFormatType"] =
+ subValue->eventFormatType;
+ asyncResp->res.jsonValue["RegistryPrefixes"] =
+ subValue->registryPrefixes;
+ asyncResp->res.jsonValue["ResourceTypes"] =
+ subValue->resourceTypes;
- asyncResp->res.jsonValue["MessageIds"] = subValue->registryMsgIds;
- asyncResp->res.jsonValue["DeliveryRetryPolicy"] = subValue->retryPolicy;
- asyncResp->res.jsonValue["VerifyCertificate"] =
- subValue->verifyCertificate;
+ asyncResp->res.jsonValue["MessageIds"] =
+ subValue->registryMsgIds;
+ asyncResp->res.jsonValue["DeliveryRetryPolicy"] =
+ subValue->retryPolicy;
+ asyncResp->res.jsonValue["VerifyCertificate"] =
+ subValue->verifyCertificate;
- nlohmann::json::array_t mrdJsonArray;
- for (const auto& mdrUri : subValue->metricReportDefinitions)
- {
- nlohmann::json::object_t mdr;
- mdr["@odata.id"] = mdrUri;
- mrdJsonArray.emplace_back(std::move(mdr));
- }
- asyncResp->res.jsonValue["MetricReportDefinitions"] = mrdJsonArray;
- });
+ nlohmann::json::array_t mrdJsonArray;
+ for (const auto& mdrUri : subValue->metricReportDefinitions)
+ {
+ nlohmann::json::object_t mdr;
+ mdr["@odata.id"] = mdrUri;
+ mrdJsonArray.emplace_back(std::move(mdr));
+ }
+ asyncResp->res.jsonValue["MetricReportDefinitions"] =
+ mrdJsonArray;
+ });
BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/<str>/")
// The below privilege is wrong, it should be ConfigureManager OR
// ConfigureSelf
@@ -703,77 +724,81 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& param) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- std::shared_ptr<Subscription> subValue =
- EventServiceManager::getInstance().getSubscription(param);
- if (subValue == nullptr)
- {
- asyncResp->res.result(boost::beast::http::status::not_found);
- return;
- }
-
- std::optional<std::string> context;
- std::optional<std::string> retryPolicy;
- std::optional<bool> verifyCertificate;
- std::optional<std::vector<nlohmann::json::object_t>> headers;
-
- if (!json_util::readJsonPatch(req, asyncResp->res, "Context", context,
- "VerifyCertificate", verifyCertificate,
- "DeliveryRetryPolicy", retryPolicy,
- "HttpHeaders", headers))
- {
- return;
- }
-
- if (context)
- {
- subValue->customText = *context;
- }
-
- if (headers)
- {
- boost::beast::http::fields fields;
- for (const nlohmann::json::object_t& headerChunk : *headers)
- {
- for (const auto& it : headerChunk)
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
- const std::string* value =
- it.second.get_ptr<const std::string*>();
- if (value == nullptr)
+ return;
+ }
+ std::shared_ptr<Subscription> subValue =
+ EventServiceManager::getInstance().getSubscription(param);
+ if (subValue == nullptr)
+ {
+ asyncResp->res.result(
+ boost::beast::http::status::not_found);
+ return;
+ }
+
+ std::optional<std::string> context;
+ std::optional<std::string> retryPolicy;
+ std::optional<bool> verifyCertificate;
+ std::optional<std::vector<nlohmann::json::object_t>> headers;
+
+ if (!json_util::readJsonPatch(
+ req, asyncResp->res, "Context", context,
+ "VerifyCertificate", verifyCertificate,
+ "DeliveryRetryPolicy", retryPolicy, "HttpHeaders",
+ headers))
+ {
+ return;
+ }
+
+ if (context)
+ {
+ subValue->customText = *context;
+ }
+
+ if (headers)
+ {
+ boost::beast::http::fields fields;
+ for (const nlohmann::json::object_t& headerChunk : *headers)
{
- messages::propertyValueFormatError(
- asyncResp->res, it.second,
- "HttpHeaders/" + it.first);
+ for (const auto& it : headerChunk)
+ {
+ const std::string* value =
+ it.second.get_ptr<const std::string*>();
+ if (value == nullptr)
+ {
+ messages::propertyValueFormatError(
+ asyncResp->res, it.second,
+ "HttpHeaders/" + it.first);
+ return;
+ }
+ fields.set(it.first, *value);
+ }
+ }
+ subValue->httpHeaders = std::move(fields);
+ }
+
+ if (retryPolicy)
+ {
+ if (std::ranges::find(supportedRetryPolicies,
+ *retryPolicy) ==
+ supportedRetryPolicies.end())
+ {
+ messages::propertyValueNotInList(asyncResp->res,
+ *retryPolicy,
+ "DeliveryRetryPolicy");
return;
}
- fields.set(it.first, *value);
+ subValue->retryPolicy = *retryPolicy;
}
- }
- subValue->httpHeaders = std::move(fields);
- }
- if (retryPolicy)
- {
- if (std::ranges::find(supportedRetryPolicies, *retryPolicy) ==
- supportedRetryPolicies.end())
- {
- messages::propertyValueNotInList(asyncResp->res, *retryPolicy,
- "DeliveryRetryPolicy");
- return;
- }
- subValue->retryPolicy = *retryPolicy;
- }
+ if (verifyCertificate)
+ {
+ subValue->verifyCertificate = *verifyCertificate;
+ }
- if (verifyCertificate)
- {
- subValue->verifyCertificate = *verifyCertificate;
- }
-
- EventServiceManager::getInstance().updateSubscriptionData();
- });
+ EventServiceManager::getInstance().updateSubscriptionData();
+ });
BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/<str>/")
// The below privilege is wrong, it should be ConfigureManager OR
// ConfigureSelf
@@ -784,25 +809,28 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& param) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- if (param.starts_with("snmp"))
- {
- deleteSnmpTrapClient(asyncResp, param);
- EventServiceManager::getInstance().deleteSubscription(param);
- return;
- }
+ if (param.starts_with("snmp"))
+ {
+ deleteSnmpTrapClient(asyncResp, param);
+ EventServiceManager::getInstance().deleteSubscription(
+ param);
+ return;
+ }
- if (!EventServiceManager::getInstance().isSubscriptionExist(param))
- {
- asyncResp->res.result(boost::beast::http::status::not_found);
- return;
- }
- EventServiceManager::getInstance().deleteSubscription(param);
- });
+ if (!EventServiceManager::getInstance().isSubscriptionExist(
+ param))
+ {
+ asyncResp->res.result(
+ boost::beast::http::status::not_found);
+ return;
+ }
+ EventServiceManager::getInstance().deleteSubscription(param);
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/fabric_adapters.hpp b/redfish-core/lib/fabric_adapters.hpp
index c7bdbb7..20e6726 100644
--- a/redfish-core/lib/fabric_adapters.hpp
+++ b/redfish-core/lib/fabric_adapters.hpp
@@ -33,25 +33,25 @@
"xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
[asyncResp](const boost::system::error_code& ec,
const std::string& property) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for Location");
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for Location");
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- asyncResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
- property;
- });
+ asyncResp->res
+ .jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
+ property;
+ });
}
-inline void
- getFabricAdapterAsset(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& serviceName,
- const std::string& fabricAdapterPath)
+inline void getFabricAdapterAsset(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& serviceName, const std::string& fabricAdapterPath)
{
sdbusplus::asio::getAllProperties(
*crow::connections::systemBus, serviceName, fabricAdapterPath,
@@ -59,114 +59,111 @@
[fabricAdapterPath, asyncResp{asyncResp}](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& propertiesList) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for Properties");
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for Properties");
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- const std::string* serialNumber = nullptr;
- const std::string* model = nullptr;
- const std::string* partNumber = nullptr;
- const std::string* sparePartNumber = nullptr;
+ const std::string* serialNumber = nullptr;
+ const std::string* model = nullptr;
+ const std::string* partNumber = nullptr;
+ const std::string* sparePartNumber = nullptr;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), propertiesList, "SerialNumber",
- serialNumber, "Model", model, "PartNumber", partNumber,
- "SparePartNumber", sparePartNumber);
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), propertiesList,
+ "SerialNumber", serialNumber, "Model", model, "PartNumber",
+ partNumber, "SparePartNumber", sparePartNumber);
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (serialNumber != nullptr)
- {
- asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
- }
+ if (serialNumber != nullptr)
+ {
+ asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
+ }
- if (model != nullptr)
- {
- asyncResp->res.jsonValue["Model"] = *model;
- }
+ if (model != nullptr)
+ {
+ asyncResp->res.jsonValue["Model"] = *model;
+ }
- if (partNumber != nullptr)
- {
- asyncResp->res.jsonValue["PartNumber"] = *partNumber;
- }
+ if (partNumber != nullptr)
+ {
+ asyncResp->res.jsonValue["PartNumber"] = *partNumber;
+ }
- if (sparePartNumber != nullptr && !sparePartNumber->empty())
- {
- asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
- }
- });
+ if (sparePartNumber != nullptr && !sparePartNumber->empty())
+ {
+ asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
+ }
+ });
}
-inline void
- getFabricAdapterState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& serviceName,
- const std::string& fabricAdapterPath)
+inline void getFabricAdapterState(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& serviceName, const std::string& fabricAdapterPath)
{
sdbusplus::asio::getProperty<bool>(
*crow::connections::systemBus, serviceName, fabricAdapterPath,
"xyz.openbmc_project.Inventory.Item", "Present",
[asyncResp](const boost::system::error_code& ec, const bool present) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for State");
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for State");
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- if (!present)
- {
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Absent;
- }
- });
+ if (!present)
+ {
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Absent;
+ }
+ });
}
-inline void
- getFabricAdapterHealth(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& serviceName,
- const std::string& fabricAdapterPath)
+inline void getFabricAdapterHealth(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& serviceName, const std::string& fabricAdapterPath)
{
sdbusplus::asio::getProperty<bool>(
*crow::connections::systemBus, serviceName, fabricAdapterPath,
"xyz.openbmc_project.State.Decorator.OperationalStatus", "Functional",
[asyncResp](const boost::system::error_code& ec,
const bool functional) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for Health");
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for Health");
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- if (!functional)
- {
- asyncResp->res.jsonValue["Status"]["Health"] =
- resource::Health::Critical;
- }
- });
+ if (!functional)
+ {
+ asyncResp->res.jsonValue["Status"]["Health"] =
+ resource::Health::Critical;
+ }
+ });
}
-inline void doAdapterGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName,
- const std::string& adapterId,
- const std::string& fabricAdapterPath,
- const std::string& serviceName)
+inline void doAdapterGet(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName, const std::string& adapterId,
+ const std::string& fabricAdapterPath, const std::string& serviceName)
{
asyncResp->res.addHeader(
boost::beast::http::field::link,
@@ -259,11 +256,10 @@
serviceName);
}
-inline void
- handleFabricAdapterGet(App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName,
- const std::string& adapterId)
+inline void handleFabricAdapterGet(
+ App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName, const std::string& adapterId)
{
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
@@ -384,11 +380,10 @@
"</redfish/v1/JsonSchemas/FabricAdapter/FabricAdapter.json>; rel=describedby");
}
-inline void
- handleFabricAdapterHead(crow::App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName,
- const std::string& adapterId)
+inline void handleFabricAdapterHead(
+ crow::App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName, const std::string& adapterId)
{
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
diff --git a/redfish-core/lib/fan.hpp b/redfish-core/lib/fan.hpp
index 7245287..62494a8 100644
--- a/redfish-core/lib/fan.hpp
+++ b/redfish-core/lib/fan.hpp
@@ -65,19 +65,19 @@
[asyncResp, callback](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse& subtreePaths) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR(
- "DBUS response error for getAssociatedSubTreePaths {}",
- ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR(
+ "DBUS response error for getAssociatedSubTreePaths {}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- callback(subtreePaths);
- });
+ callback(subtreePaths);
+ });
}
inline void doFanCollection(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -120,15 +120,16 @@
asyncResp, chassisId,
[asyncResp,
chassisId](const std::optional<std::string>& validChassisPath) {
- if (!validChassisPath)
- {
- messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
- return;
- }
- asyncResp->res.addHeader(
- boost::beast::http::field::link,
- "</redfish/v1/JsonSchemas/FanCollection/FanCollection.json>; rel=describedby");
- });
+ if (!validChassisPath)
+ {
+ messages::resourceNotFound(asyncResp->res, "Chassis",
+ chassisId);
+ return;
+ }
+ asyncResp->res.addHeader(
+ boost::beast::http::field::link,
+ "</redfish/v1/JsonSchemas/FanCollection/FanCollection.json>; rel=describedby");
+ });
}
inline void
@@ -184,15 +185,15 @@
[fanPath, asyncResp,
callback](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& object) {
- if (ec || object.empty())
- {
- BMCWEB_LOG_ERROR("DBUS response error on getDbusObject {}",
- ec.value());
- messages::internalError(asyncResp->res);
- return;
- }
- callback(fanPath, object.begin()->first);
- });
+ if (ec || object.empty())
+ {
+ BMCWEB_LOG_ERROR("DBUS response error on getDbusObject {}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ callback(fanPath, object.begin()->first);
+ });
return;
}
@@ -210,8 +211,8 @@
asyncResp, validChassisPath,
[fanId, asyncResp, callback](
const dbus::utility::MapperGetSubTreePathsResponse& fanPaths) {
- handleFanPath(fanId, asyncResp, fanPaths, callback);
- });
+ handleFanPath(fanId, asyncResp, fanPaths, callback);
+ });
}
inline void addFanCommonProperties(crow::Response& resp,
@@ -236,23 +237,23 @@
*crow::connections::systemBus, service, fanPath,
"xyz.openbmc_project.State.Decorator.OperationalStatus", "Functional",
[asyncResp](const boost::system::error_code& ec, const bool value) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for Health {}",
- ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for Health {}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- if (!value)
- {
- asyncResp->res.jsonValue["Status"]["Health"] =
- resource::Health::Critical;
- }
- });
+ if (!value)
+ {
+ asyncResp->res.jsonValue["Status"]["Health"] =
+ resource::Health::Critical;
+ }
+ });
}
inline void getFanState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -262,23 +263,23 @@
*crow::connections::systemBus, service, fanPath,
"xyz.openbmc_project.Inventory.Item", "Present",
[asyncResp](const boost::system::error_code& ec, const bool value) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for State {}",
- ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for State {}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- if (!value)
- {
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Absent;
- }
- });
+ if (!value)
+ {
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Absent;
+ }
+ });
}
inline void getFanAsset(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -290,52 +291,53 @@
[fanPath, asyncResp{asyncResp}](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& assetList) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for Properties{}",
- ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for Properties{}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- const std::string* manufacturer = nullptr;
- const std::string* model = nullptr;
- const std::string* partNumber = nullptr;
- const std::string* serialNumber = nullptr;
- const std::string* sparePartNumber = nullptr;
+ const std::string* manufacturer = nullptr;
+ const std::string* model = nullptr;
+ const std::string* partNumber = nullptr;
+ const std::string* serialNumber = nullptr;
+ const std::string* sparePartNumber = nullptr;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), assetList, "Manufacturer",
- manufacturer, "Model", model, "PartNumber", partNumber,
- "SerialNumber", serialNumber, "SparePartNumber", sparePartNumber);
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- if (manufacturer != nullptr)
- {
- asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
- }
- if (model != nullptr)
- {
- asyncResp->res.jsonValue["Model"] = *model;
- }
- if (partNumber != nullptr)
- {
- asyncResp->res.jsonValue["PartNumber"] = *partNumber;
- }
- if (serialNumber != nullptr)
- {
- asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
- }
- if (sparePartNumber != nullptr && !sparePartNumber->empty())
- {
- asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
- }
- });
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), assetList, "Manufacturer",
+ manufacturer, "Model", model, "PartNumber", partNumber,
+ "SerialNumber", serialNumber, "SparePartNumber",
+ sparePartNumber);
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (manufacturer != nullptr)
+ {
+ asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
+ }
+ if (model != nullptr)
+ {
+ asyncResp->res.jsonValue["Model"] = *model;
+ }
+ if (partNumber != nullptr)
+ {
+ asyncResp->res.jsonValue["PartNumber"] = *partNumber;
+ }
+ if (serialNumber != nullptr)
+ {
+ asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
+ }
+ if (sparePartNumber != nullptr && !sparePartNumber->empty())
+ {
+ asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
+ }
+ });
}
inline void getFanLocation(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -347,19 +349,20 @@
"xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
[asyncResp](const boost::system::error_code& ec,
const std::string& property) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for Location{}",
- ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for Location{}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- asyncResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
- property;
- });
+ asyncResp->res
+ .jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
+ property;
+ });
}
inline void
@@ -403,18 +406,20 @@
asyncResp, chassisId,
[asyncResp, chassisId,
fanId](const std::optional<std::string>& validChassisPath) {
- if (!validChassisPath)
- {
- messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
- return;
- }
- getValidFanPath(asyncResp, *validChassisPath, fanId,
- [asyncResp](const std::string&, const std::string&) {
- asyncResp->res.addHeader(
- boost::beast::http::field::link,
- "</redfish/v1/JsonSchemas/Fan/Fan.json>; rel=describedby");
+ if (!validChassisPath)
+ {
+ messages::resourceNotFound(asyncResp->res, "Chassis",
+ chassisId);
+ return;
+ }
+ getValidFanPath(
+ asyncResp, *validChassisPath, fanId,
+ [asyncResp](const std::string&, const std::string&) {
+ asyncResp->res.addHeader(
+ boost::beast::http::field::link,
+ "</redfish/v1/JsonSchemas/Fan/Fan.json>; rel=describedby");
+ });
});
- });
}
inline void handleFanGet(App& app, const crow::Request& req,
diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp
index a69908a..af1aaf9 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -44,64 +44,69 @@
"xyz.openbmc_project.State.Host", "CurrentHostState",
[asyncResp](const boost::system::error_code& ec,
const std::string& hostState) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
- // This is an optional D-Bus object so just return if
- // error occurs
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
+ // This is an optional D-Bus object so just return if
+ // error occurs
+ return;
+ }
- BMCWEB_LOG_DEBUG("Hypervisor state: {}", hostState);
- // Verify Host State
- if (hostState == "xyz.openbmc_project.State.Host.HostState.Running")
- {
- asyncResp->res.jsonValue["PowerState"] = resource::PowerState::On;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Enabled;
- }
- else if (hostState == "xyz.openbmc_project.State.Host.HostState."
- "Quiesced")
- {
- asyncResp->res.jsonValue["PowerState"] = resource::PowerState::On;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Quiesced;
- }
- else if (hostState == "xyz.openbmc_project.State.Host.HostState."
- "Standby")
- {
- asyncResp->res.jsonValue["PowerState"] = resource::PowerState::On;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::StandbyOffline;
- }
- else if (hostState == "xyz.openbmc_project.State.Host.HostState."
- "TransitioningToRunning")
- {
- asyncResp->res.jsonValue["PowerState"] =
- resource::PowerState::PoweringOn;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Starting;
- }
- else if (hostState == "xyz.openbmc_project.State.Host.HostState."
- "TransitioningToOff")
- {
- asyncResp->res.jsonValue["PowerState"] =
- resource::PowerState::PoweringOff;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Enabled;
- }
- else if (hostState == "xyz.openbmc_project.State.Host.HostState.Off")
- {
- asyncResp->res.jsonValue["PowerState"] = resource::PowerState::Off;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Disabled;
- }
- else
- {
- messages::internalError(asyncResp->res);
- return;
- }
- });
+ BMCWEB_LOG_DEBUG("Hypervisor state: {}", hostState);
+ // Verify Host State
+ if (hostState == "xyz.openbmc_project.State.Host.HostState.Running")
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::On;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Enabled;
+ }
+ else if (hostState == "xyz.openbmc_project.State.Host.HostState."
+ "Quiesced")
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::On;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Quiesced;
+ }
+ else if (hostState == "xyz.openbmc_project.State.Host.HostState."
+ "Standby")
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::On;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::StandbyOffline;
+ }
+ else if (hostState == "xyz.openbmc_project.State.Host.HostState."
+ "TransitioningToRunning")
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::PoweringOn;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Starting;
+ }
+ else if (hostState == "xyz.openbmc_project.State.Host.HostState."
+ "TransitioningToOff")
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::PoweringOff;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Enabled;
+ }
+ else if (hostState ==
+ "xyz.openbmc_project.State.Host.HostState.Off")
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::Off;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Disabled;
+ }
+ else
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ });
}
/**
@@ -126,37 +131,37 @@
const boost::system::error_code& ec,
const std::vector<std::pair<std::string, std::vector<std::string>>>&
objInfo) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
- // This is an optional D-Bus object so just return if
- // error occurs
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
+ // This is an optional D-Bus object so just return if
+ // error occurs
+ return;
+ }
- if (objInfo.empty())
- {
- // As noted above, this is an optional interface so just return
- // if there is no instance found
- return;
- }
+ if (objInfo.empty())
+ {
+ // As noted above, this is an optional interface so just return
+ // if there is no instance found
+ return;
+ }
- if (objInfo.size() > 1)
- {
- // More then one hypervisor object is not supported and is an
- // error
- messages::internalError(asyncResp->res);
- return;
- }
+ if (objInfo.size() > 1)
+ {
+ // More then one hypervisor object is not supported and is an
+ // error
+ messages::internalError(asyncResp->res);
+ return;
+ }
- // Object present so system support limited ComputerSystem Action
- nlohmann::json& reset =
- asyncResp->res.jsonValue["Actions"]["#ComputerSystem.Reset"];
- reset["target"] =
- "/redfish/v1/Systems/hypervisor/Actions/ComputerSystem.Reset";
- reset["@Redfish.ActionInfo"] =
- "/redfish/v1/Systems/hypervisor/ResetActionInfo";
- });
+ // Object present so system support limited ComputerSystem Action
+ nlohmann::json& reset =
+ asyncResp->res.jsonValue["Actions"]["#ComputerSystem.Reset"];
+ reset["target"] =
+ "/redfish/v1/Systems/hypervisor/Actions/ComputerSystem.Reset";
+ reset["@Redfish.ActionInfo"] =
+ "/redfish/v1/Systems/hypervisor/ResetActionInfo";
+ });
}
inline bool extractHypervisorInterfaceData(
@@ -329,22 +334,22 @@
callback = std::forward<CallbackFunc>(callback)](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) mutable {
- EthernetInterfaceData ethData{};
- std::vector<IPv4AddressData> ipv4Data;
- if (ec)
- {
- callback(false, ethData, ipv4Data);
- return;
- }
+ EthernetInterfaceData ethData{};
+ std::vector<IPv4AddressData> ipv4Data;
+ if (ec)
+ {
+ callback(false, ethData, ipv4Data);
+ return;
+ }
- bool found = extractHypervisorInterfaceData(ethIfaceId, resp, ethData,
- ipv4Data);
- if (!found)
- {
- BMCWEB_LOG_INFO("Hypervisor Interface not found");
- }
- callback(found, ethData, ipv4Data);
- });
+ bool found = extractHypervisorInterfaceData(ethIfaceId, resp,
+ ethData, ipv4Data);
+ if (!found)
+ {
+ BMCWEB_LOG_INFO("Hypervisor Interface not found");
+ }
+ callback(found, ethData, ipv4Data);
+ });
}
/**
@@ -363,11 +368,11 @@
BMCWEB_LOG_DEBUG("Setting the Hypervisor IPaddress : {} on Iface: {}",
ipv4Address, ethIfaceId);
- setDbusProperty(asyncResp, "IPv4StaticAddresses/1/Address",
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/network/hypervisor/" + ethIfaceId +
- "/ipv4/addr0",
- "xyz.openbmc_project.Network.IP", "Address", ipv4Address);
+ setDbusProperty(
+ asyncResp, "IPv4StaticAddresses/1/Address",
+ "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/network/hypervisor/" + ethIfaceId + "/ipv4/addr0",
+ "xyz.openbmc_project.Network.IP", "Address", ipv4Address);
}
/**
@@ -386,11 +391,11 @@
BMCWEB_LOG_DEBUG("Setting the Hypervisor subnet : {} on Iface: {}", subnet,
ethIfaceId);
- setDbusProperty(asyncResp, "IPv4StaticAddresses/1/SubnetMask",
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/network/hypervisor/" + ethIfaceId +
- "/ipv4/addr0",
- "xyz.openbmc_project.Network.IP", "PrefixLength", subnet);
+ setDbusProperty(
+ asyncResp, "IPv4StaticAddresses/1/SubnetMask",
+ "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/network/hypervisor/" + ethIfaceId + "/ipv4/addr0",
+ "xyz.openbmc_project.Network.IP", "PrefixLength", subnet);
}
/**
@@ -523,11 +528,11 @@
origin = "xyz.openbmc_project.Network.IP.AddressOrigin.DHCP";
}
- setDbusProperty(asyncResp, "IPv4StaticAddresses/1/AddressOrigin",
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/network/hypervisor/" + ifaceId +
- "/ipv4/addr0",
- "xyz.openbmc_project.Network.IP", "Origin", origin);
+ setDbusProperty(
+ asyncResp, "IPv4StaticAddresses/1/AddressOrigin",
+ "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/network/hypervisor/" + ifaceId + "/ipv4/addr0",
+ "xyz.openbmc_project.Network.IP", "Origin", origin);
}
inline void handleHypervisorIPv4StaticPatch(
@@ -636,39 +641,41 @@
[asyncResp](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse& ifaceList) {
- if (ec)
- {
- messages::resourceNotFound(asyncResp->res, "System", "hypervisor");
- return;
- }
- asyncResp->res.jsonValue["@odata.type"] =
- "#EthernetInterfaceCollection."
- "EthernetInterfaceCollection";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/hypervisor/EthernetInterfaces";
- asyncResp->res.jsonValue["Name"] = "Hypervisor Ethernet "
- "Interface Collection";
- asyncResp->res.jsonValue["Description"] =
- "Collection of Virtual Management "
- "Interfaces for the hypervisor";
-
- nlohmann::json& ifaceArray = asyncResp->res.jsonValue["Members"];
- ifaceArray = nlohmann::json::array();
- for (const std::string& iface : ifaceList)
- {
- sdbusplus::message::object_path path(iface);
- std::string name = path.filename();
- if (name.empty())
+ if (ec)
{
- continue;
+ messages::resourceNotFound(asyncResp->res, "System",
+ "hypervisor");
+ return;
}
- nlohmann::json::object_t ethIface;
- ethIface["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/hypervisor/EthernetInterfaces/{}", name);
- ifaceArray.emplace_back(std::move(ethIface));
- }
- asyncResp->res.jsonValue["Members@odata.count"] = ifaceArray.size();
- });
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#EthernetInterfaceCollection."
+ "EthernetInterfaceCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/hypervisor/EthernetInterfaces";
+ asyncResp->res.jsonValue["Name"] = "Hypervisor Ethernet "
+ "Interface Collection";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of Virtual Management "
+ "Interfaces for the hypervisor";
+
+ nlohmann::json& ifaceArray = asyncResp->res.jsonValue["Members"];
+ ifaceArray = nlohmann::json::array();
+ for (const std::string& iface : ifaceList)
+ {
+ sdbusplus::message::object_path path(iface);
+ std::string name = path.filename();
+ if (name.empty())
+ {
+ continue;
+ }
+ nlohmann::json::object_t ethIface;
+ ethIface["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Systems/hypervisor/EthernetInterfaces/{}",
+ name);
+ ifaceArray.emplace_back(std::move(ethIface));
+ }
+ asyncResp->res.jsonValue["Members@odata.count"] = ifaceArray.size();
+ });
}
inline void handleHypervisorEthernetInterfaceGet(
@@ -683,20 +690,20 @@
id, [asyncResp, ifaceId{std::string(id)}](
bool success, const EthernetInterfaceData& ethData,
const std::vector<IPv4AddressData>& ipv4Data) {
- if (!success)
- {
- messages::resourceNotFound(asyncResp->res, "EthernetInterface",
- ifaceId);
- return;
- }
- asyncResp->res.jsonValue["@odata.type"] =
- "#EthernetInterface.v1_9_0.EthernetInterface";
- asyncResp->res.jsonValue["Name"] = "Hypervisor Ethernet Interface";
- asyncResp->res.jsonValue["Description"] =
- "Hypervisor's Virtual Management Ethernet Interface";
- parseInterfaceData(asyncResp->res.jsonValue, ifaceId, ethData,
- ipv4Data);
- });
+ if (!success)
+ {
+ messages::resourceNotFound(asyncResp->res, "EthernetInterface",
+ ifaceId);
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#EthernetInterface.v1_9_0.EthernetInterface";
+ asyncResp->res.jsonValue["Name"] = "Hypervisor Ethernet Interface";
+ asyncResp->res.jsonValue["Description"] =
+ "Hypervisor's Virtual Management Ethernet Interface";
+ parseInterfaceData(asyncResp->res.jsonValue, ifaceId, ethData,
+ ipv4Data);
+ });
}
inline void handleHypervisorSystemGet(
@@ -708,34 +715,36 @@
"xyz.openbmc_project.Network.SystemConfiguration", "HostName",
[asyncResp](const boost::system::error_code& ec,
const std::string& /*hostName*/) {
- if (ec)
- {
- messages::resourceNotFound(asyncResp->res, "System", "hypervisor");
- return;
- }
- BMCWEB_LOG_DEBUG("Hypervisor is available");
+ if (ec)
+ {
+ messages::resourceNotFound(asyncResp->res, "System",
+ "hypervisor");
+ return;
+ }
+ BMCWEB_LOG_DEBUG("Hypervisor is available");
- asyncResp->res.jsonValue["@odata.type"] =
- "#ComputerSystem.v1_6_0.ComputerSystem";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/hypervisor";
- asyncResp->res.jsonValue["Description"] = "Hypervisor";
- asyncResp->res.jsonValue["Name"] = "Hypervisor";
- asyncResp->res.jsonValue["Id"] = "hypervisor";
- asyncResp->res.jsonValue["SystemType"] =
- computer_system::SystemType::OS;
- nlohmann::json::array_t managedBy;
- nlohmann::json::object_t manager;
- manager["@odata.id"] = boost::urls::format(
- "/redfish/v1/Managers/{}", BMCWEB_REDFISH_MANAGER_URI_NAME);
- managedBy.emplace_back(std::move(manager));
- asyncResp->res.jsonValue["Links"]["ManagedBy"] = std::move(managedBy);
- asyncResp->res.jsonValue["EthernetInterfaces"]["@odata.id"] =
- "/redfish/v1/Systems/hypervisor/EthernetInterfaces";
- getHypervisorState(asyncResp);
- getHypervisorActions(asyncResp);
- // TODO: Add "SystemType" : "hypervisor"
- });
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ComputerSystem.v1_6_0.ComputerSystem";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/hypervisor";
+ asyncResp->res.jsonValue["Description"] = "Hypervisor";
+ asyncResp->res.jsonValue["Name"] = "Hypervisor";
+ asyncResp->res.jsonValue["Id"] = "hypervisor";
+ asyncResp->res.jsonValue["SystemType"] =
+ computer_system::SystemType::OS;
+ nlohmann::json::array_t managedBy;
+ nlohmann::json::object_t manager;
+ manager["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}", BMCWEB_REDFISH_MANAGER_URI_NAME);
+ managedBy.emplace_back(std::move(manager));
+ asyncResp->res.jsonValue["Links"]["ManagedBy"] =
+ std::move(managedBy);
+ asyncResp->res.jsonValue["EthernetInterfaces"]["@odata.id"] =
+ "/redfish/v1/Systems/hypervisor/EthernetInterfaces";
+ getHypervisorState(asyncResp);
+ getHypervisorActions(asyncResp);
+ // TODO: Add "SystemType" : "hypervisor"
+ });
}
inline void handleHypervisorEthernetInterfacePatch(
@@ -754,10 +763,10 @@
std::optional<std::vector<nlohmann::json::object_t>> ipv4Addresses;
std::optional<bool> ipv4DHCPEnabled;
- if (!json_util::readJsonPatch(req, asyncResp->res, "HostName", hostName,
- "IPv4StaticAddresses", ipv4StaticAddresses,
- "IPv4Addresses", ipv4Addresses,
- "DHCPv4/DHCPEnabled", ipv4DHCPEnabled))
+ if (!json_util::readJsonPatch(
+ req, asyncResp->res, "HostName", hostName, "IPv4StaticAddresses",
+ ipv4StaticAddresses, "IPv4Addresses", ipv4Addresses,
+ "DHCPv4/DHCPEnabled", ipv4DHCPEnabled))
{
return;
}
@@ -774,67 +783,70 @@
ipv4StaticAddresses = std::move(ipv4StaticAddresses),
ipv4DHCPEnabled](bool success, const EthernetInterfaceData& ethData,
const std::vector<IPv4AddressData>&) mutable {
- if (!success)
- {
- messages::resourceNotFound(asyncResp->res, "EthernetInterface",
- ifaceId);
- return;
- }
-
- if (ipv4StaticAddresses)
- {
- std::vector<std::variant<nlohmann::json::object_t, std::nullptr_t>>&
- ipv4Static = *ipv4StaticAddresses;
- if (ipv4Static.begin() == ipv4Static.end())
+ if (!success)
{
- messages::propertyValueTypeError(asyncResp->res,
- std::vector<std::string>(),
- "IPv4StaticAddresses");
+ messages::resourceNotFound(asyncResp->res, "EthernetInterface",
+ ifaceId);
return;
}
- // One and only one hypervisor instance supported
- if (ipv4Static.size() != 1)
+ if (ipv4StaticAddresses)
{
- messages::propertyValueFormatError(asyncResp->res, "[]",
- "IPv4StaticAddresses");
- return;
+ std::vector<std::variant<nlohmann::json::object_t,
+ std::nullptr_t>>& ipv4Static =
+ *ipv4StaticAddresses;
+ if (ipv4Static.begin() == ipv4Static.end())
+ {
+ messages::propertyValueTypeError(asyncResp->res,
+ std::vector<std::string>(),
+ "IPv4StaticAddresses");
+ return;
+ }
+
+ // One and only one hypervisor instance supported
+ if (ipv4Static.size() != 1)
+ {
+ messages::propertyValueFormatError(asyncResp->res, "[]",
+ "IPv4StaticAddresses");
+ return;
+ }
+
+ std::variant<nlohmann::json::object_t, std::nullptr_t>&
+ ipv4Json = ipv4Static[0];
+ // Check if the param is 'null'. If its null, it means
+ // that user wants to delete the IP address. Deleting
+ // the IP address is allowed only if its statically
+ // configured. Deleting the address originated from DHCP
+ // is not allowed.
+ if (std::holds_alternative<std::nullptr_t>(ipv4Json) &&
+ translateDhcpEnabledToBool(ethData.dhcpEnabled, true))
+ {
+ BMCWEB_LOG_INFO(
+ "Ignoring the delete on ipv4StaticAddresses "
+ "as the interface is DHCP enabled");
+ }
+ else
+ {
+ handleHypervisorIPv4StaticPatch(ifaceId, ipv4Static,
+ asyncResp);
+ }
}
- std::variant<nlohmann::json::object_t, std::nullptr_t>& ipv4Json =
- ipv4Static[0];
- // Check if the param is 'null'. If its null, it means
- // that user wants to delete the IP address. Deleting
- // the IP address is allowed only if its statically
- // configured. Deleting the address originated from DHCP
- // is not allowed.
- if (std::holds_alternative<std::nullptr_t>(ipv4Json) &&
- translateDhcpEnabledToBool(ethData.dhcpEnabled, true))
+ if (hostName)
{
- BMCWEB_LOG_INFO("Ignoring the delete on ipv4StaticAddresses "
- "as the interface is DHCP enabled");
+ handleHypervisorHostnamePatch(*hostName, asyncResp);
}
- else
+
+ if (ipv4DHCPEnabled)
{
- handleHypervisorIPv4StaticPatch(ifaceId, ipv4Static, asyncResp);
+ setDHCPEnabled(ifaceId, *ipv4DHCPEnabled, asyncResp);
}
- }
- if (hostName)
- {
- handleHypervisorHostnamePatch(*hostName, asyncResp);
- }
-
- if (ipv4DHCPEnabled)
- {
- setDHCPEnabled(ifaceId, *ipv4DHCPEnabled, asyncResp);
- }
-
- // Set this interface to disabled/inactive. This will be set
- // to enabled/active by the pldm once the hypervisor
- // consumes the updated settings from the user.
- setIPv4InterfaceEnabled(ifaceId, false, asyncResp);
- });
+ // Set this interface to disabled/inactive. This will be set
+ // to enabled/active by the pldm once the hypervisor
+ // consumes the updated settings from the user.
+ setIPv4InterfaceEnabled(ifaceId, false, asyncResp);
+ });
asyncResp->res.result(boost::beast::http::status::accepted);
}
@@ -850,50 +862,50 @@
const boost::system::error_code& ec,
const std::vector<std::pair<std::string, std::vector<std::string>>>&
objInfo) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
-
- // No hypervisor objects found by mapper
- if (ec.value() == boost::system::errc::io_error)
+ if (ec)
{
- messages::resourceNotFound(asyncResp->res, "hypervisor",
- "ResetActionInfo");
+ BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
+
+ // No hypervisor objects found by mapper
+ if (ec.value() == boost::system::errc::io_error)
+ {
+ messages::resourceNotFound(asyncResp->res, "hypervisor",
+ "ResetActionInfo");
+ return;
+ }
+
+ messages::internalError(asyncResp->res);
return;
}
- messages::internalError(asyncResp->res);
- return;
- }
+ // One and only one hypervisor instance supported
+ if (objInfo.size() != 1)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- // One and only one hypervisor instance supported
- if (objInfo.size() != 1)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ // The hypervisor object only support the ability to
+ // turn On The system object Action should be utilized
+ // for other operations
- // The hypervisor object only support the ability to
- // turn On The system object Action should be utilized
- // for other operations
-
- asyncResp->res.jsonValue["@odata.type"] =
- "#ActionInfo.v1_1_2.ActionInfo";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/hypervisor/ResetActionInfo";
- asyncResp->res.jsonValue["Name"] = "Reset Action Info";
- asyncResp->res.jsonValue["Id"] = "ResetActionInfo";
- nlohmann::json::array_t parameters;
- nlohmann::json::object_t parameter;
- parameter["Name"] = "ResetType";
- parameter["Required"] = true;
- parameter["DataType"] = action_info::ParameterTypes::String;
- nlohmann::json::array_t allowed;
- allowed.emplace_back("On");
- parameter["AllowableValues"] = std::move(allowed);
- parameters.emplace_back(std::move(parameter));
- asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
- });
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ActionInfo.v1_1_2.ActionInfo";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/hypervisor/ResetActionInfo";
+ asyncResp->res.jsonValue["Name"] = "Reset Action Info";
+ asyncResp->res.jsonValue["Id"] = "ResetActionInfo";
+ nlohmann::json::array_t parameters;
+ nlohmann::json::object_t parameter;
+ parameter["Name"] = "ResetType";
+ parameter["Required"] = true;
+ parameter["DataType"] = action_info::ParameterTypes::String;
+ nlohmann::json::array_t allowed;
+ allowed.emplace_back("On");
+ parameter["AllowableValues"] = std::move(allowed);
+ parameters.emplace_back(std::move(parameter));
+ asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
+ });
}
inline void handleHypervisorSystemResetPost(
@@ -928,12 +940,12 @@
std::string command = "xyz.openbmc_project.State.Host.Transition.On";
- setDbusPropertyAction(asyncResp, "xyz.openbmc_project.State.Hypervisor",
- sdbusplus::message::object_path(
- "/xyz/openbmc_project/state/hypervisor0"),
- "xyz.openbmc_project.State.Host",
- "RequestedHostTransition", "ResetType",
- "ComputerSystem.Reset", command);
+ setDbusPropertyAction(
+ asyncResp, "xyz.openbmc_project.State.Hypervisor",
+ sdbusplus::message::object_path(
+ "/xyz/openbmc_project/state/hypervisor0"),
+ "xyz.openbmc_project.State.Host", "RequestedHostTransition",
+ "ResetType", "ComputerSystem.Reset", command);
}
inline void requestRoutesHypervisorSystems(App& app)
diff --git a/redfish-core/lib/led.hpp b/redfish-core/lib/led.hpp
index b54edb0..2f677fe 100644
--- a/redfish-core/lib/led.hpp
+++ b/redfish-core/lib/led.hpp
@@ -42,56 +42,56 @@
"/xyz/openbmc_project/led/groups/enclosure_identify_blink",
"xyz.openbmc_project.Led.Group", "Asserted",
[asyncResp](const boost::system::error_code& ec, const bool blinking) {
- // Some systems may not have enclosure_identify_blink object so
- // proceed to get enclosure_identify state.
- if (ec == boost::system::errc::invalid_argument)
- {
- BMCWEB_LOG_DEBUG(
- "Get identity blinking LED failed, mismatch in property type");
- messages::internalError(asyncResp->res);
- return;
- }
-
- // Blinking ON, no need to check enclosure_identify assert.
- if (!ec && blinking)
- {
- asyncResp->res.jsonValue["IndicatorLED"] =
- chassis::IndicatorLED::Blinking;
- return;
- }
-
- sdbusplus::asio::getProperty<bool>(
- *crow::connections::systemBus,
- "xyz.openbmc_project.LED.GroupManager",
- "/xyz/openbmc_project/led/groups/enclosure_identify",
- "xyz.openbmc_project.Led.Group", "Asserted",
- [asyncResp](const boost::system::error_code& ec2,
- const bool ledOn) {
- if (ec2 == boost::system::errc::invalid_argument)
+ // Some systems may not have enclosure_identify_blink object so
+ // proceed to get enclosure_identify state.
+ if (ec == boost::system::errc::invalid_argument)
{
BMCWEB_LOG_DEBUG(
- "Get enclosure identity led failed, mismatch in property type");
+ "Get identity blinking LED failed, mismatch in property type");
messages::internalError(asyncResp->res);
return;
}
- if (ec2)
+ // Blinking ON, no need to check enclosure_identify assert.
+ if (!ec && blinking)
{
+ asyncResp->res.jsonValue["IndicatorLED"] =
+ chassis::IndicatorLED::Blinking;
return;
}
- if (ledOn)
- {
- asyncResp->res.jsonValue["IndicatorLED"] =
- chassis::IndicatorLED::Lit;
- }
- else
- {
- asyncResp->res.jsonValue["IndicatorLED"] =
- chassis::IndicatorLED::Off;
- }
+ sdbusplus::asio::getProperty<bool>(
+ *crow::connections::systemBus,
+ "xyz.openbmc_project.LED.GroupManager",
+ "/xyz/openbmc_project/led/groups/enclosure_identify",
+ "xyz.openbmc_project.Led.Group", "Asserted",
+ [asyncResp](const boost::system::error_code& ec2,
+ const bool ledOn) {
+ if (ec2 == boost::system::errc::invalid_argument)
+ {
+ BMCWEB_LOG_DEBUG(
+ "Get enclosure identity led failed, mismatch in property type");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ if (ec2)
+ {
+ return;
+ }
+
+ if (ledOn)
+ {
+ asyncResp->res.jsonValue["IndicatorLED"] =
+ chassis::IndicatorLED::Lit;
+ }
+ else
+ {
+ asyncResp->res.jsonValue["IndicatorLED"] =
+ chassis::IndicatorLED::Off;
+ }
+ });
});
- });
}
/**
@@ -132,22 +132,23 @@
"xyz.openbmc_project.Led.Group", "Asserted", ledBlinkng,
[asyncResp, ledOn,
ledBlinkng](const boost::system::error_code& ec) mutable {
- if (ec)
- {
- // Some systems may not have enclosure_identify_blink object so
- // Lets set enclosure_identify state to true if Blinking is
- // true.
- if (ledBlinkng)
+ if (ec)
{
- ledOn = true;
+ // Some systems may not have enclosure_identify_blink object so
+ // Lets set enclosure_identify state to true if Blinking is
+ // true.
+ if (ledBlinkng)
+ {
+ ledOn = true;
+ }
}
- }
- setDbusProperty(
- asyncResp, "IndicatorLED", "xyz.openbmc_project.LED.GroupManager",
- sdbusplus::message::object_path(
- "/xyz/openbmc_project/led/groups/enclosure_identify"),
- "xyz.openbmc_project.Led.Group", "Asserted", ledBlinkng);
- });
+ setDbusProperty(
+ asyncResp, "IndicatorLED",
+ "xyz.openbmc_project.LED.GroupManager",
+ sdbusplus::message::object_path(
+ "/xyz/openbmc_project/led/groups/enclosure_identify"),
+ "xyz.openbmc_project.Led.Group", "Asserted", ledBlinkng);
+ });
}
/**
@@ -166,46 +167,46 @@
"/xyz/openbmc_project/led/groups/enclosure_identify_blink",
"xyz.openbmc_project.Led.Group", "Asserted",
[asyncResp](const boost::system::error_code& ec, const bool blinking) {
- // Some systems may not have enclosure_identify_blink object so
- // proceed to get enclosure_identify state.
- if (ec == boost::system::errc::invalid_argument)
- {
- BMCWEB_LOG_DEBUG(
- "Get identity blinking LED failed, mismatch in property type");
- messages::internalError(asyncResp->res);
- return;
- }
-
- // Blinking ON, no need to check enclosure_identify assert.
- if (!ec && blinking)
- {
- asyncResp->res.jsonValue["LocationIndicatorActive"] = true;
- return;
- }
-
- sdbusplus::asio::getProperty<bool>(
- *crow::connections::systemBus,
- "xyz.openbmc_project.LED.GroupManager",
- "/xyz/openbmc_project/led/groups/enclosure_identify",
- "xyz.openbmc_project.Led.Group", "Asserted",
- [asyncResp](const boost::system::error_code& ec2,
- const bool ledOn) {
- if (ec2 == boost::system::errc::invalid_argument)
+ // Some systems may not have enclosure_identify_blink object so
+ // proceed to get enclosure_identify state.
+ if (ec == boost::system::errc::invalid_argument)
{
BMCWEB_LOG_DEBUG(
- "Get enclosure identity led failed, mismatch in property type");
+ "Get identity blinking LED failed, mismatch in property type");
messages::internalError(asyncResp->res);
return;
}
- if (ec2)
+ // Blinking ON, no need to check enclosure_identify assert.
+ if (!ec && blinking)
{
+ asyncResp->res.jsonValue["LocationIndicatorActive"] = true;
return;
}
- asyncResp->res.jsonValue["LocationIndicatorActive"] = ledOn;
+ sdbusplus::asio::getProperty<bool>(
+ *crow::connections::systemBus,
+ "xyz.openbmc_project.LED.GroupManager",
+ "/xyz/openbmc_project/led/groups/enclosure_identify",
+ "xyz.openbmc_project.Led.Group", "Asserted",
+ [asyncResp](const boost::system::error_code& ec2,
+ const bool ledOn) {
+ if (ec2 == boost::system::errc::invalid_argument)
+ {
+ BMCWEB_LOG_DEBUG(
+ "Get enclosure identity led failed, mismatch in property type");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ if (ec2)
+ {
+ return;
+ }
+
+ asyncResp->res.jsonValue["LocationIndicatorActive"] = ledOn;
+ });
});
- });
}
/**
@@ -226,18 +227,18 @@
"/xyz/openbmc_project/led/groups/enclosure_identify_blink",
"xyz.openbmc_project.Led.Group", "Asserted", ledState,
[asyncResp, ledState](const boost::system::error_code& ec) {
- if (ec)
- {
- // Some systems may not have enclosure_identify_blink object so
- // lets set enclosure_identify state also if
- // enclosure_identify_blink failed
- setDbusProperty(
- asyncResp, "LocationIndicatorActive",
- "xyz.openbmc_project.LED.GroupManager",
- sdbusplus::message::object_path(
- "/xyz/openbmc_project/led/groups/enclosure_identify"),
- "xyz.openbmc_project.Led.Group", "Asserted", ledState);
- }
- });
+ if (ec)
+ {
+ // Some systems may not have enclosure_identify_blink object so
+ // lets set enclosure_identify state also if
+ // enclosure_identify_blink failed
+ setDbusProperty(
+ asyncResp, "LocationIndicatorActive",
+ "xyz.openbmc_project.LED.GroupManager",
+ sdbusplus::message::object_path(
+ "/xyz/openbmc_project/led/groups/enclosure_identify"),
+ "xyz.openbmc_project.Led.Group", "Asserted", ledState);
+ }
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index b5efd27..1fb88ea 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -359,102 +359,103 @@
[asyncResp, entriesPath,
dumpType](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& objects) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DumpEntry resp_handler got error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DumpEntry resp_handler got error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- // Remove ending slash
- std::string odataIdStr = entriesPath;
- if (!odataIdStr.empty())
- {
- odataIdStr.pop_back();
- }
+ // Remove ending slash
+ std::string odataIdStr = entriesPath;
+ if (!odataIdStr.empty())
+ {
+ odataIdStr.pop_back();
+ }
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogEntryCollection.LogEntryCollection";
- asyncResp->res.jsonValue["@odata.id"] = std::move(odataIdStr);
- asyncResp->res.jsonValue["Name"] = dumpType + " Dump Entries";
- asyncResp->res.jsonValue["Description"] = "Collection of " + dumpType +
- " Dump Entries";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogEntryCollection.LogEntryCollection";
+ asyncResp->res.jsonValue["@odata.id"] = std::move(odataIdStr);
+ asyncResp->res.jsonValue["Name"] = dumpType + " Dump Entries";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of " + dumpType + " Dump Entries";
- nlohmann::json::array_t entriesArray;
- std::string dumpEntryPath = getDumpPath(dumpType) + "/entry/";
+ nlohmann::json::array_t entriesArray;
+ std::string dumpEntryPath = getDumpPath(dumpType) + "/entry/";
- dbus::utility::ManagedObjectType resp(objects);
- std::ranges::sort(resp, [](const auto& l, const auto& r) {
- return AlphanumLess<std::string>()(l.first.filename(),
- r.first.filename());
+ dbus::utility::ManagedObjectType resp(objects);
+ std::ranges::sort(resp, [](const auto& l, const auto& r) {
+ return AlphanumLess<std::string>()(l.first.filename(),
+ r.first.filename());
+ });
+
+ for (auto& object : resp)
+ {
+ if (object.first.str.find(dumpEntryPath) == std::string::npos)
+ {
+ continue;
+ }
+ uint64_t timestampUs = 0;
+ uint64_t size = 0;
+ std::string dumpStatus;
+ std::string originatorId;
+ log_entry::OriginatorTypes originatorType =
+ log_entry::OriginatorTypes::Internal;
+ nlohmann::json::object_t thisEntry;
+
+ std::string entryID = object.first.filename();
+ if (entryID.empty())
+ {
+ continue;
+ }
+
+ parseDumpEntryFromDbusObject(object, dumpStatus, size,
+ timestampUs, originatorId,
+ originatorType, asyncResp);
+
+ if (dumpStatus !=
+ "xyz.openbmc_project.Common.Progress.OperationStatus.Completed" &&
+ !dumpStatus.empty())
+ {
+ // Dump status is not Complete, no need to enumerate
+ continue;
+ }
+
+ thisEntry["@odata.type"] = "#LogEntry.v1_11_0.LogEntry";
+ thisEntry["@odata.id"] = entriesPath + entryID;
+ thisEntry["Id"] = entryID;
+ thisEntry["EntryType"] = "Event";
+ thisEntry["Name"] = dumpType + " Dump Entry";
+ thisEntry["Created"] =
+ redfish::time_utils::getDateTimeUintUs(timestampUs);
+
+ if (!originatorId.empty())
+ {
+ thisEntry["Originator"] = originatorId;
+ thisEntry["OriginatorType"] = originatorType;
+ }
+
+ if (dumpType == "BMC")
+ {
+ thisEntry["DiagnosticDataType"] = "Manager";
+ thisEntry["AdditionalDataURI"] =
+ entriesPath + entryID + "/attachment";
+ thisEntry["AdditionalDataSizeBytes"] = size;
+ }
+ else if (dumpType == "System")
+ {
+ thisEntry["DiagnosticDataType"] = "OEM";
+ thisEntry["OEMDiagnosticDataType"] = "System";
+ thisEntry["AdditionalDataURI"] =
+ entriesPath + entryID + "/attachment";
+ thisEntry["AdditionalDataSizeBytes"] = size;
+ }
+ entriesArray.emplace_back(std::move(thisEntry));
+ }
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ entriesArray.size();
+ asyncResp->res.jsonValue["Members"] = std::move(entriesArray);
});
-
- for (auto& object : resp)
- {
- if (object.first.str.find(dumpEntryPath) == std::string::npos)
- {
- continue;
- }
- uint64_t timestampUs = 0;
- uint64_t size = 0;
- std::string dumpStatus;
- std::string originatorId;
- log_entry::OriginatorTypes originatorType =
- log_entry::OriginatorTypes::Internal;
- nlohmann::json::object_t thisEntry;
-
- std::string entryID = object.first.filename();
- if (entryID.empty())
- {
- continue;
- }
-
- parseDumpEntryFromDbusObject(object, dumpStatus, size, timestampUs,
- originatorId, originatorType,
- asyncResp);
-
- if (dumpStatus !=
- "xyz.openbmc_project.Common.Progress.OperationStatus.Completed" &&
- !dumpStatus.empty())
- {
- // Dump status is not Complete, no need to enumerate
- continue;
- }
-
- thisEntry["@odata.type"] = "#LogEntry.v1_11_0.LogEntry";
- thisEntry["@odata.id"] = entriesPath + entryID;
- thisEntry["Id"] = entryID;
- thisEntry["EntryType"] = "Event";
- thisEntry["Name"] = dumpType + " Dump Entry";
- thisEntry["Created"] =
- redfish::time_utils::getDateTimeUintUs(timestampUs);
-
- if (!originatorId.empty())
- {
- thisEntry["Originator"] = originatorId;
- thisEntry["OriginatorType"] = originatorType;
- }
-
- if (dumpType == "BMC")
- {
- thisEntry["DiagnosticDataType"] = "Manager";
- thisEntry["AdditionalDataURI"] = entriesPath + entryID +
- "/attachment";
- thisEntry["AdditionalDataSizeBytes"] = size;
- }
- else if (dumpType == "System")
- {
- thisEntry["DiagnosticDataType"] = "OEM";
- thisEntry["OEMDiagnosticDataType"] = "System";
- thisEntry["AdditionalDataURI"] = entriesPath + entryID +
- "/attachment";
- thisEntry["AdditionalDataSizeBytes"] = size;
- }
- entriesArray.emplace_back(std::move(thisEntry));
- }
- asyncResp->res.jsonValue["Members@odata.count"] = entriesArray.size();
- asyncResp->res.jsonValue["Members"] = std::move(entriesArray);
- });
}
inline void
@@ -474,85 +475,86 @@
[asyncResp, entryID, dumpType,
entriesPath](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DumpEntry resp_handler got error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
-
- bool foundDumpEntry = false;
- std::string dumpEntryPath = getDumpPath(dumpType) + "/entry/";
-
- for (const auto& objectPath : resp)
- {
- if (objectPath.first.str != dumpEntryPath + entryID)
+ if (ec)
{
- continue;
+ BMCWEB_LOG_ERROR("DumpEntry resp_handler got error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
}
- foundDumpEntry = true;
- uint64_t timestampUs = 0;
- uint64_t size = 0;
- std::string dumpStatus;
- std::string originatorId;
- log_entry::OriginatorTypes originatorType =
- log_entry::OriginatorTypes::Internal;
+ bool foundDumpEntry = false;
+ std::string dumpEntryPath = getDumpPath(dumpType) + "/entry/";
- parseDumpEntryFromDbusObject(objectPath, dumpStatus, size,
- timestampUs, originatorId,
- originatorType, asyncResp);
-
- if (dumpStatus !=
- "xyz.openbmc_project.Common.Progress.OperationStatus.Completed" &&
- !dumpStatus.empty())
+ for (const auto& objectPath : resp)
{
- // Dump status is not Complete
- // return not found until status is changed to Completed
+ if (objectPath.first.str != dumpEntryPath + entryID)
+ {
+ continue;
+ }
+
+ foundDumpEntry = true;
+ uint64_t timestampUs = 0;
+ uint64_t size = 0;
+ std::string dumpStatus;
+ std::string originatorId;
+ log_entry::OriginatorTypes originatorType =
+ log_entry::OriginatorTypes::Internal;
+
+ parseDumpEntryFromDbusObject(objectPath, dumpStatus, size,
+ timestampUs, originatorId,
+ originatorType, asyncResp);
+
+ if (dumpStatus !=
+ "xyz.openbmc_project.Common.Progress.OperationStatus.Completed" &&
+ !dumpStatus.empty())
+ {
+ // Dump status is not Complete
+ // return not found until status is changed to Completed
+ messages::resourceNotFound(asyncResp->res,
+ dumpType + " dump", entryID);
+ return;
+ }
+
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogEntry.v1_11_0.LogEntry";
+ asyncResp->res.jsonValue["@odata.id"] = entriesPath + entryID;
+ asyncResp->res.jsonValue["Id"] = entryID;
+ asyncResp->res.jsonValue["EntryType"] = "Event";
+ asyncResp->res.jsonValue["Name"] = dumpType + " Dump Entry";
+ asyncResp->res.jsonValue["Created"] =
+ redfish::time_utils::getDateTimeUintUs(timestampUs);
+
+ if (!originatorId.empty())
+ {
+ asyncResp->res.jsonValue["Originator"] = originatorId;
+ asyncResp->res.jsonValue["OriginatorType"] = originatorType;
+ }
+
+ if (dumpType == "BMC")
+ {
+ asyncResp->res.jsonValue["DiagnosticDataType"] = "Manager";
+ asyncResp->res.jsonValue["AdditionalDataURI"] =
+ entriesPath + entryID + "/attachment";
+ asyncResp->res.jsonValue["AdditionalDataSizeBytes"] = size;
+ }
+ else if (dumpType == "System")
+ {
+ asyncResp->res.jsonValue["DiagnosticDataType"] = "OEM";
+ asyncResp->res.jsonValue["OEMDiagnosticDataType"] =
+ "System";
+ asyncResp->res.jsonValue["AdditionalDataURI"] =
+ entriesPath + entryID + "/attachment";
+ asyncResp->res.jsonValue["AdditionalDataSizeBytes"] = size;
+ }
+ }
+ if (!foundDumpEntry)
+ {
+ BMCWEB_LOG_WARNING("Can't find Dump Entry {}", entryID);
messages::resourceNotFound(asyncResp->res, dumpType + " dump",
entryID);
return;
}
-
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogEntry.v1_11_0.LogEntry";
- asyncResp->res.jsonValue["@odata.id"] = entriesPath + entryID;
- asyncResp->res.jsonValue["Id"] = entryID;
- asyncResp->res.jsonValue["EntryType"] = "Event";
- asyncResp->res.jsonValue["Name"] = dumpType + " Dump Entry";
- asyncResp->res.jsonValue["Created"] =
- redfish::time_utils::getDateTimeUintUs(timestampUs);
-
- if (!originatorId.empty())
- {
- asyncResp->res.jsonValue["Originator"] = originatorId;
- asyncResp->res.jsonValue["OriginatorType"] = originatorType;
- }
-
- if (dumpType == "BMC")
- {
- asyncResp->res.jsonValue["DiagnosticDataType"] = "Manager";
- asyncResp->res.jsonValue["AdditionalDataURI"] =
- entriesPath + entryID + "/attachment";
- asyncResp->res.jsonValue["AdditionalDataSizeBytes"] = size;
- }
- else if (dumpType == "System")
- {
- asyncResp->res.jsonValue["DiagnosticDataType"] = "OEM";
- asyncResp->res.jsonValue["OEMDiagnosticDataType"] = "System";
- asyncResp->res.jsonValue["AdditionalDataURI"] =
- entriesPath + entryID + "/attachment";
- asyncResp->res.jsonValue["AdditionalDataSizeBytes"] = size;
- }
- }
- if (!foundDumpEntry)
- {
- BMCWEB_LOG_WARNING("Can't find Dump Entry {}", entryID);
- messages::resourceNotFound(asyncResp->res, dumpType + " dump",
- entryID);
- return;
- }
- });
+ });
}
inline void deleteDumpEntry(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -611,12 +613,11 @@
}
return true;
}
-inline void
- downloadEntryCallback(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& entryID,
- const std::string& downloadEntryType,
- const boost::system::error_code& ec,
- const sdbusplus::message::unix_fd& unixfd)
+inline void downloadEntryCallback(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& entryID, const std::string& downloadEntryType,
+ const boost::system::error_code& ec,
+ const sdbusplus::message::unix_fd& unixfd)
{
if (ec.value() == EBADR)
{
@@ -684,26 +685,25 @@
return;
}
- std::string dumpEntryPath = std::format("{}/entry/{}",
- getDumpPath(dumpType), entryID);
+ std::string dumpEntryPath =
+ std::format("{}/entry/{}", getDumpPath(dumpType), entryID);
auto downloadDumpEntryHandler =
[asyncResp, entryID,
dumpType](const boost::system::error_code& ec,
const sdbusplus::message::unix_fd& unixfd) {
- downloadEntryCallback(asyncResp, entryID, dumpType, ec, unixfd);
- };
+ downloadEntryCallback(asyncResp, entryID, dumpType, ec, unixfd);
+ };
crow::connections::systemBus->async_method_call(
std::move(downloadDumpEntryHandler), "xyz.openbmc_project.Dump.Manager",
dumpEntryPath, "xyz.openbmc_project.Dump.Entry", "GetFileHandle");
}
-inline void
- downloadEventLogEntry(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName,
- const std::string& entryID,
- const std::string& dumpType)
+inline void downloadEventLogEntry(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName, const std::string& entryID,
+ const std::string& dumpType)
{
if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
@@ -727,8 +727,8 @@
[asyncResp, entryID,
dumpType](const boost::system::error_code& ec,
const sdbusplus::message::unix_fd& unixfd) {
- downloadEntryCallback(asyncResp, entryID, dumpType, ec, unixfd);
- };
+ downloadEntryCallback(asyncResp, entryID, dumpType, ec, unixfd);
+ };
crow::connections::systemBus->async_method_call(
std::move(downloadEventLogEntryHandler), "xyz.openbmc_project.Logging",
@@ -808,114 +808,121 @@
dumpEntryPath{std::move(dumpEntryPath)},
dumpId](const boost::system::error_code& ec,
const std::string& introspectXml) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Introspect call failed with error: {}",
- ec.message());
- messages::internalError(asyncResp->res);
- return;
- }
-
- // Check if the created dump object has implemented Progress
- // interface to track dump completion. If yes, fetch the "Status"
- // property of the interface, modify the task state accordingly.
- // Else, return task completed.
- tinyxml2::XMLDocument doc;
-
- doc.Parse(introspectXml.data(), introspectXml.size());
- tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node");
- if (pRoot == nullptr)
- {
- BMCWEB_LOG_ERROR("XML document failed to parse");
- messages::internalError(asyncResp->res);
- return;
- }
- tinyxml2::XMLElement* interfaceNode =
- pRoot->FirstChildElement("interface");
-
- bool isProgressIntfPresent = false;
- while (interfaceNode != nullptr)
- {
- const char* thisInterfaceName = interfaceNode->Attribute("name");
- if (thisInterfaceName != nullptr)
+ if (ec)
{
- if (thisInterfaceName ==
- std::string_view("xyz.openbmc_project.Common.Progress"))
+ BMCWEB_LOG_ERROR("Introspect call failed with error: {}",
+ ec.message());
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ // Check if the created dump object has implemented Progress
+ // interface to track dump completion. If yes, fetch the "Status"
+ // property of the interface, modify the task state accordingly.
+ // Else, return task completed.
+ tinyxml2::XMLDocument doc;
+
+ doc.Parse(introspectXml.data(), introspectXml.size());
+ tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node");
+ if (pRoot == nullptr)
+ {
+ BMCWEB_LOG_ERROR("XML document failed to parse");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ tinyxml2::XMLElement* interfaceNode =
+ pRoot->FirstChildElement("interface");
+
+ bool isProgressIntfPresent = false;
+ while (interfaceNode != nullptr)
+ {
+ const char* thisInterfaceName =
+ interfaceNode->Attribute("name");
+ if (thisInterfaceName != nullptr)
{
- interfaceNode =
- interfaceNode->NextSiblingElement("interface");
- continue;
+ if (thisInterfaceName ==
+ std::string_view("xyz.openbmc_project.Common.Progress"))
+ {
+ interfaceNode =
+ interfaceNode->NextSiblingElement("interface");
+ continue;
+ }
+ isProgressIntfPresent = true;
+ break;
}
- isProgressIntfPresent = true;
- break;
- }
- interfaceNode = interfaceNode->NextSiblingElement("interface");
- }
-
- std::shared_ptr<task::TaskData> task = task::TaskData::createTask(
- [createdObjPath, dumpEntryPath, dumpId, isProgressIntfPresent](
- const boost::system::error_code& ec2, sdbusplus::message_t& msg,
- const std::shared_ptr<task::TaskData>& taskData) {
- if (ec2)
- {
- BMCWEB_LOG_ERROR("{}: Error in creating dump",
- createdObjPath.str);
- taskData->messages.emplace_back(messages::internalError());
- taskData->state = "Cancelled";
- return task::completed;
+ interfaceNode = interfaceNode->NextSiblingElement("interface");
}
- if (isProgressIntfPresent)
- {
- dbus::utility::DBusPropertiesMap values;
- std::string prop;
- msg.read(prop, values);
+ std::shared_ptr<task::TaskData> task = task::TaskData::createTask(
+ [createdObjPath, dumpEntryPath, dumpId, isProgressIntfPresent](
+ const boost::system::error_code& ec2,
+ sdbusplus::message_t& msg,
+ const std::shared_ptr<task::TaskData>& taskData) {
+ if (ec2)
+ {
+ BMCWEB_LOG_ERROR("{}: Error in creating dump",
+ createdObjPath.str);
+ taskData->messages.emplace_back(
+ messages::internalError());
+ taskData->state = "Cancelled";
+ return task::completed;
+ }
- DumpCreationProgress dumpStatus =
- getDumpCompletionStatus(values);
- if (dumpStatus == DumpCreationProgress::DUMP_CREATE_FAILED)
- {
- BMCWEB_LOG_ERROR("{}: Error in creating dump",
+ if (isProgressIntfPresent)
+ {
+ dbus::utility::DBusPropertiesMap values;
+ std::string prop;
+ msg.read(prop, values);
+
+ DumpCreationProgress dumpStatus =
+ getDumpCompletionStatus(values);
+ if (dumpStatus ==
+ DumpCreationProgress::DUMP_CREATE_FAILED)
+ {
+ BMCWEB_LOG_ERROR("{}: Error in creating dump",
+ createdObjPath.str);
+ taskData->state = "Cancelled";
+ return task::completed;
+ }
+
+ if (dumpStatus ==
+ DumpCreationProgress::DUMP_CREATE_INPROGRESS)
+ {
+ BMCWEB_LOG_DEBUG(
+ "{}: Dump creation task is in progress",
+ createdObjPath.str);
+ return !task::completed;
+ }
+ }
+
+ nlohmann::json retMessage = messages::success();
+ taskData->messages.emplace_back(retMessage);
+
+ boost::urls::url url = boost::urls::format(
+ "/redfish/v1/Managers/{}/LogServices/Dump/Entries/{}",
+ BMCWEB_REDFISH_MANAGER_URI_NAME, dumpId);
+
+ std::string headerLoc = "Location: ";
+ headerLoc += url.buffer();
+
+ taskData->payload->httpHeaders.emplace_back(
+ std::move(headerLoc));
+
+ BMCWEB_LOG_DEBUG("{}: Dump creation task completed",
createdObjPath.str);
- taskData->state = "Cancelled";
+ taskData->state = "Completed";
return task::completed;
- }
+ },
+ "type='signal',interface='org.freedesktop.DBus.Properties',"
+ "member='PropertiesChanged',path='" +
+ createdObjPath.str + "'");
- if (dumpStatus == DumpCreationProgress::DUMP_CREATE_INPROGRESS)
- {
- BMCWEB_LOG_DEBUG("{}: Dump creation task is in progress",
- createdObjPath.str);
- return !task::completed;
- }
- }
-
- nlohmann::json retMessage = messages::success();
- taskData->messages.emplace_back(retMessage);
-
- boost::urls::url url = boost::urls::format(
- "/redfish/v1/Managers/{}/LogServices/Dump/Entries/{}",
- BMCWEB_REDFISH_MANAGER_URI_NAME, dumpId);
-
- std::string headerLoc = "Location: ";
- headerLoc += url.buffer();
-
- taskData->payload->httpHeaders.emplace_back(std::move(headerLoc));
-
- BMCWEB_LOG_DEBUG("{}: Dump creation task completed",
- createdObjPath.str);
- taskData->state = "Completed";
- return task::completed;
+ // The task timer is set to max time limit within which the
+ // requested dump will be collected.
+ task->startTimer(std::chrono::minutes(6));
+ task->populateResp(asyncResp->res);
+ task->payload.emplace(payload);
},
- "type='signal',interface='org.freedesktop.DBus.Properties',"
- "member='PropertiesChanged',path='" +
- createdObjPath.str + "'");
-
- // The task timer is set to max time limit within which the
- // requested dump will be collected.
- task->startTimer(std::chrono::minutes(6));
- task->populateResp(asyncResp->res);
- task->payload.emplace(payload);
- },
"xyz.openbmc_project.Dump.Manager", createdObjPath,
"org.freedesktop.DBus.Introspectable", "Introspect");
}
@@ -1006,52 +1013,52 @@
dumpPath](const boost::system::error_code& ec,
const sdbusplus::message_t& msg,
const sdbusplus::message::object_path& objPath) mutable {
- if (ec)
- {
- BMCWEB_LOG_ERROR("CreateDump resp_handler got error {}", ec);
- const sd_bus_error* dbusError = msg.get_error();
- if (dbusError == nullptr)
+ if (ec)
{
+ BMCWEB_LOG_ERROR("CreateDump resp_handler got error {}", ec);
+ const sd_bus_error* dbusError = msg.get_error();
+ if (dbusError == nullptr)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ BMCWEB_LOG_ERROR("CreateDump DBus error: {} and error msg: {}",
+ dbusError->name, dbusError->message);
+ if (std::string_view(
+ "xyz.openbmc_project.Common.Error.NotAllowed") ==
+ dbusError->name)
+ {
+ messages::resourceInStandby(asyncResp->res);
+ return;
+ }
+ if (std::string_view(
+ "xyz.openbmc_project.Dump.Create.Error.Disabled") ==
+ dbusError->name)
+ {
+ messages::serviceDisabled(asyncResp->res, dumpPath);
+ return;
+ }
+ if (std::string_view(
+ "xyz.openbmc_project.Common.Error.Unavailable") ==
+ dbusError->name)
+ {
+ messages::resourceInUse(asyncResp->res);
+ return;
+ }
+ // Other Dbus errors such as:
+ // xyz.openbmc_project.Common.Error.InvalidArgument &
+ // org.freedesktop.DBus.Error.InvalidArgs are all related to
+ // the dbus call that is made here in the bmcweb
+ // implementation and has nothing to do with the client's
+ // input in the request. Hence, returning internal error
+ // back to the client.
messages::internalError(asyncResp->res);
return;
}
-
- BMCWEB_LOG_ERROR("CreateDump DBus error: {} and error msg: {}",
- dbusError->name, dbusError->message);
- if (std::string_view(
- "xyz.openbmc_project.Common.Error.NotAllowed") ==
- dbusError->name)
- {
- messages::resourceInStandby(asyncResp->res);
- return;
- }
- if (std::string_view(
- "xyz.openbmc_project.Dump.Create.Error.Disabled") ==
- dbusError->name)
- {
- messages::serviceDisabled(asyncResp->res, dumpPath);
- return;
- }
- if (std::string_view(
- "xyz.openbmc_project.Common.Error.Unavailable") ==
- dbusError->name)
- {
- messages::resourceInUse(asyncResp->res);
- return;
- }
- // Other Dbus errors such as:
- // xyz.openbmc_project.Common.Error.InvalidArgument &
- // org.freedesktop.DBus.Error.InvalidArgs are all related to
- // the dbus call that is made here in the bmcweb
- // implementation and has nothing to do with the client's
- // input in the request. Hence, returning internal error
- // back to the client.
- messages::internalError(asyncResp->res);
- return;
- }
- BMCWEB_LOG_DEBUG("Dump Created. Path: {}", objPath.str);
- createDumpTaskCallback(std::move(payload), asyncResp, objPath);
- },
+ BMCWEB_LOG_DEBUG("Dump Created. Path: {}", objPath.str);
+ createDumpTaskCallback(std::move(payload), asyncResp, objPath);
+ },
"xyz.openbmc_project.Dump.Manager", getDumpPath(dumpType),
"xyz.openbmc_project.Dump.Create", "CreateDump", createDumpParamVec);
}
@@ -1061,21 +1068,20 @@
{
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("clearDump resp_handler got error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- },
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("clearDump resp_handler got error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ },
"xyz.openbmc_project.Dump.Manager", getDumpPath(dumpType),
"xyz.openbmc_project.Collection.DeleteAll", "DeleteAll");
}
-inline void
- parseCrashdumpParameters(const dbus::utility::DBusPropertiesMap& params,
- std::string& filename, std::string& timestamp,
- std::string& logfile)
+inline void parseCrashdumpParameters(
+ const dbus::utility::DBusPropertiesMap& params, std::string& filename,
+ std::string& timestamp, std::string& logfile)
{
const std::string* filenamePtr = nullptr;
const std::string* timestampPtr = nullptr;
@@ -1113,154 +1119,160 @@
*/
BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/")
.privileges(redfish::privileges::getLogServiceCollection)
- .methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
-
- // Collections don't include the static data added by SubRoute
- // because it has a duplicate entry for members
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogServiceCollection.LogServiceCollection";
- asyncResp->res.jsonValue["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- asyncResp->res.jsonValue["Name"] = "System Log Services Collection";
- asyncResp->res.jsonValue["Description"] =
- "Collection of LogServices for this Computer System";
- nlohmann::json& logServiceArray = asyncResp->res.jsonValue["Members"];
- logServiceArray = nlohmann::json::array();
- nlohmann::json::object_t eventLog;
- eventLog["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/EventLog",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- logServiceArray.emplace_back(std::move(eventLog));
- if constexpr (BMCWEB_REDFISH_DUMP_LOG)
- {
- nlohmann::json::object_t dumpLog;
- dumpLog["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/Dump",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- logServiceArray.emplace_back(std::move(dumpLog));
- }
-
- if constexpr (BMCWEB_REDFISH_CPU_LOG)
- {
- nlohmann::json::object_t crashdump;
- crashdump["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/Crashdump",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- logServiceArray.emplace_back(std::move(crashdump));
- }
-
- if constexpr (BMCWEB_REDFISH_HOST_LOGGER)
- {
- nlohmann::json::object_t hostlogger;
- hostlogger["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/HostLogger",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- logServiceArray.emplace_back(std::move(hostlogger));
- }
- asyncResp->res.jsonValue["Members@odata.count"] =
- logServiceArray.size();
-
- constexpr std::array<std::string_view, 1> interfaces = {
- "xyz.openbmc_project.State.Boot.PostCode"};
- dbus::utility::getSubTreePaths(
- "/", 0, interfaces,
- [asyncResp](const boost::system::error_code& ec,
- const dbus::utility::MapperGetSubTreePathsResponse&
- subtreePath) {
- if (ec)
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
- BMCWEB_LOG_ERROR("{}", ec);
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
return;
}
- for (const auto& pathStr : subtreePath)
+ // Collections don't include the static data added by SubRoute
+ // because it has a duplicate entry for members
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogServiceCollection.LogServiceCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ std::format("/redfish/v1/Systems/{}/LogServices",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ asyncResp->res.jsonValue["Name"] = "System Log Services Collection";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of LogServices for this Computer System";
+ nlohmann::json& logServiceArray =
+ asyncResp->res.jsonValue["Members"];
+ logServiceArray = nlohmann::json::array();
+ nlohmann::json::object_t eventLog;
+ eventLog["@odata.id"] =
+ std::format("/redfish/v1/Systems/{}/LogServices/EventLog",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ logServiceArray.emplace_back(std::move(eventLog));
+ if constexpr (BMCWEB_REDFISH_DUMP_LOG)
{
- if (pathStr.find("PostCode") != std::string::npos)
- {
- nlohmann::json& logServiceArrayLocal =
- asyncResp->res.jsonValue["Members"];
- nlohmann::json::object_t member;
- member["@odata.id"] = std::format(
- "/redfish/v1/Systems/{}/LogServices/PostCodes",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
-
- logServiceArrayLocal.emplace_back(std::move(member));
-
- asyncResp->res.jsonValue["Members@odata.count"] =
- logServiceArrayLocal.size();
- return;
- }
+ nlohmann::json::object_t dumpLog;
+ dumpLog["@odata.id"] =
+ std::format("/redfish/v1/Systems/{}/LogServices/Dump",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ logServiceArray.emplace_back(std::move(dumpLog));
}
+
+ if constexpr (BMCWEB_REDFISH_CPU_LOG)
+ {
+ nlohmann::json::object_t crashdump;
+ crashdump["@odata.id"] =
+ std::format("/redfish/v1/Systems/{}/LogServices/Crashdump",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ logServiceArray.emplace_back(std::move(crashdump));
+ }
+
+ if constexpr (BMCWEB_REDFISH_HOST_LOGGER)
+ {
+ nlohmann::json::object_t hostlogger;
+ hostlogger["@odata.id"] =
+ std::format("/redfish/v1/Systems/{}/LogServices/HostLogger",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ logServiceArray.emplace_back(std::move(hostlogger));
+ }
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ logServiceArray.size();
+
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.State.Boot.PostCode"};
+ dbus::utility::getSubTreePaths(
+ "/", 0, interfaces,
+ [asyncResp](const boost::system::error_code& ec,
+ const dbus::utility::MapperGetSubTreePathsResponse&
+ subtreePath) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("{}", ec);
+ return;
+ }
+
+ for (const auto& pathStr : subtreePath)
+ {
+ if (pathStr.find("PostCode") != std::string::npos)
+ {
+ nlohmann::json& logServiceArrayLocal =
+ asyncResp->res.jsonValue["Members"];
+ nlohmann::json::object_t member;
+ member["@odata.id"] = std::format(
+ "/redfish/v1/Systems/{}/LogServices/PostCodes",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+
+ logServiceArrayLocal.emplace_back(
+ std::move(member));
+
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ logServiceArrayLocal.size();
+ return;
+ }
+ }
+ });
});
- });
}
inline void requestRoutesEventLogService(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/EventLog/")
.privileges(redfish::privileges::getLogService)
- .methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- asyncResp->res.jsonValue["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/EventLog",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogService.v1_2_0.LogService";
- asyncResp->res.jsonValue["Name"] = "Event Log Service";
- asyncResp->res.jsonValue["Description"] = "System Event Log Service";
- asyncResp->res.jsonValue["Id"] = "EventLog";
- asyncResp->res.jsonValue["OverWritePolicy"] =
- log_service::OverWritePolicy::WrapsWhenFull;
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.id"] =
+ std::format("/redfish/v1/Systems/{}/LogServices/EventLog",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogService.v1_2_0.LogService";
+ asyncResp->res.jsonValue["Name"] = "Event Log Service";
+ asyncResp->res.jsonValue["Description"] =
+ "System Event Log Service";
+ asyncResp->res.jsonValue["Id"] = "EventLog";
+ asyncResp->res.jsonValue["OverWritePolicy"] =
+ log_service::OverWritePolicy::WrapsWhenFull;
- std::pair<std::string, std::string> redfishDateTimeOffset =
- redfish::time_utils::getDateTimeOffsetNow();
+ std::pair<std::string, std::string> redfishDateTimeOffset =
+ redfish::time_utils::getDateTimeOffsetNow();
- asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
- asyncResp->res.jsonValue["DateTimeLocalOffset"] =
- redfishDateTimeOffset.second;
+ asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
+ asyncResp->res.jsonValue["DateTimeLocalOffset"] =
+ redfishDateTimeOffset.second;
- asyncResp->res.jsonValue["Entries"]["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/EventLog/Entries",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- asyncResp->res.jsonValue["Actions"]["#LogService.ClearLog"]["target"]
-
- = std::format(
- "/redfish/v1/Systems/{}/LogServices/EventLog/Actions/LogService.ClearLog",
+ asyncResp->res.jsonValue["Entries"]["@odata.id"] = std::format(
+ "/redfish/v1/Systems/{}/LogServices/EventLog/Entries",
BMCWEB_REDFISH_SYSTEM_URI_NAME);
- });
+ asyncResp->res
+ .jsonValue["Actions"]["#LogService.ClearLog"]["target"]
+
+ = std::format(
+ "/redfish/v1/Systems/{}/LogServices/EventLog/Actions/LogService.ClearLog",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ });
}
inline void handleSystemsLogServicesEventLogActionsClearPost(
@@ -1293,15 +1305,15 @@
// Reload rsyslog so it knows to start new log files
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Failed to reload rsyslog: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("Failed to reload rsyslog: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- messages::success(asyncResp->res);
- },
+ messages::success(asyncResp->res);
+ },
"org.freedesktop.systemd1", "/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager", "ReloadUnit", "rsyslog.service",
"replace");
@@ -1324,10 +1336,9 @@
messageIdNotInRegistry,
};
-static LogParseError
- fillEventLogEntryJson(const std::string& logEntryID,
- const std::string& logEntry,
- nlohmann::json::object_t& logEntryJson)
+static LogParseError fillEventLogEntryJson(
+ const std::string& logEntryID, const std::string& logEntry,
+ nlohmann::json::object_t& logEntryJson)
{
// The redfish log format is "<Timestamp> <MessageId>,<MessageArgs>"
// First get the Timestamp
@@ -1369,8 +1380,8 @@
logEntryFields.end());
messageArgs.resize(message->numberOfArgs);
- std::string msg = redfish::registries::fillMessageArgs(messageArgs,
- message->message);
+ std::string msg =
+ redfish::registries::fillMessageArgs(messageArgs, message->message);
if (msg.empty())
{
return LogParseError::parseFailed;
@@ -1485,10 +1496,10 @@
for (const auto& objectPath : resp)
{
dbus::utility::DBusPropertiesMap propsFlattened;
- auto isEntry = std::ranges::find_if(objectPath.second,
- [](const auto& object) {
- return object.first == "xyz.openbmc_project.Logging.Entry";
- });
+ auto isEntry =
+ std::ranges::find_if(objectPath.second, [](const auto& object) {
+ return object.first == "xyz.openbmc_project.Logging.Entry";
+ });
if (isEntry == objectPath.second.end())
{
continue;
@@ -1587,8 +1598,8 @@
firstEntry = false;
nlohmann::json::object_t bmcLogEntry;
- LogParseError status = fillEventLogEntryJson(idStr, logEntry,
- bmcLogEntry);
+ LogParseError status =
+ fillEventLogEntryJson(idStr, logEntry, bmcLogEntry);
if (status == LogParseError::messageIdNotInRegistry)
{
continue;
@@ -1684,8 +1695,8 @@
if (idStr == targetID)
{
nlohmann::json::object_t bmcLogEntry;
- LogParseError status = fillEventLogEntryJson(idStr, logEntry,
- bmcLogEntry);
+ LogParseError status =
+ fillEventLogEntryJson(idStr, logEntry, bmcLogEntry);
if (status != LogParseError::success)
{
messages::internalError(asyncResp->res);
@@ -1730,8 +1741,8 @@
"xyz.openbmc_project.Logging", path,
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) {
- afterLogEntriesGetManagedObjects(asyncResp, ec, resp);
- });
+ afterLogEntriesGetManagedObjects(asyncResp, ec, resp);
+ });
}
inline void requestRoutesDBusEventLogEntryCollection(App& app)
@@ -1742,30 +1753,29 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- dBusEventLogEntryCollection(asyncResp);
- });
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ dBusEventLogEntryCollection(asyncResp);
+ });
}
-inline void
- dBusEventLogEntryGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- std::string entryID)
+inline void dBusEventLogEntryGet(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, std::string entryID)
{
dbus::utility::escapePathForDbus(entryID);
@@ -1776,23 +1786,23 @@
"/xyz/openbmc_project/logging/entry/" + entryID, "",
[asyncResp, entryID](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& resp) {
- if (ec.value() == EBADR)
- {
- messages::resourceNotFound(asyncResp->res, "EventLogEntry",
- entryID);
- return;
- }
- if (ec)
- {
- BMCWEB_LOG_ERROR("EventLogEntry (DBus) resp_handler got error {}",
- ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec.value() == EBADR)
+ {
+ messages::resourceNotFound(asyncResp->res, "EventLogEntry",
+ entryID);
+ return;
+ }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR(
+ "EventLogEntry (DBus) resp_handler got error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- fillEventLogLogEntryFromPropertyMap(asyncResp, resp,
- asyncResp->res.jsonValue);
- });
+ fillEventLogLogEntryFromPropertyMap(asyncResp, resp,
+ asyncResp->res.jsonValue);
+ });
}
inline void
@@ -1814,9 +1824,8 @@
resolved.value_or(false));
}
-inline void
- dBusEventLogEntryDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- std::string entryID)
+inline void dBusEventLogEntryDelete(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, std::string entryID)
{
BMCWEB_LOG_DEBUG("Do delete single event entries.");
@@ -1860,26 +1869,26 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName, const std::string& entryId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- dBusEventLogEntryGet(asyncResp, entryId);
- });
+ dBusEventLogEntryGet(asyncResp, entryId);
+ });
BMCWEB_ROUTE(
app, "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/<str>/")
@@ -1888,26 +1897,26 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName, const std::string& entryId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- dBusEventLogEntryPatch(req, asyncResp, entryId);
- });
+ dBusEventLogEntryPatch(req, asyncResp, entryId);
+ });
BMCWEB_ROUTE(
app, "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/<str>/")
@@ -1917,25 +1926,25 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName, const std::string& param) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- dBusEventLogEntryDelete(asyncResp, param);
- });
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ dBusEventLogEntryDelete(asyncResp, param);
+ });
}
constexpr const char* hostLoggerFolderPath = "/var/log/console";
@@ -2023,35 +2032,35 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- asyncResp->res.jsonValue["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/HostLogger",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogService.v1_2_0.LogService";
- asyncResp->res.jsonValue["Name"] = "Host Logger Service";
- asyncResp->res.jsonValue["Description"] = "Host Logger Service";
- asyncResp->res.jsonValue["Id"] = "HostLogger";
- asyncResp->res.jsonValue["Entries"]["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/HostLogger/Entries",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- });
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.id"] =
+ std::format("/redfish/v1/Systems/{}/LogServices/HostLogger",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogService.v1_2_0.LogService";
+ asyncResp->res.jsonValue["Name"] = "Host Logger Service";
+ asyncResp->res.jsonValue["Description"] = "Host Logger Service";
+ asyncResp->res.jsonValue["Id"] = "HostLogger";
+ asyncResp->res.jsonValue["Entries"]["@odata.id"] = std::format(
+ "/redfish/v1/Systems/{}/LogServices/HostLogger/Entries",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ });
}
inline void requestRoutesSystemHostLoggerCollection(App& app)
@@ -2059,92 +2068,94 @@
BMCWEB_ROUTE(app,
"/redfish/v1/Systems/<str>/LogServices/HostLogger/Entries/")
.privileges(redfish::privileges::getLogEntry)
- .methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName) {
- query_param::QueryCapabilities capabilities = {
- .canDelegateTop = true,
- .canDelegateSkip = true,
- };
- query_param::Query delegatedQuery;
- if (!redfish::setUpRedfishRouteWithDelegation(
- app, req, asyncResp, delegatedQuery, capabilities))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- asyncResp->res.jsonValue["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/HostLogger/Entries",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogEntryCollection.LogEntryCollection";
- asyncResp->res.jsonValue["Name"] = "HostLogger Entries";
- asyncResp->res.jsonValue["Description"] =
- "Collection of HostLogger Entries";
- nlohmann::json& logEntryArray = asyncResp->res.jsonValue["Members"];
- logEntryArray = nlohmann::json::array();
- asyncResp->res.jsonValue["Members@odata.count"] = 0;
-
- std::vector<std::filesystem::path> hostLoggerFiles;
- if (!getHostLoggerFiles(hostLoggerFolderPath, hostLoggerFiles))
- {
- BMCWEB_LOG_DEBUG("Failed to get host log file path");
- return;
- }
- // If we weren't provided top and skip limits, use the defaults.
- size_t skip = delegatedQuery.skip.value_or(0);
- size_t top = delegatedQuery.top.value_or(query_param::Query::maxTop);
- size_t logCount = 0;
- // This vector only store the entries we want to expose that
- // control by skip and top.
- std::vector<std::string> logEntries;
- if (!getHostLoggerEntries(hostLoggerFiles, skip, top, logEntries,
- logCount))
- {
- messages::internalError(asyncResp->res);
- return;
- }
- // If vector is empty, that means skip value larger than total
- // log count
- if (logEntries.empty())
- {
- asyncResp->res.jsonValue["Members@odata.count"] = logCount;
- return;
- }
- if (!logEntries.empty())
- {
- for (size_t i = 0; i < logEntries.size(); i++)
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName) {
+ query_param::QueryCapabilities capabilities = {
+ .canDelegateTop = true,
+ .canDelegateSkip = true,
+ };
+ query_param::Query delegatedQuery;
+ if (!redfish::setUpRedfishRouteWithDelegation(
+ app, req, asyncResp, delegatedQuery, capabilities))
{
- nlohmann::json::object_t hostLogEntry;
- fillHostLoggerEntryJson(std::to_string(skip + i), logEntries[i],
- hostLogEntry);
- logEntryArray.emplace_back(std::move(hostLogEntry));
+ return;
}
-
- asyncResp->res.jsonValue["Members@odata.count"] = logCount;
- if (skip + top < logCount)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
- asyncResp->res.jsonValue["Members@odata.nextLink"] =
- std::format(
- "/redfish/v1/Systems/{}/LogServices/HostLogger/Entries?$skip=",
- BMCWEB_REDFISH_SYSTEM_URI_NAME) +
- std::to_string(skip + top);
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
}
- }
- });
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.id"] = std::format(
+ "/redfish/v1/Systems/{}/LogServices/HostLogger/Entries",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogEntryCollection.LogEntryCollection";
+ asyncResp->res.jsonValue["Name"] = "HostLogger Entries";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of HostLogger Entries";
+ nlohmann::json& logEntryArray = asyncResp->res.jsonValue["Members"];
+ logEntryArray = nlohmann::json::array();
+ asyncResp->res.jsonValue["Members@odata.count"] = 0;
+
+ std::vector<std::filesystem::path> hostLoggerFiles;
+ if (!getHostLoggerFiles(hostLoggerFolderPath, hostLoggerFiles))
+ {
+ BMCWEB_LOG_DEBUG("Failed to get host log file path");
+ return;
+ }
+ // If we weren't provided top and skip limits, use the defaults.
+ size_t skip = delegatedQuery.skip.value_or(0);
+ size_t top =
+ delegatedQuery.top.value_or(query_param::Query::maxTop);
+ size_t logCount = 0;
+ // This vector only store the entries we want to expose that
+ // control by skip and top.
+ std::vector<std::string> logEntries;
+ if (!getHostLoggerEntries(hostLoggerFiles, skip, top, logEntries,
+ logCount))
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ // If vector is empty, that means skip value larger than total
+ // log count
+ if (logEntries.empty())
+ {
+ asyncResp->res.jsonValue["Members@odata.count"] = logCount;
+ return;
+ }
+ if (!logEntries.empty())
+ {
+ for (size_t i = 0; i < logEntries.size(); i++)
+ {
+ nlohmann::json::object_t hostLogEntry;
+ fillHostLoggerEntryJson(std::to_string(skip + i),
+ logEntries[i], hostLogEntry);
+ logEntryArray.emplace_back(std::move(hostLogEntry));
+ }
+
+ asyncResp->res.jsonValue["Members@odata.count"] = logCount;
+ if (skip + top < logCount)
+ {
+ asyncResp->res.jsonValue["Members@odata.nextLink"] =
+ std::format(
+ "/redfish/v1/Systems/{}/LogServices/HostLogger/Entries?$skip=",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME) +
+ std::to_string(skip + top);
+ }
+ }
+ });
}
inline void requestRoutesSystemHostLoggerLogEntry(App& app)
@@ -2156,66 +2167,68 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName, const std::string& param) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- std::string_view targetID = param;
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ std::string_view targetID = param;
- uint64_t idInt = 0;
+ uint64_t idInt = 0;
- auto [ptr, ec] = std::from_chars(targetID.begin(), targetID.end(),
- idInt);
- if (ec != std::errc{} || ptr != targetID.end())
- {
- messages::resourceNotFound(asyncResp->res, "LogEntry", param);
- return;
- }
+ auto [ptr, ec] =
+ std::from_chars(targetID.begin(), targetID.end(), idInt);
+ if (ec != std::errc{} || ptr != targetID.end())
+ {
+ messages::resourceNotFound(asyncResp->res, "LogEntry",
+ param);
+ return;
+ }
- std::vector<std::filesystem::path> hostLoggerFiles;
- if (!getHostLoggerFiles(hostLoggerFolderPath, hostLoggerFiles))
- {
- BMCWEB_LOG_DEBUG("Failed to get host log file path");
- return;
- }
+ std::vector<std::filesystem::path> hostLoggerFiles;
+ if (!getHostLoggerFiles(hostLoggerFolderPath, hostLoggerFiles))
+ {
+ BMCWEB_LOG_DEBUG("Failed to get host log file path");
+ return;
+ }
- size_t logCount = 0;
- size_t top = 1;
- std::vector<std::string> logEntries;
- // We can get specific entry by skip and top. For example, if we
- // want to get nth entry, we can set skip = n-1 and top = 1 to
- // get that entry
- if (!getHostLoggerEntries(hostLoggerFiles, idInt, top, logEntries,
- logCount))
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ size_t logCount = 0;
+ size_t top = 1;
+ std::vector<std::string> logEntries;
+ // We can get specific entry by skip and top. For example, if we
+ // want to get nth entry, we can set skip = n-1 and top = 1 to
+ // get that entry
+ if (!getHostLoggerEntries(hostLoggerFiles, idInt, top,
+ logEntries, logCount))
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (!logEntries.empty())
- {
- nlohmann::json::object_t hostLogEntry;
- fillHostLoggerEntryJson(targetID, logEntries[0], hostLogEntry);
- asyncResp->res.jsonValue.update(hostLogEntry);
- return;
- }
+ if (!logEntries.empty())
+ {
+ nlohmann::json::object_t hostLogEntry;
+ fillHostLoggerEntryJson(targetID, logEntries[0],
+ hostLogEntry);
+ asyncResp->res.jsonValue.update(hostLogEntry);
+ return;
+ }
- // Requested ID was not found
- messages::resourceNotFound(asyncResp->res, "LogEntry", param);
- });
+ // Requested ID was not found
+ messages::resourceNotFound(asyncResp->res, "LogEntry", param);
+ });
}
inline void handleBMCLogServicesCollectionGet(
@@ -2266,42 +2279,43 @@
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse&
subTreePaths) {
- if (ec)
- {
- BMCWEB_LOG_ERROR(
- "handleBMCLogServicesCollectionGet respHandler got error {}",
- ec);
- // Assume that getting an error simply means there are no dump
- // LogServices. Return without adding any error response.
- return;
- }
-
- nlohmann::json& logServiceArrayLocal =
- asyncResp->res.jsonValue["Members"];
-
- for (const std::string& path : subTreePaths)
- {
- if (path == "/xyz/openbmc_project/dump/bmc")
+ if (ec)
{
- nlohmann::json::object_t member;
- member["@odata.id"] = boost::urls::format(
- "/redfish/v1/Managers/{}/LogServices/Dump",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
- logServiceArrayLocal.emplace_back(std::move(member));
+ BMCWEB_LOG_ERROR(
+ "handleBMCLogServicesCollectionGet respHandler got error {}",
+ ec);
+ // Assume that getting an error simply means there are no
+ // dump LogServices. Return without adding any error
+ // response.
+ return;
}
- else if (path == "/xyz/openbmc_project/dump/faultlog")
- {
- nlohmann::json::object_t member;
- member["@odata.id"] = boost::urls::format(
- "/redfish/v1/Managers/{}/LogServices/FaultLog",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
- logServiceArrayLocal.emplace_back(std::move(member));
- }
- }
- asyncResp->res.jsonValue["Members@odata.count"] =
- logServiceArrayLocal.size();
- });
+ nlohmann::json& logServiceArrayLocal =
+ asyncResp->res.jsonValue["Members"];
+
+ for (const std::string& path : subTreePaths)
+ {
+ if (path == "/xyz/openbmc_project/dump/bmc")
+ {
+ nlohmann::json::object_t member;
+ member["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}/LogServices/Dump",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+ logServiceArrayLocal.emplace_back(std::move(member));
+ }
+ else if (path == "/xyz/openbmc_project/dump/faultlog")
+ {
+ nlohmann::json::object_t member;
+ member["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}/LogServices/FaultLog",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+ logServiceArrayLocal.emplace_back(std::move(member));
+ }
+ }
+
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ logServiceArrayLocal.size();
+ });
}
}
@@ -2379,25 +2393,26 @@
[asyncResp, dumpType, dumpPath](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse& subTreePaths) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("getDumpServiceInfo respHandler got error {}", ec);
- // Assume that getting an error simply means there are no dump
- // LogServices. Return without adding any error response.
- return;
- }
- std::string dbusDumpPath = getDumpPath(dumpType);
- for (const std::string& path : subTreePaths)
- {
- if (path == dbusDumpPath)
+ if (ec)
{
- asyncResp->res
- .jsonValue["Actions"]["#LogService.ClearLog"]["target"] =
- dumpPath + "/Actions/LogService.ClearLog";
- break;
+ BMCWEB_LOG_ERROR("getDumpServiceInfo respHandler got error {}",
+ ec);
+ // Assume that getting an error simply means there are no dump
+ // LogServices. Return without adding any error response.
+ return;
}
- }
- });
+ std::string dbusDumpPath = getDumpPath(dumpType);
+ for (const std::string& path : subTreePaths)
+ {
+ if (path == dbusDumpPath)
+ {
+ asyncResp->res.jsonValue["Actions"]["#LogService.ClearLog"]
+ ["target"] =
+ dumpPath + "/Actions/LogService.ClearLog";
+ break;
+ }
+ }
+ });
}
inline void handleLogServicesDumpServiceGet(
@@ -2843,60 +2858,62 @@
// This is incorrect, should be:
//.privileges(redfish::privileges::getLogService)
.privileges({{"ConfigureManager"}})
- .methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- // Copy over the static data to include the entries added by
- // SubRoute
- asyncResp->res.jsonValue["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/Crashdump",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogService.v1_2_0.LogService";
- asyncResp->res.jsonValue["Name"] = "Open BMC Oem Crashdump Service";
- asyncResp->res.jsonValue["Description"] = "Oem Crashdump Service";
- asyncResp->res.jsonValue["Id"] = "Crashdump";
- asyncResp->res.jsonValue["OverWritePolicy"] =
- log_service::OverWritePolicy::WrapsWhenFull;
- asyncResp->res.jsonValue["MaxNumberOfRecords"] = 3;
+ // Copy over the static data to include the entries added by
+ // SubRoute
+ asyncResp->res.jsonValue["@odata.id"] =
+ std::format("/redfish/v1/Systems/{}/LogServices/Crashdump",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogService.v1_2_0.LogService";
+ asyncResp->res.jsonValue["Name"] = "Open BMC Oem Crashdump Service";
+ asyncResp->res.jsonValue["Description"] = "Oem Crashdump Service";
+ asyncResp->res.jsonValue["Id"] = "Crashdump";
+ asyncResp->res.jsonValue["OverWritePolicy"] =
+ log_service::OverWritePolicy::WrapsWhenFull;
+ asyncResp->res.jsonValue["MaxNumberOfRecords"] = 3;
- std::pair<std::string, std::string> redfishDateTimeOffset =
- redfish::time_utils::getDateTimeOffsetNow();
- asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
- asyncResp->res.jsonValue["DateTimeLocalOffset"] =
- redfishDateTimeOffset.second;
+ std::pair<std::string, std::string> redfishDateTimeOffset =
+ redfish::time_utils::getDateTimeOffsetNow();
+ asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
+ asyncResp->res.jsonValue["DateTimeLocalOffset"] =
+ redfishDateTimeOffset.second;
- asyncResp->res.jsonValue["Entries"]["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/Crashdump/Entries",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- asyncResp->res.jsonValue["Actions"]["#LogService.ClearLog"]
- ["target"] = std::format(
- "/redfish/v1/Systems/{}/LogServices/Crashdump/Actions/LogService.ClearLog",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- asyncResp->res.jsonValue["Actions"]["#LogService.CollectDiagnosticData"]
- ["target"] = std::format(
- "/redfish/v1/Systems/{}/LogServices/Crashdump/Actions/LogService.CollectDiagnosticData",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- });
+ asyncResp->res.jsonValue["Entries"]["@odata.id"] = std::format(
+ "/redfish/v1/Systems/{}/LogServices/Crashdump/Entries",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ asyncResp->res.jsonValue["Actions"]["#LogService.ClearLog"]
+ ["target"] = std::format(
+ "/redfish/v1/Systems/{}/LogServices/Crashdump/Actions/LogService.ClearLog",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ asyncResp->res
+ .jsonValue["Actions"]["#LogService.CollectDiagnosticData"]
+ ["target"] = std::format(
+ "/redfish/v1/Systems/{}/LogServices/Crashdump/Actions/LogService.CollectDiagnosticData",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ });
}
void inline requestRoutesCrashdumpClear(App& app)
@@ -2911,35 +2928,36 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec,
- const std::string&) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- messages::success(asyncResp->res);
- },
- crashdumpObject, crashdumpPath, deleteAllInterface, "DeleteAll");
- });
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code& ec,
+ const std::string&) {
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ messages::success(asyncResp->res);
+ },
+ crashdumpObject, crashdumpPath, deleteAllInterface,
+ "DeleteAll");
+ });
}
static void
@@ -2950,63 +2968,65 @@
[asyncResp, logID,
&logEntryJson](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& params) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("failed to get log ec: {}", ec.message());
- if (ec.value() ==
- boost::system::linux_error::bad_request_descriptor)
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("failed to get log ec: {}", ec.message());
+ if (ec.value() ==
+ boost::system::linux_error::bad_request_descriptor)
+ {
+ messages::resourceNotFound(asyncResp->res, "LogEntry",
+ logID);
+ }
+ else
+ {
+ messages::internalError(asyncResp->res);
+ }
+ return;
+ }
+
+ std::string timestamp{};
+ std::string filename{};
+ std::string logfile{};
+ parseCrashdumpParameters(params, filename, timestamp, logfile);
+
+ if (filename.empty() || timestamp.empty())
{
messages::resourceNotFound(asyncResp->res, "LogEntry", logID);
+ return;
+ }
+
+ std::string crashdumpURI =
+ std::format(
+ "/redfish/v1/Systems/{}/LogServices/Crashdump/Entries/",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME) +
+ logID + "/" + filename;
+ nlohmann::json::object_t logEntry;
+ logEntry["@odata.type"] = "#LogEntry.v1_9_0.LogEntry";
+ logEntry["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Systems/{}/LogServices/Crashdump/Entries/{}",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, logID);
+ logEntry["Name"] = "CPU Crashdump";
+ logEntry["Id"] = logID;
+ logEntry["EntryType"] = log_entry::LogEntryType::Oem;
+ logEntry["AdditionalDataURI"] = std::move(crashdumpURI);
+ logEntry["DiagnosticDataType"] = "OEM";
+ logEntry["OEMDiagnosticDataType"] = "PECICrashdump";
+ logEntry["Created"] = std::move(timestamp);
+
+ // If logEntryJson references an array of LogEntry resources
+ // ('Members' list), then push this as a new entry, otherwise set it
+ // directly
+ if (logEntryJson.is_array())
+ {
+ logEntryJson.push_back(logEntry);
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ logEntryJson.size();
}
else
{
- messages::internalError(asyncResp->res);
+ logEntryJson.update(logEntry);
}
- return;
- }
-
- std::string timestamp{};
- std::string filename{};
- std::string logfile{};
- parseCrashdumpParameters(params, filename, timestamp, logfile);
-
- if (filename.empty() || timestamp.empty())
- {
- messages::resourceNotFound(asyncResp->res, "LogEntry", logID);
- return;
- }
-
- std::string crashdumpURI =
- std::format("/redfish/v1/Systems/{}/LogServices/Crashdump/Entries/",
- BMCWEB_REDFISH_SYSTEM_URI_NAME) +
- logID + "/" + filename;
- nlohmann::json::object_t logEntry;
- logEntry["@odata.type"] = "#LogEntry.v1_9_0.LogEntry";
- logEntry["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/{}/LogServices/Crashdump/Entries/{}",
- BMCWEB_REDFISH_SYSTEM_URI_NAME, logID);
- logEntry["Name"] = "CPU Crashdump";
- logEntry["Id"] = logID;
- logEntry["EntryType"] = log_entry::LogEntryType::Oem;
- logEntry["AdditionalDataURI"] = std::move(crashdumpURI);
- logEntry["DiagnosticDataType"] = "OEM";
- logEntry["OEMDiagnosticDataType"] = "PECICrashdump";
- logEntry["Created"] = std::move(timestamp);
-
- // If logEntryJson references an array of LogEntry resources
- // ('Members' list), then push this as a new entry, otherwise set it
- // directly
- if (logEntryJson.is_array())
- {
- logEntryJson.push_back(logEntry);
- asyncResp->res.jsonValue["Members@odata.count"] =
- logEntryJson.size();
- }
- else
- {
- logEntryJson.update(logEntry);
- }
- };
+ };
sdbusplus::asio::getAllProperties(
*crow::connections::systemBus, crashdumpObject,
crashdumpPath + std::string("/") + logID, crashdumpInterface,
@@ -3025,71 +3045,74 @@
// This is incorrect, should be.
//.privileges(redfish::privileges::postLogEntryCollection)
.privileges({{"ConfigureComponents"}})
- .methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
-
- constexpr std::array<std::string_view, 1> interfaces = {
- crashdumpInterface};
- dbus::utility::getSubTreePaths(
- "/", 0, interfaces,
- [asyncResp](const boost::system::error_code& ec,
- const std::vector<std::string>& resp) {
- if (ec)
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
- if (ec.value() !=
- boost::system::errc::no_such_file_or_directory)
- {
- BMCWEB_LOG_DEBUG("failed to get entries ec: {}",
- ec.message());
- messages::internalError(asyncResp->res);
- return;
- }
+ return;
}
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogEntryCollection.LogEntryCollection";
- asyncResp->res.jsonValue["@odata.id"] = std::format(
- "/redfish/v1/Systems/{}/LogServices/Crashdump/Entries",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- asyncResp->res.jsonValue["Name"] = "Open BMC Crashdump Entries";
- asyncResp->res.jsonValue["Description"] =
- "Collection of Crashdump Entries";
- asyncResp->res.jsonValue["Members"] = nlohmann::json::array();
- asyncResp->res.jsonValue["Members@odata.count"] = 0;
-
- for (const std::string& path : resp)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
- const sdbusplus::message::object_path objPath(path);
- // Get the log ID
- std::string logID = objPath.filename();
- if (logID.empty())
- {
- continue;
- }
- // Add the log entry to the array
- logCrashdumpEntry(asyncResp, logID,
- asyncResp->res.jsonValue["Members"]);
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
}
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+
+ constexpr std::array<std::string_view, 1> interfaces = {
+ crashdumpInterface};
+ dbus::utility::getSubTreePaths(
+ "/", 0, interfaces,
+ [asyncResp](const boost::system::error_code& ec,
+ const std::vector<std::string>& resp) {
+ if (ec)
+ {
+ if (ec.value() !=
+ boost::system::errc::no_such_file_or_directory)
+ {
+ BMCWEB_LOG_DEBUG("failed to get entries ec: {}",
+ ec.message());
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogEntryCollection.LogEntryCollection";
+ asyncResp->res.jsonValue["@odata.id"] = std::format(
+ "/redfish/v1/Systems/{}/LogServices/Crashdump/Entries",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ asyncResp->res.jsonValue["Name"] =
+ "Open BMC Crashdump Entries";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of Crashdump Entries";
+ asyncResp->res.jsonValue["Members"] =
+ nlohmann::json::array();
+ asyncResp->res.jsonValue["Members@odata.count"] = 0;
+
+ for (const std::string& path : resp)
+ {
+ const sdbusplus::message::object_path objPath(path);
+ // Get the log ID
+ std::string logID = objPath.filename();
+ if (logID.empty())
+ {
+ continue;
+ }
+ // Add the log entry to the array
+ logCrashdumpEntry(asyncResp, logID,
+ asyncResp->res.jsonValue["Members"]);
+ }
+ });
});
- });
}
inline void requestRoutesCrashdumpEntry(App& app)
@@ -3106,26 +3129,26 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName, const std::string& param) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- const std::string& logID = param;
- logCrashdumpEntry(asyncResp, logID, asyncResp->res.jsonValue);
- });
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ const std::string& logID = param;
+ logCrashdumpEntry(asyncResp, logID, asyncResp->res.jsonValue);
+ });
}
inline void requestRoutesCrashdumpFile(App& app)
@@ -3141,73 +3164,79 @@
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName, const std::string& logID,
const std::string& fileName) {
- // Do not call getRedfishRoute here since the crashdump file is not a
- // Redfish resource.
+ // Do not call getRedfishRoute here since the crashdump file is
+ // not a Redfish resource.
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- auto getStoredLogCallback =
- [asyncResp, logID, fileName, url(boost::urls::url(req.url()))](
- const boost::system::error_code& ec,
- const std::vector<
- std::pair<std::string, dbus::utility::DbusVariantType>>&
- resp) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("failed to get log ec: {}", ec.message());
- messages::internalError(asyncResp->res);
- return;
- }
+ auto getStoredLogCallback =
+ [asyncResp, logID, fileName,
+ url(boost::urls::url(req.url()))](
+ const boost::system::error_code& ec,
+ const std::vector<std::pair<
+ std::string, dbus::utility::DbusVariantType>>&
+ resp) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("failed to get log ec: {}",
+ ec.message());
+ messages::internalError(asyncResp->res);
+ return;
+ }
- std::string dbusFilename{};
- std::string dbusTimestamp{};
- std::string dbusFilepath{};
+ std::string dbusFilename{};
+ std::string dbusTimestamp{};
+ std::string dbusFilepath{};
- parseCrashdumpParameters(resp, dbusFilename, dbusTimestamp,
- dbusFilepath);
+ parseCrashdumpParameters(resp, dbusFilename,
+ dbusTimestamp, dbusFilepath);
- if (dbusFilename.empty() || dbusTimestamp.empty() ||
- dbusFilepath.empty())
- {
- messages::resourceNotFound(asyncResp->res, "LogEntry", logID);
- return;
- }
+ if (dbusFilename.empty() || dbusTimestamp.empty() ||
+ dbusFilepath.empty())
+ {
+ messages::resourceNotFound(asyncResp->res,
+ "LogEntry", logID);
+ return;
+ }
- // Verify the file name parameter is correct
- if (fileName != dbusFilename)
- {
- messages::resourceNotFound(asyncResp->res, "LogEntry", logID);
- return;
- }
+ // Verify the file name parameter is correct
+ if (fileName != dbusFilename)
+ {
+ messages::resourceNotFound(asyncResp->res,
+ "LogEntry", logID);
+ return;
+ }
- if (!asyncResp->res.openFile(dbusFilepath))
- {
- messages::resourceNotFound(asyncResp->res, "LogEntry", logID);
- return;
- }
+ if (!asyncResp->res.openFile(dbusFilepath))
+ {
+ messages::resourceNotFound(asyncResp->res,
+ "LogEntry", logID);
+ return;
+ }
- // Configure this to be a file download when accessed
- // from a browser
- asyncResp->res.addHeader(
- boost::beast::http::field::content_disposition, "attachment");
- };
- sdbusplus::asio::getAllProperties(
- *crow::connections::systemBus, crashdumpObject,
- crashdumpPath + std::string("/") + logID, crashdumpInterface,
- std::move(getStoredLogCallback));
- });
+ // Configure this to be a file download when accessed
+ // from a browser
+ asyncResp->res.addHeader(
+ boost::beast::http::field::content_disposition,
+ "attachment");
+ };
+ sdbusplus::asio::getAllProperties(
+ *crow::connections::systemBus, crashdumpObject,
+ crashdumpPath + std::string("/") + logID,
+ crashdumpInterface, std::move(getStoredLogCallback));
+ });
}
enum class OEMDiagnosticType
@@ -3245,122 +3274,131 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
-
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
-
- std::string diagnosticDataType;
- std::string oemDiagnosticDataType;
- if (!redfish::json_util::readJsonAction(
- req, asyncResp->res, "DiagnosticDataType", diagnosticDataType,
- "OEMDiagnosticDataType", oemDiagnosticDataType))
- {
- return;
- }
-
- if (diagnosticDataType != "OEM")
- {
- BMCWEB_LOG_ERROR(
- "Only OEM DiagnosticDataType supported for Crashdump");
- messages::actionParameterValueFormatError(
- asyncResp->res, diagnosticDataType, "DiagnosticDataType",
- "CollectDiagnosticData");
- return;
- }
-
- OEMDiagnosticType oemDiagType =
- getOEMDiagnosticType(oemDiagnosticDataType);
-
- std::string iface;
- std::string method;
- std::string taskMatchStr;
- if (oemDiagType == OEMDiagnosticType::onDemand)
- {
- iface = crashdumpOnDemandInterface;
- method = "GenerateOnDemandLog";
- taskMatchStr = "type='signal',"
- "interface='org.freedesktop.DBus.Properties',"
- "member='PropertiesChanged',"
- "arg0namespace='com.intel.crashdump'";
- }
- else if (oemDiagType == OEMDiagnosticType::telemetry)
- {
- iface = crashdumpTelemetryInterface;
- method = "GenerateTelemetryLog";
- taskMatchStr = "type='signal',"
- "interface='org.freedesktop.DBus.Properties',"
- "member='PropertiesChanged',"
- "arg0namespace='com.intel.crashdump'";
- }
- else
- {
- BMCWEB_LOG_ERROR("Unsupported OEMDiagnosticDataType: {}",
- oemDiagnosticDataType);
- messages::actionParameterValueFormatError(
- asyncResp->res, oemDiagnosticDataType, "OEMDiagnosticDataType",
- "CollectDiagnosticData");
- return;
- }
-
- auto collectCrashdumpCallback =
- [asyncResp, payload(task::Payload(req)),
- taskMatchStr](const boost::system::error_code& ec,
- const std::string&) mutable {
- if (ec)
- {
- if (ec.value() == boost::system::errc::operation_not_supported)
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
- messages::resourceInStandby(asyncResp->res);
+ return;
}
- else if (ec.value() ==
- boost::system::errc::device_or_resource_busy)
+
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
- messages::serviceTemporarilyUnavailable(asyncResp->res,
- "60");
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+
+ std::string diagnosticDataType;
+ std::string oemDiagnosticDataType;
+ if (!redfish::json_util::readJsonAction(
+ req, asyncResp->res, "DiagnosticDataType",
+ diagnosticDataType, "OEMDiagnosticDataType",
+ oemDiagnosticDataType))
+ {
+ return;
+ }
+
+ if (diagnosticDataType != "OEM")
+ {
+ BMCWEB_LOG_ERROR(
+ "Only OEM DiagnosticDataType supported for Crashdump");
+ messages::actionParameterValueFormatError(
+ asyncResp->res, diagnosticDataType,
+ "DiagnosticDataType", "CollectDiagnosticData");
+ return;
+ }
+
+ OEMDiagnosticType oemDiagType =
+ getOEMDiagnosticType(oemDiagnosticDataType);
+
+ std::string iface;
+ std::string method;
+ std::string taskMatchStr;
+ if (oemDiagType == OEMDiagnosticType::onDemand)
+ {
+ iface = crashdumpOnDemandInterface;
+ method = "GenerateOnDemandLog";
+ taskMatchStr =
+ "type='signal',"
+ "interface='org.freedesktop.DBus.Properties',"
+ "member='PropertiesChanged',"
+ "arg0namespace='com.intel.crashdump'";
+ }
+ else if (oemDiagType == OEMDiagnosticType::telemetry)
+ {
+ iface = crashdumpTelemetryInterface;
+ method = "GenerateTelemetryLog";
+ taskMatchStr =
+ "type='signal',"
+ "interface='org.freedesktop.DBus.Properties',"
+ "member='PropertiesChanged',"
+ "arg0namespace='com.intel.crashdump'";
}
else
{
- messages::internalError(asyncResp->res);
+ BMCWEB_LOG_ERROR("Unsupported OEMDiagnosticDataType: {}",
+ oemDiagnosticDataType);
+ messages::actionParameterValueFormatError(
+ asyncResp->res, oemDiagnosticDataType,
+ "OEMDiagnosticDataType", "CollectDiagnosticData");
+ return;
}
- return;
- }
- std::shared_ptr<task::TaskData> task = task::TaskData::createTask(
- [](const boost::system::error_code& ec2, sdbusplus::message_t&,
- const std::shared_ptr<task::TaskData>& taskData) {
- if (!ec2)
- {
- taskData->messages.emplace_back(messages::taskCompletedOK(
- std::to_string(taskData->index)));
- taskData->state = "Completed";
- }
- return task::completed;
- },
- taskMatchStr);
- task->startTimer(std::chrono::minutes(5));
- task->populateResp(asyncResp->res);
- task->payload.emplace(std::move(payload));
- };
+ auto collectCrashdumpCallback =
+ [asyncResp, payload(task::Payload(req)),
+ taskMatchStr](const boost::system::error_code& ec,
+ const std::string&) mutable {
+ if (ec)
+ {
+ if (ec.value() ==
+ boost::system::errc::operation_not_supported)
+ {
+ messages::resourceInStandby(asyncResp->res);
+ }
+ else if (ec.value() == boost::system::errc::
+ device_or_resource_busy)
+ {
+ messages::serviceTemporarilyUnavailable(
+ asyncResp->res, "60");
+ }
+ else
+ {
+ messages::internalError(asyncResp->res);
+ }
+ return;
+ }
+ std::shared_ptr<task::TaskData> task =
+ task::TaskData::createTask(
+ [](const boost::system::error_code& ec2,
+ sdbusplus::message_t&,
+ const std::shared_ptr<task::TaskData>&
+ taskData) {
+ if (!ec2)
+ {
+ taskData->messages.emplace_back(
+ messages::taskCompletedOK(
+ std::to_string(
+ taskData->index)));
+ taskData->state = "Completed";
+ }
+ return task::completed;
+ },
+ taskMatchStr);
- crow::connections::systemBus->async_method_call(
- std::move(collectCrashdumpCallback), crashdumpObject, crashdumpPath,
- iface, method);
- });
+ task->startTimer(std::chrono::minutes(5));
+ task->populateResp(asyncResp->res);
+ task->payload.emplace(std::move(payload));
+ };
+
+ crow::connections::systemBus->async_method_call(
+ std::move(collectCrashdumpCallback), crashdumpObject,
+ crashdumpPath, iface, method);
+ });
}
inline void dBusLogServiceActionsClear(
@@ -3409,25 +3447,25 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- dBusLogServiceActionsClear(asyncResp);
- });
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ dBusLogServiceActionsClear(asyncResp);
+ });
}
/****************************************************
@@ -3438,52 +3476,53 @@
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/PostCodes/")
.privileges(redfish::privileges::getLogService)
- .methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- asyncResp->res.jsonValue["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/PostCodes",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogService.v1_2_0.LogService";
- asyncResp->res.jsonValue["Name"] = "POST Code Log Service";
- asyncResp->res.jsonValue["Description"] = "POST Code Log Service";
- asyncResp->res.jsonValue["Id"] = "PostCodes";
- asyncResp->res.jsonValue["OverWritePolicy"] =
- log_service::OverWritePolicy::WrapsWhenFull;
- asyncResp->res.jsonValue["Entries"]["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/PostCodes/Entries",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.id"] =
+ std::format("/redfish/v1/Systems/{}/LogServices/PostCodes",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogService.v1_2_0.LogService";
+ asyncResp->res.jsonValue["Name"] = "POST Code Log Service";
+ asyncResp->res.jsonValue["Description"] = "POST Code Log Service";
+ asyncResp->res.jsonValue["Id"] = "PostCodes";
+ asyncResp->res.jsonValue["OverWritePolicy"] =
+ log_service::OverWritePolicy::WrapsWhenFull;
+ asyncResp->res.jsonValue["Entries"]["@odata.id"] = std::format(
+ "/redfish/v1/Systems/{}/LogServices/PostCodes/Entries",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
- std::pair<std::string, std::string> redfishDateTimeOffset =
- redfish::time_utils::getDateTimeOffsetNow();
- asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
- asyncResp->res.jsonValue["DateTimeLocalOffset"] =
- redfishDateTimeOffset.second;
+ std::pair<std::string, std::string> redfishDateTimeOffset =
+ redfish::time_utils::getDateTimeOffsetNow();
+ asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
+ asyncResp->res.jsonValue["DateTimeLocalOffset"] =
+ redfishDateTimeOffset.second;
- asyncResp->res.jsonValue["Actions"]["#LogService.ClearLog"]
- ["target"] = std::format(
- "/redfish/v1/Systems/{}/LogServices/PostCodes/Actions/LogService.ClearLog",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- });
+ asyncResp->res.jsonValue["Actions"]["#LogService.ClearLog"]
+ ["target"] = std::format(
+ "/redfish/v1/Systems/{}/LogServices/PostCodes/Actions/LogService.ClearLog",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ });
}
inline void requestRoutesPostCodesClear(App& app)
@@ -3498,44 +3537,45 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- BMCWEB_LOG_DEBUG("Do delete all postcodes entries.");
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ BMCWEB_LOG_DEBUG("Do delete all postcodes entries.");
- // Make call to post-code service to request clear all
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- // TODO Handle for specific error code
- BMCWEB_LOG_ERROR("doClearPostCodes resp_handler got error {}",
- ec);
- asyncResp->res.result(
- boost::beast::http::status::internal_server_error);
- messages::internalError(asyncResp->res);
- return;
- }
- messages::success(asyncResp->res);
- },
- "xyz.openbmc_project.State.Boot.PostCode0",
- "/xyz/openbmc_project/State/Boot/PostCode0",
- "xyz.openbmc_project.Collection.DeleteAll", "DeleteAll");
- });
+ // Make call to post-code service to request clear all
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code& ec) {
+ if (ec)
+ {
+ // TODO Handle for specific error code
+ BMCWEB_LOG_ERROR(
+ "doClearPostCodes resp_handler got error {}",
+ ec);
+ asyncResp->res.result(boost::beast::http::status::
+ internal_server_error);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ messages::success(asyncResp->res);
+ },
+ "xyz.openbmc_project.State.Boot.PostCode0",
+ "/xyz/openbmc_project/State/Boot/PostCode0",
+ "xyz.openbmc_project.Collection.DeleteAll", "DeleteAll");
+ });
}
/**
@@ -3567,8 +3607,8 @@
return false;
}
postCodeNumber.remove_prefix(1);
- auto [ptrIndex, ecIndex] = std::from_chars(postCodeNumber.begin(),
- postCodeNumber.end(), index);
+ auto [ptrIndex, ecIndex] =
+ std::from_chars(postCodeNumber.begin(), postCodeNumber.end(), index);
if (ptrIndex != postCodeNumber.end() || ecIndex != std::errc())
{
return false;
@@ -3743,25 +3783,25 @@
const boost::container::flat_map<
uint64_t, std::tuple<uint64_t, std::vector<uint8_t>>>&
postcode) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS POST CODE PostCode response error");
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("DBUS POST CODE PostCode response error");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (postcode.empty())
- {
- messages::resourceNotFound(asyncResp->res, "LogEntry", entryId);
- return;
- }
+ if (postcode.empty())
+ {
+ messages::resourceNotFound(asyncResp->res, "LogEntry", entryId);
+ return;
+ }
- if (!fillPostCodeEntry(asyncResp, postcode, bootIndex, codeIndex))
- {
- messages::resourceNotFound(asyncResp->res, "LogEntry", entryId);
- return;
- }
- },
+ if (!fillPostCodeEntry(asyncResp, postcode, bootIndex, codeIndex))
+ {
+ messages::resourceNotFound(asyncResp->res, "LogEntry", entryId);
+ return;
+ }
+ },
"xyz.openbmc_project.State.Boot.PostCode0",
"/xyz/openbmc_project/State/Boot/PostCode0",
"xyz.openbmc_project.State.Boot.PostCode", "GetPostCodesWithTimeStamp",
@@ -3779,47 +3819,48 @@
const boost::container::flat_map<
uint64_t, std::tuple<uint64_t, std::vector<uint8_t>>>&
postcode) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS POST CODE PostCode response error");
- messages::internalError(asyncResp->res);
- return;
- }
-
- uint64_t endCount = entryCount;
- if (!postcode.empty())
- {
- endCount = entryCount + postcode.size();
- if (skip < endCount && (top + skip) > entryCount)
+ if (ec)
{
- uint64_t thisBootSkip = std::max(static_cast<uint64_t>(skip),
- entryCount) -
- entryCount;
- uint64_t thisBootTop =
- std::min(static_cast<uint64_t>(top + skip), endCount) -
- entryCount;
-
- fillPostCodeEntry(asyncResp, postcode, bootIndex, 0,
- thisBootSkip, thisBootTop);
+ BMCWEB_LOG_DEBUG("DBUS POST CODE PostCode response error");
+ messages::internalError(asyncResp->res);
+ return;
}
- asyncResp->res.jsonValue["Members@odata.count"] = endCount;
- }
- // continue to previous bootIndex
- if (bootIndex < bootCount)
- {
- getPostCodeForBoot(asyncResp, static_cast<uint16_t>(bootIndex + 1),
- bootCount, endCount, skip, top);
- }
- else if (skip + top < endCount)
- {
- asyncResp->res.jsonValue["Members@odata.nextLink"] =
- std::format(
- "/redfish/v1/Systems/{}/LogServices/PostCodes/Entries?$skip=",
- BMCWEB_REDFISH_SYSTEM_URI_NAME) +
- std::to_string(skip + top);
- }
- },
+ uint64_t endCount = entryCount;
+ if (!postcode.empty())
+ {
+ endCount = entryCount + postcode.size();
+ if (skip < endCount && (top + skip) > entryCount)
+ {
+ uint64_t thisBootSkip =
+ std::max(static_cast<uint64_t>(skip), entryCount) -
+ entryCount;
+ uint64_t thisBootTop =
+ std::min(static_cast<uint64_t>(top + skip), endCount) -
+ entryCount;
+
+ fillPostCodeEntry(asyncResp, postcode, bootIndex, 0,
+ thisBootSkip, thisBootTop);
+ }
+ asyncResp->res.jsonValue["Members@odata.count"] = endCount;
+ }
+
+ // continue to previous bootIndex
+ if (bootIndex < bootCount)
+ {
+ getPostCodeForBoot(asyncResp,
+ static_cast<uint16_t>(bootIndex + 1),
+ bootCount, endCount, skip, top);
+ }
+ else if (skip + top < endCount)
+ {
+ asyncResp->res.jsonValue["Members@odata.nextLink"] =
+ std::format(
+ "/redfish/v1/Systems/{}/LogServices/PostCodes/Entries?$skip=",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME) +
+ std::to_string(skip + top);
+ }
+ },
"xyz.openbmc_project.State.Boot.PostCode0",
"/xyz/openbmc_project/State/Boot/PostCode0",
"xyz.openbmc_project.State.Boot.PostCode", "GetPostCodesWithTimeStamp",
@@ -3836,16 +3877,16 @@
"xyz.openbmc_project.State.Boot.PostCode0",
"/xyz/openbmc_project/State/Boot/PostCode0",
"xyz.openbmc_project.State.Boot.PostCode", "CurrentBootCycleCount",
- [asyncResp, entryCount, skip, top](const boost::system::error_code& ec,
- const uint16_t bootCount) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- getPostCodeForBoot(asyncResp, 1, bootCount, entryCount, skip, top);
- });
+ [asyncResp, entryCount, skip,
+ top](const boost::system::error_code& ec, const uint16_t bootCount) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ getPostCodeForBoot(asyncResp, 1, bootCount, entryCount, skip, top);
+ });
}
inline void requestRoutesPostCodesEntryCollection(App& app)
@@ -3857,44 +3898,45 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName) {
- query_param::QueryCapabilities capabilities = {
- .canDelegateTop = true,
- .canDelegateSkip = true,
- };
- query_param::Query delegatedQuery;
- if (!redfish::setUpRedfishRouteWithDelegation(
- app, req, asyncResp, delegatedQuery, capabilities))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ query_param::QueryCapabilities capabilities = {
+ .canDelegateTop = true,
+ .canDelegateSkip = true,
+ };
+ query_param::Query delegatedQuery;
+ if (!redfish::setUpRedfishRouteWithDelegation(
+ app, req, asyncResp, delegatedQuery, capabilities))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogEntryCollection.LogEntryCollection";
- asyncResp->res.jsonValue["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/LogServices/PostCodes/Entries",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- asyncResp->res.jsonValue["Name"] = "BIOS POST Code Log Entries";
- asyncResp->res.jsonValue["Description"] =
- "Collection of POST Code Log Entries";
- asyncResp->res.jsonValue["Members"] = nlohmann::json::array();
- asyncResp->res.jsonValue["Members@odata.count"] = 0;
- size_t skip = delegatedQuery.skip.value_or(0);
- size_t top = delegatedQuery.top.value_or(query_param::Query::maxTop);
- getCurrentBootNumber(asyncResp, skip, top);
- });
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogEntryCollection.LogEntryCollection";
+ asyncResp->res.jsonValue["@odata.id"] = std::format(
+ "/redfish/v1/Systems/{}/LogServices/PostCodes/Entries",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ asyncResp->res.jsonValue["Name"] = "BIOS POST Code Log Entries";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of POST Code Log Entries";
+ asyncResp->res.jsonValue["Members"] = nlohmann::json::array();
+ asyncResp->res.jsonValue["Members@odata.count"] = 0;
+ size_t skip = delegatedQuery.skip.value_or(0);
+ size_t top =
+ delegatedQuery.top.value_or(query_param::Query::maxTop);
+ getCurrentBootNumber(asyncResp, skip, top);
+ });
}
inline void requestRoutesPostCodesEntryAdditionalData(App& app)
@@ -3903,93 +3945,99 @@
app,
"/redfish/v1/Systems/<str>/LogServices/PostCodes/Entries/<str>/attachment/")
.privileges(redfish::privileges::getLogEntry)
- .methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName,
- const std::string& postCodeID) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if (!http_helpers::isContentTypeAllowed(
- req.getHeaderValue("Accept"),
- http_helpers::ContentType::OctetStream, true))
- {
- asyncResp->res.result(boost::beast::http::status::bad_request);
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName,
+ const std::string& postCodeID) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if (!http_helpers::isContentTypeAllowed(
+ req.getHeaderValue("Accept"),
+ http_helpers::ContentType::OctetStream, true))
+ {
+ asyncResp->res.result(boost::beast::http::status::bad_request);
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- uint64_t currentValue = 0;
- uint16_t index = 0;
- if (!parsePostCode(postCodeID, currentValue, index))
- {
- messages::resourceNotFound(asyncResp->res, "LogEntry", postCodeID);
- return;
- }
-
- crow::connections::systemBus->async_method_call(
- [asyncResp, postCodeID, currentValue](
- const boost::system::error_code& ec,
- const std::vector<std::tuple<uint64_t, std::vector<uint8_t>>>&
- postcodes) {
- if (ec.value() == EBADR)
+ uint64_t currentValue = 0;
+ uint16_t index = 0;
+ if (!parsePostCode(postCodeID, currentValue, index))
{
messages::resourceNotFound(asyncResp->res, "LogEntry",
postCodeID);
return;
}
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- size_t value = static_cast<size_t>(currentValue) - 1;
- if (value == std::string::npos || postcodes.size() < currentValue)
- {
- BMCWEB_LOG_WARNING("Wrong currentValue value");
- messages::resourceNotFound(asyncResp->res, "LogEntry",
- postCodeID);
- return;
- }
+ crow::connections::systemBus->async_method_call(
+ [asyncResp, postCodeID, currentValue](
+ const boost::system::error_code& ec,
+ const std::vector<std::tuple<
+ uint64_t, std::vector<uint8_t>>>& postcodes) {
+ if (ec.value() == EBADR)
+ {
+ messages::resourceNotFound(asyncResp->res, "LogEntry",
+ postCodeID);
+ return;
+ }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- const auto& [tID, c] = postcodes[value];
- if (c.empty())
- {
- BMCWEB_LOG_WARNING("No found post code data");
- messages::resourceNotFound(asyncResp->res, "LogEntry",
- postCodeID);
- return;
- }
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
- const char* d = reinterpret_cast<const char*>(c.data());
- std::string_view strData(d, c.size());
+ size_t value = static_cast<size_t>(currentValue) - 1;
+ if (value == std::string::npos ||
+ postcodes.size() < currentValue)
+ {
+ BMCWEB_LOG_WARNING("Wrong currentValue value");
+ messages::resourceNotFound(asyncResp->res, "LogEntry",
+ postCodeID);
+ return;
+ }
- asyncResp->res.addHeader(boost::beast::http::field::content_type,
- "application/octet-stream");
- asyncResp->res.addHeader(
- boost::beast::http::field::content_transfer_encoding, "Base64");
- asyncResp->res.write(crow::utility::base64encode(strData));
- },
- "xyz.openbmc_project.State.Boot.PostCode0",
- "/xyz/openbmc_project/State/Boot/PostCode0",
- "xyz.openbmc_project.State.Boot.PostCode", "GetPostCodes", index);
- });
+ const auto& [tID, c] = postcodes[value];
+ if (c.empty())
+ {
+ BMCWEB_LOG_WARNING("No found post code data");
+ messages::resourceNotFound(asyncResp->res, "LogEntry",
+ postCodeID);
+ return;
+ }
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
+ const char* d = reinterpret_cast<const char*>(c.data());
+ std::string_view strData(d, c.size());
+
+ asyncResp->res.addHeader(
+ boost::beast::http::field::content_type,
+ "application/octet-stream");
+ asyncResp->res.addHeader(
+ boost::beast::http::field::content_transfer_encoding,
+ "Base64");
+ asyncResp->res.write(crow::utility::base64encode(strData));
+ },
+ "xyz.openbmc_project.State.Boot.PostCode0",
+ "/xyz/openbmc_project/State/Boot/PostCode0",
+ "xyz.openbmc_project.State.Boot.PostCode", "GetPostCodes",
+ index);
+ });
}
inline void requestRoutesPostCodesEntry(App& app)
@@ -4001,26 +4049,26 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName, const std::string& targetID) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- getPostCodeForEntry(asyncResp, targetID);
- });
+ getPostCodeForEntry(asyncResp, targetID);
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/manager_diagnostic_data.hpp b/redfish-core/lib/manager_diagnostic_data.hpp
index 1856e1f..1ca80fd 100644
--- a/redfish-core/lib/manager_diagnostic_data.hpp
+++ b/redfish-core/lib/manager_diagnostic_data.hpp
@@ -106,8 +106,8 @@
}
static constexpr double roundFactor = 10000; // 4 decimal places
- asyncResp->res.jsonValue[jPtr] = std::round(userCPU * roundFactor) /
- roundFactor;
+ asyncResp->res.jsonValue[jPtr] =
+ std::round(userCPU * roundFactor) / roundFactor;
}
inline void managerGetProcessorStatistics(
diff --git a/redfish-core/lib/manager_logservices_journal.hpp b/redfish-core/lib/manager_logservices_journal.hpp
index 8d383bd..94ade20 100644
--- a/redfish-core/lib/manager_logservices_journal.hpp
+++ b/redfish-core/lib/manager_logservices_journal.hpp
@@ -72,8 +72,8 @@
return false;
}
entryIDStrView.remove_prefix(1);
- auto [ptr, indexEc] = std::from_chars(entryIDStrView.begin(),
- entryIDStrView.end(), index);
+ auto [ptr, indexEc] =
+ std::from_chars(entryIDStrView.begin(), entryIDStrView.end(), index);
if (indexEc != std::errc() || ptr != entryIDStrView.end())
{
messages::resourceNotFound(asyncResp->res, "LogEntry", entryIDStrView);
@@ -156,10 +156,9 @@
return true;
}
-inline bool
- fillBMCJournalLogEntryJson(const std::string& bmcJournalLogEntryID,
- sd_journal* journal,
- nlohmann::json::object_t& bmcJournalLogEntryJson)
+inline bool fillBMCJournalLogEntryJson(
+ const std::string& bmcJournalLogEntryID, sd_journal* journal,
+ nlohmann::json::object_t& bmcJournalLogEntryJson)
{
// Get the Log Entry contents
std::string message;
@@ -268,10 +267,9 @@
uint64_t prevTs = 0;
};
-inline void
- readJournalEntries(uint64_t topEntryCount,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- JournalReadState&& readState)
+inline void readJournalEntries(
+ uint64_t topEntryCount, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ JournalReadState&& readState)
{
nlohmann::json& logEntry = asyncResp->res.jsonValue["Members"];
nlohmann::json::array_t* logEntryArray =
@@ -301,9 +299,9 @@
boost::asio::post(crow::connections::systemBus->get_io_context(),
[asyncResp, topEntryCount,
readState = std::move(readState)]() mutable {
- readJournalEntries(topEntryCount, asyncResp,
- std::move(readState));
- });
+ readJournalEntries(topEntryCount, asyncResp,
+ std::move(readState));
+ });
return;
}
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 3c08cb5..fe65187 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -70,16 +70,16 @@
*crow::connections::systemBus, processName, objectPath, interfaceName,
destProperty, propertyValue,
[asyncResp](const boost::system::error_code& ec) {
- // Use "Set" method to set the property value.
- if (ec)
- {
- BMCWEB_LOG_DEBUG("[Set] Bad D-Bus request error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ // Use "Set" method to set the property value.
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("[Set] Bad D-Bus request error: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- messages::success(asyncResp->res);
- });
+ messages::success(asyncResp->res);
+ });
}
inline void
@@ -97,16 +97,16 @@
*crow::connections::systemBus, processName, objectPath, interfaceName,
destProperty, propertyValue,
[asyncResp](const boost::system::error_code& ec) {
- // Use "Set" method to set the property value.
- if (ec)
- {
- BMCWEB_LOG_DEBUG("[Set] Bad D-Bus request error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ // Use "Set" method to set the property value.
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("[Set] Bad D-Bus request error: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- messages::success(asyncResp->res);
- });
+ messages::success(asyncResp->res);
+ });
}
/**
@@ -127,44 +127,46 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& managerId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "Manager", managerId);
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "Manager",
+ managerId);
+ return;
+ }
- BMCWEB_LOG_DEBUG("Post Manager Reset.");
+ BMCWEB_LOG_DEBUG("Post Manager Reset.");
- std::string resetType;
+ std::string resetType;
- if (!json_util::readJsonAction(req, asyncResp->res, "ResetType",
- resetType))
- {
- return;
- }
+ if (!json_util::readJsonAction(req, asyncResp->res, "ResetType",
+ resetType))
+ {
+ return;
+ }
- if (resetType == "GracefulRestart")
- {
- BMCWEB_LOG_DEBUG("Proceeding with {}", resetType);
- doBMCGracefulRestart(asyncResp);
- return;
- }
- if (resetType == "ForceRestart")
- {
- BMCWEB_LOG_DEBUG("Proceeding with {}", resetType);
- doBMCForceRestart(asyncResp);
- return;
- }
- BMCWEB_LOG_DEBUG("Invalid property value for ResetType: {}", resetType);
- messages::actionParameterNotSupported(asyncResp->res, resetType,
- "ResetType");
+ if (resetType == "GracefulRestart")
+ {
+ BMCWEB_LOG_DEBUG("Proceeding with {}", resetType);
+ doBMCGracefulRestart(asyncResp);
+ return;
+ }
+ if (resetType == "ForceRestart")
+ {
+ BMCWEB_LOG_DEBUG("Proceeding with {}", resetType);
+ doBMCForceRestart(asyncResp);
+ return;
+ }
+ BMCWEB_LOG_DEBUG("Invalid property value for ResetType: {}",
+ resetType);
+ messages::actionParameterNotSupported(asyncResp->res, resetType,
+ "ResetType");
- return;
- });
+ return;
+ });
}
/**
@@ -188,70 +190,73 @@
BMCWEB_ROUTE(app,
"/redfish/v1/Managers/<str>/Actions/Manager.ResetToDefaults/")
.privileges(redfish::privileges::postManager)
- .methods(boost::beast::http::verb::post)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& managerId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
-
- if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "Manager", managerId);
- return;
- }
-
- BMCWEB_LOG_DEBUG("Post ResetToDefaults.");
-
- std::optional<std::string> resetType;
- std::optional<std::string> resetToDefaultsType;
-
- if (!json_util::readJsonAction(req, asyncResp->res, "ResetType",
- resetType, "ResetToDefaultsType",
- resetToDefaultsType))
- {
- BMCWEB_LOG_DEBUG("Missing property ResetType.");
-
- messages::actionParameterMissing(asyncResp->res, "ResetToDefaults",
- "ResetType");
- return;
- }
-
- if (resetToDefaultsType && !resetType)
- {
- BMCWEB_LOG_WARNING(
- "Using deprecated ResetToDefaultsType, should be ResetType."
- "Support for the ResetToDefaultsType will be dropped in 2Q24");
- resetType = resetToDefaultsType;
- }
-
- if (resetType != "ResetAll")
- {
- BMCWEB_LOG_DEBUG("Invalid property value for ResetType: {}",
- *resetType);
- messages::actionParameterNotSupported(asyncResp->res, *resetType,
- "ResetType");
- return;
- }
-
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
+ .methods(
+ boost::beast::http::verb::
+ post)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& managerId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
- BMCWEB_LOG_DEBUG("Failed to ResetToDefaults: {}", ec);
- messages::internalError(asyncResp->res);
return;
}
- // Factory Reset doesn't actually happen until a reboot
- // Can't erase what the BMC is running on
- doBMCGracefulRestart(asyncResp);
- },
- "xyz.openbmc_project.Software.BMC.Updater",
- "/xyz/openbmc_project/software",
- "xyz.openbmc_project.Common.FactoryReset", "Reset");
- });
+
+ if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "Manager",
+ managerId);
+ return;
+ }
+
+ BMCWEB_LOG_DEBUG("Post ResetToDefaults.");
+
+ std::optional<std::string> resetType;
+ std::optional<std::string> resetToDefaultsType;
+
+ if (!json_util::readJsonAction(req, asyncResp->res, "ResetType",
+ resetType, "ResetToDefaultsType",
+ resetToDefaultsType))
+ {
+ BMCWEB_LOG_DEBUG("Missing property ResetType.");
+
+ messages::actionParameterMissing(
+ asyncResp->res, "ResetToDefaults", "ResetType");
+ return;
+ }
+
+ if (resetToDefaultsType && !resetType)
+ {
+ BMCWEB_LOG_WARNING(
+ "Using deprecated ResetToDefaultsType, should be ResetType."
+ "Support for the ResetToDefaultsType will be dropped in 2Q24");
+ resetType = resetToDefaultsType;
+ }
+
+ if (resetType != "ResetAll")
+ {
+ BMCWEB_LOG_DEBUG("Invalid property value for ResetType: {}",
+ *resetType);
+ messages::actionParameterNotSupported(asyncResp->res,
+ *resetType, "ResetType");
+ return;
+ }
+
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code& ec) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("Failed to ResetToDefaults: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ // Factory Reset doesn't actually happen until a reboot
+ // Can't erase what the BMC is running on
+ doBMCGracefulRestart(asyncResp);
+ },
+ "xyz.openbmc_project.Software.BMC.Updater",
+ "/xyz/openbmc_project/software",
+ "xyz.openbmc_project.Common.FactoryReset", "Reset");
+ });
}
/**
@@ -270,39 +275,40 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& managerId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "Manager", managerId);
- return;
- }
+ if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "Manager",
+ managerId);
+ return;
+ }
- asyncResp->res.jsonValue["@odata.type"] =
- "#ActionInfo.v1_1_2.ActionInfo";
- asyncResp->res.jsonValue["@odata.id"] =
- boost::urls::format("/redfish/v1/Managers/{}/ResetActionInfo",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
- asyncResp->res.jsonValue["Name"] = "Reset Action Info";
- asyncResp->res.jsonValue["Id"] = "ResetActionInfo";
- nlohmann::json::object_t parameter;
- parameter["Name"] = "ResetType";
- parameter["Required"] = true;
- parameter["DataType"] = action_info::ParameterTypes::String;
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ActionInfo.v1_1_2.ActionInfo";
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}/ResetActionInfo",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+ asyncResp->res.jsonValue["Name"] = "Reset Action Info";
+ asyncResp->res.jsonValue["Id"] = "ResetActionInfo";
+ nlohmann::json::object_t parameter;
+ parameter["Name"] = "ResetType";
+ parameter["Required"] = true;
+ parameter["DataType"] = action_info::ParameterTypes::String;
- nlohmann::json::array_t allowableValues;
- allowableValues.emplace_back("GracefulRestart");
- allowableValues.emplace_back("ForceRestart");
- parameter["AllowableValues"] = std::move(allowableValues);
+ nlohmann::json::array_t allowableValues;
+ allowableValues.emplace_back("GracefulRestart");
+ allowableValues.emplace_back("ForceRestart");
+ parameter["AllowableValues"] = std::move(allowableValues);
- nlohmann::json::array_t parameters;
- parameters.emplace_back(std::move(parameter));
+ nlohmann::json::array_t parameters;
+ parameters.emplace_back(std::move(parameter));
- asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
- });
+ asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
+ });
}
static constexpr const char* objectManagerIface =
@@ -328,397 +334,218 @@
[asyncResp, currentProfile, supportedProfiles](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& managedObj) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("{}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- nlohmann::json& configRoot =
- asyncResp->res.jsonValue["Oem"]["OpenBmc"]["Fan"];
- nlohmann::json& fans = configRoot["FanControllers"];
- fans["@odata.type"] = "#OpenBMCManager.v1_0_0.Manager.FanControllers";
- fans["@odata.id"] = boost::urls::format(
- "/redfish/v1/Managers/{}#/Oem/OpenBmc/Fan/FanControllers",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
-
- nlohmann::json& pids = configRoot["PidControllers"];
- pids["@odata.type"] = "#OpenBMCManager.v1_0_0.Manager.PidControllers";
- pids["@odata.id"] = boost::urls::format(
- "/redfish/v1/Managers/{}#/Oem/OpenBmc/Fan/PidControllers",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
-
- nlohmann::json& stepwise = configRoot["StepwiseControllers"];
- stepwise["@odata.type"] =
- "#OpenBMCManager.v1_0_0.Manager.StepwiseControllers";
- stepwise["@odata.id"] = boost::urls::format(
- "/redfish/v1/Managers/{}#/Oem/OpenBmc/Fan/StepwiseControllers",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
-
- nlohmann::json& zones = configRoot["FanZones"];
- zones["@odata.id"] = boost::urls::format(
- "/redfish/v1/Managers/{}#/Oem/OpenBmc/Fan/FanZones",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
- zones["@odata.type"] = "#OpenBMCManager.v1_0_0.Manager.FanZones";
- configRoot["@odata.id"] =
- boost::urls::format("/redfish/v1/Managers/{}#/Oem/OpenBmc/Fan",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
- configRoot["@odata.type"] = "#OpenBMCManager.v1_0_0.Manager.Fan";
- configRoot["Profile@Redfish.AllowableValues"] = supportedProfiles;
-
- if (!currentProfile.empty())
- {
- configRoot["Profile"] = currentProfile;
- }
- BMCWEB_LOG_DEBUG("profile = {} !", currentProfile);
-
- for (const auto& pathPair : managedObj)
- {
- for (const auto& intfPair : pathPair.second)
+ if (ec)
{
- if (intfPair.first != pidConfigurationIface &&
- intfPair.first != pidZoneConfigurationIface &&
- intfPair.first != stepwiseConfigurationIface)
+ BMCWEB_LOG_ERROR("{}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ nlohmann::json& configRoot =
+ asyncResp->res.jsonValue["Oem"]["OpenBmc"]["Fan"];
+ nlohmann::json& fans = configRoot["FanControllers"];
+ fans["@odata.type"] =
+ "#OpenBMCManager.v1_0_0.Manager.FanControllers";
+ fans["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}#/Oem/OpenBmc/Fan/FanControllers",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+
+ nlohmann::json& pids = configRoot["PidControllers"];
+ pids["@odata.type"] =
+ "#OpenBMCManager.v1_0_0.Manager.PidControllers";
+ pids["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}#/Oem/OpenBmc/Fan/PidControllers",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+
+ nlohmann::json& stepwise = configRoot["StepwiseControllers"];
+ stepwise["@odata.type"] =
+ "#OpenBMCManager.v1_0_0.Manager.StepwiseControllers";
+ stepwise["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}#/Oem/OpenBmc/Fan/StepwiseControllers",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+
+ nlohmann::json& zones = configRoot["FanZones"];
+ zones["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}#/Oem/OpenBmc/Fan/FanZones",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+ zones["@odata.type"] = "#OpenBMCManager.v1_0_0.Manager.FanZones";
+ configRoot["@odata.id"] =
+ boost::urls::format("/redfish/v1/Managers/{}#/Oem/OpenBmc/Fan",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+ configRoot["@odata.type"] = "#OpenBMCManager.v1_0_0.Manager.Fan";
+ configRoot["Profile@Redfish.AllowableValues"] = supportedProfiles;
+
+ if (!currentProfile.empty())
+ {
+ configRoot["Profile"] = currentProfile;
+ }
+ BMCWEB_LOG_DEBUG("profile = {} !", currentProfile);
+
+ for (const auto& pathPair : managedObj)
+ {
+ for (const auto& intfPair : pathPair.second)
{
- continue;
- }
-
- std::string name;
-
- for (const std::pair<std::string,
- dbus::utility::DbusVariantType>& propPair :
- intfPair.second)
- {
- if (propPair.first == "Name")
- {
- const std::string* namePtr =
- std::get_if<std::string>(&propPair.second);
- if (namePtr == nullptr)
- {
- BMCWEB_LOG_ERROR("Pid Name Field illegal");
- messages::internalError(asyncResp->res);
- return;
- }
- name = *namePtr;
- dbus::utility::escapePathForDbus(name);
- }
- else if (propPair.first == "Profiles")
- {
- const std::vector<std::string>* profiles =
- std::get_if<std::vector<std::string>>(
- &propPair.second);
- if (profiles == nullptr)
- {
- BMCWEB_LOG_ERROR("Pid Profiles Field illegal");
- messages::internalError(asyncResp->res);
- return;
- }
- if (std::find(profiles->begin(), profiles->end(),
- currentProfile) == profiles->end())
- {
- BMCWEB_LOG_INFO(
- "{} not supported in current profile", name);
- continue;
- }
- }
- }
- nlohmann::json* config = nullptr;
- const std::string* classPtr = nullptr;
-
- for (const std::pair<std::string,
- dbus::utility::DbusVariantType>& propPair :
- intfPair.second)
- {
- if (propPair.first == "Class")
- {
- classPtr = std::get_if<std::string>(&propPair.second);
- }
- }
-
- boost::urls::url url(
- boost::urls::format("/redfish/v1/Managers/{}",
- BMCWEB_REDFISH_MANAGER_URI_NAME));
- if (intfPair.first == pidZoneConfigurationIface)
- {
- std::string chassis;
- if (!dbus::utility::getNthStringFromPath(pathPair.first.str,
- 5, chassis))
- {
- chassis = "#IllegalValue";
- }
- nlohmann::json& zone = zones[name];
- zone["Chassis"]["@odata.id"] =
- boost::urls::format("/redfish/v1/Chassis/{}", chassis);
- url.set_fragment(
- ("/Oem/OpenBmc/Fan/FanZones"_json_pointer / name)
- .to_string());
- zone["@odata.id"] = std::move(url);
- zone["@odata.type"] =
- "#OpenBMCManager.v1_0_0.Manager.FanZone";
- config = &zone;
- }
-
- else if (intfPair.first == stepwiseConfigurationIface)
- {
- if (classPtr == nullptr)
- {
- BMCWEB_LOG_ERROR("Pid Class Field illegal");
- messages::internalError(asyncResp->res);
- return;
- }
-
- nlohmann::json& controller = stepwise[name];
- config = &controller;
- url.set_fragment(
- ("/Oem/OpenBmc/Fan/StepwiseControllers"_json_pointer /
- name)
- .to_string());
- controller["@odata.id"] = std::move(url);
- controller["@odata.type"] =
- "#OpenBMCManager.v1_0_0.Manager.StepwiseController";
-
- controller["Direction"] = *classPtr;
- }
-
- // pid and fans are off the same configuration
- else if (intfPair.first == pidConfigurationIface)
- {
- if (classPtr == nullptr)
- {
- BMCWEB_LOG_ERROR("Pid Class Field illegal");
- messages::internalError(asyncResp->res);
- return;
- }
- bool isFan = *classPtr == "fan";
- nlohmann::json& element = isFan ? fans[name] : pids[name];
- config = &element;
- if (isFan)
- {
- url.set_fragment(
- ("/Oem/OpenBmc/Fan/FanControllers"_json_pointer /
- name)
- .to_string());
- element["@odata.id"] = std::move(url);
- element["@odata.type"] =
- "#OpenBMCManager.v1_0_0.Manager.FanController";
- }
- else
- {
- url.set_fragment(
- ("/Oem/OpenBmc/Fan/PidControllers"_json_pointer /
- name)
- .to_string());
- element["@odata.id"] = std::move(url);
- element["@odata.type"] =
- "#OpenBMCManager.v1_0_0.Manager.PidController";
- }
- }
- else
- {
- BMCWEB_LOG_ERROR("Unexpected configuration");
- messages::internalError(asyncResp->res);
- return;
- }
-
- // used for making maps out of 2 vectors
- const std::vector<double>* keys = nullptr;
- const std::vector<double>* values = nullptr;
-
- for (const auto& propertyPair : intfPair.second)
- {
- if (propertyPair.first == "Type" ||
- propertyPair.first == "Class" ||
- propertyPair.first == "Name")
+ if (intfPair.first != pidConfigurationIface &&
+ intfPair.first != pidZoneConfigurationIface &&
+ intfPair.first != stepwiseConfigurationIface)
{
continue;
}
- // zones
+ std::string name;
+
+ for (const std::pair<std::string,
+ dbus::utility::DbusVariantType>&
+ propPair : intfPair.second)
+ {
+ if (propPair.first == "Name")
+ {
+ const std::string* namePtr =
+ std::get_if<std::string>(&propPair.second);
+ if (namePtr == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Pid Name Field illegal");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ name = *namePtr;
+ dbus::utility::escapePathForDbus(name);
+ }
+ else if (propPair.first == "Profiles")
+ {
+ const std::vector<std::string>* profiles =
+ std::get_if<std::vector<std::string>>(
+ &propPair.second);
+ if (profiles == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Pid Profiles Field illegal");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (std::find(profiles->begin(), profiles->end(),
+ currentProfile) == profiles->end())
+ {
+ BMCWEB_LOG_INFO(
+ "{} not supported in current profile",
+ name);
+ continue;
+ }
+ }
+ }
+ nlohmann::json* config = nullptr;
+ const std::string* classPtr = nullptr;
+
+ for (const std::pair<std::string,
+ dbus::utility::DbusVariantType>&
+ propPair : intfPair.second)
+ {
+ if (propPair.first == "Class")
+ {
+ classPtr =
+ std::get_if<std::string>(&propPair.second);
+ }
+ }
+
+ boost::urls::url url(
+ boost::urls::format("/redfish/v1/Managers/{}",
+ BMCWEB_REDFISH_MANAGER_URI_NAME));
if (intfPair.first == pidZoneConfigurationIface)
{
- const double* ptr =
- std::get_if<double>(&propertyPair.second);
- if (ptr == nullptr)
+ std::string chassis;
+ if (!dbus::utility::getNthStringFromPath(
+ pathPair.first.str, 5, chassis))
{
- BMCWEB_LOG_ERROR("Field Illegal {}",
- propertyPair.first);
+ chassis = "#IllegalValue";
+ }
+ nlohmann::json& zone = zones[name];
+ zone["Chassis"]["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Chassis/{}", chassis);
+ url.set_fragment(
+ ("/Oem/OpenBmc/Fan/FanZones"_json_pointer / name)
+ .to_string());
+ zone["@odata.id"] = std::move(url);
+ zone["@odata.type"] =
+ "#OpenBMCManager.v1_0_0.Manager.FanZone";
+ config = &zone;
+ }
+
+ else if (intfPair.first == stepwiseConfigurationIface)
+ {
+ if (classPtr == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Pid Class Field illegal");
messages::internalError(asyncResp->res);
return;
}
- (*config)[propertyPair.first] = *ptr;
- }
- if (intfPair.first == stepwiseConfigurationIface)
- {
- if (propertyPair.first == "Reading" ||
- propertyPair.first == "Output")
- {
- const std::vector<double>* ptr =
- std::get_if<std::vector<double>>(
- &propertyPair.second);
+ nlohmann::json& controller = stepwise[name];
+ config = &controller;
+ url.set_fragment(
+ ("/Oem/OpenBmc/Fan/StepwiseControllers"_json_pointer /
+ name)
+ .to_string());
+ controller["@odata.id"] = std::move(url);
+ controller["@odata.type"] =
+ "#OpenBMCManager.v1_0_0.Manager.StepwiseController";
- if (ptr == nullptr)
- {
- BMCWEB_LOG_ERROR("Field Illegal {}",
- propertyPair.first);
- messages::internalError(asyncResp->res);
- return;
- }
-
- if (propertyPair.first == "Reading")
- {
- keys = ptr;
- }
- else
- {
- values = ptr;
- }
- if (keys != nullptr && values != nullptr)
- {
- if (keys->size() != values->size())
- {
- BMCWEB_LOG_ERROR(
- "Reading and Output size don't match ");
- messages::internalError(asyncResp->res);
- return;
- }
- nlohmann::json& steps = (*config)["Steps"];
- steps = nlohmann::json::array();
- for (size_t ii = 0; ii < keys->size(); ii++)
- {
- nlohmann::json::object_t step;
- step["Target"] = (*keys)[ii];
- step["Output"] = (*values)[ii];
- steps.emplace_back(std::move(step));
- }
- }
- }
- if (propertyPair.first == "NegativeHysteresis" ||
- propertyPair.first == "PositiveHysteresis")
- {
- const double* ptr =
- std::get_if<double>(&propertyPair.second);
- if (ptr == nullptr)
- {
- BMCWEB_LOG_ERROR("Field Illegal {}",
- propertyPair.first);
- messages::internalError(asyncResp->res);
- return;
- }
- (*config)[propertyPair.first] = *ptr;
- }
+ controller["Direction"] = *classPtr;
}
// pid and fans are off the same configuration
- if (intfPair.first == pidConfigurationIface ||
- intfPair.first == stepwiseConfigurationIface)
+ else if (intfPair.first == pidConfigurationIface)
{
- if (propertyPair.first == "Zones")
+ if (classPtr == nullptr)
{
- const std::vector<std::string>* inputs =
- std::get_if<std::vector<std::string>>(
- &propertyPair.second);
-
- if (inputs == nullptr)
- {
- BMCWEB_LOG_ERROR("Zones Pid Field Illegal");
- messages::internalError(asyncResp->res);
- return;
- }
- auto& data = (*config)[propertyPair.first];
- data = nlohmann::json::array();
- for (std::string itemCopy : *inputs)
- {
- dbus::utility::escapePathForDbus(itemCopy);
- nlohmann::json::object_t input;
- boost::urls::url managerUrl = boost::urls::format(
- "/redfish/v1/Managers/{}#{}",
- BMCWEB_REDFISH_MANAGER_URI_NAME,
- ("/Oem/OpenBmc/Fan/FanZones"_json_pointer /
- itemCopy)
- .to_string());
- input["@odata.id"] = std::move(managerUrl);
- data.emplace_back(std::move(input));
- }
+ BMCWEB_LOG_ERROR("Pid Class Field illegal");
+ messages::internalError(asyncResp->res);
+ return;
}
- // todo(james): may never happen, but this
- // assumes configuration data referenced in the
- // PID config is provided by the same daemon, we
- // could add another loop to cover all cases,
- // but I'm okay kicking this can down the road a
- // bit
-
- else if (propertyPair.first == "Inputs" ||
- propertyPair.first == "Outputs")
+ bool isFan = *classPtr == "fan";
+ nlohmann::json& element =
+ isFan ? fans[name] : pids[name];
+ config = &element;
+ if (isFan)
{
- auto& data = (*config)[propertyPair.first];
- const std::vector<std::string>* inputs =
- std::get_if<std::vector<std::string>>(
- &propertyPair.second);
-
- if (inputs == nullptr)
- {
- BMCWEB_LOG_ERROR("Field Illegal {}",
- propertyPair.first);
- messages::internalError(asyncResp->res);
- return;
- }
- data = *inputs;
+ url.set_fragment(
+ ("/Oem/OpenBmc/Fan/FanControllers"_json_pointer /
+ name)
+ .to_string());
+ element["@odata.id"] = std::move(url);
+ element["@odata.type"] =
+ "#OpenBMCManager.v1_0_0.Manager.FanController";
}
- else if (propertyPair.first == "SetPointOffset")
+ else
{
- const std::string* ptr =
- std::get_if<std::string>(&propertyPair.second);
-
- if (ptr == nullptr)
- {
- BMCWEB_LOG_ERROR("Field Illegal {}",
- propertyPair.first);
- messages::internalError(asyncResp->res);
- return;
- }
- // translate from dbus to redfish
- if (*ptr == "WarningHigh")
- {
- (*config)["SetPointOffset"] =
- "UpperThresholdNonCritical";
- }
- else if (*ptr == "WarningLow")
- {
- (*config)["SetPointOffset"] =
- "LowerThresholdNonCritical";
- }
- else if (*ptr == "CriticalHigh")
- {
- (*config)["SetPointOffset"] =
- "UpperThresholdCritical";
- }
- else if (*ptr == "CriticalLow")
- {
- (*config)["SetPointOffset"] =
- "LowerThresholdCritical";
- }
- else
- {
- BMCWEB_LOG_ERROR("Value Illegal {}", *ptr);
- messages::internalError(asyncResp->res);
- return;
- }
+ url.set_fragment(
+ ("/Oem/OpenBmc/Fan/PidControllers"_json_pointer /
+ name)
+ .to_string());
+ element["@odata.id"] = std::move(url);
+ element["@odata.type"] =
+ "#OpenBMCManager.v1_0_0.Manager.PidController";
}
- // doubles
- else if (propertyPair.first == "FFGainCoefficient" ||
- propertyPair.first == "FFOffCoefficient" ||
- propertyPair.first == "ICoefficient" ||
- propertyPair.first == "ILimitMax" ||
- propertyPair.first == "ILimitMin" ||
- propertyPair.first == "PositiveHysteresis" ||
- propertyPair.first == "NegativeHysteresis" ||
- propertyPair.first == "OutLimitMax" ||
- propertyPair.first == "OutLimitMin" ||
- propertyPair.first == "PCoefficient" ||
- propertyPair.first == "SetPoint" ||
- propertyPair.first == "SlewNeg" ||
- propertyPair.first == "SlewPos")
+ }
+ else
+ {
+ BMCWEB_LOG_ERROR("Unexpected configuration");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ // used for making maps out of 2 vectors
+ const std::vector<double>* keys = nullptr;
+ const std::vector<double>* values = nullptr;
+
+ for (const auto& propertyPair : intfPair.second)
+ {
+ if (propertyPair.first == "Type" ||
+ propertyPair.first == "Class" ||
+ propertyPair.first == "Name")
+ {
+ continue;
+ }
+
+ // zones
+ if (intfPair.first == pidZoneConfigurationIface)
{
const double* ptr =
std::get_if<double>(&propertyPair.second);
@@ -731,11 +558,200 @@
}
(*config)[propertyPair.first] = *ptr;
}
+
+ if (intfPair.first == stepwiseConfigurationIface)
+ {
+ if (propertyPair.first == "Reading" ||
+ propertyPair.first == "Output")
+ {
+ const std::vector<double>* ptr =
+ std::get_if<std::vector<double>>(
+ &propertyPair.second);
+
+ if (ptr == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Field Illegal {}",
+ propertyPair.first);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ if (propertyPair.first == "Reading")
+ {
+ keys = ptr;
+ }
+ else
+ {
+ values = ptr;
+ }
+ if (keys != nullptr && values != nullptr)
+ {
+ if (keys->size() != values->size())
+ {
+ BMCWEB_LOG_ERROR(
+ "Reading and Output size don't match ");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ nlohmann::json& steps = (*config)["Steps"];
+ steps = nlohmann::json::array();
+ for (size_t ii = 0; ii < keys->size(); ii++)
+ {
+ nlohmann::json::object_t step;
+ step["Target"] = (*keys)[ii];
+ step["Output"] = (*values)[ii];
+ steps.emplace_back(std::move(step));
+ }
+ }
+ }
+ if (propertyPair.first == "NegativeHysteresis" ||
+ propertyPair.first == "PositiveHysteresis")
+ {
+ const double* ptr =
+ std::get_if<double>(&propertyPair.second);
+ if (ptr == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Field Illegal {}",
+ propertyPair.first);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ (*config)[propertyPair.first] = *ptr;
+ }
+ }
+
+ // pid and fans are off the same configuration
+ if (intfPair.first == pidConfigurationIface ||
+ intfPair.first == stepwiseConfigurationIface)
+ {
+ if (propertyPair.first == "Zones")
+ {
+ const std::vector<std::string>* inputs =
+ std::get_if<std::vector<std::string>>(
+ &propertyPair.second);
+
+ if (inputs == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Zones Pid Field Illegal");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ auto& data = (*config)[propertyPair.first];
+ data = nlohmann::json::array();
+ for (std::string itemCopy : *inputs)
+ {
+ dbus::utility::escapePathForDbus(itemCopy);
+ nlohmann::json::object_t input;
+ boost::urls::url managerUrl =
+ boost::urls::format(
+ "/redfish/v1/Managers/{}#{}",
+ BMCWEB_REDFISH_MANAGER_URI_NAME,
+ ("/Oem/OpenBmc/Fan/FanZones"_json_pointer /
+ itemCopy)
+ .to_string());
+ input["@odata.id"] = std::move(managerUrl);
+ data.emplace_back(std::move(input));
+ }
+ }
+ // todo(james): may never happen, but this
+ // assumes configuration data referenced in the
+ // PID config is provided by the same daemon, we
+ // could add another loop to cover all cases,
+ // but I'm okay kicking this can down the road a
+ // bit
+
+ else if (propertyPair.first == "Inputs" ||
+ propertyPair.first == "Outputs")
+ {
+ auto& data = (*config)[propertyPair.first];
+ const std::vector<std::string>* inputs =
+ std::get_if<std::vector<std::string>>(
+ &propertyPair.second);
+
+ if (inputs == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Field Illegal {}",
+ propertyPair.first);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ data = *inputs;
+ }
+ else if (propertyPair.first == "SetPointOffset")
+ {
+ const std::string* ptr =
+ std::get_if<std::string>(
+ &propertyPair.second);
+
+ if (ptr == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Field Illegal {}",
+ propertyPair.first);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ // translate from dbus to redfish
+ if (*ptr == "WarningHigh")
+ {
+ (*config)["SetPointOffset"] =
+ "UpperThresholdNonCritical";
+ }
+ else if (*ptr == "WarningLow")
+ {
+ (*config)["SetPointOffset"] =
+ "LowerThresholdNonCritical";
+ }
+ else if (*ptr == "CriticalHigh")
+ {
+ (*config)["SetPointOffset"] =
+ "UpperThresholdCritical";
+ }
+ else if (*ptr == "CriticalLow")
+ {
+ (*config)["SetPointOffset"] =
+ "LowerThresholdCritical";
+ }
+ else
+ {
+ BMCWEB_LOG_ERROR("Value Illegal {}", *ptr);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ }
+ // doubles
+ else if (propertyPair.first ==
+ "FFGainCoefficient" ||
+ propertyPair.first == "FFOffCoefficient" ||
+ propertyPair.first == "ICoefficient" ||
+ propertyPair.first == "ILimitMax" ||
+ propertyPair.first == "ILimitMin" ||
+ propertyPair.first ==
+ "PositiveHysteresis" ||
+ propertyPair.first ==
+ "NegativeHysteresis" ||
+ propertyPair.first == "OutLimitMax" ||
+ propertyPair.first == "OutLimitMin" ||
+ propertyPair.first == "PCoefficient" ||
+ propertyPair.first == "SetPoint" ||
+ propertyPair.first == "SlewNeg" ||
+ propertyPair.first == "SlewPos")
+ {
+ const double* ptr =
+ std::get_if<double>(&propertyPair.second);
+ if (ptr == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Field Illegal {}",
+ propertyPair.first);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ (*config)[propertyPair.first] = *ptr;
+ }
+ }
}
}
}
- }
- });
+ });
}
enum class CreatePIDRet
@@ -848,14 +864,14 @@
// delete interface
crow::connections::systemBus->async_method_call(
[response, path](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Error patching {}: {}", path, ec);
- messages::internalError(response->res);
- return;
- }
- messages::success(response->res);
- },
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("Error patching {}: {}", path, ec);
+ messages::internalError(response->res);
+ return;
+ }
+ messages::success(response->res);
+ },
"xyz.openbmc_project.EntityManager", path, iface, "Delete");
return CreatePIDRet::del;
}
@@ -916,8 +932,8 @@
return CreatePIDRet::fail;
}
if (std::find(curProfiles->begin(),
- curProfiles->end(),
- profile) == curProfiles->end())
+ curProfiles->end(), profile) ==
+ curProfiles->end())
{
std::vector<std::string> newProfiles =
*curProfiles;
@@ -1053,10 +1069,10 @@
std::optional<std::string> chassisId;
std::optional<double> failSafePercent;
std::optional<double> minThermalOutput;
- if (!redfish::json_util::readJson(jsonValue, response->res,
- "Chassis/@odata.id", chassisId,
- "FailSafePercent", failSafePercent,
- "MinThermalOutput", minThermalOutput))
+ if (!redfish::json_util::readJson(
+ jsonValue, response->res, "Chassis/@odata.id", chassisId,
+ "FailSafePercent", failSafePercent, "MinThermalOutput",
+ minThermalOutput))
{
return CreatePIDRet::fail;
}
@@ -1206,14 +1222,14 @@
[self](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtreeLocal) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("{}", ec);
- messages::internalError(self->asyncResp->res);
- return;
- }
- self->complete.subtree = subtreeLocal;
- });
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("{}", ec);
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+ self->complete.subtree = subtreeLocal;
+ });
// at the same time get the selected profile
constexpr std::array<std::string_view, 1> thermalModeIfaces = {
@@ -1223,58 +1239,61 @@
[self](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtreeLocal) {
- if (ec || subtreeLocal.empty())
- {
- return;
- }
- if (subtreeLocal[0].second.size() != 1)
- {
- // invalid mapper response, should never happen
- BMCWEB_LOG_ERROR("GetPIDValues: Mapper Error");
- messages::internalError(self->asyncResp->res);
- return;
- }
-
- const std::string& path = subtreeLocal[0].first;
- const std::string& owner = subtreeLocal[0].second[0].first;
-
- sdbusplus::asio::getAllProperties(
- *crow::connections::systemBus, owner, path, thermalModeIface,
- [path, owner,
- self](const boost::system::error_code& ec2,
- const dbus::utility::DBusPropertiesMap& resp) {
- if (ec2)
+ if (ec || subtreeLocal.empty())
{
- BMCWEB_LOG_ERROR(
- "GetPIDValues: Can't get thermalModeIface {}", path);
+ return;
+ }
+ if (subtreeLocal[0].second.size() != 1)
+ {
+ // invalid mapper response, should never happen
+ BMCWEB_LOG_ERROR("GetPIDValues: Mapper Error");
messages::internalError(self->asyncResp->res);
return;
}
- const std::string* current = nullptr;
- const std::vector<std::string>* supported = nullptr;
+ const std::string& path = subtreeLocal[0].first;
+ const std::string& owner = subtreeLocal[0].second[0].first;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), resp, "Current", current,
- "Supported", supported);
+ sdbusplus::asio::getAllProperties(
+ *crow::connections::systemBus, owner, path,
+ thermalModeIface,
+ [path, owner,
+ self](const boost::system::error_code& ec2,
+ const dbus::utility::DBusPropertiesMap& resp) {
+ if (ec2)
+ {
+ BMCWEB_LOG_ERROR(
+ "GetPIDValues: Can't get thermalModeIface {}",
+ path);
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
- if (!success)
- {
- messages::internalError(self->asyncResp->res);
- return;
- }
+ const std::string* current = nullptr;
+ const std::vector<std::string>* supported = nullptr;
- if (current == nullptr || supported == nullptr)
- {
- BMCWEB_LOG_ERROR(
- "GetPIDValues: thermal mode iface invalid {}", path);
- messages::internalError(self->asyncResp->res);
- return;
- }
- self->complete.currentProfile = *current;
- self->complete.supportedProfiles = *supported;
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), resp, "Current",
+ current, "Supported", supported);
+
+ if (!success)
+ {
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+
+ if (current == nullptr || supported == nullptr)
+ {
+ BMCWEB_LOG_ERROR(
+ "GetPIDValues: thermal mode iface invalid {}",
+ path);
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+ self->complete.currentProfile = *current;
+ self->complete.supportedProfiles = *supported;
+ });
});
- });
}
static void
@@ -1361,8 +1380,7 @@
std::pair<std::string, std::optional<nlohmann::json::object_t>>>&&
configurationsIn,
std::optional<std::string>& profileIn) :
- asyncResp(asyncRespIn),
- configuration(std::move(configurationsIn)),
+ asyncResp(asyncRespIn), configuration(std::move(configurationsIn)),
profile(std::move(profileIn))
{}
@@ -1388,30 +1406,30 @@
"xyz.openbmc_project.EntityManager", objPath,
[self](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& mObj) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Error communicating to Entity Manager");
- messages::internalError(self->asyncResp->res);
- return;
- }
- const std::array<const char*, 3> configurations = {
- pidConfigurationIface, pidZoneConfigurationIface,
- stepwiseConfigurationIface};
-
- for (const auto& [path, object] : mObj)
- {
- for (const auto& [interface, _] : object)
+ if (ec)
{
- if (std::ranges::find(configurations, interface) !=
- configurations.end())
+ BMCWEB_LOG_ERROR("Error communicating to Entity Manager");
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+ const std::array<const char*, 3> configurations = {
+ pidConfigurationIface, pidZoneConfigurationIface,
+ stepwiseConfigurationIface};
+
+ for (const auto& [path, object] : mObj)
+ {
+ for (const auto& [interface, _] : object)
{
- self->objectCount++;
- break;
+ if (std::ranges::find(configurations, interface) !=
+ configurations.end())
+ {
+ self->objectCount++;
+ break;
+ }
}
}
- }
- self->managedObj = mObj;
- });
+ self->managedObj = mObj;
+ });
// at the same time get the profile information
constexpr std::array<std::string_view, 1> thermalModeIfaces = {
@@ -1420,57 +1438,61 @@
"/", 0, thermalModeIfaces,
[self](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec || subtree.empty())
- {
- return;
- }
- if (subtree[0].second.empty())
- {
- // invalid mapper response, should never happen
- BMCWEB_LOG_ERROR("SetPIDValues: Mapper Error");
- messages::internalError(self->asyncResp->res);
- return;
- }
-
- const std::string& path = subtree[0].first;
- const std::string& owner = subtree[0].second[0].first;
- sdbusplus::asio::getAllProperties(
- *crow::connections::systemBus, owner, path, thermalModeIface,
- [self, path, owner](const boost::system::error_code& ec2,
- const dbus::utility::DBusPropertiesMap& r) {
- if (ec2)
+ if (ec || subtree.empty())
{
- BMCWEB_LOG_ERROR(
- "SetPIDValues: Can't get thermalModeIface {}", path);
- messages::internalError(self->asyncResp->res);
return;
}
- const std::string* current = nullptr;
- const std::vector<std::string>* supported = nullptr;
-
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), r, "Current", current,
- "Supported", supported);
-
- if (!success)
+ if (subtree[0].second.empty())
{
+ // invalid mapper response, should never happen
+ BMCWEB_LOG_ERROR("SetPIDValues: Mapper Error");
messages::internalError(self->asyncResp->res);
return;
}
- if (current == nullptr || supported == nullptr)
- {
- BMCWEB_LOG_ERROR(
- "SetPIDValues: thermal mode iface invalid {}", path);
- messages::internalError(self->asyncResp->res);
- return;
- }
- self->currentProfile = *current;
- self->supportedProfiles = *supported;
- self->profileConnection = owner;
- self->profilePath = path;
+ const std::string& path = subtree[0].first;
+ const std::string& owner = subtree[0].second[0].first;
+ sdbusplus::asio::getAllProperties(
+ *crow::connections::systemBus, owner, path,
+ thermalModeIface,
+ [self, path,
+ owner](const boost::system::error_code& ec2,
+ const dbus::utility::DBusPropertiesMap& r) {
+ if (ec2)
+ {
+ BMCWEB_LOG_ERROR(
+ "SetPIDValues: Can't get thermalModeIface {}",
+ path);
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+ const std::string* current = nullptr;
+ const std::vector<std::string>* supported = nullptr;
+
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), r, "Current",
+ current, "Supported", supported);
+
+ if (!success)
+ {
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+
+ if (current == nullptr || supported == nullptr)
+ {
+ BMCWEB_LOG_ERROR(
+ "SetPIDValues: thermal mode iface invalid {}",
+ path);
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+ self->currentProfile = *current;
+ self->supportedProfiles = *supported;
+ self->profileConnection = owner;
+ self->profilePath = path;
+ });
});
- });
}
void pidSetDone()
{
@@ -1493,12 +1515,12 @@
*crow::connections::systemBus, profileConnection, profilePath,
thermalModeIface, "Current", *profile,
[response](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Error patching profile{}", ec);
- messages::internalError(response->res);
- }
- });
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("Error patching profile{}", ec);
+ messages::internalError(response->res);
+ }
+ });
}
for (auto& containerPair : configuration)
@@ -1519,8 +1541,8 @@
auto pathItr = std::ranges::find_if(
managedObj, [&dbusObjName](const auto& obj) {
- return obj.first.filename() == dbusObjName;
- });
+ return obj.first.filename() == dbusObjName;
+ });
dbus::utility::DBusPropertiesMap output;
output.reserve(16); // The pid interface length
@@ -1621,15 +1643,15 @@
[response,
propertyName{std::string(property.first)}](
const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Error patching {}: {}",
- propertyName, ec);
- messages::internalError(response->res);
- return;
- }
- messages::success(response->res);
- },
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("Error patching {}: {}",
+ propertyName, ec);
+ messages::internalError(response->res);
+ return;
+ }
+ messages::success(response->res);
+ },
"xyz.openbmc_project.EntityManager", path,
"org.freedesktop.DBus.Properties", "Set", iface,
property.first, property.second);
@@ -1666,14 +1688,15 @@
crow::connections::systemBus->async_method_call(
[response](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Error Adding Pid Object {}", ec);
- messages::internalError(response->res);
- return;
- }
- messages::success(response->res);
- },
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("Error Adding Pid Object {}",
+ ec);
+ messages::internalError(response->res);
+ return;
+ }
+ messages::success(response->res);
+ },
"xyz.openbmc_project.EntityManager", chassis,
"xyz.openbmc_project.AddObject", "AddObject", output);
}
@@ -1724,17 +1747,18 @@
"xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
[asyncResp](const boost::system::error_code& ec,
const std::string& property) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error for "
- "Location");
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("DBUS response error for "
+ "Location");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- asyncResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
- property;
- });
+ asyncResp->res
+ .jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
+ property;
+ });
}
// avoid name collision systems.hpp
inline void
@@ -1748,20 +1772,20 @@
"LastRebootTime",
[asyncResp](const boost::system::error_code& ec,
const uint64_t lastResetTime) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("D-BUS response error {}", ec);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("D-BUS response error {}", ec);
+ return;
+ }
- // LastRebootTime is epoch time, in milliseconds
- // https://github.com/openbmc/phosphor-dbus-interfaces/blob/7f9a128eb9296e926422ddc312c148b625890bb6/xyz/openbmc_project/State/BMC.interface.yaml#L19
- uint64_t lastResetTimeStamp = lastResetTime / 1000;
+ // LastRebootTime is epoch time, in milliseconds
+ // https://github.com/openbmc/phosphor-dbus-interfaces/blob/7f9a128eb9296e926422ddc312c148b625890bb6/xyz/openbmc_project/State/BMC.interface.yaml#L19
+ uint64_t lastResetTimeStamp = lastResetTime / 1000;
- // Convert to ISO 8601 standard
- asyncResp->res.jsonValue["LastResetTime"] =
- redfish::time_utils::getDateTimeUint(lastResetTimeStamp);
- });
+ // Convert to ISO 8601 standard
+ asyncResp->res.jsonValue["LastResetTime"] =
+ redfish::time_utils::getDateTimeUint(lastResetTimeStamp);
+ });
}
/**
@@ -1802,81 +1826,80 @@
[asyncResp, firmwareId, runningFirmwareTarget](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& subtree) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("D-Bus response error getting objects.");
- messages::internalError(asyncResp->res);
- return;
- }
-
- if (subtree.empty())
- {
- BMCWEB_LOG_DEBUG("Can't find image!");
- messages::internalError(asyncResp->res);
- return;
- }
-
- bool foundImage = false;
- for (const auto& object : subtree)
- {
- const std::string& path =
- static_cast<const std::string&>(object.first);
- std::size_t idPos2 = path.rfind('/');
-
- if (idPos2 == std::string::npos)
+ if (ec)
{
- continue;
- }
-
- idPos2++;
- if (idPos2 >= path.size())
- {
- continue;
- }
-
- if (path.substr(idPos2) == firmwareId)
- {
- foundImage = true;
- break;
- }
- }
-
- if (!foundImage)
- {
- messages::propertyValueNotInList(
- asyncResp->res, runningFirmwareTarget, "@odata.id");
- BMCWEB_LOG_DEBUG("Invalid firmware ID.");
- return;
- }
-
- BMCWEB_LOG_DEBUG("Setting firmware version {} to priority 0.",
- firmwareId);
-
- // Only support Immediate
- // An addition could be a Redfish Setting like
- // ActiveSoftwareImageApplyTime and support OnReset
- sdbusplus::asio::setProperty(
- *crow::connections::systemBus,
- "xyz.openbmc_project.Software.BMC.Updater",
- "/xyz/openbmc_project/software/" + firmwareId,
- "xyz.openbmc_project.Software.RedundancyPriority", "Priority",
- static_cast<uint8_t>(0),
- [asyncResp](const boost::system::error_code& ec2) {
- if (ec2)
- {
- BMCWEB_LOG_DEBUG("D-Bus response error setting.");
+ BMCWEB_LOG_DEBUG("D-Bus response error getting objects.");
messages::internalError(asyncResp->res);
return;
}
- doBMCGracefulRestart(asyncResp);
+
+ if (subtree.empty())
+ {
+ BMCWEB_LOG_DEBUG("Can't find image!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ bool foundImage = false;
+ for (const auto& object : subtree)
+ {
+ const std::string& path =
+ static_cast<const std::string&>(object.first);
+ std::size_t idPos2 = path.rfind('/');
+
+ if (idPos2 == std::string::npos)
+ {
+ continue;
+ }
+
+ idPos2++;
+ if (idPos2 >= path.size())
+ {
+ continue;
+ }
+
+ if (path.substr(idPos2) == firmwareId)
+ {
+ foundImage = true;
+ break;
+ }
+ }
+
+ if (!foundImage)
+ {
+ messages::propertyValueNotInList(
+ asyncResp->res, runningFirmwareTarget, "@odata.id");
+ BMCWEB_LOG_DEBUG("Invalid firmware ID.");
+ return;
+ }
+
+ BMCWEB_LOG_DEBUG("Setting firmware version {} to priority 0.",
+ firmwareId);
+
+ // Only support Immediate
+ // An addition could be a Redfish Setting like
+ // ActiveSoftwareImageApplyTime and support OnReset
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus,
+ "xyz.openbmc_project.Software.BMC.Updater",
+ "/xyz/openbmc_project/software/" + firmwareId,
+ "xyz.openbmc_project.Software.RedundancyPriority", "Priority",
+ static_cast<uint8_t>(0),
+ [asyncResp](const boost::system::error_code& ec2) {
+ if (ec2)
+ {
+ BMCWEB_LOG_DEBUG("D-Bus response error setting.");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ doBMCGracefulRestart(asyncResp);
+ });
});
- });
}
-inline void
- afterSetDateTime(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const boost::system::error_code& ec,
- const sdbusplus::message_t& msg)
+inline void afterSetDateTime(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const boost::system::error_code& ec, const sdbusplus::message_t& msg)
{
if (ec)
{
@@ -1921,8 +1944,8 @@
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code& ec,
const sdbusplus::message_t& msg) {
- afterSetDateTime(asyncResp, ec, msg);
- },
+ afterSetDateTime(asyncResp, ec, msg);
+ },
"org.freedesktop.timedate1", "/org/freedesktop/timedate1",
"org.freedesktop.timedate1", "SetTime", us->count(), relative,
interactive);
@@ -1937,20 +1960,21 @@
"org.freedesktop.systemd1.Unit", "ActiveState",
[asyncResp](const boost::system::error_code& ec,
const std::string& val) {
- if (!ec)
- {
- if (val == "active")
+ if (!ec)
{
- asyncResp->res.jsonValue["Status"]["Health"] =
- resource::Health::Critical;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Quiesced;
- return;
+ if (val == "active")
+ {
+ asyncResp->res.jsonValue["Status"]["Health"] =
+ resource::Health::Critical;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Quiesced;
+ return;
+ }
}
- }
- asyncResp->res.jsonValue["Status"]["Health"] = resource::Health::OK;
- asyncResp->res.jsonValue["Status"]["State"] = resource::State::Enabled;
- });
+ asyncResp->res.jsonValue["Status"]["Health"] = resource::Health::OK;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Enabled;
+ });
}
inline void requestRoutesManager(App& app)
@@ -1959,296 +1983,321 @@
BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/")
.privileges(redfish::privileges::getManager)
- .methods(boost::beast::http::verb::get)(
- [&app, uuid](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& managerId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ .methods(
+ boost::beast::http::verb::
+ get)([&app,
+ uuid](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& managerId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "Manager", managerId);
- return;
- }
+ if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "Manager",
+ managerId);
+ return;
+ }
- asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/Managers/{}", BMCWEB_REDFISH_MANAGER_URI_NAME);
- asyncResp->res.jsonValue["@odata.type"] = "#Manager.v1_14_0.Manager";
- asyncResp->res.jsonValue["Id"] = BMCWEB_REDFISH_MANAGER_URI_NAME;
- asyncResp->res.jsonValue["Name"] = "OpenBmc Manager";
- asyncResp->res.jsonValue["Description"] =
- "Baseboard Management Controller";
- asyncResp->res.jsonValue["PowerState"] = resource::PowerState::On;
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}", BMCWEB_REDFISH_MANAGER_URI_NAME);
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#Manager.v1_14_0.Manager";
+ asyncResp->res.jsonValue["Id"] = BMCWEB_REDFISH_MANAGER_URI_NAME;
+ asyncResp->res.jsonValue["Name"] = "OpenBmc Manager";
+ asyncResp->res.jsonValue["Description"] =
+ "Baseboard Management Controller";
+ asyncResp->res.jsonValue["PowerState"] = resource::PowerState::On;
- asyncResp->res.jsonValue["ManagerType"] = manager::ManagerType::BMC;
- asyncResp->res.jsonValue["UUID"] = systemd_utils::getUuid();
- asyncResp->res.jsonValue["ServiceEntryPointUUID"] = uuid;
- asyncResp->res.jsonValue["Model"] = "OpenBmc"; // TODO(ed), get model
+ asyncResp->res.jsonValue["ManagerType"] = manager::ManagerType::BMC;
+ asyncResp->res.jsonValue["UUID"] = systemd_utils::getUuid();
+ asyncResp->res.jsonValue["ServiceEntryPointUUID"] = uuid;
+ asyncResp->res.jsonValue["Model"] =
+ "OpenBmc"; // TODO(ed), get model
- asyncResp->res.jsonValue["LogServices"]["@odata.id"] =
- boost::urls::format("/redfish/v1/Managers/{}/LogServices",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
- asyncResp->res.jsonValue["NetworkProtocol"]["@odata.id"] =
- boost::urls::format("/redfish/v1/Managers/{}/NetworkProtocol",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
- asyncResp->res.jsonValue["EthernetInterfaces"]["@odata.id"] =
- boost::urls::format("/redfish/v1/Managers/{}/EthernetInterfaces",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
-
- if constexpr (BMCWEB_VM_NBDPROXY)
- {
- asyncResp->res.jsonValue["VirtualMedia"]["@odata.id"] =
- boost::urls::format("/redfish/v1/Managers/{}/VirtualMedia",
+ asyncResp->res.jsonValue["LogServices"]["@odata.id"] =
+ boost::urls::format("/redfish/v1/Managers/{}/LogServices",
BMCWEB_REDFISH_MANAGER_URI_NAME);
- }
+ asyncResp->res.jsonValue["NetworkProtocol"]["@odata.id"] =
+ boost::urls::format("/redfish/v1/Managers/{}/NetworkProtocol",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+ asyncResp->res.jsonValue["EthernetInterfaces"]["@odata.id"] =
+ boost::urls::format(
+ "/redfish/v1/Managers/{}/EthernetInterfaces",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
- // default oem data
- nlohmann::json& oem = asyncResp->res.jsonValue["Oem"];
- nlohmann::json& oemOpenbmc = oem["OpenBmc"];
- oem["@odata.id"] = boost::urls::format("/redfish/v1/Managers/{}#/Oem",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
- oemOpenbmc["@odata.type"] = "#OpenBMCManager.v1_0_0.Manager";
- oemOpenbmc["@odata.id"] =
- boost::urls::format("/redfish/v1/Managers/{}#/Oem/OpenBmc",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
-
- nlohmann::json::object_t certificates;
- certificates["@odata.id"] = boost::urls::format(
- "/redfish/v1/Managers/{}/Truststore/Certificates",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
- oemOpenbmc["Certificates"] = std::move(certificates);
-
- // Manager.Reset (an action) can be many values, OpenBMC only
- // supports BMC reboot.
- nlohmann::json& managerReset =
- asyncResp->res.jsonValue["Actions"]["#Manager.Reset"];
- managerReset["target"] =
- boost::urls::format("/redfish/v1/Managers/{}/Actions/Manager.Reset",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
- managerReset["@Redfish.ActionInfo"] =
- boost::urls::format("/redfish/v1/Managers/{}/ResetActionInfo",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
-
- // ResetToDefaults (Factory Reset) has values like
- // PreserveNetworkAndUsers and PreserveNetwork that aren't supported
- // on OpenBMC
- nlohmann::json& resetToDefaults =
- asyncResp->res.jsonValue["Actions"]["#Manager.ResetToDefaults"];
- resetToDefaults["target"] = boost::urls::format(
- "/redfish/v1/Managers/{}/Actions/Manager.ResetToDefaults",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
- resetToDefaults["ResetType@Redfish.AllowableValues"] =
- nlohmann::json::array_t({"ResetAll"});
-
- std::pair<std::string, std::string> redfishDateTimeOffset =
- redfish::time_utils::getDateTimeOffsetNow();
-
- asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
- asyncResp->res.jsonValue["DateTimeLocalOffset"] =
- redfishDateTimeOffset.second;
-
- // TODO (Gunnar): Remove these one day since moved to ComputerSystem
- // Still used by OCP profiles
- // https://github.com/opencomputeproject/OCP-Profiles/issues/23
- // Fill in SerialConsole info
- asyncResp->res.jsonValue["SerialConsole"]["ServiceEnabled"] = true;
- asyncResp->res.jsonValue["SerialConsole"]["MaxConcurrentSessions"] = 15;
- asyncResp->res.jsonValue["SerialConsole"]["ConnectTypesSupported"] =
- nlohmann::json::array_t({"IPMI", "SSH"});
- if constexpr (BMCWEB_KVM)
- {
- // Fill in GraphicalConsole info
- asyncResp->res.jsonValue["GraphicalConsole"]["ServiceEnabled"] =
- true;
- asyncResp->res
- .jsonValue["GraphicalConsole"]["MaxConcurrentSessions"] = 4;
- asyncResp->res
- .jsonValue["GraphicalConsole"]["ConnectTypesSupported"] =
- nlohmann::json::array_t({"KVMIP"});
- }
- if constexpr (!BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- asyncResp->res.jsonValue["Links"]["ManagerForServers@odata.count"] =
- 1;
-
- nlohmann::json::array_t managerForServers;
- nlohmann::json::object_t manager;
- manager["@odata.id"] = std::format("/redfish/v1/Systems/{}",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
- managerForServers.emplace_back(std::move(manager));
-
- asyncResp->res.jsonValue["Links"]["ManagerForServers"] =
- std::move(managerForServers);
- }
-
- sw_util::populateSoftwareInformation(asyncResp, sw_util::bmcPurpose,
- "FirmwareVersion", true);
-
- managerGetLastResetTime(asyncResp);
-
- // ManagerDiagnosticData is added for all BMCs.
- nlohmann::json& managerDiagnosticData =
- asyncResp->res.jsonValue["ManagerDiagnosticData"];
- managerDiagnosticData["@odata.id"] =
- boost::urls::format("/redfish/v1/Managers/{}/ManagerDiagnosticData",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
-
- if constexpr (BMCWEB_REDFISH_OEM_MANAGER_FAN_DATA)
- {
- auto pids = std::make_shared<GetPIDValues>(asyncResp);
- pids->run();
- }
-
- getMainChassisId(asyncResp,
- [](const std::string& chassisId,
- const std::shared_ptr<bmcweb::AsyncResp>& aRsp) {
- aRsp->res.jsonValue["Links"]["ManagerForChassis@odata.count"] = 1;
- nlohmann::json::array_t managerForChassis;
- nlohmann::json::object_t managerObj;
- boost::urls::url chassiUrl =
- boost::urls::format("/redfish/v1/Chassis/{}", chassisId);
- managerObj["@odata.id"] = chassiUrl;
- managerForChassis.emplace_back(std::move(managerObj));
- aRsp->res.jsonValue["Links"]["ManagerForChassis"] =
- std::move(managerForChassis);
- aRsp->res.jsonValue["Links"]["ManagerInChassis"]["@odata.id"] =
- chassiUrl;
- });
-
- sdbusplus::asio::getProperty<double>(
- *crow::connections::systemBus, "org.freedesktop.systemd1",
- "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager",
- "Progress",
- [asyncResp](const boost::system::error_code& ec, double val) {
- if (ec)
+ if constexpr (BMCWEB_VM_NBDPROXY)
{
- BMCWEB_LOG_ERROR("Error while getting progress");
- messages::internalError(asyncResp->res);
- return;
- }
- if (val < 1.0)
- {
- asyncResp->res.jsonValue["Status"]["Health"] =
- resource::Health::OK;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Starting;
- return;
- }
- checkForQuiesced(asyncResp);
- });
-
- constexpr std::array<std::string_view, 1> interfaces = {
- "xyz.openbmc_project.Inventory.Item.Bmc"};
- dbus::utility::getSubTree(
- "/xyz/openbmc_project/inventory", 0, interfaces,
- [asyncResp](
- const boost::system::error_code& ec,
- const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("D-Bus response error on GetSubTree {}", ec);
- return;
- }
- if (subtree.empty())
- {
- BMCWEB_LOG_DEBUG("Can't find bmc D-Bus object!");
- return;
- }
- // Assume only 1 bmc D-Bus object
- // Throw an error if there is more than 1
- if (subtree.size() > 1)
- {
- BMCWEB_LOG_DEBUG("Found more than 1 bmc D-Bus object!");
- messages::internalError(asyncResp->res);
- return;
+ asyncResp->res.jsonValue["VirtualMedia"]["@odata.id"] =
+ boost::urls::format("/redfish/v1/Managers/{}/VirtualMedia",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
}
- if (subtree[0].first.empty() || subtree[0].second.size() != 1)
+ // default oem data
+ nlohmann::json& oem = asyncResp->res.jsonValue["Oem"];
+ nlohmann::json& oemOpenbmc = oem["OpenBmc"];
+ oem["@odata.id"] =
+ boost::urls::format("/redfish/v1/Managers/{}#/Oem",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+ oemOpenbmc["@odata.type"] = "#OpenBMCManager.v1_0_0.Manager";
+ oemOpenbmc["@odata.id"] =
+ boost::urls::format("/redfish/v1/Managers/{}#/Oem/OpenBmc",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+
+ nlohmann::json::object_t certificates;
+ certificates["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}/Truststore/Certificates",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+ oemOpenbmc["Certificates"] = std::move(certificates);
+
+ // Manager.Reset (an action) can be many values, OpenBMC only
+ // supports BMC reboot.
+ nlohmann::json& managerReset =
+ asyncResp->res.jsonValue["Actions"]["#Manager.Reset"];
+ managerReset["target"] = boost::urls::format(
+ "/redfish/v1/Managers/{}/Actions/Manager.Reset",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+ managerReset["@Redfish.ActionInfo"] =
+ boost::urls::format("/redfish/v1/Managers/{}/ResetActionInfo",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+
+ // ResetToDefaults (Factory Reset) has values like
+ // PreserveNetworkAndUsers and PreserveNetwork that aren't supported
+ // on OpenBMC
+ nlohmann::json& resetToDefaults =
+ asyncResp->res.jsonValue["Actions"]["#Manager.ResetToDefaults"];
+ resetToDefaults["target"] = boost::urls::format(
+ "/redfish/v1/Managers/{}/Actions/Manager.ResetToDefaults",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+ resetToDefaults["ResetType@Redfish.AllowableValues"] =
+ nlohmann::json::array_t({"ResetAll"});
+
+ std::pair<std::string, std::string> redfishDateTimeOffset =
+ redfish::time_utils::getDateTimeOffsetNow();
+
+ asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
+ asyncResp->res.jsonValue["DateTimeLocalOffset"] =
+ redfishDateTimeOffset.second;
+
+ // TODO (Gunnar): Remove these one day since moved to ComputerSystem
+ // Still used by OCP profiles
+ // https://github.com/opencomputeproject/OCP-Profiles/issues/23
+ // Fill in SerialConsole info
+ asyncResp->res.jsonValue["SerialConsole"]["ServiceEnabled"] = true;
+ asyncResp->res.jsonValue["SerialConsole"]["MaxConcurrentSessions"] =
+ 15;
+ asyncResp->res.jsonValue["SerialConsole"]["ConnectTypesSupported"] =
+ nlohmann::json::array_t({"IPMI", "SSH"});
+ if constexpr (BMCWEB_KVM)
{
- BMCWEB_LOG_DEBUG("Error getting bmc D-Bus object!");
- messages::internalError(asyncResp->res);
- return;
+ // Fill in GraphicalConsole info
+ asyncResp->res.jsonValue["GraphicalConsole"]["ServiceEnabled"] =
+ true;
+ asyncResp->res
+ .jsonValue["GraphicalConsole"]["MaxConcurrentSessions"] = 4;
+ asyncResp->res
+ .jsonValue["GraphicalConsole"]["ConnectTypesSupported"] =
+ nlohmann::json::array_t({"KVMIP"});
+ }
+ if constexpr (!BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ asyncResp->res
+ .jsonValue["Links"]["ManagerForServers@odata.count"] = 1;
+
+ nlohmann::json::array_t managerForServers;
+ nlohmann::json::object_t manager;
+ manager["@odata.id"] = std::format(
+ "/redfish/v1/Systems/{}", BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ managerForServers.emplace_back(std::move(manager));
+
+ asyncResp->res.jsonValue["Links"]["ManagerForServers"] =
+ std::move(managerForServers);
}
- const std::string& path = subtree[0].first;
- const std::string& connectionName = subtree[0].second[0].first;
+ sw_util::populateSoftwareInformation(asyncResp, sw_util::bmcPurpose,
+ "FirmwareVersion", true);
- for (const auto& interfaceName : subtree[0].second[0].second)
+ managerGetLastResetTime(asyncResp);
+
+ // ManagerDiagnosticData is added for all BMCs.
+ nlohmann::json& managerDiagnosticData =
+ asyncResp->res.jsonValue["ManagerDiagnosticData"];
+ managerDiagnosticData["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}/ManagerDiagnosticData",
+ BMCWEB_REDFISH_MANAGER_URI_NAME);
+
+ if constexpr (BMCWEB_REDFISH_OEM_MANAGER_FAN_DATA)
{
- if (interfaceName ==
- "xyz.openbmc_project.Inventory.Decorator.Asset")
- {
- sdbusplus::asio::getAllProperties(
- *crow::connections::systemBus, connectionName, path,
- "xyz.openbmc_project.Inventory.Decorator.Asset",
- [asyncResp](const boost::system::error_code& ec2,
+ auto pids = std::make_shared<GetPIDValues>(asyncResp);
+ pids->run();
+ }
+
+ getMainChassisId(asyncResp, [](const std::string& chassisId,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>& aRsp) {
+ aRsp->res.jsonValue["Links"]["ManagerForChassis@odata.count"] =
+ 1;
+ nlohmann::json::array_t managerForChassis;
+ nlohmann::json::object_t managerObj;
+ boost::urls::url chassiUrl =
+ boost::urls::format("/redfish/v1/Chassis/{}", chassisId);
+ managerObj["@odata.id"] = chassiUrl;
+ managerForChassis.emplace_back(std::move(managerObj));
+ aRsp->res.jsonValue["Links"]["ManagerForChassis"] =
+ std::move(managerForChassis);
+ aRsp->res.jsonValue["Links"]["ManagerInChassis"]["@odata.id"] =
+ chassiUrl;
+ });
+
+ sdbusplus::asio::getProperty<double>(
+ *crow::connections::systemBus, "org.freedesktop.systemd1",
+ "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager",
+ "Progress",
+ [asyncResp](const boost::system::error_code& ec, double val) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("Error while getting progress");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (val < 1.0)
+ {
+ asyncResp->res.jsonValue["Status"]["Health"] =
+ resource::Health::OK;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Starting;
+ return;
+ }
+ checkForQuiesced(asyncResp);
+ });
+
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.Bmc"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
+ [asyncResp](
+ const boost::system::error_code& ec,
+ const dbus::utility::MapperGetSubTreeResponse& subtree) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG(
+ "D-Bus response error on GetSubTree {}", ec);
+ return;
+ }
+ if (subtree.empty())
+ {
+ BMCWEB_LOG_DEBUG("Can't find bmc D-Bus object!");
+ return;
+ }
+ // Assume only 1 bmc D-Bus object
+ // Throw an error if there is more than 1
+ if (subtree.size() > 1)
+ {
+ BMCWEB_LOG_DEBUG("Found more than 1 bmc D-Bus object!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ if (subtree[0].first.empty() ||
+ subtree[0].second.size() != 1)
+ {
+ BMCWEB_LOG_DEBUG("Error getting bmc D-Bus object!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ const std::string& path = subtree[0].first;
+ const std::string& connectionName =
+ subtree[0].second[0].first;
+
+ for (const auto& interfaceName :
+ subtree[0].second[0].second)
+ {
+ if (interfaceName ==
+ "xyz.openbmc_project.Inventory.Decorator.Asset")
+ {
+ sdbusplus::asio::getAllProperties(
+ *crow::connections::systemBus, connectionName,
+ path,
+ "xyz.openbmc_project.Inventory.Decorator.Asset",
+ [asyncResp](
+ const boost::system::error_code& ec2,
const dbus::utility::DBusPropertiesMap&
propertiesList) {
- if (ec2)
- {
- BMCWEB_LOG_DEBUG("Can't get bmc asset!");
- return;
+ if (ec2)
+ {
+ BMCWEB_LOG_DEBUG(
+ "Can't get bmc asset!");
+ return;
+ }
+
+ const std::string* partNumber = nullptr;
+ const std::string* serialNumber = nullptr;
+ const std::string* manufacturer = nullptr;
+ const std::string* model = nullptr;
+ const std::string* sparePartNumber =
+ nullptr;
+
+ const bool success =
+ sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(),
+ propertiesList, "PartNumber",
+ partNumber, "SerialNumber",
+ serialNumber, "Manufacturer",
+ manufacturer, "Model", model,
+ "SparePartNumber", sparePartNumber);
+
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ if (partNumber != nullptr)
+ {
+ asyncResp->res.jsonValue["PartNumber"] =
+ *partNumber;
+ }
+
+ if (serialNumber != nullptr)
+ {
+ asyncResp->res
+ .jsonValue["SerialNumber"] =
+ *serialNumber;
+ }
+
+ if (manufacturer != nullptr)
+ {
+ asyncResp->res
+ .jsonValue["Manufacturer"] =
+ *manufacturer;
+ }
+
+ if (model != nullptr)
+ {
+ asyncResp->res.jsonValue["Model"] =
+ *model;
+ }
+
+ if (sparePartNumber != nullptr)
+ {
+ asyncResp->res
+ .jsonValue["SparePartNumber"] =
+ *sparePartNumber;
+ }
+ });
}
-
- const std::string* partNumber = nullptr;
- const std::string* serialNumber = nullptr;
- const std::string* manufacturer = nullptr;
- const std::string* model = nullptr;
- const std::string* sparePartNumber = nullptr;
-
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), propertiesList,
- "PartNumber", partNumber, "SerialNumber",
- serialNumber, "Manufacturer", manufacturer, "Model",
- model, "SparePartNumber", sparePartNumber);
-
- if (!success)
+ else if (
+ interfaceName ==
+ "xyz.openbmc_project.Inventory.Decorator.LocationCode")
{
- messages::internalError(asyncResp->res);
- return;
+ getLocation(asyncResp, connectionName, path);
}
-
- if (partNumber != nullptr)
- {
- asyncResp->res.jsonValue["PartNumber"] =
- *partNumber;
- }
-
- if (serialNumber != nullptr)
- {
- asyncResp->res.jsonValue["SerialNumber"] =
- *serialNumber;
- }
-
- if (manufacturer != nullptr)
- {
- asyncResp->res.jsonValue["Manufacturer"] =
- *manufacturer;
- }
-
- if (model != nullptr)
- {
- asyncResp->res.jsonValue["Model"] = *model;
- }
-
- if (sparePartNumber != nullptr)
- {
- asyncResp->res.jsonValue["SparePartNumber"] =
- *sparePartNumber;
- }
- });
- }
- else if (interfaceName ==
- "xyz.openbmc_project.Inventory.Decorator.LocationCode")
- {
- getLocation(asyncResp, connectionName, path);
- }
- }
+ }
+ });
});
- });
BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/")
.privileges(redfish::privileges::patchManager)
@@ -2256,26 +2305,27 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& managerId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "Manager", managerId);
- return;
- }
+ if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "Manager",
+ managerId);
+ return;
+ }
- std::optional<std::string> activeSoftwareImageOdataId;
- std::optional<std::string> datetime;
- std::optional<nlohmann::json::object_t> pidControllers;
- std::optional<nlohmann::json::object_t> fanControllers;
- std::optional<nlohmann::json::object_t> fanZones;
- std::optional<nlohmann::json::object_t> stepwiseControllers;
- std::optional<std::string> profile;
+ std::optional<std::string> activeSoftwareImageOdataId;
+ std::optional<std::string> datetime;
+ std::optional<nlohmann::json::object_t> pidControllers;
+ std::optional<nlohmann::json::object_t> fanControllers;
+ std::optional<nlohmann::json::object_t> fanZones;
+ std::optional<nlohmann::json::object_t> stepwiseControllers;
+ std::optional<std::string> profile;
- // clang-format off
+ // clang-format off
if (!json_util::readJsonPatch(req, asyncResp->res,
"DateTime", datetime,
"Links/ActiveSoftwareImage/@odata.id", activeSoftwareImageOdataId,
@@ -2288,56 +2338,60 @@
{
return;
}
- // clang-format on
+ // clang-format on
- if (pidControllers || fanControllers || fanZones ||
- stepwiseControllers || profile)
- {
- if constexpr (BMCWEB_REDFISH_OEM_MANAGER_FAN_DATA)
- {
- std::vector<std::pair<std::string,
+ if (pidControllers || fanControllers || fanZones ||
+ stepwiseControllers || profile)
+ {
+ if constexpr (BMCWEB_REDFISH_OEM_MANAGER_FAN_DATA)
+ {
+ std::vector<
+ std::pair<std::string,
std::optional<nlohmann::json::object_t>>>
- configuration;
- if (pidControllers)
- {
- configuration.emplace_back("PidControllers",
- std::move(pidControllers));
+ configuration;
+ if (pidControllers)
+ {
+ configuration.emplace_back(
+ "PidControllers", std::move(pidControllers));
+ }
+ if (fanControllers)
+ {
+ configuration.emplace_back(
+ "FanControllers", std::move(fanControllers));
+ }
+ if (fanZones)
+ {
+ configuration.emplace_back("FanZones",
+ std::move(fanZones));
+ }
+ if (stepwiseControllers)
+ {
+ configuration.emplace_back(
+ "StepwiseControllers",
+ std::move(stepwiseControllers));
+ }
+ auto pid = std::make_shared<SetPIDValues>(
+ asyncResp, std::move(configuration), profile);
+ pid->run();
+ }
+ else
+ {
+ messages::propertyUnknown(asyncResp->res, "Oem");
+ return;
+ }
}
- if (fanControllers)
- {
- configuration.emplace_back("FanControllers",
- std::move(fanControllers));
- }
- if (fanZones)
- {
- configuration.emplace_back("FanZones", std::move(fanZones));
- }
- if (stepwiseControllers)
- {
- configuration.emplace_back("StepwiseControllers",
- std::move(stepwiseControllers));
- }
- auto pid = std::make_shared<SetPIDValues>(
- asyncResp, std::move(configuration), profile);
- pid->run();
- }
- else
- {
- messages::propertyUnknown(asyncResp->res, "Oem");
- return;
- }
- }
- if (activeSoftwareImageOdataId)
- {
- setActiveFirmwareImage(asyncResp, *activeSoftwareImageOdataId);
- }
+ if (activeSoftwareImageOdataId)
+ {
+ setActiveFirmwareImage(asyncResp,
+ *activeSoftwareImageOdataId);
+ }
- if (datetime)
- {
- setDateTime(asyncResp, *datetime);
- }
- });
+ if (datetime)
+ {
+ setDateTime(asyncResp, *datetime);
+ }
+ });
}
inline void requestRoutesManagerCollection(App& app)
@@ -2347,22 +2401,22 @@
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- // Collections don't include the static data added by SubRoute
- // because it has a duplicate entry for members
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers";
- asyncResp->res.jsonValue["@odata.type"] =
- "#ManagerCollection.ManagerCollection";
- asyncResp->res.jsonValue["Name"] = "Manager Collection";
- asyncResp->res.jsonValue["Members@odata.count"] = 1;
- nlohmann::json::array_t members;
- nlohmann::json& bmc = members.emplace_back();
- bmc["@odata.id"] = boost::urls::format("/redfish/v1/Managers/{}",
- BMCWEB_REDFISH_MANAGER_URI_NAME);
- asyncResp->res.jsonValue["Members"] = std::move(members);
- });
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ // Collections don't include the static data added by SubRoute
+ // because it has a duplicate entry for members
+ asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ManagerCollection.ManagerCollection";
+ asyncResp->res.jsonValue["Name"] = "Manager Collection";
+ asyncResp->res.jsonValue["Members@odata.count"] = 1;
+ nlohmann::json::array_t members;
+ nlohmann::json& bmc = members.emplace_back();
+ bmc["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}", BMCWEB_REDFISH_MANAGER_URI_NAME);
+ asyncResp->res.jsonValue["Members"] = std::move(members);
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp
index cd87d42..39ab0ac 100644
--- a/redfish-core/lib/memory.hpp
+++ b/redfish-core/lib/memory.hpp
@@ -370,34 +370,38 @@
if (dataLockCapable != nullptr)
{
- asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
- ["DataLockCapable"] = *dataLockCapable;
+ asyncResp->res
+ .jsonValue[jsonPtr]["SecurityCapabilities"]["DataLockCapable"] =
+ *dataLockCapable;
}
if (passphraseCapable != nullptr)
{
- asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
- ["PassphraseCapable"] = *passphraseCapable;
+ asyncResp->res
+ .jsonValue[jsonPtr]["SecurityCapabilities"]["PassphraseCapable"] =
+ *passphraseCapable;
}
if (maxPassphraseCount != nullptr)
{
- asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
- ["MaxPassphraseCount"] = *maxPassphraseCount;
+ asyncResp->res
+ .jsonValue[jsonPtr]["SecurityCapabilities"]["MaxPassphraseCount"] =
+ *maxPassphraseCount;
}
if (passphraseLockLimit != nullptr)
{
- asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"]
- ["PassphraseLockLimit"] = *passphraseLockLimit;
+ asyncResp->res
+ .jsonValue[jsonPtr]["SecurityCapabilities"]["PassphraseLockLimit"] =
+ *passphraseLockLimit;
}
}
-inline void
- assembleDimmProperties(std::string_view dimmId,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const dbus::utility::DBusPropertiesMap& properties,
- const nlohmann::json::json_pointer& jsonPtr)
+inline void assembleDimmProperties(
+ std::string_view dimmId,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const dbus::utility::DBusPropertiesMap& properties,
+ const nlohmann::json::json_pointer& jsonPtr)
{
asyncResp->res.jsonValue[jsonPtr]["Id"] = dimmId;
asyncResp->res.jsonValue[jsonPtr]["Name"] = "DIMM Slot";
@@ -575,8 +579,9 @@
if (memoryController != nullptr)
{
- asyncResp->res.jsonValue[jsonPtr]["MemoryLocation"]
- ["MemoryController"] = *memoryController;
+ asyncResp->res
+ .jsonValue[jsonPtr]["MemoryLocation"]["MemoryController"] =
+ *memoryController;
}
if (slot != nullptr)
@@ -601,17 +606,17 @@
if (locationCode != nullptr)
{
- asyncResp->res.jsonValue[jsonPtr]["Location"]["PartLocation"]
- ["ServiceLabel"] = *locationCode;
+ asyncResp->res
+ .jsonValue[jsonPtr]["Location"]["PartLocation"]["ServiceLabel"] =
+ *locationCode;
}
getPersistentMemoryProperties(asyncResp, properties, jsonPtr);
}
-inline void getDimmDataByService(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
- const std::string& dimmId,
- const std::string& service,
- const std::string& objPath)
+inline void getDimmDataByService(
+ std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& dimmId,
+ const std::string& service, const std::string& objPath)
{
BMCWEB_LOG_DEBUG("Get available system components.");
sdbusplus::asio::getAllProperties(
@@ -619,14 +624,15 @@
[dimmId, asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error");
- messages::internalError(asyncResp->res);
- return;
- }
- assembleDimmProperties(dimmId, asyncResp, properties, ""_json_pointer);
- });
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("DBUS response error");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ assembleDimmProperties(dimmId, asyncResp, properties,
+ ""_json_pointer);
+ });
}
inline void assembleDimmPartitionData(
@@ -692,16 +698,16 @@
[asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error");
- messages::internalError(asyncResp->res);
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("DBUS response error");
+ messages::internalError(asyncResp->res);
- return;
+ return;
+ }
+ nlohmann::json::json_pointer regionPtr = "/Regions"_json_pointer;
+ assembleDimmPartitionData(asyncResp, properties, regionPtr);
}
- nlohmann::json::json_pointer regionPtr = "/Regions"_json_pointer;
- assembleDimmPartitionData(asyncResp, properties, regionPtr);
- }
);
}
@@ -718,57 +724,57 @@
[dimmId, asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error");
- messages::internalError(asyncResp->res);
-
- return;
- }
- bool found = false;
- for (const auto& [rawPath, object] : subtree)
- {
- sdbusplus::message::object_path path(rawPath);
- for (const auto& [service, interfaces] : object)
+ if (ec)
{
- for (const auto& interface : interfaces)
- {
- if (interface ==
- "xyz.openbmc_project.Inventory.Item.Dimm" &&
- path.filename() == dimmId)
- {
- getDimmDataByService(asyncResp, dimmId, service,
- rawPath);
- found = true;
- }
+ BMCWEB_LOG_DEBUG("DBUS response error");
+ messages::internalError(asyncResp->res);
- // partitions are separate as there can be multiple
- // per
- // device, i.e.
- // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition1
- // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition2
- if (interface ==
- "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition" &&
- path.parent_path().filename() == dimmId)
+ return;
+ }
+ bool found = false;
+ for (const auto& [rawPath, object] : subtree)
+ {
+ sdbusplus::message::object_path path(rawPath);
+ for (const auto& [service, interfaces] : object)
+ {
+ for (const auto& interface : interfaces)
{
- getDimmPartitionData(asyncResp, service, rawPath);
+ if (interface ==
+ "xyz.openbmc_project.Inventory.Item.Dimm" &&
+ path.filename() == dimmId)
+ {
+ getDimmDataByService(asyncResp, dimmId, service,
+ rawPath);
+ found = true;
+ }
+
+ // partitions are separate as there can be multiple
+ // per
+ // device, i.e.
+ // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition1
+ // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition2
+ if (interface ==
+ "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition" &&
+ path.parent_path().filename() == dimmId)
+ {
+ getDimmPartitionData(asyncResp, service, rawPath);
+ }
}
}
}
- }
- // Object not found
- if (!found)
- {
- messages::resourceNotFound(asyncResp->res, "Memory", dimmId);
+ // Object not found
+ if (!found)
+ {
+ messages::resourceNotFound(asyncResp->res, "Memory", dimmId);
+ return;
+ }
+ // Set @odata only if object is found
+ asyncResp->res.jsonValue["@odata.type"] = "#Memory.v1_11_0.Memory";
+ asyncResp->res.jsonValue["@odata.id"] =
+ boost::urls::format("/redfish/v1/Systems/{}/Memory/{}",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, dimmId);
return;
- }
- // Set @odata only if object is found
- asyncResp->res.jsonValue["@odata.type"] = "#Memory.v1_11_0.Memory";
- asyncResp->res.jsonValue["@odata.id"] =
- boost::urls::format("/redfish/v1/Systems/{}/Memory/{}",
- BMCWEB_REDFISH_SYSTEM_URI_NAME, dimmId);
- return;
- });
+ });
}
inline void requestRoutesMemoryCollection(App& app)
@@ -782,38 +788,39 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- asyncResp->res.jsonValue["@odata.type"] =
- "#MemoryCollection.MemoryCollection";
- asyncResp->res.jsonValue["Name"] = "Memory Module Collection";
- asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/{}/Memory", BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#MemoryCollection.MemoryCollection";
+ asyncResp->res.jsonValue["Name"] = "Memory Module Collection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ boost::urls::format("/redfish/v1/Systems/{}/Memory",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
- constexpr std::array<std::string_view, 1> interfaces{
- "xyz.openbmc_project.Inventory.Item.Dimm"};
- collection_util::getCollectionMembers(
- asyncResp,
- boost::urls::format("/redfish/v1/Systems/{}/Memory",
- BMCWEB_REDFISH_SYSTEM_URI_NAME),
- interfaces, "/xyz/openbmc_project/inventory");
- });
+ constexpr std::array<std::string_view, 1> interfaces{
+ "xyz.openbmc_project.Inventory.Item.Dimm"};
+ collection_util::getCollectionMembers(
+ asyncResp,
+ boost::urls::format("/redfish/v1/Systems/{}/Memory",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME),
+ interfaces, "/xyz/openbmc_project/inventory");
+ });
}
inline void requestRoutesMemory(App& app)
@@ -827,28 +834,28 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName, const std::string& dimmId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- getDimmData(asyncResp, dimmId);
- });
+ getDimmData(asyncResp, dimmId);
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp
index 94588ac..6cacc17 100644
--- a/redfish-core/lib/message_registries.hpp
+++ b/redfish-core/lib/message_registries.hpp
@@ -56,8 +56,8 @@
{"Base", "TaskEvent", "ResourceEvent", "OpenBMC", "Telemetry"}))
{
nlohmann::json::object_t member;
- member["@odata.id"] = boost::urls::format("/redfish/v1/Registries/{}",
- memberName);
+ member["@odata.id"] =
+ boost::urls::format("/redfish/v1/Registries/{}", memberName);
members.emplace_back(std::move(member));
}
}
@@ -123,8 +123,8 @@
asyncResp->res.jsonValue["@odata.type"] =
"#MessageRegistryFile.v1_1_0.MessageRegistryFile";
asyncResp->res.jsonValue["Name"] = registry + " Message Registry File";
- asyncResp->res.jsonValue["Description"] = dmtf + registry +
- " Message Registry File Location";
+ asyncResp->res.jsonValue["Description"] =
+ dmtf + registry + " Message Registry File Location";
asyncResp->res.jsonValue["Id"] = header->registryPrefix;
asyncResp->res.jsonValue["Registry"] = header->id;
nlohmann::json::array_t languages;
diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp
index 3eb6927..c47ba13 100644
--- a/redfish-core/lib/metric_report.hpp
+++ b/redfish-core/lib/metric_report.hpp
@@ -65,24 +65,25 @@
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- asyncResp->res.jsonValue["@odata.type"] =
- "#MetricReportCollection.MetricReportCollection";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/TelemetryService/MetricReports";
- asyncResp->res.jsonValue["Name"] = "Metric Report Collection";
- constexpr std::array<std::string_view, 1> interfaces{
- telemetry::reportInterface};
- collection_util::getCollectionMembers(
- asyncResp,
- boost::urls::url("/redfish/v1/TelemetryService/MetricReports"),
- interfaces,
- "/xyz/openbmc_project/Telemetry/Reports/TelemetryService");
- });
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#MetricReportCollection.MetricReportCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/TelemetryService/MetricReports";
+ asyncResp->res.jsonValue["Name"] = "Metric Report Collection";
+ constexpr std::array<std::string_view, 1> interfaces{
+ telemetry::reportInterface};
+ collection_util::getCollectionMembers(
+ asyncResp,
+ boost::urls::url(
+ "/redfish/v1/TelemetryService/MetricReports"),
+ interfaces,
+ "/xyz/openbmc_project/Telemetry/Reports/TelemetryService");
+ });
}
inline void requestRoutesMetricReport(App& app)
@@ -93,43 +94,49 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& id) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- const std::string reportPath = telemetry::getDbusReportPath(id);
- crow::connections::systemBus->async_method_call(
- [asyncResp, id, reportPath](const boost::system::error_code& ec) {
- if (ec.value() == EBADR ||
- ec == boost::system::errc::host_unreachable)
- {
- messages::resourceNotFound(asyncResp->res, "MetricReport", id);
- return;
- }
- if (ec)
- {
- BMCWEB_LOG_ERROR("respHandler DBus error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
-
- sdbusplus::asio::getProperty<telemetry::TimestampReadings>(
- *crow::connections::systemBus, telemetry::service, reportPath,
- telemetry::reportInterface, "Readings",
- [asyncResp, id](const boost::system::error_code& ec2,
- const telemetry::TimestampReadings& ret) {
- if (ec2)
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
- BMCWEB_LOG_ERROR("respHandler DBus error {}", ec2);
- messages::internalError(asyncResp->res);
return;
}
+ const std::string reportPath = telemetry::getDbusReportPath(id);
+ crow::connections::systemBus->async_method_call(
+ [asyncResp, id,
+ reportPath](const boost::system::error_code& ec) {
+ if (ec.value() == EBADR ||
+ ec == boost::system::errc::host_unreachable)
+ {
+ messages::resourceNotFound(asyncResp->res,
+ "MetricReport", id);
+ return;
+ }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("respHandler DBus error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- telemetry::fillReport(asyncResp->res.jsonValue, id, ret);
+ sdbusplus::asio::getProperty<
+ telemetry::TimestampReadings>(
+ *crow::connections::systemBus, telemetry::service,
+ reportPath, telemetry::reportInterface, "Readings",
+ [asyncResp,
+ id](const boost::system::error_code& ec2,
+ const telemetry::TimestampReadings& ret) {
+ if (ec2)
+ {
+ BMCWEB_LOG_ERROR(
+ "respHandler DBus error {}", ec2);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ telemetry::fillReport(asyncResp->res.jsonValue,
+ id, ret);
+ });
+ },
+ telemetry::service, reportPath, telemetry::reportInterface,
+ "Update");
});
- },
- telemetry::service, reportPath, telemetry::reportInterface,
- "Update");
- });
}
} // namespace redfish
diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
index 06244ac..c83ada4 100644
--- a/redfish-core/lib/metric_report_definition.hpp
+++ b/redfish-core/lib/metric_report_definition.hpp
@@ -246,10 +246,9 @@
return triggers;
}
-inline void
- fillReportDefinition(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& id,
- const dbus::utility::DBusPropertiesMap& properties)
+inline void fillReportDefinition(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& id,
+ const dbus::utility::DBusPropertiesMap& properties)
{
std::vector<std::string> reportActions;
ReadingParameters readingParams;
@@ -642,9 +641,9 @@
getChassisSensorNode(metric.uris, matched);
if (error)
{
- messages::propertyValueIncorrect(asyncResp->res, error->uri,
- "MetricProperties/" +
- std::to_string(error->index));
+ messages::propertyValueIncorrect(
+ asyncResp->res, error->uri,
+ "MetricProperties/" + std::to_string(error->index));
return false;
}
}
@@ -656,8 +655,7 @@
public:
AddReport(AddReportArgs&& argsIn,
const std::shared_ptr<bmcweb::AsyncResp>& asyncRespIn) :
- asyncResp(asyncRespIn),
- args(std::move(argsIn))
+ asyncResp(asyncRespIn), args(std::move(argsIn))
{}
~AddReport()
@@ -696,9 +694,9 @@
BMCWEB_LOG_ERROR(
"Failed to find DBus sensor corresponding to URI {}",
uri);
- messages::propertyValueNotInList(asyncResp->res, uri,
- "MetricProperties/" +
- std::to_string(i));
+ messages::propertyValueNotInList(
+ asyncResp->res, uri,
+ "MetricProperties/" + std::to_string(i));
return;
}
@@ -714,37 +712,37 @@
crow::connections::systemBus->async_method_call(
[asyncResp, id = args.id, uriToDbus](
const boost::system::error_code& ec, const std::string&) {
- if (ec == boost::system::errc::file_exists)
- {
- messages::resourceAlreadyExists(
- asyncResp->res, "MetricReportDefinition", "Id", id);
- return;
- }
- if (ec == boost::system::errc::too_many_files_open)
- {
- messages::createLimitReachedForResource(asyncResp->res);
- return;
- }
- if (ec == boost::system::errc::argument_list_too_long)
- {
- nlohmann::json metricProperties = nlohmann::json::array();
- for (const auto& [uri, _] : uriToDbus)
+ if (ec == boost::system::errc::file_exists)
{
- metricProperties.emplace_back(uri);
+ messages::resourceAlreadyExists(
+ asyncResp->res, "MetricReportDefinition", "Id", id);
+ return;
}
- messages::propertyValueIncorrect(
- asyncResp->res, "MetricProperties", metricProperties);
- return;
- }
- if (ec)
- {
- messages::internalError(asyncResp->res);
- BMCWEB_LOG_ERROR("respHandler DBus error {}", ec);
- return;
- }
+ if (ec == boost::system::errc::too_many_files_open)
+ {
+ messages::createLimitReachedForResource(asyncResp->res);
+ return;
+ }
+ if (ec == boost::system::errc::argument_list_too_long)
+ {
+ nlohmann::json metricProperties = nlohmann::json::array();
+ for (const auto& [uri, _] : uriToDbus)
+ {
+ metricProperties.emplace_back(uri);
+ }
+ messages::propertyValueIncorrect(
+ asyncResp->res, "MetricProperties", metricProperties);
+ return;
+ }
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ BMCWEB_LOG_ERROR("respHandler DBus error {}", ec);
+ return;
+ }
- messages::created(asyncResp->res);
- },
+ messages::created(asyncResp->res);
+ },
telemetry::service, "/xyz/openbmc_project/Telemetry/Reports",
"xyz.openbmc_project.Telemetry.ReportManager", "AddReport",
"TelemetryService/" + args.id, args.name, args.reportingType,
@@ -773,8 +771,7 @@
public:
UpdateMetrics(std::string_view idIn,
const std::shared_ptr<bmcweb::AsyncResp>& asyncRespIn) :
- id(idIn),
- asyncResp(asyncRespIn)
+ id(idIn), asyncResp(asyncRespIn)
{}
~UpdateMetrics()
@@ -809,10 +806,11 @@
additionalMetricPropertyToDbusPaths.end());
}
- void emplace(std::span<const std::tuple<sdbusplus::message::object_path,
- std::string>>
- pathAndUri,
- const AddReportArgs::MetricArgs& metricArgs)
+ void emplace(
+ std::span<
+ const std::tuple<sdbusplus::message::object_path, std::string>>
+ pathAndUri,
+ const AddReportArgs::MetricArgs& metricArgs)
{
readingParamsUris.emplace_back(metricArgs.uris);
readingParams.emplace_back(
@@ -847,11 +845,11 @@
crow::connections::systemBus->async_method_call(
[asyncResp(this->asyncResp),
reportId = id](const boost::system::error_code& ec) {
- if (!verifyCommonErrors(asyncResp->res, reportId, ec))
- {
- return;
- }
- },
+ if (!verifyCommonErrors(asyncResp->res, reportId, ec))
+ {
+ return;
+ }
+ },
"xyz.openbmc_project.Telemetry", getDbusReportPath(id),
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Telemetry.Report", "ReadingParameters",
@@ -892,11 +890,11 @@
{
crow::connections::systemBus->async_method_call(
[asyncResp, id = std::string(id)](const boost::system::error_code& ec) {
- if (!verifyCommonErrors(asyncResp->res, id, ec))
- {
- return;
- }
- },
+ if (!verifyCommonErrors(asyncResp->res, id, ec))
+ {
+ return;
+ }
+ },
"xyz.openbmc_project.Telemetry", getDbusReportPath(id),
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Telemetry.Report", "Enabled",
@@ -909,11 +907,11 @@
{
crow::connections::systemBus->async_method_call(
[asyncResp, id = std::string(id)](const boost::system::error_code& ec) {
- if (!verifyCommonErrors(asyncResp->res, id, ec))
- {
- return;
- }
- },
+ if (!verifyCommonErrors(asyncResp->res, id, ec))
+ {
+ return;
+ }
+ },
"xyz.openbmc_project.Telemetry", getDbusReportPath(id),
"xyz.openbmc_project.Telemetry.Report", "SetReportingProperties",
reportingType, recurrenceInterval);
@@ -925,127 +923,126 @@
{
crow::connections::systemBus->async_method_call(
[asyncResp, id = std::string(id)](const boost::system::error_code& ec) {
- if (!verifyCommonErrors(asyncResp->res, id, ec))
- {
- return;
- }
- },
+ if (!verifyCommonErrors(asyncResp->res, id, ec))
+ {
+ return;
+ }
+ },
"xyz.openbmc_project.Telemetry", getDbusReportPath(id),
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Telemetry.Report", "ReportUpdates",
dbus::utility::DbusVariantType{reportUpdates});
}
-inline void
- setReportActions(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- std::string_view id,
- const std::vector<std::string>& dbusReportActions)
+inline void setReportActions(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, std::string_view id,
+ const std::vector<std::string>& dbusReportActions)
{
crow::connections::systemBus->async_method_call(
[asyncResp, id = std::string(id)](const boost::system::error_code& ec) {
- if (!verifyCommonErrors(asyncResp->res, id, ec))
- {
- return;
- }
- },
+ if (!verifyCommonErrors(asyncResp->res, id, ec))
+ {
+ return;
+ }
+ },
"xyz.openbmc_project.Telemetry", getDbusReportPath(id),
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Telemetry.Report", "ReportActions",
dbus::utility::DbusVariantType{dbusReportActions});
}
-inline void
- setReportMetrics(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- std::string_view id,
- std::span<nlohmann::json::object_t> metrics)
+inline void setReportMetrics(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, std::string_view id,
+ std::span<nlohmann::json::object_t> metrics)
{
sdbusplus::asio::getAllProperties(
*crow::connections::systemBus, telemetry::service,
telemetry::getDbusReportPath(id), telemetry::reportInterface,
[asyncResp, id = std::string(id),
- redfishMetrics = std::vector<nlohmann::json::object_t>(metrics.begin(),
- metrics.end())](
+ redfishMetrics = std::vector<nlohmann::json::object_t>(
+ metrics.begin(), metrics.end())](
boost::system::error_code ec,
const dbus::utility::DBusPropertiesMap& properties) mutable {
- if (!redfish::telemetry::verifyCommonErrors(asyncResp->res, id, ec))
- {
- return;
- }
-
- ReadingParameters readingParams;
-
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), properties, "ReadingParameters",
- readingParams);
-
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- auto updateMetricsReq = std::make_shared<UpdateMetrics>(id, asyncResp);
-
- boost::container::flat_set<std::pair<std::string, std::string>>
- chassisSensors;
-
- size_t index = 0;
- for (nlohmann::json::object_t& metric : redfishMetrics)
- {
- AddReportArgs::MetricArgs metricArgs;
- std::vector<
- std::tuple<sdbusplus::message::object_path, std::string>>
- pathAndUri;
-
- if (index < readingParams.size())
- {
- const ReadingParameters::value_type& existing =
- readingParams[index];
-
- pathAndUri = std::get<0>(existing);
- metricArgs.collectionFunction = std::get<1>(existing);
- metricArgs.collectionTimeScope = std::get<2>(existing);
- metricArgs.collectionDuration = std::get<3>(existing);
- }
-
- if (!getUserMetric(asyncResp->res, metric, metricArgs))
+ if (!redfish::telemetry::verifyCommonErrors(asyncResp->res, id, ec))
{
return;
}
- std::optional<IncorrectMetricUri> error =
- getChassisSensorNode(metricArgs.uris, chassisSensors);
+ ReadingParameters readingParams;
- if (error)
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), properties,
+ "ReadingParameters", readingParams);
+
+ if (!success)
{
- messages::propertyValueIncorrect(
- asyncResp->res, error->uri,
- "MetricProperties/" + std::to_string(error->index));
+ messages::internalError(asyncResp->res);
return;
}
- updateMetricsReq->emplace(pathAndUri, metricArgs);
- index++;
- }
+ auto updateMetricsReq =
+ std::make_shared<UpdateMetrics>(id, asyncResp);
- for (const auto& [chassis, sensorType] : chassisSensors)
- {
- retrieveUriToDbusMap(
- chassis, sensorType,
- [asyncResp, updateMetricsReq](
- const boost::beast::http::status status,
- const std::map<std::string, std::string>& uriToDbus) {
- if (status != boost::beast::http::status::ok)
+ boost::container::flat_set<std::pair<std::string, std::string>>
+ chassisSensors;
+
+ size_t index = 0;
+ for (nlohmann::json::object_t& metric : redfishMetrics)
+ {
+ AddReportArgs::MetricArgs metricArgs;
+ std::vector<
+ std::tuple<sdbusplus::message::object_path, std::string>>
+ pathAndUri;
+
+ if (index < readingParams.size())
{
- BMCWEB_LOG_ERROR(
- "Failed to retrieve URI to dbus sensors map with err {}",
- static_cast<unsigned>(status));
+ const ReadingParameters::value_type& existing =
+ readingParams[index];
+
+ pathAndUri = std::get<0>(existing);
+ metricArgs.collectionFunction = std::get<1>(existing);
+ metricArgs.collectionTimeScope = std::get<2>(existing);
+ metricArgs.collectionDuration = std::get<3>(existing);
+ }
+
+ if (!getUserMetric(asyncResp->res, metric, metricArgs))
+ {
return;
}
- updateMetricsReq->insert(uriToDbus);
- });
- }
- });
+
+ std::optional<IncorrectMetricUri> error =
+ getChassisSensorNode(metricArgs.uris, chassisSensors);
+
+ if (error)
+ {
+ messages::propertyValueIncorrect(
+ asyncResp->res, error->uri,
+ "MetricProperties/" + std::to_string(error->index));
+ return;
+ }
+
+ updateMetricsReq->emplace(pathAndUri, metricArgs);
+ index++;
+ }
+
+ for (const auto& [chassis, sensorType] : chassisSensors)
+ {
+ retrieveUriToDbusMap(
+ chassis, sensorType,
+ [asyncResp, updateMetricsReq](
+ const boost::beast::http::status status,
+ const std::map<std::string, std::string>& uriToDbus) {
+ if (status != boost::beast::http::status::ok)
+ {
+ BMCWEB_LOG_ERROR(
+ "Failed to retrieve URI to dbus sensors map with err {}",
+ static_cast<unsigned>(status));
+ return;
+ }
+ updateMetricsReq->insert(uriToDbus);
+ });
+ }
+ });
}
inline void handleMetricReportDefinitionCollectionHead(
@@ -1088,10 +1085,9 @@
interfaces, "/xyz/openbmc_project/Telemetry/Reports/TelemetryService");
}
-inline void
- handleReportPatch(App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- std::string_view id)
+inline void handleReportPatch(
+ App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, std::string_view id)
{
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
@@ -1183,10 +1179,9 @@
}
}
-inline void
- handleReportDelete(App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- std::string_view id)
+inline void handleReportDelete(
+ App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, std::string_view id)
{
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
@@ -1198,12 +1193,12 @@
crow::connections::systemBus->async_method_call(
[asyncResp,
reportId = std::string(id)](const boost::system::error_code& ec) {
- if (!verifyCommonErrors(asyncResp->res, reportId, ec))
- {
- return;
- }
- asyncResp->res.result(boost::beast::http::status::no_content);
- },
+ if (!verifyCommonErrors(asyncResp->res, reportId, ec))
+ {
+ return;
+ }
+ asyncResp->res.result(boost::beast::http::status::no_content);
+ },
service, reportPath, "xyz.openbmc_project.Object.Delete", "Delete");
}
} // namespace telemetry
@@ -1247,8 +1242,8 @@
return;
}
- auto addReportReq = std::make_shared<telemetry::AddReport>(std::move(args),
- asyncResp);
+ auto addReportReq =
+ std::make_shared<telemetry::AddReport>(std::move(args), asyncResp);
for (const auto& [chassis, sensorType] : chassisSensors)
{
retrieveUriToDbusMap(chassis, sensorType,
@@ -1271,10 +1266,9 @@
"</redfish/v1/JsonSchemas/MetricReport/MetricReport.json>; rel=describedby");
}
-inline void
- handleMetricReportGet(App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& id)
+inline void handleMetricReportGet(
+ App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& id)
{
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
@@ -1289,13 +1283,13 @@
telemetry::getDbusReportPath(id), telemetry::reportInterface,
[asyncResp, id](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
- if (!redfish::telemetry::verifyCommonErrors(asyncResp->res, id, ec))
- {
- return;
- }
+ if (!redfish::telemetry::verifyCommonErrors(asyncResp->res, id, ec))
+ {
+ return;
+ }
- telemetry::fillReportDefinition(asyncResp, id, properties);
- });
+ telemetry::fillReportDefinition(asyncResp, id, properties);
+ });
}
inline void handleMetricReportDelete(
@@ -1312,26 +1306,26 @@
crow::connections::systemBus->async_method_call(
[asyncResp, id](const boost::system::error_code& ec) {
- /*
- * boost::system::errc and std::errc are missing value
- * for EBADR error that is defined in Linux.
- */
- if (ec.value() == EBADR)
- {
- messages::resourceNotFound(asyncResp->res, "MetricReportDefinition",
- id);
- return;
- }
+ /*
+ * boost::system::errc and std::errc are missing value
+ * for EBADR error that is defined in Linux.
+ */
+ if (ec.value() == EBADR)
+ {
+ messages::resourceNotFound(asyncResp->res,
+ "MetricReportDefinition", id);
+ return;
+ }
- if (ec)
- {
- BMCWEB_LOG_ERROR("respHandler DBus error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("respHandler DBus error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- asyncResp->res.result(boost::beast::http::status::no_content);
- },
+ asyncResp->res.result(boost::beast::http::status::no_content);
+ },
telemetry::service, reportPath, "xyz.openbmc_project.Object.Delete",
"Delete");
}
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 2b67f18..4fd606a 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -105,19 +105,20 @@
[callback = std::forward<CallbackFunc>(callback)](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& dbusData) {
- std::vector<std::string> ntpServers;
- std::vector<std::string> domainNames;
+ std::vector<std::string> ntpServers;
+ std::vector<std::string> domainNames;
- if (ec)
- {
- callback(false, ntpServers, domainNames);
- return;
- }
+ if (ec)
+ {
+ callback(false, ntpServers, domainNames);
+ return;
+ }
- extractNTPServersAndDomainNamesData(dbusData, ntpServers, domainNames);
+ extractNTPServersAndDomainNamesData(dbusData, ntpServers,
+ domainNames);
- callback(true, ntpServers, domainNames);
- });
+ callback(true, ntpServers, domainNames);
+ });
}
inline void afterNetworkPortRequest(
@@ -200,10 +201,10 @@
getNTPProtocolEnabled(asyncResp);
- getEthernetIfaceData(
- [hostName, asyncResp](const bool& success,
- const std::vector<std::string>& ntpServers,
- const std::vector<std::string>& domainNames) {
+ getEthernetIfaceData([hostName, asyncResp](
+ const bool& success,
+ const std::vector<std::string>& ntpServers,
+ const std::vector<std::string>& domainNames) {
if (!success)
{
messages::resourceNotFound(asyncResp->res, "ManagerNetworkProtocol",
@@ -290,9 +291,9 @@
// Can't delete an item that doesn't exist
if (currentNtpServer == currentNtpServers.end())
{
- messages::propertyValueNotInList(asyncResp->res, "null",
- "NTP/NTPServers/" +
- std::to_string(index));
+ messages::propertyValueNotInList(
+ asyncResp->res, "null",
+ "NTP/NTPServers/" + std::to_string(index));
return;
}
@@ -351,32 +352,32 @@
[asyncResp, currentNtpServers](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message());
- messages::internalError(asyncResp->res);
- return;
- }
-
- for (const auto& [objectPath, serviceMap] : subtree)
- {
- for (const auto& [service, interfaces] : serviceMap)
+ if (ec)
{
- for (const auto& interface : interfaces)
- {
- if (interface !=
- "xyz.openbmc_project.Network.EthernetInterface")
- {
- continue;
- }
+ BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message());
+ messages::internalError(asyncResp->res);
+ return;
+ }
- setDbusProperty(asyncResp, "NTP/NTPServers/", service,
- objectPath, interface, "StaticNTPServers",
- currentNtpServers);
+ for (const auto& [objectPath, serviceMap] : subtree)
+ {
+ for (const auto& [service, interfaces] : serviceMap)
+ {
+ for (const auto& interface : interfaces)
+ {
+ if (interface !=
+ "xyz.openbmc_project.Network.EthernetInterface")
+ {
+ continue;
+ }
+
+ setDbusProperty(asyncResp, "NTP/NTPServers/", service,
+ objectPath, interface,
+ "StaticNTPServers", currentNtpServers);
+ }
}
}
- }
- });
+ });
}
inline void
@@ -391,29 +392,29 @@
[protocolEnabled, asyncResp,
netBasePath](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- for (const auto& entry : subtree)
- {
- if (entry.first.starts_with(netBasePath))
+ if (ec)
{
- setDbusProperty(
- asyncResp, "IPMI/ProtocolEnabled",
- entry.second.begin()->first, entry.first,
- "xyz.openbmc_project.Control.Service.Attributes", "Running",
- protocolEnabled);
- setDbusProperty(
- asyncResp, "IPMI/ProtocolEnabled",
- entry.second.begin()->first, entry.first,
- "xyz.openbmc_project.Control.Service.Attributes", "Enabled",
- protocolEnabled);
+ messages::internalError(asyncResp->res);
+ return;
}
- }
- });
+
+ for (const auto& entry : subtree)
+ {
+ if (entry.first.starts_with(netBasePath))
+ {
+ setDbusProperty(
+ asyncResp, "IPMI/ProtocolEnabled",
+ entry.second.begin()->first, entry.first,
+ "xyz.openbmc_project.Control.Service.Attributes",
+ "Running", protocolEnabled);
+ setDbusProperty(
+ asyncResp, "IPMI/ProtocolEnabled",
+ entry.second.begin()->first, entry.first,
+ "xyz.openbmc_project.Control.Service.Attributes",
+ "Enabled", protocolEnabled);
+ }
+ }
+ });
}
inline std::string getHostName()
@@ -435,15 +436,15 @@
*crow::connections::systemBus, "org.freedesktop.timedate1",
"/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP",
[asyncResp](const boost::system::error_code& ec, bool enabled) {
- if (ec)
- {
- BMCWEB_LOG_WARNING(
- "Failed to get NTP status, assuming not supported");
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_WARNING(
+ "Failed to get NTP status, assuming not supported");
+ return;
+ }
- asyncResp->res.jsonValue["NTP"]["ProtocolEnabled"] = enabled;
- });
+ asyncResp->res.jsonValue["NTP"]["ProtocolEnabled"] = enabled;
+ });
}
inline std::string encodeServiceObjectPath(std::string_view serviceName)
@@ -520,14 +521,14 @@
[asyncResp, ntpServerObjects](
const bool success, std::vector<std::string>& currentNtpServers,
const std::vector<std::string>& /*domainNames*/) {
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- handleNTPServersPatch(asyncResp, *ntpServerObjects,
- std::move(currentNtpServers));
- });
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ handleNTPServersPatch(asyncResp, *ntpServerObjects,
+ std::move(currentNtpServers));
+ });
}
if (ipmiEnabled)
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index d896f6d..4415144 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -63,14 +63,14 @@
[pcieDevicePath, asyncResp,
callback](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& object) {
- if (ec || object.empty())
- {
- BMCWEB_LOG_ERROR("DBUS response error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- callback(pcieDevicePath, object.begin()->first);
- });
+ if (ec || object.empty())
+ {
+ BMCWEB_LOG_ERROR("DBUS response error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ callback(pcieDevicePath, object.begin()->first);
+ });
return;
}
@@ -90,16 +90,16 @@
callback](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse&
pcieDevicePaths) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("D-Bus response error on GetSubTree {}", ec);
- messages::internalError(asyncResp->res);
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("D-Bus response error on GetSubTree {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ handlePCIeDevicePath(pcieDeviceId, asyncResp, pcieDevicePaths,
+ callback);
return;
- }
- handlePCIeDevicePath(pcieDeviceId, asyncResp, pcieDevicePaths,
- callback);
- return;
- });
+ });
}
static inline void handlePCIeDeviceCollectionGet(
@@ -227,43 +227,42 @@
[callback = std::move(callback), asyncResp, pcieDevicePath](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse& endpoints) {
- if (ec)
- {
- if (ec.value() == EBADR)
+ if (ec)
{
- // Missing association is not an error
+ if (ec.value() == EBADR)
+ {
+ // Missing association is not an error
+ return;
+ }
+ BMCWEB_LOG_ERROR(
+ "DBUS response error for getAssociatedSubTreePaths {}",
+ ec.value());
+ messages::internalError(asyncResp->res);
return;
}
- BMCWEB_LOG_ERROR(
- "DBUS response error for getAssociatedSubTreePaths {}",
- ec.value());
- messages::internalError(asyncResp->res);
- return;
- }
- if (endpoints.size() > 1)
- {
- BMCWEB_LOG_ERROR(
- "PCIeDevice is associated with more than one PCIeSlot: {}",
- endpoints.size());
- messages::internalError(asyncResp->res);
- return;
- }
- if (endpoints.empty())
- {
- // If the device doesn't have an association, return without PCIe
- // Slot properties
- BMCWEB_LOG_DEBUG("PCIeDevice is not associated with PCIeSlot");
- return;
- }
- callback(endpoints[0]);
- });
+ if (endpoints.size() > 1)
+ {
+ BMCWEB_LOG_ERROR(
+ "PCIeDevice is associated with more than one PCIeSlot: {}",
+ endpoints.size());
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (endpoints.empty())
+ {
+ // If the device doesn't have an association, return without
+ // PCIe Slot properties
+ BMCWEB_LOG_DEBUG("PCIeDevice is not associated with PCIeSlot");
+ return;
+ }
+ callback(endpoints[0]);
+ });
}
-inline void
- afterGetDbusObject(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& pcieDeviceSlot,
- const boost::system::error_code& ec,
- const dbus::utility::MapperGetObject& object)
+inline void afterGetDbusObject(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& pcieDeviceSlot, const boost::system::error_code& ec,
+ const dbus::utility::MapperGetObject& object)
{
if (ec || object.empty())
{
@@ -278,8 +277,8 @@
[asyncResp](
const boost::system::error_code& ec2,
const dbus::utility::DBusPropertiesMap& pcieSlotProperties) {
- addPCIeSlotProperties(asyncResp->res, ec2, pcieSlotProperties);
- });
+ addPCIeSlotProperties(asyncResp->res, ec2, pcieSlotProperties);
+ });
}
inline void afterGetPCIeDeviceSlotPath(
@@ -291,69 +290,66 @@
[asyncResp,
pcieDeviceSlot](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& object) {
- afterGetDbusObject(asyncResp, pcieDeviceSlot, ec, object);
- });
+ afterGetDbusObject(asyncResp, pcieDeviceSlot, ec, object);
+ });
}
-inline void
- getPCIeDeviceHealth(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& pcieDevicePath,
- const std::string& service)
+inline void getPCIeDeviceHealth(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& pcieDevicePath, const std::string& service)
{
sdbusplus::asio::getProperty<bool>(
*crow::connections::systemBus, service, pcieDevicePath,
"xyz.openbmc_project.State.Decorator.OperationalStatus", "Functional",
[asyncResp](const boost::system::error_code& ec, const bool value) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for Health {}",
- ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for Health {}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- if (!value)
- {
- asyncResp->res.jsonValue["Status"]["Health"] =
- resource::Health::Critical;
- }
- });
+ if (!value)
+ {
+ asyncResp->res.jsonValue["Status"]["Health"] =
+ resource::Health::Critical;
+ }
+ });
}
-inline void
- getPCIeDeviceState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& pcieDevicePath,
- const std::string& service)
+inline void getPCIeDeviceState(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& pcieDevicePath, const std::string& service)
{
sdbusplus::asio::getProperty<bool>(
*crow::connections::systemBus, service, pcieDevicePath,
"xyz.openbmc_project.Inventory.Item", "Present",
[asyncResp](const boost::system::error_code& ec, bool value) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for State");
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for State");
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- if (!value)
- {
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Absent;
- }
- });
+ if (!value)
+ {
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Absent;
+ }
+ });
}
-inline void
- getPCIeDeviceAsset(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& pcieDevicePath,
- const std::string& service)
+inline void getPCIeDeviceAsset(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& pcieDevicePath, const std::string& service)
{
sdbusplus::asio::getAllProperties(
*crow::connections::systemBus, service, pcieDevicePath,
@@ -361,58 +357,59 @@
[pcieDevicePath, asyncResp{asyncResp}](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& assetList) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for Properties{}",
- ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for Properties{}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- const std::string* manufacturer = nullptr;
- const std::string* model = nullptr;
- const std::string* partNumber = nullptr;
- const std::string* serialNumber = nullptr;
- const std::string* sparePartNumber = nullptr;
+ const std::string* manufacturer = nullptr;
+ const std::string* model = nullptr;
+ const std::string* partNumber = nullptr;
+ const std::string* serialNumber = nullptr;
+ const std::string* sparePartNumber = nullptr;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), assetList, "Manufacturer",
- manufacturer, "Model", model, "PartNumber", partNumber,
- "SerialNumber", serialNumber, "SparePartNumber", sparePartNumber);
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), assetList, "Manufacturer",
+ manufacturer, "Model", model, "PartNumber", partNumber,
+ "SerialNumber", serialNumber, "SparePartNumber",
+ sparePartNumber);
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (manufacturer != nullptr)
- {
- asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
- }
- if (model != nullptr)
- {
- asyncResp->res.jsonValue["Model"] = *model;
- }
+ if (manufacturer != nullptr)
+ {
+ asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
+ }
+ if (model != nullptr)
+ {
+ asyncResp->res.jsonValue["Model"] = *model;
+ }
- if (partNumber != nullptr)
- {
- asyncResp->res.jsonValue["PartNumber"] = *partNumber;
- }
+ if (partNumber != nullptr)
+ {
+ asyncResp->res.jsonValue["PartNumber"] = *partNumber;
+ }
- if (serialNumber != nullptr)
- {
- asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
- }
+ if (serialNumber != nullptr)
+ {
+ asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
+ }
- if (sparePartNumber != nullptr && !sparePartNumber->empty())
- {
- asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
- }
- });
+ if (sparePartNumber != nullptr && !sparePartNumber->empty())
+ {
+ asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
+ }
+ });
}
inline void addPCIeDeviceProperties(
@@ -523,17 +520,17 @@
[asyncResp,
callback](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& pcieDevProperties) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for Properties");
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for Properties");
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- callback(pcieDevProperties);
- });
+ callback(pcieDevProperties);
+ });
}
inline void addPCIeDeviceCommonProperties(
@@ -570,11 +567,10 @@
std::bind_front(afterGetPCIeDeviceSlotPath, asyncResp));
}
-inline void
- handlePCIeDeviceGet(App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName,
- const std::string& pcieDeviceId)
+inline void handlePCIeDeviceGet(
+ App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName, const std::string& pcieDeviceId)
{
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
@@ -619,8 +615,8 @@
{
// Check if this function exists by
// looking for a device ID
- std::string devIDProperty = "Function" + std::to_string(functionNum) +
- "DeviceId";
+ std::string devIDProperty =
+ "Function" + std::to_string(functionNum) + "DeviceId";
const std::string* property = nullptr;
for (const auto& propEntry : pcieDevProperties)
{
@@ -666,25 +662,25 @@
pcieDeviceId, asyncResp,
[asyncResp, pcieDeviceId](const std::string& pcieDevicePath,
const std::string& service) {
- asyncResp->res.addHeader(
- boost::beast::http::field::link,
- "</redfish/v1/JsonSchemas/PCIeFunctionCollection/PCIeFunctionCollection.json>; rel=describedby");
- asyncResp->res.jsonValue["@odata.type"] =
- "#PCIeFunctionCollection.PCIeFunctionCollection";
- asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/{}/PCIeDevices/{}/PCIeFunctions",
- BMCWEB_REDFISH_SYSTEM_URI_NAME, pcieDeviceId);
- asyncResp->res.jsonValue["Name"] = "PCIe Function Collection";
- asyncResp->res.jsonValue["Description"] =
- "Collection of PCIe Functions for PCIe Device " + pcieDeviceId;
- getPCIeDeviceProperties(
- asyncResp, pcieDevicePath, service,
- [asyncResp, pcieDeviceId](
- const dbus::utility::DBusPropertiesMap& pcieDevProperties) {
- addPCIeFunctionList(asyncResp->res, pcieDeviceId,
- pcieDevProperties);
+ asyncResp->res.addHeader(
+ boost::beast::http::field::link,
+ "</redfish/v1/JsonSchemas/PCIeFunctionCollection/PCIeFunctionCollection.json>; rel=describedby");
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#PCIeFunctionCollection.PCIeFunctionCollection";
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Systems/{}/PCIeDevices/{}/PCIeFunctions",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, pcieDeviceId);
+ asyncResp->res.jsonValue["Name"] = "PCIe Function Collection";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of PCIe Functions for PCIe Device " + pcieDeviceId;
+ getPCIeDeviceProperties(
+ asyncResp, pcieDevicePath, service,
+ [asyncResp, pcieDeviceId](
+ const dbus::utility::DBusPropertiesMap& pcieDevProperties) {
+ addPCIeFunctionList(asyncResp->res, pcieDeviceId,
+ pcieDevProperties);
+ });
});
- });
}
inline void requestRoutesSystemPCIeFunctionCollection(App& app)
@@ -795,12 +791,11 @@
BMCWEB_REDFISH_SYSTEM_URI_NAME, pcieDeviceId);
}
-inline void
- handlePCIeFunctionGet(App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName,
- const std::string& pcieDeviceId,
- const std::string& pcieFunctionIdStr)
+inline void handlePCIeFunctionGet(
+ App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName, const std::string& pcieDeviceId,
+ const std::string& pcieFunctionIdStr)
{
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
@@ -831,20 +826,20 @@
return;
}
- getValidPCIeDevicePath(pcieDeviceId, asyncResp,
- [asyncResp, pcieDeviceId,
- pcieFunctionId](const std::string& pcieDevicePath,
- const std::string& service) {
- getPCIeDeviceProperties(
- asyncResp, pcieDevicePath, service,
- [asyncResp, pcieDeviceId, pcieFunctionId](
- const dbus::utility::DBusPropertiesMap& pcieDevProperties) {
- addPCIeFunctionCommonProperties(asyncResp->res, pcieDeviceId,
- pcieFunctionId);
- addPCIeFunctionProperties(asyncResp->res, pcieFunctionId,
- pcieDevProperties);
+ getValidPCIeDevicePath(
+ pcieDeviceId, asyncResp,
+ [asyncResp, pcieDeviceId, pcieFunctionId](
+ const std::string& pcieDevicePath, const std::string& service) {
+ getPCIeDeviceProperties(
+ asyncResp, pcieDevicePath, service,
+ [asyncResp, pcieDeviceId, pcieFunctionId](
+ const dbus::utility::DBusPropertiesMap& pcieDevProperties) {
+ addPCIeFunctionCommonProperties(
+ asyncResp->res, pcieDeviceId, pcieFunctionId);
+ addPCIeFunctionProperties(asyncResp->res, pcieFunctionId,
+ pcieDevProperties);
+ });
});
- });
}
inline void requestRoutesSystemPCIeFunction(App& app)
diff --git a/redfish-core/lib/pcie_slots.hpp b/redfish-core/lib/pcie_slots.hpp
index b8e6389..a6796b9 100644
--- a/redfish-core/lib/pcie_slots.hpp
+++ b/redfish-core/lib/pcie_slots.hpp
@@ -153,15 +153,14 @@
"xyz.openbmc_project.Inventory.Item.PCIeSlot",
[asyncResp](const boost::system::error_code& ec2,
const dbus::utility::DBusPropertiesMap& propertiesList) {
- onPcieSlotGetAllDone(asyncResp, ec2, propertiesList);
- });
+ onPcieSlotGetAllDone(asyncResp, ec2, propertiesList);
+ });
}
-inline void
- onMapperSubtreeDone(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& chassisID,
- const boost::system::error_code& ec,
- const dbus::utility::MapperGetSubTreeResponse& subtree)
+inline void onMapperSubtreeDone(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisID, const boost::system::error_code& ec,
+ const dbus::utility::MapperGetSubTreeResponse& subtree)
{
if (ec)
{
@@ -202,9 +201,9 @@
[asyncResp, chassisID, pcieSlotPath, connectionName](
const boost::system::error_code& ec2,
const dbus::utility::MapperEndPoints& endpoints) {
- onMapperAssociationDone(asyncResp, chassisID, pcieSlotPath,
- connectionName, ec2, endpoints);
- });
+ onMapperAssociationDone(asyncResp, chassisID, pcieSlotPath,
+ connectionName, ec2, endpoints);
+ });
}
}
}
@@ -226,8 +225,8 @@
[asyncResp,
chassisID](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- onMapperSubtreeDone(asyncResp, chassisID, ec, subtree);
- });
+ onMapperSubtreeDone(asyncResp, chassisID, ec, subtree);
+ });
}
inline void requestRoutesPCIeSlots(App& app)
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index c43c71d..c914cee 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -126,9 +126,9 @@
// A warning without a odata.type
nlohmann::json::object_t powerControl;
powerControl["@odata.type"] = "#Power.v1_0_0.PowerControl";
- powerControl["@odata.id"] = "/redfish/v1/Chassis/" +
- sensorAsyncResp->chassisId +
- "/Power#/PowerControl/0";
+ powerControl["@odata.id"] =
+ "/redfish/v1/Chassis/" + sensorAsyncResp->chassisId +
+ "/Power#/PowerControl/0";
powerControl["Name"] = "Chassis Power Control";
powerControl["MemberId"] = "0";
tempArray.emplace_back(std::move(powerControl));
@@ -191,16 +191,15 @@
{
// Redfish specification indicates PowerLimit should
// be null if the limit is not enabled.
- sensorJson["PowerLimit"]["LimitInWatts"] = powerCap *
- std::pow(10, scale);
+ sensorJson["PowerLimit"]["LimitInWatts"] =
+ powerCap * std::pow(10, scale);
}
}
using Mapper = dbus::utility::MapperGetSubTreePathsResponse;
-inline void
- afterGetChassis(const std::shared_ptr<SensorsAsyncResp>& sensorAsyncResp,
- const boost::system::error_code& ec2,
- const Mapper& chassisPaths)
+inline void afterGetChassis(
+ const std::shared_ptr<SensorsAsyncResp>& sensorAsyncResp,
+ const boost::system::error_code& ec2, const Mapper& chassisPaths)
{
if (ec2)
{
diff --git a/redfish-core/lib/power_supply.hpp b/redfish-core/lib/power_supply.hpp
index 31cd1f9..7905885 100644
--- a/redfish-core/lib/power_supply.hpp
+++ b/redfish-core/lib/power_supply.hpp
@@ -79,18 +79,18 @@
[asyncResp, chassisId](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse& subtreePaths) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error{}", ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error{}", ec.value());
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- updatePowerSupplyList(asyncResp, chassisId, subtreePaths);
- });
+ updatePowerSupplyList(asyncResp, chassisId, subtreePaths);
+ });
}
inline void handlePowerSupplyCollectionHead(
@@ -107,15 +107,16 @@
asyncResp, chassisId,
[asyncResp,
chassisId](const std::optional<std::string>& validChassisPath) {
- if (!validChassisPath)
- {
- messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
- return;
- }
- asyncResp->res.addHeader(
- boost::beast::http::field::link,
- "</redfish/v1/JsonSchemas/PowerSupplyCollection/PowerSupplyCollection.json>; rel=describedby");
- });
+ if (!validChassisPath)
+ {
+ messages::resourceNotFound(asyncResp->res, "Chassis",
+ chassisId);
+ return;
+ }
+ asyncResp->res.addHeader(
+ boost::beast::http::field::link,
+ "</redfish/v1/JsonSchemas/PowerSupplyCollection/PowerSupplyCollection.json>; rel=describedby");
+ });
}
inline void handlePowerSupplyCollectionGet(
@@ -168,38 +169,38 @@
[asyncResp, powerSupplyId, callback{std::move(callback)}](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse& subtreePaths) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR(
- "DBUS response error for getAssociatedSubTreePaths{}",
- ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR(
+ "DBUS response error for getAssociatedSubTreePaths{}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ messages::resourceNotFound(asyncResp->res, "PowerSupplies",
+ powerSupplyId);
return;
}
- messages::resourceNotFound(asyncResp->res, "PowerSupplies",
- powerSupplyId);
- return;
- }
- for (const std::string& path : subtreePaths)
- {
- if (checkPowerSupplyId(path, powerSupplyId))
+ for (const std::string& path : subtreePaths)
{
- callback(path);
+ if (checkPowerSupplyId(path, powerSupplyId))
+ {
+ callback(path);
+ return;
+ }
+ }
+
+ if (!subtreePaths.empty())
+ {
+ BMCWEB_LOG_WARNING("Power supply not found: {}", powerSupplyId);
+ messages::resourceNotFound(asyncResp->res, "PowerSupplies",
+ powerSupplyId);
return;
}
- }
-
- if (!subtreePaths.empty())
- {
- BMCWEB_LOG_WARNING("Power supply not found: {}", powerSupplyId);
- messages::resourceNotFound(asyncResp->res, "PowerSupplies",
- powerSupplyId);
- return;
- }
- });
+ });
}
inline void
@@ -210,23 +211,23 @@
*crow::connections::systemBus, service, path,
"xyz.openbmc_project.Inventory.Item", "Present",
[asyncResp](const boost::system::error_code& ec, const bool value) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for State {}",
- ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for State {}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- if (!value)
- {
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Absent;
- }
- });
+ if (!value)
+ {
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Absent;
+ }
+ });
}
inline void
@@ -237,23 +238,23 @@
*crow::connections::systemBus, service, path,
"xyz.openbmc_project.State.Decorator.OperationalStatus", "Functional",
[asyncResp](const boost::system::error_code& ec, const bool value) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for Health {}",
- ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for Health {}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- if (!value)
- {
- asyncResp->res.jsonValue["Status"]["Health"] =
- resource::Health::Critical;
- }
- });
+ if (!value)
+ {
+ asyncResp->res.jsonValue["Status"]["Health"] =
+ resource::Health::Critical;
+ }
+ });
}
inline void
@@ -265,60 +266,61 @@
"xyz.openbmc_project.Inventory.Decorator.Asset",
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& propertiesList) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for Asset {}",
- ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for Asset {}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- const std::string* partNumber = nullptr;
- const std::string* serialNumber = nullptr;
- const std::string* manufacturer = nullptr;
- const std::string* model = nullptr;
- const std::string* sparePartNumber = nullptr;
+ const std::string* partNumber = nullptr;
+ const std::string* serialNumber = nullptr;
+ const std::string* manufacturer = nullptr;
+ const std::string* model = nullptr;
+ const std::string* sparePartNumber = nullptr;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), propertiesList, "PartNumber",
- partNumber, "SerialNumber", serialNumber, "Manufacturer",
- manufacturer, "Model", model, "SparePartNumber", sparePartNumber);
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), propertiesList, "PartNumber",
+ partNumber, "SerialNumber", serialNumber, "Manufacturer",
+ manufacturer, "Model", model, "SparePartNumber",
+ sparePartNumber);
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (partNumber != nullptr)
- {
- asyncResp->res.jsonValue["PartNumber"] = *partNumber;
- }
+ if (partNumber != nullptr)
+ {
+ asyncResp->res.jsonValue["PartNumber"] = *partNumber;
+ }
- if (serialNumber != nullptr)
- {
- asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
- }
+ if (serialNumber != nullptr)
+ {
+ asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
+ }
- if (manufacturer != nullptr)
- {
- asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
- }
+ if (manufacturer != nullptr)
+ {
+ asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
+ }
- if (model != nullptr)
- {
- asyncResp->res.jsonValue["Model"] = *model;
- }
+ if (model != nullptr)
+ {
+ asyncResp->res.jsonValue["Model"] = *model;
+ }
- // SparePartNumber is optional on D-Bus so skip if it is empty
- if (sparePartNumber != nullptr && !sparePartNumber->empty())
- {
- asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
- }
- });
+ // SparePartNumber is optional on D-Bus so skip if it is empty
+ if (sparePartNumber != nullptr && !sparePartNumber->empty())
+ {
+ asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
+ }
+ });
}
inline void getPowerSupplyFirmwareVersion(
@@ -330,18 +332,19 @@
"xyz.openbmc_project.Software.Version", "Version",
[asyncResp](const boost::system::error_code& ec,
const std::string& value) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for FirmwareVersion {}",
- ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR(
+ "DBUS response error for FirmwareVersion {}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- asyncResp->res.jsonValue["FirmwareVersion"] = value;
- });
+ asyncResp->res.jsonValue["FirmwareVersion"] = value;
+ });
}
inline void
@@ -353,19 +356,19 @@
"xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
[asyncResp](const boost::system::error_code& ec,
const std::string& value) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error for Location {}",
- ec.value());
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error for Location {}",
+ ec.value());
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- asyncResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
- value;
- });
+ asyncResp->res
+ .jsonValue["Location"]["PartLocation"]["ServiceLabel"] = value;
+ });
}
inline void handleGetEfficiencyResponse(
@@ -433,8 +436,8 @@
*crow::connections::systemBus, service, path,
"xyz.openbmc_project.Control.PowerSupplyAttributes", "DeratingFactor",
[asyncResp](const boost::system::error_code& ec1, uint32_t value) {
- handleGetEfficiencyResponse(asyncResp, ec1, value);
- });
+ handleGetEfficiencyResponse(asyncResp, ec1, value);
+ });
}
inline void
@@ -447,15 +450,14 @@
"/xyz/openbmc_project", 0, efficiencyIntf,
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- handlePowerSupplyAttributesSubTreeResponse(asyncResp, ec, subtree);
- });
+ handlePowerSupplyAttributesSubTreeResponse(asyncResp, ec, subtree);
+ });
}
-inline void
- doPowerSupplyGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& chassisId,
- const std::string& powerSupplyId,
- const std::optional<std::string>& validChassisPath)
+inline void doPowerSupplyGet(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisId, const std::string& powerSupplyId,
+ const std::optional<std::string>& validChassisPath)
{
if (!validChassisPath)
{
@@ -464,55 +466,56 @@
}
// Get the correct Path and Service that match the input parameters
- getValidPowerSupplyPath(asyncResp, *validChassisPath, powerSupplyId,
- [asyncResp, chassisId, powerSupplyId](
- const std::string& powerSupplyPath) {
- asyncResp->res.addHeader(
- boost::beast::http::field::link,
- "</redfish/v1/JsonSchemas/PowerSupply/PowerSupply.json>; rel=describedby");
- asyncResp->res.jsonValue["@odata.type"] =
- "#PowerSupply.v1_5_0.PowerSupply";
- asyncResp->res.jsonValue["Name"] = "Power Supply";
- asyncResp->res.jsonValue["Id"] = powerSupplyId;
- asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/Chassis/{}/PowerSubsystem/PowerSupplies/{}", chassisId,
- powerSupplyId);
+ getValidPowerSupplyPath(
+ asyncResp, *validChassisPath, powerSupplyId,
+ [asyncResp, chassisId,
+ powerSupplyId](const std::string& powerSupplyPath) {
+ asyncResp->res.addHeader(
+ boost::beast::http::field::link,
+ "</redfish/v1/JsonSchemas/PowerSupply/PowerSupply.json>; rel=describedby");
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#PowerSupply.v1_5_0.PowerSupply";
+ asyncResp->res.jsonValue["Name"] = "Power Supply";
+ asyncResp->res.jsonValue["Id"] = powerSupplyId;
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Chassis/{}/PowerSubsystem/PowerSupplies/{}",
+ chassisId, powerSupplyId);
- asyncResp->res.jsonValue["Status"]["State"] = resource::State::Enabled;
- asyncResp->res.jsonValue["Status"]["Health"] = resource::Health::OK;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Enabled;
+ asyncResp->res.jsonValue["Status"]["Health"] = resource::Health::OK;
- dbus::utility::getDbusObject(
- powerSupplyPath, powerSupplyInterface,
- [asyncResp,
- powerSupplyPath](const boost::system::error_code& ec,
- const dbus::utility::MapperGetObject& object) {
- if (ec || object.empty())
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ dbus::utility::getDbusObject(
+ powerSupplyPath, powerSupplyInterface,
+ [asyncResp, powerSupplyPath](
+ const boost::system::error_code& ec,
+ const dbus::utility::MapperGetObject& object) {
+ if (ec || object.empty())
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- getPowerSupplyState(asyncResp, object.begin()->first,
- powerSupplyPath);
- getPowerSupplyHealth(asyncResp, object.begin()->first,
- powerSupplyPath);
- getPowerSupplyAsset(asyncResp, object.begin()->first,
- powerSupplyPath);
- getPowerSupplyFirmwareVersion(asyncResp, object.begin()->first,
- powerSupplyPath);
- getPowerSupplyLocation(asyncResp, object.begin()->first,
- powerSupplyPath);
+ getPowerSupplyState(asyncResp, object.begin()->first,
+ powerSupplyPath);
+ getPowerSupplyHealth(asyncResp, object.begin()->first,
+ powerSupplyPath);
+ getPowerSupplyAsset(asyncResp, object.begin()->first,
+ powerSupplyPath);
+ getPowerSupplyFirmwareVersion(
+ asyncResp, object.begin()->first, powerSupplyPath);
+ getPowerSupplyLocation(asyncResp, object.begin()->first,
+ powerSupplyPath);
+ });
+
+ getEfficiencyPercent(asyncResp);
});
-
- getEfficiencyPercent(asyncResp);
- });
}
-inline void
- handlePowerSupplyHead(App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& chassisId,
- const std::string& powerSupplyId)
+inline void handlePowerSupplyHead(
+ App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisId, const std::string& powerSupplyId)
{
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
@@ -523,27 +526,28 @@
asyncResp, chassisId,
[asyncResp, chassisId,
powerSupplyId](const std::optional<std::string>& validChassisPath) {
- if (!validChassisPath)
- {
- messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
- return;
- }
+ if (!validChassisPath)
+ {
+ messages::resourceNotFound(asyncResp->res, "Chassis",
+ chassisId);
+ return;
+ }
- // Get the correct Path and Service that match the input parameters
- getValidPowerSupplyPath(asyncResp, *validChassisPath, powerSupplyId,
- [asyncResp](const std::string&) {
- asyncResp->res.addHeader(
- boost::beast::http::field::link,
- "</redfish/v1/JsonSchemas/PowerSupply/PowerSupply.json>; rel=describedby");
+ // Get the correct Path and Service that match the input parameters
+ getValidPowerSupplyPath(
+ asyncResp, *validChassisPath, powerSupplyId,
+ [asyncResp](const std::string&) {
+ asyncResp->res.addHeader(
+ boost::beast::http::field::link,
+ "</redfish/v1/JsonSchemas/PowerSupply/PowerSupply.json>; rel=describedby");
+ });
});
- });
}
-inline void
- handlePowerSupplyGet(App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& chassisId,
- const std::string& powerSupplyId)
+inline void handlePowerSupplyGet(
+ App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisId, const std::string& powerSupplyId)
{
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index b49f13b..be85262 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -67,14 +67,14 @@
"xyz.openbmc_project.Common.UUID", "UUID",
[objPath, asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec, const std::string& property) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error");
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["UUID"] = property;
- });
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("DBUS response error");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["UUID"] = property;
+ });
}
inline void getCpuDataByInterface(
@@ -222,10 +222,9 @@
}
}
-inline void getCpuDataByService(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
- const std::string& cpuId,
- const std::string& service,
- const std::string& objPath)
+inline void getCpuDataByService(
+ std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& cpuId,
+ const std::string& service, const std::string& objPath)
{
BMCWEB_LOG_DEBUG("Get available system cpu resources by service.");
@@ -235,44 +234,46 @@
[cpuId, service, objPath, asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& dbusData) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error");
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["Id"] = cpuId;
- asyncResp->res.jsonValue["Name"] = "Processor";
- asyncResp->res.jsonValue["ProcessorType"] =
- processor::ProcessorType::CPU;
-
- bool slotPresent = false;
- std::string corePath = objPath + "/core";
- size_t totalCores = 0;
- for (const auto& object : dbusData)
- {
- if (object.first.str == objPath)
+ if (ec)
{
- getCpuDataByInterface(asyncResp, object.second);
+ BMCWEB_LOG_DEBUG("DBUS response error");
+ messages::internalError(asyncResp->res);
+ return;
}
- else if (object.first.str.starts_with(corePath))
+ asyncResp->res.jsonValue["Id"] = cpuId;
+ asyncResp->res.jsonValue["Name"] = "Processor";
+ asyncResp->res.jsonValue["ProcessorType"] =
+ processor::ProcessorType::CPU;
+
+ bool slotPresent = false;
+ std::string corePath = objPath + "/core";
+ size_t totalCores = 0;
+ for (const auto& object : dbusData)
{
- for (const auto& interface : object.second)
+ if (object.first.str == objPath)
{
- if (interface.first == "xyz.openbmc_project.Inventory.Item")
+ getCpuDataByInterface(asyncResp, object.second);
+ }
+ else if (object.first.str.starts_with(corePath))
+ {
+ for (const auto& interface : object.second)
{
- for (const auto& property : interface.second)
+ if (interface.first ==
+ "xyz.openbmc_project.Inventory.Item")
{
- if (property.first == "Present")
+ for (const auto& property : interface.second)
{
- const bool* present =
- std::get_if<bool>(&property.second);
- if (present != nullptr)
+ if (property.first == "Present")
{
- if (*present)
+ const bool* present =
+ std::get_if<bool>(&property.second);
+ if (present != nullptr)
{
- slotPresent = true;
- totalCores++;
+ if (*present)
+ {
+ slotPresent = true;
+ totalCores++;
+ }
}
}
}
@@ -280,16 +281,15 @@
}
}
}
- }
- // In getCpuDataByInterface(), state and health are set
- // based on the present and functional status. If core
- // count is zero, then it has a higher precedence.
- if (slotPresent)
- {
- asyncResp->res.jsonValue["TotalCores"] = totalCores;
- }
- return;
- });
+ // In getCpuDataByInterface(), state and health are set
+ // based on the present and functional status. If core
+ // count is zero, then it has a higher precedence.
+ if (slotPresent)
+ {
+ asyncResp->res.jsonValue["TotalCores"] = totalCores;
+ }
+ return;
+ });
}
/**
@@ -370,10 +370,9 @@
asyncResp->res.jsonValue["ThrottleCauses"] = std::move(rCauses);
}
-inline void
- getThrottleProperties(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& service,
- const std::string& objectPath)
+inline void getThrottleProperties(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& service, const std::string& objectPath)
{
BMCWEB_LOG_DEBUG("Get processor throttle resources");
@@ -382,8 +381,8 @@
"xyz.openbmc_project.Control.Power.Throttle",
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
- readThrottleProperties(asyncResp, ec, properties);
- });
+ readThrottleProperties(asyncResp, ec, properties);
+ });
}
inline void getCpuAssetData(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
@@ -397,67 +396,67 @@
[objPath, asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error");
- messages::internalError(asyncResp->res);
- return;
- }
-
- const std::string* serialNumber = nullptr;
- const std::string* model = nullptr;
- const std::string* manufacturer = nullptr;
- const std::string* partNumber = nullptr;
- const std::string* sparePartNumber = nullptr;
-
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), properties, "SerialNumber",
- serialNumber, "Model", model, "Manufacturer", manufacturer,
- "PartNumber", partNumber, "SparePartNumber", sparePartNumber);
-
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- if (serialNumber != nullptr && !serialNumber->empty())
- {
- asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
- }
-
- if ((model != nullptr) && !model->empty())
- {
- asyncResp->res.jsonValue["Model"] = *model;
- }
-
- if (manufacturer != nullptr)
- {
- asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
-
- // Otherwise would be unexpected.
- if (manufacturer->find("Intel") != std::string::npos)
+ if (ec)
{
- asyncResp->res.jsonValue["ProcessorArchitecture"] = "x86";
- asyncResp->res.jsonValue["InstructionSet"] = "x86-64";
+ BMCWEB_LOG_DEBUG("DBUS response error");
+ messages::internalError(asyncResp->res);
+ return;
}
- else if (manufacturer->find("IBM") != std::string::npos)
+
+ const std::string* serialNumber = nullptr;
+ const std::string* model = nullptr;
+ const std::string* manufacturer = nullptr;
+ const std::string* partNumber = nullptr;
+ const std::string* sparePartNumber = nullptr;
+
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), properties, "SerialNumber",
+ serialNumber, "Model", model, "Manufacturer", manufacturer,
+ "PartNumber", partNumber, "SparePartNumber", sparePartNumber);
+
+ if (!success)
{
- asyncResp->res.jsonValue["ProcessorArchitecture"] = "Power";
- asyncResp->res.jsonValue["InstructionSet"] = "PowerISA";
+ messages::internalError(asyncResp->res);
+ return;
}
- }
- if (partNumber != nullptr)
- {
- asyncResp->res.jsonValue["PartNumber"] = *partNumber;
- }
+ if (serialNumber != nullptr && !serialNumber->empty())
+ {
+ asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
+ }
- if (sparePartNumber != nullptr && !sparePartNumber->empty())
- {
- asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
- }
- });
+ if ((model != nullptr) && !model->empty())
+ {
+ asyncResp->res.jsonValue["Model"] = *model;
+ }
+
+ if (manufacturer != nullptr)
+ {
+ asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
+
+ // Otherwise would be unexpected.
+ if (manufacturer->find("Intel") != std::string::npos)
+ {
+ asyncResp->res.jsonValue["ProcessorArchitecture"] = "x86";
+ asyncResp->res.jsonValue["InstructionSet"] = "x86-64";
+ }
+ else if (manufacturer->find("IBM") != std::string::npos)
+ {
+ asyncResp->res.jsonValue["ProcessorArchitecture"] = "Power";
+ asyncResp->res.jsonValue["InstructionSet"] = "PowerISA";
+ }
+ }
+
+ if (partNumber != nullptr)
+ {
+ asyncResp->res.jsonValue["PartNumber"] = *partNumber;
+ }
+
+ if (sparePartNumber != nullptr && !sparePartNumber->empty())
+ {
+ asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
+ }
+ });
}
inline void getCpuRevisionData(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
@@ -471,29 +470,30 @@
[objPath, asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error");
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("DBUS response error");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- const std::string* version = nullptr;
+ const std::string* version = nullptr;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), properties, "Version", version);
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), properties, "Version",
+ version);
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (version != nullptr)
- {
- asyncResp->res.jsonValue["Version"] = *version;
- }
- });
+ if (version != nullptr)
+ {
+ asyncResp->res.jsonValue["Version"] = *version;
+ }
+ });
}
inline void getAcceleratorDataByService(
@@ -506,49 +506,49 @@
[acclrtrId, asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error");
- messages::internalError(asyncResp->res);
- return;
- }
-
- const bool* functional = nullptr;
- const bool* present = nullptr;
-
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), properties, "Functional",
- functional, "Present", present);
-
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- std::string state = "Enabled";
- std::string health = "OK";
-
- if (present != nullptr && !*present)
- {
- state = "Absent";
- }
-
- if (functional != nullptr && !*functional)
- {
- if (state == "Enabled")
+ if (ec)
{
- health = "Critical";
+ BMCWEB_LOG_DEBUG("DBUS response error");
+ messages::internalError(asyncResp->res);
+ return;
}
- }
- asyncResp->res.jsonValue["Id"] = acclrtrId;
- asyncResp->res.jsonValue["Name"] = "Processor";
- asyncResp->res.jsonValue["Status"]["State"] = state;
- asyncResp->res.jsonValue["Status"]["Health"] = health;
- asyncResp->res.jsonValue["ProcessorType"] =
- processor::ProcessorType::Accelerator;
- });
+ const bool* functional = nullptr;
+ const bool* present = nullptr;
+
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), properties, "Functional",
+ functional, "Present", present);
+
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ std::string state = "Enabled";
+ std::string health = "OK";
+
+ if (present != nullptr && !*present)
+ {
+ state = "Absent";
+ }
+
+ if (functional != nullptr && !*functional)
+ {
+ if (state == "Enabled")
+ {
+ health = "Critical";
+ }
+ }
+
+ asyncResp->res.jsonValue["Id"] = acclrtrId;
+ asyncResp->res.jsonValue["Name"] = "Processor";
+ asyncResp->res.jsonValue["Status"]["State"] = state;
+ asyncResp->res.jsonValue["Status"]["Health"] = health;
+ asyncResp->res.jsonValue["ProcessorType"] =
+ processor::ProcessorType::Accelerator;
+ });
}
// OperatingConfig D-Bus Types
@@ -621,85 +621,87 @@
[asyncResp, cpuId,
service](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
- if (ec)
- {
- BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message());
- messages::internalError(asyncResp->res);
- return;
- }
-
- nlohmann::json& json = asyncResp->res.jsonValue;
-
- const sdbusplus::message::object_path* appliedConfig = nullptr;
- const bool* baseSpeedPriorityEnabled = nullptr;
-
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), properties, "AppliedConfig",
- appliedConfig, "BaseSpeedPriorityEnabled",
- baseSpeedPriorityEnabled);
-
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- if (appliedConfig != nullptr)
- {
- const std::string& dbusPath = appliedConfig->str;
- nlohmann::json::object_t operatingConfig;
- operatingConfig["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs",
- BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuId);
- json["OperatingConfigs"] = std::move(operatingConfig);
-
- // Reuse the D-Bus config object name for the Redfish
- // URI
- size_t baseNamePos = dbusPath.rfind('/');
- if (baseNamePos == std::string::npos ||
- baseNamePos == (dbusPath.size() - 1))
+ if (ec)
{
- // If the AppliedConfig was somehow not a valid path,
- // skip adding any more properties, since everything
- // else is tied to this applied config.
+ BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message());
messages::internalError(asyncResp->res);
return;
}
- nlohmann::json::object_t appliedOperatingConfig;
- appliedOperatingConfig["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs/{}",
- BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuId,
- dbusPath.substr(baseNamePos + 1));
- json["AppliedOperatingConfig"] = std::move(appliedOperatingConfig);
- // Once we found the current applied config, queue another
- // request to read the base freq core ids out of that
- // config.
- sdbusplus::asio::getProperty<BaseSpeedPrioritySettingsProperty>(
- *crow::connections::systemBus, service, dbusPath,
- "xyz.openbmc_project.Inventory.Item.Cpu."
- "OperatingConfig",
- "BaseSpeedPrioritySettings",
- [asyncResp](
- const boost::system::error_code& ec2,
- const BaseSpeedPrioritySettingsProperty& baseSpeedList) {
- if (ec2)
+ nlohmann::json& json = asyncResp->res.jsonValue;
+
+ const sdbusplus::message::object_path* appliedConfig = nullptr;
+ const bool* baseSpeedPriorityEnabled = nullptr;
+
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), properties, "AppliedConfig",
+ appliedConfig, "BaseSpeedPriorityEnabled",
+ baseSpeedPriorityEnabled);
+
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ if (appliedConfig != nullptr)
+ {
+ const std::string& dbusPath = appliedConfig->str;
+ nlohmann::json::object_t operatingConfig;
+ operatingConfig["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuId);
+ json["OperatingConfigs"] = std::move(operatingConfig);
+
+ // Reuse the D-Bus config object name for the Redfish
+ // URI
+ size_t baseNamePos = dbusPath.rfind('/');
+ if (baseNamePos == std::string::npos ||
+ baseNamePos == (dbusPath.size() - 1))
{
- BMCWEB_LOG_WARNING("D-Bus Property Get error: {}", ec2);
+ // If the AppliedConfig was somehow not a valid path,
+ // skip adding any more properties, since everything
+ // else is tied to this applied config.
messages::internalError(asyncResp->res);
return;
}
+ nlohmann::json::object_t appliedOperatingConfig;
+ appliedOperatingConfig["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs/{}",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuId,
+ dbusPath.substr(baseNamePos + 1));
+ json["AppliedOperatingConfig"] =
+ std::move(appliedOperatingConfig);
- highSpeedCoreIdsHandler(asyncResp, baseSpeedList);
- });
- }
+ // Once we found the current applied config, queue another
+ // request to read the base freq core ids out of that
+ // config.
+ sdbusplus::asio::getProperty<BaseSpeedPrioritySettingsProperty>(
+ *crow::connections::systemBus, service, dbusPath,
+ "xyz.openbmc_project.Inventory.Item.Cpu."
+ "OperatingConfig",
+ "BaseSpeedPrioritySettings",
+ [asyncResp](const boost::system::error_code& ec2,
+ const BaseSpeedPrioritySettingsProperty&
+ baseSpeedList) {
+ if (ec2)
+ {
+ BMCWEB_LOG_WARNING("D-Bus Property Get error: {}",
+ ec2);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (baseSpeedPriorityEnabled != nullptr)
- {
- json["BaseSpeedPriorityState"] =
- *baseSpeedPriorityEnabled ? "Enabled" : "Disabled";
- }
- });
+ highSpeedCoreIdsHandler(asyncResp, baseSpeedList);
+ });
+ }
+
+ if (baseSpeedPriorityEnabled != nullptr)
+ {
+ json["BaseSpeedPriorityState"] =
+ *baseSpeedPriorityEnabled ? "Enabled" : "Disabled";
+ }
+ });
}
/**
@@ -720,16 +722,17 @@
"xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
[objPath, asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec, const std::string& property) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error");
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("DBUS response error");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- asyncResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
- property;
- });
+ asyncResp->res
+ .jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
+ property;
+ });
}
/**
@@ -751,15 +754,15 @@
"UniqueIdentifier",
[asyncResp](const boost::system::error_code& ec,
const std::string& id) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Failed to read cpu unique id: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res
- .jsonValue["ProcessorId"]["ProtectedIdentificationNumber"] = id;
- });
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("Failed to read cpu unique id: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res
+ .jsonValue["ProcessorId"]["ProtectedIdentificationNumber"] = id;
+ });
}
/**
@@ -795,57 +798,56 @@
[resp, processorId, handler = std::forward<Handler>(handler)](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error: {}", ec);
- messages::internalError(resp->res);
- return;
- }
- for (const auto& [objectPath, serviceMap] : subtree)
- {
- // Ignore any objects which don't end with our desired cpu name
- if (!objectPath.ends_with(processorId))
+ if (ec)
{
- continue;
+ BMCWEB_LOG_DEBUG("DBUS response error: {}", ec);
+ messages::internalError(resp->res);
+ return;
}
-
- bool found = false;
- // Filter out objects that don't have the CPU-specific
- // interfaces to make sure we can return 404 on non-CPUs
- // (e.g. /redfish/../Processors/dimm0)
- for (const auto& [serviceName, interfaceList] : serviceMap)
+ for (const auto& [objectPath, serviceMap] : subtree)
{
- if (std::ranges::find_first_of(interfaceList,
- processorInterfaces) !=
- std::end(interfaceList))
+ // Ignore any objects which don't end with our desired cpu name
+ if (!objectPath.ends_with(processorId))
{
- found = true;
- break;
+ continue;
}
+
+ bool found = false;
+ // Filter out objects that don't have the CPU-specific
+ // interfaces to make sure we can return 404 on non-CPUs
+ // (e.g. /redfish/../Processors/dimm0)
+ for (const auto& [serviceName, interfaceList] : serviceMap)
+ {
+ if (std::ranges::find_first_of(interfaceList,
+ processorInterfaces) !=
+ std::end(interfaceList))
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ continue;
+ }
+
+ // Process the first object which does match our cpu name and
+ // required interfaces, and potentially ignore any other
+ // matching objects. Assume all interfaces we want to process
+ // must be on the same object path.
+
+ handler(objectPath, serviceMap);
+ return;
}
-
- if (!found)
- {
- continue;
- }
-
- // Process the first object which does match our cpu name and
- // required interfaces, and potentially ignore any other
- // matching objects. Assume all interfaces we want to process
- // must be on the same object path.
-
- handler(objectPath, serviceMap);
- return;
- }
- messages::resourceNotFound(resp->res, "Processor", processorId);
- });
+ messages::resourceNotFound(resp->res, "Processor", processorId);
+ });
}
-inline void
- getProcessorData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& processorId,
- const std::string& objectPath,
- const dbus::utility::MapperServiceMap& serviceMap)
+inline void getProcessorData(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& processorId, const std::string& objectPath,
+ const dbus::utility::MapperServiceMap& serviceMap)
{
for (const auto& [serviceName, interfaceList] : serviceMap)
{
@@ -908,100 +910,101 @@
* @param[in] service D-Bus service name to query.
* @param[in] objPath D-Bus object to query.
*/
-inline void
- getOperatingConfigData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& service,
- const std::string& objPath)
+inline void getOperatingConfigData(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& service, const std::string& objPath)
{
sdbusplus::asio::getAllProperties(
*crow::connections::systemBus, service, objPath,
"xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig",
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
- if (ec)
- {
- BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message());
- messages::internalError(asyncResp->res);
- return;
- }
-
- const size_t* availableCoreCount = nullptr;
- const uint32_t* baseSpeed = nullptr;
- const uint32_t* maxJunctionTemperature = nullptr;
- const uint32_t* maxSpeed = nullptr;
- const uint32_t* powerLimit = nullptr;
- const TurboProfileProperty* turboProfile = nullptr;
- const BaseSpeedPrioritySettingsProperty* baseSpeedPrioritySettings =
- nullptr;
-
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), properties, "AvailableCoreCount",
- availableCoreCount, "BaseSpeed", baseSpeed,
- "MaxJunctionTemperature", maxJunctionTemperature, "MaxSpeed",
- maxSpeed, "PowerLimit", powerLimit, "TurboProfile", turboProfile,
- "BaseSpeedPrioritySettings", baseSpeedPrioritySettings);
-
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- nlohmann::json& json = asyncResp->res.jsonValue;
-
- if (availableCoreCount != nullptr)
- {
- json["TotalAvailableCoreCount"] = *availableCoreCount;
- }
-
- if (baseSpeed != nullptr)
- {
- json["BaseSpeedMHz"] = *baseSpeed;
- }
-
- if (maxJunctionTemperature != nullptr)
- {
- json["MaxJunctionTemperatureCelsius"] = *maxJunctionTemperature;
- }
-
- if (maxSpeed != nullptr)
- {
- json["MaxSpeedMHz"] = *maxSpeed;
- }
-
- if (powerLimit != nullptr)
- {
- json["TDPWatts"] = *powerLimit;
- }
-
- if (turboProfile != nullptr)
- {
- nlohmann::json& turboArray = json["TurboProfile"];
- turboArray = nlohmann::json::array();
- for (const auto& [turboSpeed, coreCount] : *turboProfile)
+ if (ec)
{
- nlohmann::json::object_t turbo;
- turbo["ActiveCoreCount"] = coreCount;
- turbo["MaxSpeedMHz"] = turboSpeed;
- turboArray.emplace_back(std::move(turbo));
+ BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message());
+ messages::internalError(asyncResp->res);
+ return;
}
- }
- if (baseSpeedPrioritySettings != nullptr)
- {
- nlohmann::json& baseSpeedArray = json["BaseSpeedPrioritySettings"];
- baseSpeedArray = nlohmann::json::array();
- for (const auto& [baseSpeedMhz, coreList] :
- *baseSpeedPrioritySettings)
+ const size_t* availableCoreCount = nullptr;
+ const uint32_t* baseSpeed = nullptr;
+ const uint32_t* maxJunctionTemperature = nullptr;
+ const uint32_t* maxSpeed = nullptr;
+ const uint32_t* powerLimit = nullptr;
+ const TurboProfileProperty* turboProfile = nullptr;
+ const BaseSpeedPrioritySettingsProperty* baseSpeedPrioritySettings =
+ nullptr;
+
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), properties,
+ "AvailableCoreCount", availableCoreCount, "BaseSpeed",
+ baseSpeed, "MaxJunctionTemperature", maxJunctionTemperature,
+ "MaxSpeed", maxSpeed, "PowerLimit", powerLimit, "TurboProfile",
+ turboProfile, "BaseSpeedPrioritySettings",
+ baseSpeedPrioritySettings);
+
+ if (!success)
{
- nlohmann::json::object_t speed;
- speed["CoreCount"] = coreList.size();
- speed["CoreIDs"] = coreList;
- speed["BaseSpeedMHz"] = baseSpeedMhz;
- baseSpeedArray.emplace_back(std::move(speed));
+ messages::internalError(asyncResp->res);
+ return;
}
- }
- });
+
+ nlohmann::json& json = asyncResp->res.jsonValue;
+
+ if (availableCoreCount != nullptr)
+ {
+ json["TotalAvailableCoreCount"] = *availableCoreCount;
+ }
+
+ if (baseSpeed != nullptr)
+ {
+ json["BaseSpeedMHz"] = *baseSpeed;
+ }
+
+ if (maxJunctionTemperature != nullptr)
+ {
+ json["MaxJunctionTemperatureCelsius"] = *maxJunctionTemperature;
+ }
+
+ if (maxSpeed != nullptr)
+ {
+ json["MaxSpeedMHz"] = *maxSpeed;
+ }
+
+ if (powerLimit != nullptr)
+ {
+ json["TDPWatts"] = *powerLimit;
+ }
+
+ if (turboProfile != nullptr)
+ {
+ nlohmann::json& turboArray = json["TurboProfile"];
+ turboArray = nlohmann::json::array();
+ for (const auto& [turboSpeed, coreCount] : *turboProfile)
+ {
+ nlohmann::json::object_t turbo;
+ turbo["ActiveCoreCount"] = coreCount;
+ turbo["MaxSpeedMHz"] = turboSpeed;
+ turboArray.emplace_back(std::move(turbo));
+ }
+ }
+
+ if (baseSpeedPrioritySettings != nullptr)
+ {
+ nlohmann::json& baseSpeedArray =
+ json["BaseSpeedPrioritySettings"];
+ baseSpeedArray = nlohmann::json::array();
+ for (const auto& [baseSpeedMhz, coreList] :
+ *baseSpeedPrioritySettings)
+ {
+ nlohmann::json::object_t speed;
+ speed["CoreCount"] = coreList.size();
+ speed["CoreIDs"] = coreList;
+ speed["BaseSpeedMHz"] = baseSpeedMhz;
+ baseSpeedArray.emplace_back(std::move(speed));
+ }
+ }
+ });
}
/**
@@ -1069,11 +1072,10 @@
"AppliedConfig", configPath);
}
-inline void
- handleProcessorHead(crow::App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& /* systemName */,
- const std::string& /* processorId */)
+inline void handleProcessorHead(
+ crow::App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& /* systemName */, const std::string& /* processorId */)
{
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
@@ -1103,77 +1105,81 @@
BMCWEB_ROUTE(app,
"/redfish/v1/Systems/<str>/Processors/<str>/OperatingConfigs/")
.privileges(redfish::privileges::getOperatingConfigCollection)
- .methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName, const std::string& cpuName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
-
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
-
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- asyncResp->res.jsonValue["@odata.type"] =
- "#OperatingConfigCollection.OperatingConfigCollection";
- asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs",
- BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuName);
- asyncResp->res.jsonValue["Name"] = "Operating Config Collection";
-
- // First find the matching CPU object so we know how to
- // constrain our search for related Config objects.
- const std::array<std::string_view, 1> interfaces = {
- "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig"};
- dbus::utility::getSubTreePaths(
- "/xyz/openbmc_project/inventory", 0, interfaces,
- [asyncResp, cpuName](
- const boost::system::error_code& ec,
- const dbus::utility::MapperGetSubTreePathsResponse& objects) {
- if (ec)
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName,
+ const std::string& cpuName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
- BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message());
- messages::internalError(asyncResp->res);
return;
}
- for (const std::string& object : objects)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
- if (!object.ends_with(cpuName))
- {
- continue;
- }
-
- // Not expected that there will be multiple matching
- // CPU objects, but if there are just use the first
- // one.
-
- // Use the common search routine to construct the
- // Collection of all Config objects under this CPU.
- constexpr std::array<std::string_view, 1> interface{
- "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig"};
- collection_util::getCollectionMembers(
- asyncResp,
- boost::urls::format(
- "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs",
- BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuName),
- interface, object);
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
return;
}
+
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#OperatingConfigCollection.OperatingConfigCollection";
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuName);
+ asyncResp->res.jsonValue["Name"] = "Operating Config Collection";
+
+ // First find the matching CPU object so we know how to
+ // constrain our search for related Config objects.
+ const std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig"};
+ dbus::utility::getSubTreePaths(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
+ [asyncResp,
+ cpuName](const boost::system::error_code& ec,
+ const dbus::utility::MapperGetSubTreePathsResponse&
+ objects) {
+ if (ec)
+ {
+ BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec,
+ ec.message());
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ for (const std::string& object : objects)
+ {
+ if (!object.ends_with(cpuName))
+ {
+ continue;
+ }
+
+ // Not expected that there will be multiple matching
+ // CPU objects, but if there are just use the first
+ // one.
+
+ // Use the common search routine to construct the
+ // Collection of all Config objects under this CPU.
+ constexpr std::array<std::string_view, 1> interface{
+ "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig"};
+ collection_util::getCollectionMembers(
+ asyncResp,
+ boost::urls::format(
+ "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuName),
+ interface, object);
+ return;
+ }
+ });
});
- });
}
inline void requestRoutesOperatingConfig(App& app)
@@ -1182,72 +1188,79 @@
app,
"/redfish/v1/Systems/<str>/Processors/<str>/OperatingConfigs/<str>/")
.privileges(redfish::privileges::getOperatingConfig)
- .methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName, const std::string& cpuName,
- const std::string& configName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
-
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- // Ask for all objects implementing OperatingConfig so we can search
- // for one with a matching name
- constexpr std::array<std::string_view, 1> interfaces = {
- "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig"};
- dbus::utility::getSubTree(
- "/xyz/openbmc_project/inventory", 0, interfaces,
- [asyncResp, cpuName, configName](
- const boost::system::error_code& ec,
- const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName,
+ const std::string& cpuName,
+ const std::string& configName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
- BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message());
- messages::internalError(asyncResp->res);
return;
}
- const std::string expectedEnding = cpuName + '/' + configName;
- for (const auto& [objectPath, serviceMap] : subtree)
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
{
- // Ignore any configs without matching cpuX/configY
- if (!objectPath.ends_with(expectedEnding) || serviceMap.empty())
- {
- continue;
- }
-
- nlohmann::json& json = asyncResp->res.jsonValue;
- json["@odata.type"] = "#OperatingConfig.v1_0_0.OperatingConfig";
- json["@odata.id"] = boost::urls::format(
- "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs/{}",
- BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuName, configName);
- json["Name"] = "Processor Profile";
- json["Id"] = configName;
-
- // Just use the first implementation of the object - not
- // expected that there would be multiple matching
- // services
- getOperatingConfigData(asyncResp, serviceMap.begin()->first,
- objectPath);
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
return;
}
- messages::resourceNotFound(asyncResp->res, "OperatingConfig",
- configName);
+
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ // Ask for all objects implementing OperatingConfig so we can search
+ // for one with a matching name
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig"};
+ dbus::utility::getSubTree(
+ "/xyz/openbmc_project/inventory", 0, interfaces,
+ [asyncResp, cpuName, configName](
+ const boost::system::error_code& ec,
+ const dbus::utility::MapperGetSubTreeResponse& subtree) {
+ if (ec)
+ {
+ BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec,
+ ec.message());
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ const std::string expectedEnding =
+ cpuName + '/' + configName;
+ for (const auto& [objectPath, serviceMap] : subtree)
+ {
+ // Ignore any configs without matching cpuX/configY
+ if (!objectPath.ends_with(expectedEnding) ||
+ serviceMap.empty())
+ {
+ continue;
+ }
+
+ nlohmann::json& json = asyncResp->res.jsonValue;
+ json["@odata.type"] =
+ "#OperatingConfig.v1_0_0.OperatingConfig";
+ json["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs/{}",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuName,
+ configName);
+ json["Name"] = "Processor Profile";
+ json["Id"] = configName;
+
+ // Just use the first implementation of the object - not
+ // expected that there would be multiple matching
+ // services
+ getOperatingConfigData(
+ asyncResp, serviceMap.begin()->first, objectPath);
+ return;
+ }
+ messages::resourceNotFound(asyncResp->res,
+ "OperatingConfig", configName);
+ });
});
- });
}
inline void requestRoutesProcessorCollection(App& app)
@@ -1262,47 +1275,48 @@
BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/")
.privileges(redfish::privileges::getProcessorCollection)
- .methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- asyncResp->res.addHeader(
- boost::beast::http::field::link,
- "</redfish/v1/JsonSchemas/ProcessorCollection/ProcessorCollection.json>; rel=describedby");
+ asyncResp->res.addHeader(
+ boost::beast::http::field::link,
+ "</redfish/v1/JsonSchemas/ProcessorCollection/ProcessorCollection.json>; rel=describedby");
- asyncResp->res.jsonValue["@odata.type"] =
- "#ProcessorCollection.ProcessorCollection";
- asyncResp->res.jsonValue["Name"] = "Processor Collection";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ProcessorCollection.ProcessorCollection";
+ asyncResp->res.jsonValue["Name"] = "Processor Collection";
- asyncResp->res.jsonValue["@odata.id"] =
- std::format("/redfish/v1/Systems/{}/Processors",
- BMCWEB_REDFISH_SYSTEM_URI_NAME);
+ asyncResp->res.jsonValue["@odata.id"] =
+ std::format("/redfish/v1/Systems/{}/Processors",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME);
- collection_util::getCollectionMembers(
- asyncResp,
- boost::urls::format("/redfish/v1/Systems/{}/Processors",
- BMCWEB_REDFISH_SYSTEM_URI_NAME),
- processorInterfaces, "/xyz/openbmc_project/inventory");
- });
+ collection_util::getCollectionMembers(
+ asyncResp,
+ boost::urls::format("/redfish/v1/Systems/{}/Processors",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME),
+ processorInterfaces, "/xyz/openbmc_project/inventory");
+ });
}
inline void requestRoutesProcessor(App& app)
@@ -1318,42 +1332,43 @@
BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/<str>/")
.privileges(redfish::privileges::getProcessor)
- .methods(boost::beast::http::verb::get)(
- [&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName,
- const std::string& processorId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName,
+ const std::string& processorId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- asyncResp->res.addHeader(
- boost::beast::http::field::link,
- "</redfish/v1/JsonSchemas/Processor/Processor.json>; rel=describedby");
- asyncResp->res.jsonValue["@odata.type"] =
- "#Processor.v1_18_0.Processor";
- asyncResp->res.jsonValue["@odata.id"] =
- boost::urls::format("/redfish/v1/Systems/{}/Processors/{}",
- BMCWEB_REDFISH_SYSTEM_URI_NAME, processorId);
+ asyncResp->res.addHeader(
+ boost::beast::http::field::link,
+ "</redfish/v1/JsonSchemas/Processor/Processor.json>; rel=describedby");
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#Processor.v1_18_0.Processor";
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Systems/{}/Processors/{}",
+ BMCWEB_REDFISH_SYSTEM_URI_NAME, processorId);
- getProcessorObject(
- asyncResp, processorId,
- std::bind_front(getProcessorData, asyncResp, processorId));
- });
+ getProcessorObject(
+ asyncResp, processorId,
+ std::bind_front(getProcessorData, asyncResp, processorId));
+ });
BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/<str>/")
.privileges(redfish::privileges::patchProcessor)
@@ -1362,42 +1377,42 @@
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& systemName,
const std::string& processorId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
- {
- // Option currently returns no systems. TBD
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
- if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
- {
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- systemName);
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
+ {
+ // Option currently returns no systems. TBD
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+ if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
- std::optional<std::string> appliedConfigUri;
- if (!json_util::readJsonPatch(req, asyncResp->res,
- "AppliedOperatingConfig/@odata.id",
- appliedConfigUri))
- {
- return;
- }
+ std::optional<std::string> appliedConfigUri;
+ if (!json_util::readJsonPatch(
+ req, asyncResp->res, "AppliedOperatingConfig/@odata.id",
+ appliedConfigUri))
+ {
+ return;
+ }
- if (appliedConfigUri)
- {
- // Check for 404 and find matching D-Bus object, then run
- // property patch handlers if that all succeeds.
- getProcessorObject(asyncResp, processorId,
- std::bind_front(patchAppliedOperatingConfig,
- asyncResp, processorId,
- *appliedConfigUri));
- }
- });
+ if (appliedConfigUri)
+ {
+ // Check for 404 and find matching D-Bus object, then run
+ // property patch handlers if that all succeeds.
+ getProcessorObject(
+ asyncResp, processorId,
+ std::bind_front(patchAppliedOperatingConfig, asyncResp,
+ processorId, *appliedConfigUri));
+ }
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/redfish_util.hpp b/redfish-core/lib/redfish_util.hpp
index 8fe2bbc..b6e7b20 100644
--- a/redfish-core/lib/redfish_util.hpp
+++ b/redfish-core/lib/redfish_util.hpp
@@ -71,29 +71,29 @@
[callback = std::forward<CallbackFunc>(callback),
asyncResp](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("{}", ec);
- return;
- }
- if (subtree.empty())
- {
- BMCWEB_LOG_DEBUG("Can't find chassis!");
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("{}", ec);
+ return;
+ }
+ if (subtree.empty())
+ {
+ BMCWEB_LOG_DEBUG("Can't find chassis!");
+ return;
+ }
- std::size_t idPos = subtree[0].first.rfind('/');
- if (idPos == std::string::npos ||
- (idPos + 1) >= subtree[0].first.size())
- {
- messages::internalError(asyncResp->res);
- BMCWEB_LOG_DEBUG("Can't parse chassis ID!");
- return;
- }
- std::string chassisId = subtree[0].first.substr(idPos + 1);
- BMCWEB_LOG_DEBUG("chassisId = {}", chassisId);
- callback(chassisId, asyncResp);
- });
+ std::size_t idPos = subtree[0].first.rfind('/');
+ if (idPos == std::string::npos ||
+ (idPos + 1) >= subtree[0].first.size())
+ {
+ messages::internalError(asyncResp->res);
+ BMCWEB_LOG_DEBUG("Can't parse chassis ID!");
+ return;
+ }
+ std::string chassisId = subtree[0].first.substr(idPos + 1);
+ BMCWEB_LOG_DEBUG("chassisId = {}", chassisId);
+ callback(chassisId, asyncResp);
+ });
}
template <typename CallbackFunc>
@@ -106,99 +106,101 @@
[protocolToDBus, callback = std::forward<CallbackFunc>(callback)](
const boost::system::error_code& ec,
const std::vector<UnitStruct>& r) {
- std::vector<std::tuple<std::string, std::string, bool>> socketData;
- if (ec)
- {
- BMCWEB_LOG_ERROR("{}", ec);
- // return error code
- callback(ec, socketData);
- return;
- }
-
- // save all service output into vector
- for (const UnitStruct& unit : r)
- {
- // Only traverse through <xyz>.socket units
- const std::string& unitName = std::get<NET_PROTO_UNIT_NAME>(unit);
-
- // find "." into unitsName
- size_t lastCharPos = unitName.rfind('.');
- if (lastCharPos == std::string::npos)
+ std::vector<std::tuple<std::string, std::string, bool>> socketData;
+ if (ec)
{
- continue;
+ BMCWEB_LOG_ERROR("{}", ec);
+ // return error code
+ callback(ec, socketData);
+ return;
}
- // is unitsName end with ".socket"
- std::string unitNameEnd = unitName.substr(lastCharPos);
- if (unitNameEnd != ".socket")
+ // save all service output into vector
+ for (const UnitStruct& unit : r)
{
- continue;
- }
+ // Only traverse through <xyz>.socket units
+ const std::string& unitName =
+ std::get<NET_PROTO_UNIT_NAME>(unit);
- // find "@" into unitsName
- if (size_t atCharPos = unitName.rfind('@');
- atCharPos != std::string::npos)
- {
- lastCharPos = atCharPos;
- }
-
- // unitsName without "@eth(x).socket", only <xyz>
- // unitsName without ".socket", only <xyz>
- std::string unitNameStr = unitName.substr(0, lastCharPos);
-
- for (const auto& kv : protocolToDBus)
- {
- // We are interested in services, which starts with
- // mapped service name
- if (unitNameStr != kv.second)
+ // find "." into unitsName
+ size_t lastCharPos = unitName.rfind('.');
+ if (lastCharPos == std::string::npos)
{
continue;
}
- const std::string& socketPath =
- std::get<NET_PROTO_UNIT_OBJ_PATH>(unit);
- const std::string& unitState =
- std::get<NET_PROTO_UNIT_SUB_STATE>(unit);
-
- bool isProtocolEnabled = ((unitState == "running") ||
- (unitState == "listening"));
-
- // Some protocols may have multiple services associated with
- // them (for example IPMI). Look to see if we've already added
- // an entry for the current protocol.
- auto find = std::ranges::find_if(
- socketData,
- [&kv](const std::tuple<std::string, std::string, bool>& i) {
- return std::get<1>(i) == kv.first;
- });
- if (find != socketData.end())
+ // is unitsName end with ".socket"
+ std::string unitNameEnd = unitName.substr(lastCharPos);
+ if (unitNameEnd != ".socket")
{
- // It only takes one enabled systemd service to consider a
- // protocol enabled so if the current entry already has it
- // enabled (or the new one is disabled) then just continue,
- // otherwise remove the current one and add this new one.
- if (std::get<2>(*find) || !isProtocolEnabled)
- {
- // Already registered as enabled or current one is not
- // enabled, nothing to do
- BMCWEB_LOG_DEBUG(
- "protocolName: {}, already true or current one is false: {}",
- kv.first, isProtocolEnabled);
- break;
- }
- // Remove existing entry and replace with new one (below)
- socketData.erase(find);
+ continue;
}
- socketData.emplace_back(socketPath, std::string(kv.first),
- isProtocolEnabled);
- // We found service, return from inner loop.
- break;
- }
- }
+ // find "@" into unitsName
+ if (size_t atCharPos = unitName.rfind('@');
+ atCharPos != std::string::npos)
+ {
+ lastCharPos = atCharPos;
+ }
- callback(ec, socketData);
- },
+ // unitsName without "@eth(x).socket", only <xyz>
+ // unitsName without ".socket", only <xyz>
+ std::string unitNameStr = unitName.substr(0, lastCharPos);
+
+ for (const auto& kv : protocolToDBus)
+ {
+ // We are interested in services, which starts with
+ // mapped service name
+ if (unitNameStr != kv.second)
+ {
+ continue;
+ }
+
+ const std::string& socketPath =
+ std::get<NET_PROTO_UNIT_OBJ_PATH>(unit);
+ const std::string& unitState =
+ std::get<NET_PROTO_UNIT_SUB_STATE>(unit);
+
+ bool isProtocolEnabled = ((unitState == "running") ||
+ (unitState == "listening"));
+
+ // Some protocols may have multiple services associated with
+ // them (for example IPMI). Look to see if we've already
+ // added an entry for the current protocol.
+ auto find = std::ranges::find_if(
+ socketData,
+ [&kv](const std::tuple<std::string, std::string, bool>&
+ i) { return std::get<1>(i) == kv.first; });
+ if (find != socketData.end())
+ {
+ // It only takes one enabled systemd service to consider
+ // a protocol enabled so if the current entry already
+ // has it enabled (or the new one is disabled) then just
+ // continue, otherwise remove the current one and add
+ // this new one.
+ if (std::get<2>(*find) || !isProtocolEnabled)
+ {
+ // Already registered as enabled or current one is
+ // not enabled, nothing to do
+ BMCWEB_LOG_DEBUG(
+ "protocolName: {}, already true or current one is false: {}",
+ kv.first, isProtocolEnabled);
+ break;
+ }
+ // Remove existing entry and replace with new one
+ // (below)
+ socketData.erase(find);
+ }
+
+ socketData.emplace_back(socketPath, std::string(kv.first),
+ isProtocolEnabled);
+ // We found service, return from inner loop.
+ break;
+ }
+ }
+
+ callback(ec, socketData);
+ },
"org.freedesktop.systemd1", "/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager", "ListUnits");
}
@@ -213,46 +215,46 @@
[callback = std::forward<CallbackFunc>(callback)](
const boost::system::error_code& ec,
const std::vector<std::tuple<std::string, std::string>>& resp) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("{}", ec);
- callback(ec, 0);
- return;
- }
- if (resp.empty())
- {
- // Network Protocol Listen Response Elements is empty
- boost::system::error_code ec1 =
- boost::system::errc::make_error_code(
- boost::system::errc::bad_message);
- // return error code
- callback(ec1, 0);
- BMCWEB_LOG_ERROR("{}", ec1);
- return;
- }
- const std::string& listenStream =
- std::get<NET_PROTO_LISTEN_STREAM>(resp[0]);
- const char* pa = &listenStream[listenStream.rfind(':') + 1];
- int port{0};
- if (auto [p, ec2] = std::from_chars(pa, nullptr, port);
- ec2 != std::errc())
- {
- // there is only two possibility invalid_argument and
- // result_out_of_range
- boost::system::error_code ec3 =
- boost::system::errc::make_error_code(
- boost::system::errc::invalid_argument);
- if (ec2 == std::errc::result_out_of_range)
+ if (ec)
{
- ec3 = boost::system::errc::make_error_code(
- boost::system::errc::result_out_of_range);
+ BMCWEB_LOG_ERROR("{}", ec);
+ callback(ec, 0);
+ return;
}
- // return error code
- callback(ec3, 0);
- BMCWEB_LOG_ERROR("{}", ec3);
- }
- callback(ec, port);
- });
+ if (resp.empty())
+ {
+ // Network Protocol Listen Response Elements is empty
+ boost::system::error_code ec1 =
+ boost::system::errc::make_error_code(
+ boost::system::errc::bad_message);
+ // return error code
+ callback(ec1, 0);
+ BMCWEB_LOG_ERROR("{}", ec1);
+ return;
+ }
+ const std::string& listenStream =
+ std::get<NET_PROTO_LISTEN_STREAM>(resp[0]);
+ const char* pa = &listenStream[listenStream.rfind(':') + 1];
+ int port{0};
+ if (auto [p, ec2] = std::from_chars(pa, nullptr, port);
+ ec2 != std::errc())
+ {
+ // there is only two possibility invalid_argument and
+ // result_out_of_range
+ boost::system::error_code ec3 =
+ boost::system::errc::make_error_code(
+ boost::system::errc::invalid_argument);
+ if (ec2 == std::errc::result_out_of_range)
+ {
+ ec3 = boost::system::errc::make_error_code(
+ boost::system::errc::result_out_of_range);
+ }
+ // return error code
+ callback(ec3, 0);
+ BMCWEB_LOG_ERROR("{}", ec3);
+ }
+ callback(ec, port);
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/redfish_v1.hpp b/redfish-core/lib/redfish_v1.hpp
index 41bcafe..d6a9d82 100644
--- a/redfish-core/lib/redfish_v1.hpp
+++ b/redfish-core/lib/redfish_v1.hpp
@@ -104,8 +104,8 @@
continue;
}
nlohmann::json::object_t member;
- member["@odata.id"] = boost::urls::format("/redfish/v1/JsonSchemas/{}",
- split[0]);
+ member["@odata.id"] =
+ boost::urls::format("/redfish/v1/JsonSchemas/{}", split[0]);
members.emplace_back(std::move(member));
}
@@ -146,8 +146,8 @@
}
nlohmann::json& json = asyncResp->res.jsonValue;
- json["@odata.id"] = boost::urls::format("/redfish/v1/JsonSchemas/{}",
- schema);
+ json["@odata.id"] =
+ boost::urls::format("/redfish/v1/JsonSchemas/{}", schema);
json["@odata.type"] = "#JsonSchemaFile.v1_0_2.JsonSchemaFile";
json["Name"] = schema + " Schema File";
json["Description"] = schema + " Schema File Location";
diff --git a/redfish-core/lib/roles.hpp b/redfish-core/lib/roles.hpp
index a0f4f34..aa69008 100644
--- a/redfish-core/lib/roles.hpp
+++ b/redfish-core/lib/roles.hpp
@@ -85,31 +85,33 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& roleId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- std::optional<nlohmann::json::array_t> privArray =
- getAssignedPrivFromRole(roleId);
- if (!privArray)
- {
- messages::resourceNotFound(asyncResp->res, "Role", roleId);
+ std::optional<nlohmann::json::array_t> privArray =
+ getAssignedPrivFromRole(roleId);
+ if (!privArray)
+ {
+ messages::resourceNotFound(asyncResp->res, "Role", roleId);
- return;
- }
+ return;
+ }
- asyncResp->res.jsonValue["@odata.type"] = "#Role.v1_2_2.Role";
- asyncResp->res.jsonValue["Name"] = "User Role";
- asyncResp->res.jsonValue["Description"] = roleId + " User Role";
- asyncResp->res.jsonValue["OemPrivileges"] = nlohmann::json::array();
- asyncResp->res.jsonValue["IsPredefined"] = true;
- asyncResp->res.jsonValue["Id"] = roleId;
- asyncResp->res.jsonValue["RoleId"] = roleId;
- asyncResp->res.jsonValue["@odata.id"] =
- boost::urls::format("/redfish/v1/AccountService/Roles/{}", roleId);
- asyncResp->res.jsonValue["AssignedPrivileges"] = std::move(*privArray);
- });
+ asyncResp->res.jsonValue["@odata.type"] = "#Role.v1_2_2.Role";
+ asyncResp->res.jsonValue["Name"] = "User Role";
+ asyncResp->res.jsonValue["Description"] = roleId + " User Role";
+ asyncResp->res.jsonValue["OemPrivileges"] =
+ nlohmann::json::array();
+ asyncResp->res.jsonValue["IsPredefined"] = true;
+ asyncResp->res.jsonValue["Id"] = roleId;
+ asyncResp->res.jsonValue["RoleId"] = roleId;
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/AccountService/Roles/{}", roleId);
+ asyncResp->res.jsonValue["AssignedPrivileges"] =
+ std::move(*privArray);
+ });
}
inline void requestRoutesRoleCollection(App& app)
@@ -119,46 +121,49 @@
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
-
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/AccountService/Roles";
- asyncResp->res.jsonValue["@odata.type"] =
- "#RoleCollection.RoleCollection";
- asyncResp->res.jsonValue["Name"] = "Roles Collection";
- asyncResp->res.jsonValue["Description"] = "BMC User Roles";
-
- sdbusplus::asio::getProperty<std::vector<std::string>>(
- *crow::connections::systemBus, "xyz.openbmc_project.User.Manager",
- "/xyz/openbmc_project/user", "xyz.openbmc_project.User.Manager",
- "AllPrivileges",
- [asyncResp](const boost::system::error_code& ec,
- const std::vector<std::string>& privList) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- nlohmann::json& memberArray = asyncResp->res.jsonValue["Members"];
- memberArray = nlohmann::json::array();
- for (const std::string& priv : privList)
- {
- std::string role = getRoleFromPrivileges(priv);
- if (!role.empty())
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
- nlohmann::json::object_t member;
- member["@odata.id"] = boost::urls::format(
- "/redfish/v1/AccountService/Roles/{}", role);
- memberArray.emplace_back(std::move(member));
+ return;
}
- }
- asyncResp->res.jsonValue["Members@odata.count"] =
- memberArray.size();
- });
- });
+
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/AccountService/Roles";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#RoleCollection.RoleCollection";
+ asyncResp->res.jsonValue["Name"] = "Roles Collection";
+ asyncResp->res.jsonValue["Description"] = "BMC User Roles";
+
+ sdbusplus::asio::getProperty<std::vector<std::string>>(
+ *crow::connections::systemBus,
+ "xyz.openbmc_project.User.Manager",
+ "/xyz/openbmc_project/user",
+ "xyz.openbmc_project.User.Manager", "AllPrivileges",
+ [asyncResp](const boost::system::error_code& ec,
+ const std::vector<std::string>& privList) {
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ nlohmann::json& memberArray =
+ asyncResp->res.jsonValue["Members"];
+ memberArray = nlohmann::json::array();
+ for (const std::string& priv : privList)
+ {
+ std::string role = getRoleFromPrivileges(priv);
+ if (!role.empty())
+ {
+ nlohmann::json::object_t member;
+ member["@odata.id"] = boost::urls::format(
+ "/redfish/v1/AccountService/Roles/{}",
+ role);
+ memberArray.emplace_back(std::move(member));
+ }
+ }
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ memberArray.size();
+ });
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 228fae04..8627194 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -217,9 +217,8 @@
const std::string& chassisIdIn,
std::span<const std::string_view> typesIn,
std::string_view subNode) :
- asyncResp(asyncRespIn),
- chassisId(chassisIdIn), types(typesIn), chassisSubNode(subNode),
- efficientExpand(false)
+ asyncResp(asyncRespIn), chassisId(chassisIdIn), types(typesIn),
+ chassisSubNode(subNode), efficientExpand(false)
{}
// Store extra data about sensor mapping and return it in callback
@@ -228,9 +227,9 @@
std::span<const std::string_view> typesIn,
std::string_view subNode,
DataCompleteCb&& creationComplete) :
- asyncResp(asyncRespIn),
- chassisId(chassisIdIn), types(typesIn), chassisSubNode(subNode),
- efficientExpand(false), metadata{std::vector<SensorData>()},
+ asyncResp(asyncRespIn), chassisId(chassisIdIn), types(typesIn),
+ chassisSubNode(subNode), efficientExpand(false),
+ metadata{std::vector<SensorData>()},
dataComplete{std::move(creationComplete)}
{}
@@ -239,9 +238,8 @@
const std::string& chassisIdIn,
std::span<const std::string_view> typesIn,
const std::string_view& subNode, bool efficientExpandIn) :
- asyncResp(asyncRespIn),
- chassisId(chassisIdIn), types(typesIn), chassisSubNode(subNode),
- efficientExpand(efficientExpandIn)
+ asyncResp(asyncRespIn), chassisId(chassisIdIn), types(typesIn),
+ chassisSubNode(subNode), efficientExpand(efficientExpandIn)
{}
~SensorsAsyncResp()
@@ -375,50 +373,51 @@
[callback = std::forward<Callback>(callback), sensorsAsyncResp,
sensorNames](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- // Response handler for parsing objects subtree
- BMCWEB_LOG_DEBUG("getObjectsWithConnection resp_handler enter");
- if (ec)
- {
- messages::internalError(sensorsAsyncResp->asyncResp->res);
- BMCWEB_LOG_ERROR(
- "getObjectsWithConnection resp_handler: Dbus error {}", ec);
- return;
- }
-
- BMCWEB_LOG_DEBUG("Found {} subtrees", subtree.size());
-
- // Make unique list of connections only for requested sensor types and
- // found in the chassis
- std::set<std::string> connections;
- std::set<std::pair<std::string, std::string>> objectsWithConnection;
-
- BMCWEB_LOG_DEBUG("sensorNames list count: {}", sensorNames->size());
- for (const std::string& tsensor : *sensorNames)
- {
- BMCWEB_LOG_DEBUG("Sensor to find: {}", tsensor);
- }
-
- for (const std::pair<
- std::string,
- std::vector<std::pair<std::string, std::vector<std::string>>>>&
- object : subtree)
- {
- if (sensorNames->find(object.first) != sensorNames->end())
+ // Response handler for parsing objects subtree
+ BMCWEB_LOG_DEBUG("getObjectsWithConnection resp_handler enter");
+ if (ec)
{
- for (const std::pair<std::string, std::vector<std::string>>&
- objData : object.second)
+ messages::internalError(sensorsAsyncResp->asyncResp->res);
+ BMCWEB_LOG_ERROR(
+ "getObjectsWithConnection resp_handler: Dbus error {}", ec);
+ return;
+ }
+
+ BMCWEB_LOG_DEBUG("Found {} subtrees", subtree.size());
+
+ // Make unique list of connections only for requested sensor types
+ // and found in the chassis
+ std::set<std::string> connections;
+ std::set<std::pair<std::string, std::string>> objectsWithConnection;
+
+ BMCWEB_LOG_DEBUG("sensorNames list count: {}", sensorNames->size());
+ for (const std::string& tsensor : *sensorNames)
+ {
+ BMCWEB_LOG_DEBUG("Sensor to find: {}", tsensor);
+ }
+
+ for (const std::pair<std::string,
+ std::vector<std::pair<
+ std::string, std::vector<std::string>>>>&
+ object : subtree)
+ {
+ if (sensorNames->find(object.first) != sensorNames->end())
{
- BMCWEB_LOG_DEBUG("Adding connection: {}", objData.first);
- connections.insert(objData.first);
- objectsWithConnection.insert(
- std::make_pair(object.first, objData.first));
+ for (const std::pair<std::string, std::vector<std::string>>&
+ objData : object.second)
+ {
+ BMCWEB_LOG_DEBUG("Adding connection: {}",
+ objData.first);
+ connections.insert(objData.first);
+ objectsWithConnection.insert(
+ std::make_pair(object.first, objData.first));
+ }
}
}
- }
- BMCWEB_LOG_DEBUG("Found {} connections", connections.size());
- callback(std::move(connections), std::move(objectsWithConnection));
- BMCWEB_LOG_DEBUG("getObjectsWithConnection resp_handler exit");
- });
+ BMCWEB_LOG_DEBUG("Found {} connections", connections.size());
+ callback(std::move(connections), std::move(objectsWithConnection));
+ BMCWEB_LOG_DEBUG("getObjectsWithConnection resp_handler exit");
+ });
BMCWEB_LOG_DEBUG("getObjectsWithConnection exit");
}
@@ -541,63 +540,67 @@
chassisSubNode{std::string(chassisSubNode)}, sensorTypes](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse& chassisPaths) {
- BMCWEB_LOG_DEBUG("getChassis respHandler enter");
- if (ec)
- {
- BMCWEB_LOG_ERROR("getChassis respHandler DBUS error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- const std::string* chassisPath = nullptr;
- for (const std::string& chassis : chassisPaths)
- {
- sdbusplus::message::object_path path(chassis);
- std::string chassisName = path.filename();
- if (chassisName.empty())
+ BMCWEB_LOG_DEBUG("getChassis respHandler enter");
+ if (ec)
{
- BMCWEB_LOG_ERROR("Failed to find '/' in {}", chassis);
- continue;
+ BMCWEB_LOG_ERROR("getChassis respHandler DBUS error: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
}
- if (chassisName == chassisIdStr)
+ const std::string* chassisPath = nullptr;
+ for (const std::string& chassis : chassisPaths)
{
- chassisPath = &chassis;
- break;
- }
- }
- if (chassisPath == nullptr)
- {
- messages::resourceNotFound(asyncResp->res, "Chassis", chassisIdStr);
- return;
- }
- populateChassisNode(asyncResp->res.jsonValue, chassisSubNode);
-
- asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
- "/redfish/v1/Chassis/{}/{}", chassisIdStr, chassisSubNode);
-
- // Get the list of all sensors for this Chassis element
- std::string sensorPath = *chassisPath + "/all_sensors";
- dbus::utility::getAssociationEndPoints(
- sensorPath,
- [asyncResp, chassisSubNode, sensorTypes,
- callback = std::forward<const Callback>(callback)](
- const boost::system::error_code& ec2,
- const dbus::utility::MapperEndPoints& nodeSensorList) {
- if (ec2)
- {
- if (ec2.value() != EBADR)
+ sdbusplus::message::object_path path(chassis);
+ std::string chassisName = path.filename();
+ if (chassisName.empty())
{
- messages::internalError(asyncResp->res);
- return;
+ BMCWEB_LOG_ERROR("Failed to find '/' in {}", chassis);
+ continue;
+ }
+ if (chassisName == chassisIdStr)
+ {
+ chassisPath = &chassis;
+ break;
}
}
- const std::shared_ptr<std::set<std::string>> culledSensorList =
- std::make_shared<std::set<std::string>>();
- reduceSensorList(asyncResp->res, chassisSubNode, sensorTypes,
- &nodeSensorList, culledSensorList);
- BMCWEB_LOG_DEBUG("Finishing with {}", culledSensorList->size());
- callback(culledSensorList);
+ if (chassisPath == nullptr)
+ {
+ messages::resourceNotFound(asyncResp->res, "Chassis",
+ chassisIdStr);
+ return;
+ }
+ populateChassisNode(asyncResp->res.jsonValue, chassisSubNode);
+
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Chassis/{}/{}", chassisIdStr, chassisSubNode);
+
+ // Get the list of all sensors for this Chassis element
+ std::string sensorPath = *chassisPath + "/all_sensors";
+ dbus::utility::getAssociationEndPoints(
+ sensorPath,
+ [asyncResp, chassisSubNode, sensorTypes,
+ callback = std::forward<const Callback>(callback)](
+ const boost::system::error_code& ec2,
+ const dbus::utility::MapperEndPoints& nodeSensorList) {
+ if (ec2)
+ {
+ if (ec2.value() != EBADR)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ }
+ const std::shared_ptr<std::set<std::string>>
+ culledSensorList =
+ std::make_shared<std::set<std::string>>();
+ reduceSensorList(asyncResp->res, chassisSubNode,
+ sensorTypes, &nodeSensorList,
+ culledSensorList);
+ BMCWEB_LOG_DEBUG("Finishing with {}",
+ culledSensorList->size());
+ callback(culledSensorList);
+ });
});
- });
BMCWEB_LOG_DEBUG("getChassis exit");
}
@@ -789,8 +792,8 @@
}
sensorJson["Status"]["State"] = getState(inventoryItem, available);
- sensorJson["Status"]["Health"] = getHealth(sensorJson, propertiesDict,
- inventoryItem);
+ sensorJson["Status"]["Health"] =
+ getHealth(sensorJson, propertiesDict, inventoryItem);
// Parameter to set to override the type we get from dbus, and force it to
// int, regardless of what is available. This is used for schemas like fan,
@@ -1026,167 +1029,184 @@
[sensorsAsyncResp](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& resp) {
- if (ec)
- {
- return; // don't have to have this interface
- }
- for (const std::pair<std::string, dbus::utility::MapperServiceMap>&
- pathPair : resp)
- {
- const std::string& path = pathPair.first;
- const dbus::utility::MapperServiceMap& objDict = pathPair.second;
- if (objDict.empty())
+ if (ec)
{
- continue; // this should be impossible
+ return; // don't have to have this interface
}
-
- const std::string& owner = objDict.begin()->first;
- dbus::utility::getAssociationEndPoints(
- path + "/chassis",
- [path, owner, sensorsAsyncResp](
- const boost::system::error_code& ec2,
- const dbus::utility::MapperEndPoints& endpoints) {
- if (ec2)
+ for (const std::pair<std::string, dbus::utility::MapperServiceMap>&
+ pathPair : resp)
+ {
+ const std::string& path = pathPair.first;
+ const dbus::utility::MapperServiceMap& objDict =
+ pathPair.second;
+ if (objDict.empty())
{
- return; // if they don't have an association we
- // can't tell what chassis is
+ continue; // this should be impossible
}
- auto found = std::ranges::find_if(
- endpoints, [sensorsAsyncResp](const std::string& entry) {
- return entry.find(sensorsAsyncResp->chassisId) !=
- std::string::npos;
- });
- if (found == endpoints.end())
- {
- return;
- }
- sdbusplus::asio::getAllProperties(
- *crow::connections::systemBus, owner, path,
- "xyz.openbmc_project.Control.FanRedundancy",
- [path, sensorsAsyncResp](
- const boost::system::error_code& ec3,
- const dbus::utility::DBusPropertiesMap& ret) {
- if (ec3)
- {
- return; // don't have to have this
- // interface
- }
-
- const uint8_t* allowedFailures = nullptr;
- const std::vector<std::string>* collection = nullptr;
- const std::string* status = nullptr;
-
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), ret,
- "AllowedFailures", allowedFailures, "Collection",
- collection, "Status", status);
-
- if (!success)
- {
- messages::internalError(
- sensorsAsyncResp->asyncResp->res);
- return;
- }
-
- if (allowedFailures == nullptr || collection == nullptr ||
- status == nullptr)
- {
- BMCWEB_LOG_ERROR("Invalid redundancy interface");
- messages::internalError(
- sensorsAsyncResp->asyncResp->res);
- return;
- }
-
- sdbusplus::message::object_path objectPath(path);
- std::string name = objectPath.filename();
- if (name.empty())
- {
- // this should be impossible
- messages::internalError(
- sensorsAsyncResp->asyncResp->res);
- return;
- }
- std::ranges::replace(name, '_', ' ');
-
- std::string health;
-
- if (status->ends_with("Full"))
- {
- health = "OK";
- }
- else if (status->ends_with("Degraded"))
- {
- health = "Warning";
- }
- else
- {
- health = "Critical";
- }
- nlohmann::json::array_t redfishCollection;
- const auto& fanRedfish =
- sensorsAsyncResp->asyncResp->res.jsonValue["Fans"];
- for (const std::string& item : *collection)
- {
- sdbusplus::message::object_path itemPath(item);
- std::string itemName = itemPath.filename();
- if (itemName.empty())
+ const std::string& owner = objDict.begin()->first;
+ dbus::utility::getAssociationEndPoints(
+ path + "/chassis",
+ [path, owner, sensorsAsyncResp](
+ const boost::system::error_code& ec2,
+ const dbus::utility::MapperEndPoints& endpoints) {
+ if (ec2)
{
- continue;
+ return; // if they don't have an association we
+ // can't tell what chassis is
}
- /*
- todo(ed): merge patch that fixes the names
- std::replace(itemName.begin(),
- itemName.end(), '_', ' ');*/
- auto schemaItem = std::ranges::find_if(
- fanRedfish, [itemName](const nlohmann::json& fan) {
- return fan["Name"] == itemName;
- });
- if (schemaItem != fanRedfish.end())
+ auto found = std::ranges::find_if(
+ endpoints,
+ [sensorsAsyncResp](const std::string& entry) {
+ return entry.find(
+ sensorsAsyncResp->chassisId) !=
+ std::string::npos;
+ });
+
+ if (found == endpoints.end())
{
- nlohmann::json::object_t collectionId;
- collectionId["@odata.id"] =
- (*schemaItem)["@odata.id"];
- redfishCollection.emplace_back(
- std::move(collectionId));
- }
- else
- {
- BMCWEB_LOG_ERROR("failed to find fan in schema");
- messages::internalError(
- sensorsAsyncResp->asyncResp->res);
return;
}
- }
+ sdbusplus::asio::getAllProperties(
+ *crow::connections::systemBus, owner, path,
+ "xyz.openbmc_project.Control.FanRedundancy",
+ [path, sensorsAsyncResp](
+ const boost::system::error_code& ec3,
+ const dbus::utility::DBusPropertiesMap& ret) {
+ if (ec3)
+ {
+ return; // don't have to have this
+ // interface
+ }
- size_t minNumNeeded = collection->empty()
- ? 0
- : collection->size() -
- *allowedFailures;
- nlohmann::json& jResp = sensorsAsyncResp->asyncResp->res
- .jsonValue["Redundancy"];
+ const uint8_t* allowedFailures = nullptr;
+ const std::vector<std::string>* collection =
+ nullptr;
+ const std::string* status = nullptr;
- nlohmann::json::object_t redundancy;
- boost::urls::url url =
- boost::urls::format("/redfish/v1/Chassis/{}/{}",
- sensorsAsyncResp->chassisId,
- sensorsAsyncResp->chassisSubNode);
- url.set_fragment(("/Redundancy"_json_pointer / jResp.size())
- .to_string());
- redundancy["@odata.id"] = std::move(url);
- redundancy["@odata.type"] = "#Redundancy.v1_3_2.Redundancy";
- redundancy["MinNumNeeded"] = minNumNeeded;
- redundancy["Mode"] = redundancy::RedundancyType::NPlusM;
- redundancy["Name"] = name;
- redundancy["RedundancySet"] = redfishCollection;
- redundancy["Status"]["Health"] = health;
- redundancy["Status"]["State"] = resource::State::Enabled;
+ const bool success =
+ sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), ret,
+ "AllowedFailures", allowedFailures,
+ "Collection", collection, "Status",
+ status);
- jResp.emplace_back(std::move(redundancy));
- });
- });
- }
- });
+ if (!success)
+ {
+ messages::internalError(
+ sensorsAsyncResp->asyncResp->res);
+ return;
+ }
+
+ if (allowedFailures == nullptr ||
+ collection == nullptr || status == nullptr)
+ {
+ BMCWEB_LOG_ERROR(
+ "Invalid redundancy interface");
+ messages::internalError(
+ sensorsAsyncResp->asyncResp->res);
+ return;
+ }
+
+ sdbusplus::message::object_path objectPath(
+ path);
+ std::string name = objectPath.filename();
+ if (name.empty())
+ {
+ // this should be impossible
+ messages::internalError(
+ sensorsAsyncResp->asyncResp->res);
+ return;
+ }
+ std::ranges::replace(name, '_', ' ');
+
+ std::string health;
+
+ if (status->ends_with("Full"))
+ {
+ health = "OK";
+ }
+ else if (status->ends_with("Degraded"))
+ {
+ health = "Warning";
+ }
+ else
+ {
+ health = "Critical";
+ }
+ nlohmann::json::array_t redfishCollection;
+ const auto& fanRedfish =
+ sensorsAsyncResp->asyncResp->res
+ .jsonValue["Fans"];
+ for (const std::string& item : *collection)
+ {
+ sdbusplus::message::object_path itemPath(
+ item);
+ std::string itemName = itemPath.filename();
+ if (itemName.empty())
+ {
+ continue;
+ }
+ /*
+ todo(ed): merge patch that fixes the names
+ std::replace(itemName.begin(),
+ itemName.end(), '_', ' ');*/
+ auto schemaItem = std::ranges::find_if(
+ fanRedfish,
+ [itemName](const nlohmann::json& fan) {
+ return fan["Name"] == itemName;
+ });
+ if (schemaItem != fanRedfish.end())
+ {
+ nlohmann::json::object_t collectionId;
+ collectionId["@odata.id"] =
+ (*schemaItem)["@odata.id"];
+ redfishCollection.emplace_back(
+ std::move(collectionId));
+ }
+ else
+ {
+ BMCWEB_LOG_ERROR(
+ "failed to find fan in schema");
+ messages::internalError(
+ sensorsAsyncResp->asyncResp->res);
+ return;
+ }
+ }
+
+ size_t minNumNeeded =
+ collection->empty()
+ ? 0
+ : collection->size() - *allowedFailures;
+ nlohmann::json& jResp =
+ sensorsAsyncResp->asyncResp->res
+ .jsonValue["Redundancy"];
+
+ nlohmann::json::object_t redundancy;
+ boost::urls::url url = boost::urls::format(
+ "/redfish/v1/Chassis/{}/{}",
+ sensorsAsyncResp->chassisId,
+ sensorsAsyncResp->chassisSubNode);
+ url.set_fragment(
+ ("/Redundancy"_json_pointer / jResp.size())
+ .to_string());
+ redundancy["@odata.id"] = std::move(url);
+ redundancy["@odata.type"] =
+ "#Redundancy.v1_3_2.Redundancy";
+ redundancy["MinNumNeeded"] = minNumNeeded;
+ redundancy["Mode"] =
+ redundancy::RedundancyType::NPlusM;
+ redundancy["Name"] = name;
+ redundancy["RedundancySet"] = redfishCollection;
+ redundancy["Status"]["Health"] = health;
+ redundancy["Status"]["State"] =
+ resource::State::Enabled;
+
+ jResp.emplace_back(std::move(redundancy));
+ });
+ });
+ }
+ });
}
inline void
@@ -1205,8 +1225,8 @@
{
std::sort(entry->begin(), entry->end(),
[](const nlohmann::json& c1, const nlohmann::json& c2) {
- return c1["Name"] < c2["Name"];
- });
+ return c1["Name"] < c2["Name"];
+ });
// add the index counts to the end of each entry
size_t count = 0;
@@ -1276,9 +1296,8 @@
* @param ledObjPath D-Bus object path of led.
* @return Inventory item within vector, or nullptr if no match found.
*/
-inline InventoryItem*
- findInventoryItemForLed(std::vector<InventoryItem>& inventoryItems,
- const std::string& ledObjPath)
+inline InventoryItem* findInventoryItemForLed(
+ std::vector<InventoryItem>& inventoryItems, const std::string& ledObjPath)
{
for (InventoryItem& inventoryItem : inventoryItems)
{
@@ -1309,8 +1328,8 @@
const std::string& invItemObjPath, const std::string& sensorObjPath)
{
// Look for inventory item in vector
- InventoryItem* inventoryItem = findInventoryItem(inventoryItems,
- invItemObjPath);
+ InventoryItem* inventoryItem =
+ findInventoryItem(inventoryItems, invItemObjPath);
// If inventory item doesn't exist in vector, add it
if (inventoryItem == nullptr)
@@ -1489,38 +1508,40 @@
callback = std::forward<Callback>(callback), invConnectionsIndex](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) {
- BMCWEB_LOG_DEBUG("getInventoryItemsData respHandler enter");
- if (ec)
- {
- BMCWEB_LOG_ERROR(
- "getInventoryItemsData respHandler DBus error {}", ec);
- messages::internalError(sensorsAsyncResp->asyncResp->res);
- return;
- }
-
- // Loop through returned object paths
- for (const auto& objDictEntry : resp)
- {
- const std::string& objPath =
- static_cast<const std::string&>(objDictEntry.first);
-
- // If this object path is one of the specified inventory items
- InventoryItem* inventoryItem = findInventoryItem(inventoryItems,
- objPath);
- if (inventoryItem != nullptr)
+ BMCWEB_LOG_DEBUG("getInventoryItemsData respHandler enter");
+ if (ec)
{
- // Store inventory data in InventoryItem
- storeInventoryItemData(*inventoryItem, objDictEntry.second);
+ BMCWEB_LOG_ERROR(
+ "getInventoryItemsData respHandler DBus error {}", ec);
+ messages::internalError(sensorsAsyncResp->asyncResp->res);
+ return;
}
- }
- // Recurse to get inventory item data from next connection
- getInventoryItemsData(sensorsAsyncResp, inventoryItems,
- invConnections, std::move(callback),
- invConnectionsIndex + 1);
+ // Loop through returned object paths
+ for (const auto& objDictEntry : resp)
+ {
+ const std::string& objPath =
+ static_cast<const std::string&>(objDictEntry.first);
- BMCWEB_LOG_DEBUG("getInventoryItemsData respHandler exit");
- });
+ // If this object path is one of the specified inventory
+ // items
+ InventoryItem* inventoryItem =
+ findInventoryItem(inventoryItems, objPath);
+ if (inventoryItem != nullptr)
+ {
+ // Store inventory data in InventoryItem
+ storeInventoryItemData(*inventoryItem,
+ objDictEntry.second);
+ }
+ }
+
+ // Recurse to get inventory item data from next connection
+ getInventoryItemsData(sensorsAsyncResp, inventoryItems,
+ invConnections, std::move(callback),
+ invConnectionsIndex + 1);
+
+ BMCWEB_LOG_DEBUG("getInventoryItemsData respHandler exit");
+ });
}
BMCWEB_LOG_DEBUG("getInventoryItemsData exit");
@@ -1566,43 +1587,44 @@
inventoryItems](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- // Response handler for parsing output from GetSubTree
- BMCWEB_LOG_DEBUG("getInventoryItemsConnections respHandler enter");
- if (ec)
- {
- messages::internalError(sensorsAsyncResp->asyncResp->res);
- BMCWEB_LOG_ERROR(
- "getInventoryItemsConnections respHandler DBus error {}", ec);
- return;
- }
-
- // Make unique list of connections for desired inventory items
- std::shared_ptr<std::set<std::string>> invConnections =
- std::make_shared<std::set<std::string>>();
-
- // Loop through objects from GetSubTree
- for (const std::pair<
- std::string,
- std::vector<std::pair<std::string, std::vector<std::string>>>>&
- object : subtree)
- {
- // Check if object path is one of the specified inventory items
- const std::string& objPath = object.first;
- if (findInventoryItem(inventoryItems, objPath) != nullptr)
+ // Response handler for parsing output from GetSubTree
+ BMCWEB_LOG_DEBUG("getInventoryItemsConnections respHandler enter");
+ if (ec)
{
- // Store all connections to inventory item
- for (const std::pair<std::string, std::vector<std::string>>&
- objData : object.second)
+ messages::internalError(sensorsAsyncResp->asyncResp->res);
+ BMCWEB_LOG_ERROR(
+ "getInventoryItemsConnections respHandler DBus error {}",
+ ec);
+ return;
+ }
+
+ // Make unique list of connections for desired inventory items
+ std::shared_ptr<std::set<std::string>> invConnections =
+ std::make_shared<std::set<std::string>>();
+
+ // Loop through objects from GetSubTree
+ for (const std::pair<std::string,
+ std::vector<std::pair<
+ std::string, std::vector<std::string>>>>&
+ object : subtree)
+ {
+ // Check if object path is one of the specified inventory items
+ const std::string& objPath = object.first;
+ if (findInventoryItem(inventoryItems, objPath) != nullptr)
{
- const std::string& invConnection = objData.first;
- invConnections->insert(invConnection);
+ // Store all connections to inventory item
+ for (const std::pair<std::string, std::vector<std::string>>&
+ objData : object.second)
+ {
+ const std::string& invConnection = objData.first;
+ invConnections->insert(invConnection);
+ }
}
}
- }
- callback(invConnections);
- BMCWEB_LOG_DEBUG("getInventoryItemsConnections respHandler exit");
- });
+ callback(invConnections);
+ BMCWEB_LOG_DEBUG("getInventoryItemsConnections respHandler exit");
+ });
BMCWEB_LOG_DEBUG("getInventoryItemsConnections exit");
}
@@ -1641,112 +1663,119 @@
[callback = std::forward<Callback>(callback), sensorsAsyncResp,
sensorNames](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) {
- BMCWEB_LOG_DEBUG("getInventoryItemAssociations respHandler enter");
- if (ec)
- {
- BMCWEB_LOG_ERROR(
- "getInventoryItemAssociations respHandler DBus error {}", ec);
- messages::internalError(sensorsAsyncResp->asyncResp->res);
- return;
- }
-
- // Create vector to hold list of inventory items
- std::shared_ptr<std::vector<InventoryItem>> inventoryItems =
- std::make_shared<std::vector<InventoryItem>>();
-
- // Loop through returned object paths
- std::string sensorAssocPath;
- sensorAssocPath.reserve(128); // avoid memory allocations
- for (const auto& objDictEntry : resp)
- {
- const std::string& objPath =
- static_cast<const std::string&>(objDictEntry.first);
-
- // If path is inventory association for one of the specified sensors
- for (const std::string& sensorName : *sensorNames)
+ BMCWEB_LOG_DEBUG("getInventoryItemAssociations respHandler enter");
+ if (ec)
{
- sensorAssocPath = sensorName;
- sensorAssocPath += "/inventory";
- if (objPath == sensorAssocPath)
+ BMCWEB_LOG_ERROR(
+ "getInventoryItemAssociations respHandler DBus error {}",
+ ec);
+ messages::internalError(sensorsAsyncResp->asyncResp->res);
+ return;
+ }
+
+ // Create vector to hold list of inventory items
+ std::shared_ptr<std::vector<InventoryItem>> inventoryItems =
+ std::make_shared<std::vector<InventoryItem>>();
+
+ // Loop through returned object paths
+ std::string sensorAssocPath;
+ sensorAssocPath.reserve(128); // avoid memory allocations
+ for (const auto& objDictEntry : resp)
+ {
+ const std::string& objPath =
+ static_cast<const std::string&>(objDictEntry.first);
+
+ // If path is inventory association for one of the specified
+ // sensors
+ for (const std::string& sensorName : *sensorNames)
{
- // Get Association interface for object path
- for (const auto& [interface, values] : objDictEntry.second)
+ sensorAssocPath = sensorName;
+ sensorAssocPath += "/inventory";
+ if (objPath == sensorAssocPath)
{
- if (interface == "xyz.openbmc_project.Association")
+ // Get Association interface for object path
+ for (const auto& [interface, values] :
+ objDictEntry.second)
{
- for (const auto& [valueName, value] : values)
+ if (interface == "xyz.openbmc_project.Association")
{
- if (valueName == "endpoints")
+ for (const auto& [valueName, value] : values)
{
- const std::vector<std::string>* endpoints =
- std::get_if<std::vector<std::string>>(
- &value);
- if ((endpoints != nullptr) &&
- !endpoints->empty())
+ if (valueName == "endpoints")
{
- // Add inventory item to vector
- const std::string& invItemPath =
- endpoints->front();
- addInventoryItem(inventoryItems,
- invItemPath,
- sensorName);
+ const std::vector<std::string>*
+ endpoints = std::get_if<
+ std::vector<std::string>>(
+ &value);
+ if ((endpoints != nullptr) &&
+ !endpoints->empty())
+ {
+ // Add inventory item to vector
+ const std::string& invItemPath =
+ endpoints->front();
+ addInventoryItem(inventoryItems,
+ invItemPath,
+ sensorName);
+ }
}
}
}
}
+ break;
}
- break;
}
}
- }
- // Now loop through the returned object paths again, this time to
- // find the leds associated with the inventory items we just found
- std::string inventoryAssocPath;
- inventoryAssocPath.reserve(128); // avoid memory allocations
- for (const auto& objDictEntry : resp)
- {
- const std::string& objPath =
- static_cast<const std::string&>(objDictEntry.first);
-
- for (InventoryItem& inventoryItem : *inventoryItems)
+ // Now loop through the returned object paths again, this time to
+ // find the leds associated with the inventory items we just found
+ std::string inventoryAssocPath;
+ inventoryAssocPath.reserve(128); // avoid memory allocations
+ for (const auto& objDictEntry : resp)
{
- inventoryAssocPath = inventoryItem.objectPath;
- inventoryAssocPath += "/leds";
- if (objPath == inventoryAssocPath)
+ const std::string& objPath =
+ static_cast<const std::string&>(objDictEntry.first);
+
+ for (InventoryItem& inventoryItem : *inventoryItems)
{
- for (const auto& [interface, values] : objDictEntry.second)
+ inventoryAssocPath = inventoryItem.objectPath;
+ inventoryAssocPath += "/leds";
+ if (objPath == inventoryAssocPath)
{
- if (interface == "xyz.openbmc_project.Association")
+ for (const auto& [interface, values] :
+ objDictEntry.second)
{
- for (const auto& [valueName, value] : values)
+ if (interface == "xyz.openbmc_project.Association")
{
- if (valueName == "endpoints")
+ for (const auto& [valueName, value] : values)
{
- const std::vector<std::string>* endpoints =
- std::get_if<std::vector<std::string>>(
- &value);
- if ((endpoints != nullptr) &&
- !endpoints->empty())
+ if (valueName == "endpoints")
{
- // Add inventory item to vector
- // Store LED path in inventory item
- const std::string& ledPath =
- endpoints->front();
- inventoryItem.ledObjectPath = ledPath;
+ const std::vector<std::string>*
+ endpoints = std::get_if<
+ std::vector<std::string>>(
+ &value);
+ if ((endpoints != nullptr) &&
+ !endpoints->empty())
+ {
+ // Add inventory item to vector
+ // Store LED path in inventory item
+ const std::string& ledPath =
+ endpoints->front();
+ inventoryItem.ledObjectPath =
+ ledPath;
+ }
}
}
}
}
- }
- break;
+ break;
+ }
}
}
- }
- callback(inventoryItems);
- BMCWEB_LOG_DEBUG("getInventoryItemAssociations respHandler exit");
- });
+ callback(inventoryItems);
+ BMCWEB_LOG_DEBUG("getInventoryItemAssociations respHandler exit");
+ });
BMCWEB_LOG_DEBUG("getInventoryItemAssociations exit");
}
@@ -1809,47 +1838,47 @@
[sensorsAsyncResp, inventoryItems, ledConnections, ledPath,
callback = std::forward<Callback>(callback), ledConnectionsIndex](
const boost::system::error_code& ec, const std::string& state) {
- BMCWEB_LOG_DEBUG("getInventoryLedData respHandler enter");
- if (ec)
- {
- BMCWEB_LOG_ERROR(
- "getInventoryLedData respHandler DBus error {}", ec);
- messages::internalError(sensorsAsyncResp->asyncResp->res);
- return;
- }
+ BMCWEB_LOG_DEBUG("getInventoryLedData respHandler enter");
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR(
+ "getInventoryLedData respHandler DBus error {}", ec);
+ messages::internalError(sensorsAsyncResp->asyncResp->res);
+ return;
+ }
- BMCWEB_LOG_DEBUG("Led state: {}", state);
- // Find inventory item with this LED object path
- InventoryItem* inventoryItem =
- findInventoryItemForLed(*inventoryItems, ledPath);
- if (inventoryItem != nullptr)
- {
- // Store LED state in InventoryItem
- if (state.ends_with("On"))
+ BMCWEB_LOG_DEBUG("Led state: {}", state);
+ // Find inventory item with this LED object path
+ InventoryItem* inventoryItem =
+ findInventoryItemForLed(*inventoryItems, ledPath);
+ if (inventoryItem != nullptr)
{
- inventoryItem->ledState = LedState::ON;
+ // Store LED state in InventoryItem
+ if (state.ends_with("On"))
+ {
+ inventoryItem->ledState = LedState::ON;
+ }
+ else if (state.ends_with("Blink"))
+ {
+ inventoryItem->ledState = LedState::BLINK;
+ }
+ else if (state.ends_with("Off"))
+ {
+ inventoryItem->ledState = LedState::OFF;
+ }
+ else
+ {
+ inventoryItem->ledState = LedState::UNKNOWN;
+ }
}
- else if (state.ends_with("Blink"))
- {
- inventoryItem->ledState = LedState::BLINK;
- }
- else if (state.ends_with("Off"))
- {
- inventoryItem->ledState = LedState::OFF;
- }
- else
- {
- inventoryItem->ledState = LedState::UNKNOWN;
- }
- }
- // Recurse to get LED data from next connection
- getInventoryLedData(sensorsAsyncResp, inventoryItems,
- ledConnections, std::move(callback),
- ledConnectionsIndex + 1);
+ // Recurse to get LED data from next connection
+ getInventoryLedData(sensorsAsyncResp, inventoryItems,
+ ledConnections, std::move(callback),
+ ledConnectionsIndex + 1);
- BMCWEB_LOG_DEBUG("getInventoryLedData respHandler exit");
- };
+ BMCWEB_LOG_DEBUG("getInventoryLedData respHandler exit");
+ };
// Get the State property for the current LED
sdbusplus::asio::getProperty<std::string>(
@@ -1902,41 +1931,45 @@
inventoryItems](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- // Response handler for parsing output from GetSubTree
- BMCWEB_LOG_DEBUG("getInventoryLeds respHandler enter");
- if (ec)
- {
- messages::internalError(sensorsAsyncResp->asyncResp->res);
- BMCWEB_LOG_ERROR("getInventoryLeds respHandler DBus error {}", ec);
- return;
- }
-
- // Build map of LED object paths to connections
- std::shared_ptr<std::map<std::string, std::string>> ledConnections =
- std::make_shared<std::map<std::string, std::string>>();
-
- // Loop through objects from GetSubTree
- for (const std::pair<
- std::string,
- std::vector<std::pair<std::string, std::vector<std::string>>>>&
- object : subtree)
- {
- // Check if object path is LED for one of the specified inventory
- // items
- const std::string& ledPath = object.first;
- if (findInventoryItemForLed(*inventoryItems, ledPath) != nullptr)
+ // Response handler for parsing output from GetSubTree
+ BMCWEB_LOG_DEBUG("getInventoryLeds respHandler enter");
+ if (ec)
{
- // Add mapping from ledPath to connection
- const std::string& connection = object.second.begin()->first;
- (*ledConnections)[ledPath] = connection;
- BMCWEB_LOG_DEBUG("Added mapping {} -> {}", ledPath, connection);
+ messages::internalError(sensorsAsyncResp->asyncResp->res);
+ BMCWEB_LOG_ERROR("getInventoryLeds respHandler DBus error {}",
+ ec);
+ return;
}
- }
- getInventoryLedData(sensorsAsyncResp, inventoryItems, ledConnections,
- std::move(callback));
- BMCWEB_LOG_DEBUG("getInventoryLeds respHandler exit");
- });
+ // Build map of LED object paths to connections
+ std::shared_ptr<std::map<std::string, std::string>> ledConnections =
+ std::make_shared<std::map<std::string, std::string>>();
+
+ // Loop through objects from GetSubTree
+ for (const std::pair<std::string,
+ std::vector<std::pair<
+ std::string, std::vector<std::string>>>>&
+ object : subtree)
+ {
+ // Check if object path is LED for one of the specified
+ // inventory items
+ const std::string& ledPath = object.first;
+ if (findInventoryItemForLed(*inventoryItems, ledPath) !=
+ nullptr)
+ {
+ // Add mapping from ledPath to connection
+ const std::string& connection =
+ object.second.begin()->first;
+ (*ledConnections)[ledPath] = connection;
+ BMCWEB_LOG_DEBUG("Added mapping {} -> {}", ledPath,
+ connection);
+ }
+ }
+
+ getInventoryLedData(sensorsAsyncResp, inventoryItems,
+ ledConnections, std::move(callback));
+ BMCWEB_LOG_DEBUG("getInventoryLeds respHandler exit");
+ });
BMCWEB_LOG_DEBUG("getInventoryLeds exit");
}
@@ -2074,53 +2107,53 @@
inventoryItems](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- // Response handler for parsing output from GetSubTree
- BMCWEB_LOG_DEBUG("getPowerSupplyAttributes respHandler enter");
- if (ec)
- {
- messages::internalError(sensorsAsyncResp->asyncResp->res);
- BMCWEB_LOG_ERROR(
- "getPowerSupplyAttributes respHandler DBus error {}", ec);
- return;
- }
- if (subtree.empty())
- {
- BMCWEB_LOG_DEBUG("Can't find Power Supply Attributes!");
- callback(inventoryItems);
- return;
- }
+ // Response handler for parsing output from GetSubTree
+ BMCWEB_LOG_DEBUG("getPowerSupplyAttributes respHandler enter");
+ if (ec)
+ {
+ messages::internalError(sensorsAsyncResp->asyncResp->res);
+ BMCWEB_LOG_ERROR(
+ "getPowerSupplyAttributes respHandler DBus error {}", ec);
+ return;
+ }
+ if (subtree.empty())
+ {
+ BMCWEB_LOG_DEBUG("Can't find Power Supply Attributes!");
+ callback(inventoryItems);
+ return;
+ }
- // Currently we only support 1 power supply attribute, use this for
- // all the power supplies. Build map of object path to connection.
- // Assume just 1 connection and 1 path for now.
- std::map<std::string, std::string> psAttributesConnections;
+ // Currently we only support 1 power supply attribute, use this for
+ // all the power supplies. Build map of object path to connection.
+ // Assume just 1 connection and 1 path for now.
+ std::map<std::string, std::string> psAttributesConnections;
- if (subtree[0].first.empty() || subtree[0].second.empty())
- {
- BMCWEB_LOG_DEBUG("Power Supply Attributes mapper error!");
- callback(inventoryItems);
- return;
- }
+ if (subtree[0].first.empty() || subtree[0].second.empty())
+ {
+ BMCWEB_LOG_DEBUG("Power Supply Attributes mapper error!");
+ callback(inventoryItems);
+ return;
+ }
- const std::string& psAttributesPath = subtree[0].first;
- const std::string& connection = subtree[0].second.begin()->first;
+ const std::string& psAttributesPath = subtree[0].first;
+ const std::string& connection = subtree[0].second.begin()->first;
- if (connection.empty())
- {
- BMCWEB_LOG_DEBUG("Power Supply Attributes mapper error!");
- callback(inventoryItems);
- return;
- }
+ if (connection.empty())
+ {
+ BMCWEB_LOG_DEBUG("Power Supply Attributes mapper error!");
+ callback(inventoryItems);
+ return;
+ }
- psAttributesConnections[psAttributesPath] = connection;
- BMCWEB_LOG_DEBUG("Added mapping {} -> {}", psAttributesPath,
- connection);
+ psAttributesConnections[psAttributesPath] = connection;
+ BMCWEB_LOG_DEBUG("Added mapping {} -> {}", psAttributesPath,
+ connection);
- getPowerSupplyAttributesData(sensorsAsyncResp, inventoryItems,
- psAttributesConnections,
- std::move(callback));
- BMCWEB_LOG_DEBUG("getPowerSupplyAttributes respHandler exit");
- });
+ getPowerSupplyAttributesData(sensorsAsyncResp, inventoryItems,
+ psAttributesConnections,
+ std::move(callback));
+ BMCWEB_LOG_DEBUG("getPowerSupplyAttributes respHandler exit");
+ });
BMCWEB_LOG_DEBUG("getPowerSupplyAttributes exit");
}
@@ -2156,44 +2189,50 @@
auto getInventoryItemAssociationsCb =
[sensorsAsyncResp, callback = std::forward<Callback>(callback)](
std::shared_ptr<std::vector<InventoryItem>> inventoryItems) {
- BMCWEB_LOG_DEBUG("getInventoryItemAssociationsCb enter");
- auto getInventoryItemsConnectionsCb =
- [sensorsAsyncResp, inventoryItems,
- callback = std::forward<const Callback>(callback)](
- std::shared_ptr<std::set<std::string>> invConnections) {
- BMCWEB_LOG_DEBUG("getInventoryItemsConnectionsCb enter");
- auto getInventoryItemsDataCb = [sensorsAsyncResp, inventoryItems,
- callback{std::move(callback)}]() {
- BMCWEB_LOG_DEBUG("getInventoryItemsDataCb enter");
+ BMCWEB_LOG_DEBUG("getInventoryItemAssociationsCb enter");
+ auto getInventoryItemsConnectionsCb =
+ [sensorsAsyncResp, inventoryItems,
+ callback = std::forward<const Callback>(callback)](
+ std::shared_ptr<std::set<std::string>> invConnections) {
+ BMCWEB_LOG_DEBUG("getInventoryItemsConnectionsCb enter");
+ auto getInventoryItemsDataCb =
+ [sensorsAsyncResp, inventoryItems,
+ callback{std::move(callback)}]() {
+ BMCWEB_LOG_DEBUG("getInventoryItemsDataCb enter");
- auto getInventoryLedsCb = [sensorsAsyncResp, inventoryItems,
- callback{std::move(callback)}]() {
- BMCWEB_LOG_DEBUG("getInventoryLedsCb enter");
- // Find Power Supply Attributes and get the data
- getPowerSupplyAttributes(sensorsAsyncResp, inventoryItems,
- std::move(callback));
- BMCWEB_LOG_DEBUG("getInventoryLedsCb exit");
+ auto getInventoryLedsCb =
+ [sensorsAsyncResp, inventoryItems,
+ callback{std::move(callback)}]() {
+ BMCWEB_LOG_DEBUG(
+ "getInventoryLedsCb enter");
+ // Find Power Supply Attributes and get the
+ // data
+ getPowerSupplyAttributes(
+ sensorsAsyncResp, inventoryItems,
+ std::move(callback));
+ BMCWEB_LOG_DEBUG("getInventoryLedsCb exit");
+ };
+
+ // Find led connections and get the data
+ getInventoryLeds(sensorsAsyncResp, inventoryItems,
+ std::move(getInventoryLedsCb));
+ BMCWEB_LOG_DEBUG("getInventoryItemsDataCb exit");
+ };
+
+ // Get inventory item data from connections
+ getInventoryItemsData(sensorsAsyncResp, inventoryItems,
+ invConnections,
+ std::move(getInventoryItemsDataCb));
+ BMCWEB_LOG_DEBUG("getInventoryItemsConnectionsCb exit");
};
- // Find led connections and get the data
- getInventoryLeds(sensorsAsyncResp, inventoryItems,
- std::move(getInventoryLedsCb));
- BMCWEB_LOG_DEBUG("getInventoryItemsDataCb exit");
- };
-
- // Get inventory item data from connections
- getInventoryItemsData(sensorsAsyncResp, inventoryItems,
- invConnections,
- std::move(getInventoryItemsDataCb));
- BMCWEB_LOG_DEBUG("getInventoryItemsConnectionsCb exit");
+ // Get connections that provide inventory item data
+ getInventoryItemsConnections(
+ sensorsAsyncResp, inventoryItems,
+ std::move(getInventoryItemsConnectionsCb));
+ BMCWEB_LOG_DEBUG("getInventoryItemAssociationsCb exit");
};
- // Get connections that provide inventory item data
- getInventoryItemsConnections(sensorsAsyncResp, inventoryItems,
- std::move(getInventoryItemsConnectionsCb));
- BMCWEB_LOG_DEBUG("getInventoryItemAssociationsCb exit");
- };
-
// Get associations from sensors to inventory items
getInventoryItemAssociations(sensorsAsyncResp, sensorNames,
std::move(getInventoryItemAssociationsCb));
@@ -2245,8 +2284,8 @@
// Add new PowerSupply object to JSON array
powerSupplyArray.push_back({});
nlohmann::json& powerSupply = powerSupplyArray.back();
- boost::urls::url url = boost::urls::format("/redfish/v1/Chassis/{}/Power",
- chassisId);
+ boost::urls::url url =
+ boost::urls::format("/redfish/v1/Chassis/{}/Power", chassisId);
url.set_fragment(("/PowerSupplies"_json_pointer).to_string());
powerSupply["@odata.id"] = std::move(url);
std::string escaped;
@@ -2314,215 +2353,222 @@
[sensorsAsyncResp, sensorNames,
inventoryItems](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) {
- BMCWEB_LOG_DEBUG("getManagedObjectsCb enter");
- if (ec)
- {
- BMCWEB_LOG_ERROR("getManagedObjectsCb DBUS error: {}", ec);
- messages::internalError(sensorsAsyncResp->asyncResp->res);
- return;
- }
- // Go through all objects and update response with sensor data
- for (const auto& objDictEntry : resp)
- {
- const std::string& objPath =
- static_cast<const std::string&>(objDictEntry.first);
- BMCWEB_LOG_DEBUG("getManagedObjectsCb parsing object {}",
- objPath);
-
- std::vector<std::string> split;
- // Reserve space for
- // /xyz/openbmc_project/sensors/<name>/<subname>
- split.reserve(6);
- // NOLINTNEXTLINE
- bmcweb::split(split, objPath, '/');
- if (split.size() < 6)
+ BMCWEB_LOG_DEBUG("getManagedObjectsCb enter");
+ if (ec)
{
- BMCWEB_LOG_ERROR("Got path that isn't long enough {}",
+ BMCWEB_LOG_ERROR("getManagedObjectsCb DBUS error: {}", ec);
+ messages::internalError(sensorsAsyncResp->asyncResp->res);
+ return;
+ }
+ // Go through all objects and update response with sensor data
+ for (const auto& objDictEntry : resp)
+ {
+ const std::string& objPath =
+ static_cast<const std::string&>(objDictEntry.first);
+ BMCWEB_LOG_DEBUG("getManagedObjectsCb parsing object {}",
objPath);
- continue;
- }
- // These indexes aren't intuitive, as split puts an empty
- // string at the beginning
- const std::string& sensorType = split[4];
- const std::string& sensorName = split[5];
- BMCWEB_LOG_DEBUG("sensorName {} sensorType {}", sensorName,
- sensorType);
- if (sensorNames->find(objPath) == sensorNames->end())
- {
- BMCWEB_LOG_DEBUG("{} not in sensor list ", sensorName);
- continue;
- }
- // Find inventory item (if any) associated with sensor
- InventoryItem* inventoryItem =
- findInventoryItemForSensor(inventoryItems, objPath);
-
- const std::string& sensorSchema =
- sensorsAsyncResp->chassisSubNode;
-
- nlohmann::json* sensorJson = nullptr;
-
- if (sensorSchema == sensors::node::sensors &&
- !sensorsAsyncResp->efficientExpand)
- {
- std::string sensorTypeEscaped(sensorType);
- auto remove = std::ranges::remove(sensorTypeEscaped, '_');
-
- sensorTypeEscaped.erase(std::ranges::begin(remove),
- sensorTypeEscaped.end());
- std::string sensorId(sensorTypeEscaped);
- sensorId += "_";
- sensorId += sensorName;
-
- sensorsAsyncResp->asyncResp->res.jsonValue["@odata.id"] =
- boost::urls::format("/redfish/v1/Chassis/{}/{}/{}",
- sensorsAsyncResp->chassisId,
- sensorsAsyncResp->chassisSubNode,
- sensorId);
- sensorJson = &(sensorsAsyncResp->asyncResp->res.jsonValue);
- }
- else
- {
- std::string fieldName;
- if (sensorsAsyncResp->efficientExpand)
+ std::vector<std::string> split;
+ // Reserve space for
+ // /xyz/openbmc_project/sensors/<name>/<subname>
+ split.reserve(6);
+ // NOLINTNEXTLINE
+ bmcweb::split(split, objPath, '/');
+ if (split.size() < 6)
{
- fieldName = "Members";
+ BMCWEB_LOG_ERROR("Got path that isn't long enough {}",
+ objPath);
+ continue;
}
- else if (sensorType == "temperature")
+ // These indexes aren't intuitive, as split puts an empty
+ // string at the beginning
+ const std::string& sensorType = split[4];
+ const std::string& sensorName = split[5];
+ BMCWEB_LOG_DEBUG("sensorName {} sensorType {}", sensorName,
+ sensorType);
+ if (sensorNames->find(objPath) == sensorNames->end())
{
- fieldName = "Temperatures";
- }
- else if (sensorType == "fan" || sensorType == "fan_tach" ||
- sensorType == "fan_pwm")
- {
- fieldName = "Fans";
- }
- else if (sensorType == "voltage")
- {
- fieldName = "Voltages";
- }
- else if (sensorType == "power")
- {
- if (sensorName == "total_power")
- {
- fieldName = "PowerControl";
- }
- else if ((inventoryItem != nullptr) &&
- (inventoryItem->isPowerSupply))
- {
- fieldName = "PowerSupplies";
- }
- else
- {
- // Other power sensors are in SensorCollection
- continue;
- }
- }
- else
- {
- BMCWEB_LOG_ERROR("Unsure how to handle sensorType {}",
- sensorType);
+ BMCWEB_LOG_DEBUG("{} not in sensor list ", sensorName);
continue;
}
- nlohmann::json& tempArray =
- sensorsAsyncResp->asyncResp->res.jsonValue[fieldName];
- if (fieldName == "PowerControl")
- {
- if (tempArray.empty())
- {
- // Put multiple "sensors" into a single
- // PowerControl. Follows MemberId naming and
- // naming in power.hpp.
- nlohmann::json::object_t power;
- boost::urls::url url = boost::urls::format(
- "/redfish/v1/Chassis/{}/{}",
- sensorsAsyncResp->chassisId,
- sensorsAsyncResp->chassisSubNode);
- url.set_fragment((""_json_pointer / fieldName / "0")
- .to_string());
- power["@odata.id"] = std::move(url);
- tempArray.emplace_back(std::move(power));
- }
- sensorJson = &(tempArray.back());
- }
- else if (fieldName == "PowerSupplies")
- {
- if (inventoryItem != nullptr)
- {
- sensorJson =
- &(getPowerSupply(tempArray, *inventoryItem,
- sensorsAsyncResp->chassisId));
- }
- }
- else if (fieldName == "Members")
+ // Find inventory item (if any) associated with sensor
+ InventoryItem* inventoryItem =
+ findInventoryItemForSensor(inventoryItems, objPath);
+
+ const std::string& sensorSchema =
+ sensorsAsyncResp->chassisSubNode;
+
+ nlohmann::json* sensorJson = nullptr;
+
+ if (sensorSchema == sensors::node::sensors &&
+ !sensorsAsyncResp->efficientExpand)
{
std::string sensorTypeEscaped(sensorType);
- auto remove = std::ranges::remove(sensorTypeEscaped,
- '_');
+ auto remove =
+ std::ranges::remove(sensorTypeEscaped, '_');
+
sensorTypeEscaped.erase(std::ranges::begin(remove),
sensorTypeEscaped.end());
std::string sensorId(sensorTypeEscaped);
sensorId += "_";
sensorId += sensorName;
- nlohmann::json::object_t member;
- member["@odata.id"] = boost::urls::format(
+ sensorsAsyncResp->asyncResp->res
+ .jsonValue["@odata.id"] = boost::urls::format(
"/redfish/v1/Chassis/{}/{}/{}",
sensorsAsyncResp->chassisId,
sensorsAsyncResp->chassisSubNode, sensorId);
- tempArray.emplace_back(std::move(member));
- sensorJson = &(tempArray.back());
+ sensorJson =
+ &(sensorsAsyncResp->asyncResp->res.jsonValue);
}
else
{
- nlohmann::json::object_t member;
- boost::urls::url url = boost::urls::format(
- "/redfish/v1/Chassis/{}/{}",
- sensorsAsyncResp->chassisId,
- sensorsAsyncResp->chassisSubNode);
- url.set_fragment(
- (""_json_pointer / fieldName).to_string());
- member["@odata.id"] = std::move(url);
- tempArray.emplace_back(std::move(member));
- sensorJson = &(tempArray.back());
+ std::string fieldName;
+ if (sensorsAsyncResp->efficientExpand)
+ {
+ fieldName = "Members";
+ }
+ else if (sensorType == "temperature")
+ {
+ fieldName = "Temperatures";
+ }
+ else if (sensorType == "fan" ||
+ sensorType == "fan_tach" ||
+ sensorType == "fan_pwm")
+ {
+ fieldName = "Fans";
+ }
+ else if (sensorType == "voltage")
+ {
+ fieldName = "Voltages";
+ }
+ else if (sensorType == "power")
+ {
+ if (sensorName == "total_power")
+ {
+ fieldName = "PowerControl";
+ }
+ else if ((inventoryItem != nullptr) &&
+ (inventoryItem->isPowerSupply))
+ {
+ fieldName = "PowerSupplies";
+ }
+ else
+ {
+ // Other power sensors are in SensorCollection
+ continue;
+ }
+ }
+ else
+ {
+ BMCWEB_LOG_ERROR(
+ "Unsure how to handle sensorType {}",
+ sensorType);
+ continue;
+ }
+
+ nlohmann::json& tempArray =
+ sensorsAsyncResp->asyncResp->res
+ .jsonValue[fieldName];
+ if (fieldName == "PowerControl")
+ {
+ if (tempArray.empty())
+ {
+ // Put multiple "sensors" into a single
+ // PowerControl. Follows MemberId naming and
+ // naming in power.hpp.
+ nlohmann::json::object_t power;
+ boost::urls::url url = boost::urls::format(
+ "/redfish/v1/Chassis/{}/{}",
+ sensorsAsyncResp->chassisId,
+ sensorsAsyncResp->chassisSubNode);
+ url.set_fragment(
+ (""_json_pointer / fieldName / "0")
+ .to_string());
+ power["@odata.id"] = std::move(url);
+ tempArray.emplace_back(std::move(power));
+ }
+ sensorJson = &(tempArray.back());
+ }
+ else if (fieldName == "PowerSupplies")
+ {
+ if (inventoryItem != nullptr)
+ {
+ sensorJson = &(getPowerSupply(
+ tempArray, *inventoryItem,
+ sensorsAsyncResp->chassisId));
+ }
+ }
+ else if (fieldName == "Members")
+ {
+ std::string sensorTypeEscaped(sensorType);
+ auto remove =
+ std::ranges::remove(sensorTypeEscaped, '_');
+ sensorTypeEscaped.erase(std::ranges::begin(remove),
+ sensorTypeEscaped.end());
+ std::string sensorId(sensorTypeEscaped);
+ sensorId += "_";
+ sensorId += sensorName;
+
+ nlohmann::json::object_t member;
+ member["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Chassis/{}/{}/{}",
+ sensorsAsyncResp->chassisId,
+ sensorsAsyncResp->chassisSubNode, sensorId);
+ tempArray.emplace_back(std::move(member));
+ sensorJson = &(tempArray.back());
+ }
+ else
+ {
+ nlohmann::json::object_t member;
+ boost::urls::url url = boost::urls::format(
+ "/redfish/v1/Chassis/{}/{}",
+ sensorsAsyncResp->chassisId,
+ sensorsAsyncResp->chassisSubNode);
+ url.set_fragment(
+ (""_json_pointer / fieldName).to_string());
+ member["@odata.id"] = std::move(url);
+ tempArray.emplace_back(std::move(member));
+ sensorJson = &(tempArray.back());
+ }
+ }
+
+ if (sensorJson != nullptr)
+ {
+ objectInterfacesToJson(sensorName, sensorType,
+ sensorsAsyncResp->chassisSubNode,
+ objDictEntry.second, *sensorJson,
+ inventoryItem);
+
+ std::string path = "/xyz/openbmc_project/sensors/";
+ path += sensorType;
+ path += "/";
+ path += sensorName;
+ sensorsAsyncResp->addMetadata(*sensorJson, path);
}
}
-
- if (sensorJson != nullptr)
+ if (sensorsAsyncResp.use_count() == 1)
{
- objectInterfacesToJson(sensorName, sensorType,
- sensorsAsyncResp->chassisSubNode,
- objDictEntry.second, *sensorJson,
- inventoryItem);
-
- std::string path = "/xyz/openbmc_project/sensors/";
- path += sensorType;
- path += "/";
- path += sensorName;
- sensorsAsyncResp->addMetadata(*sensorJson, path);
+ sortJSONResponse(sensorsAsyncResp);
+ if (sensorsAsyncResp->chassisSubNode ==
+ sensors::node::sensors &&
+ sensorsAsyncResp->efficientExpand)
+ {
+ sensorsAsyncResp->asyncResp->res
+ .jsonValue["Members@odata.count"] =
+ sensorsAsyncResp->asyncResp->res
+ .jsonValue["Members"]
+ .size();
+ }
+ else if (sensorsAsyncResp->chassisSubNode ==
+ sensors::node::thermal)
+ {
+ populateFanRedundancy(sensorsAsyncResp);
+ }
}
- }
- if (sensorsAsyncResp.use_count() == 1)
- {
- sortJSONResponse(sensorsAsyncResp);
- if (sensorsAsyncResp->chassisSubNode ==
- sensors::node::sensors &&
- sensorsAsyncResp->efficientExpand)
- {
- sensorsAsyncResp->asyncResp->res
- .jsonValue["Members@odata.count"] =
- sensorsAsyncResp->asyncResp->res.jsonValue["Members"]
- .size();
- }
- else if (sensorsAsyncResp->chassisSubNode ==
- sensors::node::thermal)
- {
- populateFanRedundancy(sensorsAsyncResp);
- }
- }
- BMCWEB_LOG_DEBUG("getManagedObjectsCb exit");
- });
+ BMCWEB_LOG_DEBUG("getManagedObjectsCb exit");
+ });
}
BMCWEB_LOG_DEBUG("getSensorData exit");
}
@@ -2535,15 +2581,15 @@
const std::set<std::string>& connections) {
BMCWEB_LOG_DEBUG("getConnectionCb enter");
auto getInventoryItemsCb =
- [sensorsAsyncResp, sensorNames,
- connections](const std::shared_ptr<std::vector<InventoryItem>>&
- inventoryItems) {
- BMCWEB_LOG_DEBUG("getInventoryItemsCb enter");
- // Get sensor data and store results in JSON
- getSensorData(sensorsAsyncResp, sensorNames, connections,
- inventoryItems);
- BMCWEB_LOG_DEBUG("getInventoryItemsCb exit");
- };
+ [sensorsAsyncResp, sensorNames, connections](
+ const std::shared_ptr<std::vector<InventoryItem>>&
+ inventoryItems) {
+ BMCWEB_LOG_DEBUG("getInventoryItemsCb enter");
+ // Get sensor data and store results in JSON
+ getSensorData(sensorsAsyncResp, sensorNames, connections,
+ inventoryItems);
+ BMCWEB_LOG_DEBUG("getInventoryItemsCb exit");
+ };
// Get inventory items associated with sensors
getInventoryItems(sensorsAsyncResp, sensorNames,
@@ -2568,10 +2614,10 @@
auto getChassisCb =
[sensorsAsyncResp](
const std::shared_ptr<std::set<std::string>>& sensorNames) {
- BMCWEB_LOG_DEBUG("getChassisCb enter");
- processSensorList(sensorsAsyncResp, sensorNames);
- BMCWEB_LOG_DEBUG("getChassisCb exit");
- };
+ BMCWEB_LOG_DEBUG("getChassisCb enter");
+ processSensorList(sensorsAsyncResp, sensorNames);
+ BMCWEB_LOG_DEBUG("getChassisCb exit");
+ };
// SensorCollection doesn't contain the Redundancy property
if (sensorsAsyncResp->chassisSubNode != sensors::node::sensors)
{
@@ -2594,10 +2640,9 @@
* @param sensorsModified The list of sensors that were found as a result of
* repeated calls to this function
*/
-inline bool
- findSensorNameUsingSensorPath(std::string_view sensorName,
- const std::set<std::string>& sensorsList,
- std::set<std::string>& sensorsModified)
+inline bool findSensorNameUsingSensorPath(
+ std::string_view sensorName, const std::set<std::string>& sensorsList,
+ std::set<std::string>& sensorsModified)
{
for (const auto& chassisSensor : sensorsList)
{
@@ -2680,10 +2725,11 @@
}
}
- auto getChassisSensorListCb =
- [sensorAsyncResp, overrideMap,
- propertyValueNameStr = std::string(propertyValueName)](
- const std::shared_ptr<std::set<std::string>>& sensorsList) {
+ auto getChassisSensorListCb = [sensorAsyncResp, overrideMap,
+ propertyValueNameStr =
+ std::string(propertyValueName)](
+ const std::shared_ptr<
+ std::set<std::string>>& sensorsList) {
// Match sensor names in the PATCH request to those managed by the
// chassis node
const std::shared_ptr<std::set<std::string>> sensorNames =
@@ -2703,22 +2749,24 @@
}
}
// Get the connection to which the memberId belongs
- auto getObjectsWithConnectionCb =
- [sensorAsyncResp, overrideMap, propertyValueNameStr](
- const std::set<std::string>& /*connections*/,
- const std::set<std::pair<std::string, std::string>>&
- objectsWithConnection) {
+ auto getObjectsWithConnectionCb = [sensorAsyncResp, overrideMap,
+ propertyValueNameStr](
+ const std::set<
+ std::string>& /*connections*/,
+ const std::set<std::pair<
+ std::string, std::string>>&
+ objectsWithConnection) {
if (objectsWithConnection.size() != overrideMap.size())
{
BMCWEB_LOG_INFO(
"Unable to find all objects with proper connection {} requested {}",
objectsWithConnection.size(), overrideMap.size());
- messages::resourceNotFound(sensorAsyncResp->asyncResp->res,
- sensorAsyncResp->chassisSubNode ==
- sensors::node::thermal
- ? "Temperatures"
- : "Voltages",
- "Count");
+ messages::resourceNotFound(
+ sensorAsyncResp->asyncResp->res,
+ sensorAsyncResp->chassisSubNode == sensors::node::thermal
+ ? "Temperatures"
+ : "Voltages",
+ "Count");
return;
}
for (const auto& item : objectsWithConnection)
@@ -2773,9 +2821,8 @@
* @param mapComplete Callback to be called with retrieval result
*/
template <typename Callback>
-inline void retrieveUriToDbusMap(const std::string& chassis,
- const std::string& node,
- Callback&& mapComplete)
+inline void retrieveUriToDbusMap(
+ const std::string& chassis, const std::string& node, Callback&& mapComplete)
{
decltype(sensors::paths)::const_iterator pathIt =
std::find_if(sensors::paths.cbegin(), sensors::paths.cend(),
@@ -2789,12 +2836,12 @@
}
auto asyncResp = std::make_shared<bmcweb::AsyncResp>();
- auto callback = [asyncResp,
- mapCompleteCb = std::forward<Callback>(mapComplete)](
- const boost::beast::http::status status,
- const std::map<std::string, std::string>& uriToDbus) {
- mapCompleteCb(status, uriToDbus);
- };
+ auto callback =
+ [asyncResp, mapCompleteCb = std::forward<Callback>(mapComplete)](
+ const boost::beast::http::status status,
+ const std::map<std::string, std::string>& uriToDbus) {
+ mapCompleteCb(status, uriToDbus);
+ };
auto resp = std::make_shared<SensorsAsyncResp>(
asyncResp, chassis, pathIt->second, node, std::move(callback));
@@ -2900,18 +2947,19 @@
[asyncResp,
sensorPath](const boost::system::error_code& ec,
const ::dbus::utility::DBusPropertiesMap& valuesDict) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- sdbusplus::message::object_path path(sensorPath);
- std::string name = path.filename();
- path = path.parent_path();
- std::string type = path.filename();
- objectPropertiesToJson(name, type, sensors::node::sensors, valuesDict,
- asyncResp->res.jsonValue, nullptr);
- });
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ sdbusplus::message::object_path path(sensorPath);
+ std::string name = path.filename();
+ path = path.parent_path();
+ std::string type = path.filename();
+ objectPropertiesToJson(name, type, sensors::node::sensors,
+ valuesDict, asyncResp->res.jsonValue,
+ nullptr);
+ });
}
inline void handleSensorGet(App& app, const crow::Request& req,
@@ -2947,23 +2995,23 @@
[asyncResp, sensorId,
sensorPath](const boost::system::error_code& ec,
const ::dbus::utility::MapperGetObject& subtree) {
- BMCWEB_LOG_DEBUG("respHandler1 enter");
- if (ec == boost::system::errc::io_error)
- {
- BMCWEB_LOG_WARNING("Sensor not found from getSensorPaths");
- messages::resourceNotFound(asyncResp->res, sensorId, "Sensor");
- return;
- }
- if (ec)
- {
- messages::internalError(asyncResp->res);
- BMCWEB_LOG_ERROR(
- "Sensor getSensorPaths resp_handler: Dbus error {}", ec);
- return;
- }
- getSensorFromDbus(asyncResp, sensorPath, subtree);
- BMCWEB_LOG_DEBUG("respHandler1 exit");
- });
+ BMCWEB_LOG_DEBUG("respHandler1 enter");
+ if (ec == boost::system::errc::io_error)
+ {
+ BMCWEB_LOG_WARNING("Sensor not found from getSensorPaths");
+ messages::resourceNotFound(asyncResp->res, sensorId, "Sensor");
+ return;
+ }
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ BMCWEB_LOG_ERROR(
+ "Sensor getSensorPaths resp_handler: Dbus error {}", ec);
+ return;
+ }
+ getSensorFromDbus(asyncResp, sensorPath, subtree);
+ BMCWEB_LOG_DEBUG("respHandler1 exit");
+ });
}
} // namespace sensors
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp
index cb5e752..161cb6a 100644
--- a/redfish-core/lib/storage.hpp
+++ b/redfish-core/lib/storage.hpp
@@ -163,9 +163,9 @@
subtree,
[&storageId](const std::pair<std::string,
dbus::utility::MapperServiceMap>& object) {
- return sdbusplus::message::object_path(object.first).filename() ==
- storageId;
- });
+ return sdbusplus::message::object_path(object.first).filename() ==
+ storageId;
+ });
if (storage == subtree.end())
{
messages::resourceNotFound(asyncResp->res, "#Storage.v1_13_0.Storage",
@@ -187,11 +187,10 @@
BMCWEB_REDFISH_SYSTEM_URI_NAME, storageId);
}
-inline void
- handleSystemsStorageGet(App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& systemName,
- const std::string& storageId)
+inline void handleSystemsStorageGet(
+ App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName, const std::string& storageId)
{
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
@@ -228,9 +227,9 @@
subtree,
[&storageId](const std::pair<std::string,
dbus::utility::MapperServiceMap>& object) {
- return sdbusplus::message::object_path(object.first).filename() ==
- storageId;
- });
+ return sdbusplus::message::object_path(object.first).filename() ==
+ storageId;
+ });
if (storage == subtree.end())
{
messages::resourceNotFound(asyncResp->res, "#Storage.v1_13_0.Storage",
@@ -299,48 +298,48 @@
const std::vector<
std::pair<std::string, dbus::utility::DbusVariantType>>&
propertiesList) {
- if (ec)
- {
- // this interface isn't necessary
- return;
- }
+ if (ec)
+ {
+ // this interface isn't necessary
+ return;
+ }
- const std::string* partNumber = nullptr;
- const std::string* serialNumber = nullptr;
- const std::string* manufacturer = nullptr;
- const std::string* model = nullptr;
+ const std::string* partNumber = nullptr;
+ const std::string* serialNumber = nullptr;
+ const std::string* manufacturer = nullptr;
+ const std::string* model = nullptr;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), propertiesList, "PartNumber",
- partNumber, "SerialNumber", serialNumber, "Manufacturer",
- manufacturer, "Model", model);
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), propertiesList, "PartNumber",
+ partNumber, "SerialNumber", serialNumber, "Manufacturer",
+ manufacturer, "Model", model);
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (partNumber != nullptr)
- {
- asyncResp->res.jsonValue["PartNumber"] = *partNumber;
- }
+ if (partNumber != nullptr)
+ {
+ asyncResp->res.jsonValue["PartNumber"] = *partNumber;
+ }
- if (serialNumber != nullptr)
- {
- asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
- }
+ if (serialNumber != nullptr)
+ {
+ asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
+ }
- if (manufacturer != nullptr)
- {
- asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
- }
+ if (manufacturer != nullptr)
+ {
+ asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
+ }
- if (model != nullptr)
- {
- asyncResp->res.jsonValue["Model"] = *model;
- }
- });
+ if (model != nullptr)
+ {
+ asyncResp->res.jsonValue["Model"] = *model;
+ }
+ });
}
inline void getDrivePresent(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -350,21 +349,21 @@
sdbusplus::asio::getProperty<bool>(
*crow::connections::systemBus, connectionName, path,
"xyz.openbmc_project.Inventory.Item", "Present",
- [asyncResp, path](const boost::system::error_code& ec,
- const bool isPresent) {
- // this interface isn't necessary, only check it if
- // we get a good return
- if (ec)
- {
- return;
- }
+ [asyncResp,
+ path](const boost::system::error_code& ec, const bool isPresent) {
+ // this interface isn't necessary, only check it if
+ // we get a good return
+ if (ec)
+ {
+ return;
+ }
- if (!isPresent)
- {
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Absent;
- }
- });
+ if (!isPresent)
+ {
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Absent;
+ }
+ });
}
inline void getDriveState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -375,23 +374,23 @@
*crow::connections::systemBus, connectionName, path,
"xyz.openbmc_project.State.Drive", "Rebuilding",
[asyncResp](const boost::system::error_code& ec, const bool updating) {
- // this interface isn't necessary, only check it
- // if we get a good return
- if (ec)
- {
- return;
- }
+ // this interface isn't necessary, only check it
+ // if we get a good return
+ if (ec)
+ {
+ return;
+ }
- // updating and disabled in the backend shouldn't be
- // able to be set at the same time, so we don't need
- // to check for the race condition of these two
- // calls
- if (updating)
- {
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Updating;
- }
- });
+ // updating and disabled in the backend shouldn't be
+ // able to be set at the same time, so we don't need
+ // to check for the race condition of these two
+ // calls
+ if (updating)
+ {
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Updating;
+ }
+ });
}
inline std::optional<drive::MediaType> convertDriveType(std::string_view type)
@@ -440,10 +439,9 @@
return protocol::Protocol::Invalid;
}
-inline void
- getDriveItemProperties(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& connectionName,
- const std::string& path)
+inline void getDriveItemProperties(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& connectionName, const std::string& path)
{
sdbusplus::asio::getAllProperties(
*crow::connections::systemBus, connectionName, path,
@@ -452,157 +450,159 @@
const std::vector<
std::pair<std::string, dbus::utility::DbusVariantType>>&
propertiesList) {
- if (ec)
- {
- // this interface isn't required
- return;
- }
- const std::string* encryptionStatus = nullptr;
- const bool* isLocked = nullptr;
- for (const std::pair<std::string, dbus::utility::DbusVariantType>&
- property : propertiesList)
- {
- const std::string& propertyName = property.first;
- if (propertyName == "Type")
+ if (ec)
{
- const std::string* value =
- std::get_if<std::string>(&property.second);
- if (value == nullptr)
+ // this interface isn't required
+ return;
+ }
+ const std::string* encryptionStatus = nullptr;
+ const bool* isLocked = nullptr;
+ for (const std::pair<std::string, dbus::utility::DbusVariantType>&
+ property : propertiesList)
+ {
+ const std::string& propertyName = property.first;
+ if (propertyName == "Type")
{
- // illegal property
- BMCWEB_LOG_ERROR("Illegal property: Type");
- messages::internalError(asyncResp->res);
- return;
- }
+ const std::string* value =
+ std::get_if<std::string>(&property.second);
+ if (value == nullptr)
+ {
+ // illegal property
+ BMCWEB_LOG_ERROR("Illegal property: Type");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- std::optional<drive::MediaType> mediaType =
- convertDriveType(*value);
- if (!mediaType)
- {
- BMCWEB_LOG_WARNING("UnknownDriveType Interface: {}",
- *value);
- continue;
- }
- if (*mediaType == drive::MediaType::Invalid)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ std::optional<drive::MediaType> mediaType =
+ convertDriveType(*value);
+ if (!mediaType)
+ {
+ BMCWEB_LOG_WARNING("UnknownDriveType Interface: {}",
+ *value);
+ continue;
+ }
+ if (*mediaType == drive::MediaType::Invalid)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- asyncResp->res.jsonValue["MediaType"] = *mediaType;
- }
- else if (propertyName == "Capacity")
- {
- const uint64_t* capacity =
- std::get_if<uint64_t>(&property.second);
- if (capacity == nullptr)
- {
- BMCWEB_LOG_ERROR("Illegal property: Capacity");
- messages::internalError(asyncResp->res);
- return;
+ asyncResp->res.jsonValue["MediaType"] = *mediaType;
}
- if (*capacity == 0)
+ else if (propertyName == "Capacity")
{
- // drive capacity not known
- continue;
- }
+ const uint64_t* capacity =
+ std::get_if<uint64_t>(&property.second);
+ if (capacity == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Illegal property: Capacity");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (*capacity == 0)
+ {
+ // drive capacity not known
+ continue;
+ }
- asyncResp->res.jsonValue["CapacityBytes"] = *capacity;
- }
- else if (propertyName == "Protocol")
- {
- const std::string* value =
- std::get_if<std::string>(&property.second);
- if (value == nullptr)
- {
- BMCWEB_LOG_ERROR("Illegal property: Protocol");
- messages::internalError(asyncResp->res);
- return;
+ asyncResp->res.jsonValue["CapacityBytes"] = *capacity;
}
+ else if (propertyName == "Protocol")
+ {
+ const std::string* value =
+ std::get_if<std::string>(&property.second);
+ if (value == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Illegal property: Protocol");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- std::optional<protocol::Protocol> proto =
- convertDriveProtocol(*value);
- if (!proto)
- {
- BMCWEB_LOG_WARNING("Unknown DrivePrototype Interface: {}",
- *value);
- continue;
+ std::optional<protocol::Protocol> proto =
+ convertDriveProtocol(*value);
+ if (!proto)
+ {
+ BMCWEB_LOG_WARNING(
+ "Unknown DrivePrototype Interface: {}", *value);
+ continue;
+ }
+ if (*proto == protocol::Protocol::Invalid)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["Protocol"] = *proto;
}
- if (*proto == protocol::Protocol::Invalid)
+ else if (propertyName == "PredictedMediaLifeLeftPercent")
{
- messages::internalError(asyncResp->res);
- return;
+ const uint8_t* lifeLeft =
+ std::get_if<uint8_t>(&property.second);
+ if (lifeLeft == nullptr)
+ {
+ BMCWEB_LOG_ERROR(
+ "Illegal property: PredictedMediaLifeLeftPercent");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ // 255 means reading the value is not supported
+ if (*lifeLeft != 255)
+ {
+ asyncResp->res
+ .jsonValue["PredictedMediaLifeLeftPercent"] =
+ *lifeLeft;
+ }
}
- asyncResp->res.jsonValue["Protocol"] = *proto;
- }
- else if (propertyName == "PredictedMediaLifeLeftPercent")
- {
- const uint8_t* lifeLeft =
- std::get_if<uint8_t>(&property.second);
- if (lifeLeft == nullptr)
+ else if (propertyName == "EncryptionStatus")
{
- BMCWEB_LOG_ERROR(
- "Illegal property: PredictedMediaLifeLeftPercent");
- messages::internalError(asyncResp->res);
- return;
+ encryptionStatus =
+ std::get_if<std::string>(&property.second);
+ if (encryptionStatus == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Illegal property: EncryptionStatus");
+ messages::internalError(asyncResp->res);
+ return;
+ }
}
- // 255 means reading the value is not supported
- if (*lifeLeft != 255)
+ else if (propertyName == "Locked")
{
- asyncResp->res.jsonValue["PredictedMediaLifeLeftPercent"] =
- *lifeLeft;
+ isLocked = std::get_if<bool>(&property.second);
+ if (isLocked == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Illegal property: Locked");
+ messages::internalError(asyncResp->res);
+ return;
+ }
}
}
- else if (propertyName == "EncryptionStatus")
- {
- encryptionStatus = std::get_if<std::string>(&property.second);
- if (encryptionStatus == nullptr)
- {
- BMCWEB_LOG_ERROR("Illegal property: EncryptionStatus");
- messages::internalError(asyncResp->res);
- return;
- }
- }
- else if (propertyName == "Locked")
- {
- isLocked = std::get_if<bool>(&property.second);
- if (isLocked == nullptr)
- {
- BMCWEB_LOG_ERROR("Illegal property: Locked");
- messages::internalError(asyncResp->res);
- return;
- }
- }
- }
- if (encryptionStatus == nullptr || isLocked == nullptr ||
- *encryptionStatus ==
- "xyz.openbmc_project.Inventory.Item.Drive.DriveEncryptionState.Unknown")
- {
- return;
- }
- if (*encryptionStatus !=
- "xyz.openbmc_project.Inventory.Item.Drive.DriveEncryptionState.Encrypted")
- {
- //"The drive is not currently encrypted."
+ if (encryptionStatus == nullptr || isLocked == nullptr ||
+ *encryptionStatus ==
+ "xyz.openbmc_project.Inventory.Item.Drive.DriveEncryptionState.Unknown")
+ {
+ return;
+ }
+ if (*encryptionStatus !=
+ "xyz.openbmc_project.Inventory.Item.Drive.DriveEncryptionState.Encrypted")
+ {
+ //"The drive is not currently encrypted."
+ asyncResp->res.jsonValue["EncryptionStatus"] =
+ drive::EncryptionStatus::Unencrypted;
+ return;
+ }
+ if (*isLocked)
+ {
+ //"The drive is currently encrypted and the data is not
+ // accessible to the user."
+ asyncResp->res.jsonValue["EncryptionStatus"] =
+ drive::EncryptionStatus::Locked;
+ return;
+ }
+ // if not locked
+ // "The drive is currently encrypted but the data is accessible
+ // to the user in unencrypted form."
asyncResp->res.jsonValue["EncryptionStatus"] =
- drive::EncryptionStatus::Unencrypted;
- return;
- }
- if (*isLocked)
- {
- //"The drive is currently encrypted and the data is not
- // accessible to the user."
- asyncResp->res.jsonValue["EncryptionStatus"] =
- drive::EncryptionStatus::Locked;
- return;
- }
- // if not locked
- // "The drive is currently encrypted but the data is accessible
- // to the user in unencrypted form."
- asyncResp->res.jsonValue["EncryptionStatus"] =
- drive::EncryptionStatus::Unlocked;
- });
+ drive::EncryptionStatus::Unlocked;
+ });
}
static void addAllDriveInfo(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -647,9 +647,9 @@
subtree,
[&driveId](const std::pair<std::string,
dbus::utility::MapperServiceMap>& object) {
- return sdbusplus::message::object_path(object.first).filename() ==
- driveId;
- });
+ return sdbusplus::message::object_path(object.first).filename() ==
+ driveId;
+ });
if (drive == subtree.end())
{
@@ -675,12 +675,12 @@
return;
}
- getMainChassisId(asyncResp,
- [](const std::string& chassisId,
- const std::shared_ptr<bmcweb::AsyncResp>& aRsp) {
- aRsp->res.jsonValue["Links"]["Chassis"]["@odata.id"] =
- boost::urls::format("/redfish/v1/Chassis/{}", chassisId);
- });
+ getMainChassisId(
+ asyncResp, [](const std::string& chassisId,
+ const std::shared_ptr<bmcweb::AsyncResp>& aRsp) {
+ aRsp->res.jsonValue["Links"]["Chassis"]["@odata.id"] =
+ boost::urls::format("/redfish/v1/Chassis/{}", chassisId);
+ });
// default it to Enabled
asyncResp->res.jsonValue["Status"]["State"] = resource::State::Enabled;
@@ -771,35 +771,36 @@
path + "/drive",
[asyncResp, chassisId](const boost::system::error_code& ec3,
const dbus::utility::MapperEndPoints& resp) {
- if (ec3)
- {
- BMCWEB_LOG_ERROR("Error in chassis Drive association ");
- }
- nlohmann::json& members = asyncResp->res.jsonValue["Members"];
- // important if array is empty
- members = nlohmann::json::array();
+ if (ec3)
+ {
+ BMCWEB_LOG_ERROR("Error in chassis Drive association ");
+ }
+ nlohmann::json& members = asyncResp->res.jsonValue["Members"];
+ // important if array is empty
+ members = nlohmann::json::array();
- std::vector<std::string> leafNames;
- for (const auto& drive : resp)
- {
- sdbusplus::message::object_path drivePath(drive);
- leafNames.push_back(drivePath.filename());
- }
+ std::vector<std::string> leafNames;
+ for (const auto& drive : resp)
+ {
+ sdbusplus::message::object_path drivePath(drive);
+ leafNames.push_back(drivePath.filename());
+ }
- std::ranges::sort(leafNames, AlphanumLess<std::string>());
+ std::ranges::sort(leafNames, AlphanumLess<std::string>());
- for (const auto& leafName : leafNames)
- {
- nlohmann::json::object_t member;
- member["@odata.id"] = boost::urls::format(
- "/redfish/v1/Chassis/{}/Drives/{}", chassisId, leafName);
- members.emplace_back(std::move(member));
- // navigation links will be registered in next patch set
- }
- asyncResp->res.jsonValue["Members@odata.count"] = resp.size();
- }); // end association lambda
+ for (const auto& leafName : leafNames)
+ {
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ boost::urls::format("/redfish/v1/Chassis/{}/Drives/{}",
+ chassisId, leafName);
+ members.emplace_back(std::move(member));
+ // navigation links will be registered in next patch set
+ }
+ asyncResp->res.jsonValue["Members@odata.count"] = resp.size();
+ }); // end association lambda
- } // end Iterate over all retrieved ObjectPaths
+ } // end Iterate over all retrieved ObjectPaths
}
/**
* Chassis drives, this URL will show all the DriveCollection
@@ -880,11 +881,10 @@
}
}
-inline void
- matchAndFillDrive(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& chassisId,
- const std::string& driveName,
- const std::vector<std::string>& resp)
+inline void matchAndFillDrive(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisId, const std::string& driveName,
+ const std::vector<std::string>& resp)
{
for (const std::string& drivePath : resp)
{
@@ -902,16 +902,15 @@
[asyncResp, chassisId, driveName](
const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- buildDrive(asyncResp, chassisId, driveName, ec, subtree);
- });
+ buildDrive(asyncResp, chassisId, driveName, ec, subtree);
+ });
}
}
-inline void
- handleChassisDriveGet(crow::App& app, const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& chassisId,
- const std::string& driveName)
+inline void handleChassisDriveGet(
+ crow::App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisId, const std::string& driveName)
{
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
@@ -927,41 +926,42 @@
[asyncResp, chassisId,
driveName](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- // Iterate over all retrieved ObjectPaths.
- for (const auto& [path, connectionNames] : subtree)
- {
- sdbusplus::message::object_path objPath(path);
- if (objPath.filename() != chassisId)
+ if (ec)
{
- continue;
+ messages::internalError(asyncResp->res);
+ return;
}
- if (connectionNames.empty())
+ // Iterate over all retrieved ObjectPaths.
+ for (const auto& [path, connectionNames] : subtree)
{
- BMCWEB_LOG_ERROR("Got 0 Connection names");
- continue;
- }
-
- dbus::utility::getAssociationEndPoints(
- path + "/drive",
- [asyncResp, chassisId,
- driveName](const boost::system::error_code& ec3,
- const dbus::utility::MapperEndPoints& resp) {
- if (ec3)
+ sdbusplus::message::object_path objPath(path);
+ if (objPath.filename() != chassisId)
{
- return; // no drives = no failures
+ continue;
}
- matchAndFillDrive(asyncResp, chassisId, driveName, resp);
- });
- break;
- }
- });
+
+ if (connectionNames.empty())
+ {
+ BMCWEB_LOG_ERROR("Got 0 Connection names");
+ continue;
+ }
+
+ dbus::utility::getAssociationEndPoints(
+ path + "/drive",
+ [asyncResp, chassisId,
+ driveName](const boost::system::error_code& ec3,
+ const dbus::utility::MapperEndPoints& resp) {
+ if (ec3)
+ {
+ return; // no drives = no failures
+ }
+ matchAndFillDrive(asyncResp, chassisId, driveName,
+ resp);
+ });
+ break;
+ }
+ });
}
/**
@@ -1040,19 +1040,19 @@
*crow::connections::systemBus, connectionName, path,
"xyz.openbmc_project.Inventory.Item", "Present",
[asyncResp](const boost::system::error_code& ec, bool isPresent) {
- // this interface isn't necessary, only check it
- // if we get a good return
- if (ec)
- {
- BMCWEB_LOG_DEBUG("Failed to get Present property");
- return;
- }
- if (!isPresent)
- {
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Absent;
- }
- });
+ // this interface isn't necessary, only check it
+ // if we get a good return
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("Failed to get Present property");
+ return;
+ }
+ if (!isPresent)
+ {
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Absent;
+ }
+ });
sdbusplus::asio::getAllProperties(
*crow::connections::systemBus, connectionName, path,
@@ -1061,8 +1061,8 @@
const std::vector<
std::pair<std::string, dbus::utility::DbusVariantType>>&
propertiesList) {
- getStorageControllerAsset(asyncResp, ec, propertiesList);
- });
+ getStorageControllerAsset(asyncResp, ec, propertiesList);
+ });
}
inline void getStorageControllerHandler(
@@ -1170,8 +1170,8 @@
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse&
controllerList) {
- populateStorageControllerCollection(asyncResp, ec, controllerList);
- });
+ populateStorageControllerCollection(asyncResp, ec, controllerList);
+ });
}
inline void handleSystemsStorageControllerGet(
@@ -1198,8 +1198,8 @@
[asyncResp,
controllerId](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- getStorageControllerHandler(asyncResp, controllerId, ec, subtree);
- });
+ getStorageControllerHandler(asyncResp, controllerId, ec, subtree);
+ });
}
inline void requestRoutesStorageControllerCollection(App& app)
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index ae6145a..b87be5f 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -67,9 +67,8 @@
*
* @return None.
*/
-inline void
- updateDimmProperties(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- bool isDimmFunctional)
+inline void updateDimmProperties(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, bool isDimmFunctional)
{
BMCWEB_LOG_DEBUG("Dimm Functional: {}", isDimmFunctional);
@@ -126,9 +125,8 @@
*
* @return None.
*/
-inline void
- modifyCpuPresenceState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- bool isCpuPresent)
+inline void modifyCpuPresenceState(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, bool isCpuPresent)
{
BMCWEB_LOG_DEBUG("Cpu Present: {}", isCpuPresent);
@@ -218,14 +216,14 @@
[asyncResp, service,
path](const boost::system::error_code& ec2,
const dbus::utility::DBusPropertiesMap& properties) {
- if (ec2)
- {
- BMCWEB_LOG_ERROR("DBUS response error {}", ec2);
- messages::internalError(asyncResp->res);
- return;
- }
- getProcessorProperties(asyncResp, properties);
- });
+ if (ec2)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error {}", ec2);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ getProcessorProperties(asyncResp, properties);
+ });
}
/*
@@ -297,14 +295,14 @@
[asyncResp, service,
path](const boost::system::error_code& ec2,
const dbus::utility::DBusPropertiesMap& properties) {
- if (ec2)
- {
- BMCWEB_LOG_ERROR("DBUS response error {}", ec2);
- messages::internalError(asyncResp->res);
- return;
- }
- processMemoryProperties(asyncResp, properties);
- });
+ if (ec2)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error {}", ec2);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ processMemoryProperties(asyncResp, properties);
+ });
}
inline void afterGetUUID(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -405,10 +403,9 @@
"BiosVersion", false);
}
-inline void
- afterGetAssetTag(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const boost::system::error_code& ec,
- const std::string& value)
+inline void afterGetAssetTag(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const boost::system::error_code& ec, const std::string& value)
{
if (ec)
{
@@ -475,8 +472,8 @@
[asyncResp](const boost::system::error_code& ec3,
const dbus::utility::DBusPropertiesMap&
properties) {
- afterGetUUID(asyncResp, ec3, properties);
- });
+ afterGetUUID(asyncResp, ec3, properties);
+ });
}
else if (interfaceName ==
"xyz.openbmc_project.Inventory.Item.System")
@@ -487,8 +484,8 @@
[asyncResp](const boost::system::error_code& ec3,
const dbus::utility::DBusPropertiesMap&
properties) {
- afterGetInventory(asyncResp, ec3, properties);
- });
+ afterGetInventory(asyncResp, ec3, properties);
+ });
sdbusplus::asio::getProperty<std::string>(
*crow::connections::systemBus, connection.first, path,
@@ -541,66 +538,71 @@
"CurrentHostState",
[asyncResp](const boost::system::error_code& ec,
const std::string& hostState) {
- if (ec)
- {
- if (ec == boost::system::errc::host_unreachable)
+ if (ec)
{
- // Service not available, no error, just don't return
- // host state info
- BMCWEB_LOG_DEBUG("Service not available {}", ec);
+ if (ec == boost::system::errc::host_unreachable)
+ {
+ // Service not available, no error, just don't return
+ // host state info
+ BMCWEB_LOG_DEBUG("Service not available {}", ec);
+ return;
+ }
+ BMCWEB_LOG_ERROR("DBUS response error {}", ec);
+ messages::internalError(asyncResp->res);
return;
}
- BMCWEB_LOG_ERROR("DBUS response error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- BMCWEB_LOG_DEBUG("Host state: {}", hostState);
- // Verify Host State
- if (hostState == "xyz.openbmc_project.State.Host.HostState.Running")
- {
- asyncResp->res.jsonValue["PowerState"] = resource::PowerState::On;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Enabled;
- }
- else if (hostState ==
- "xyz.openbmc_project.State.Host.HostState.Quiesced")
- {
- asyncResp->res.jsonValue["PowerState"] = resource::PowerState::On;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Quiesced;
- }
- else if (hostState ==
- "xyz.openbmc_project.State.Host.HostState.DiagnosticMode")
- {
- asyncResp->res.jsonValue["PowerState"] = resource::PowerState::On;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::InTest;
- }
- else if (
- hostState ==
- "xyz.openbmc_project.State.Host.HostState.TransitioningToRunning")
- {
- asyncResp->res.jsonValue["PowerState"] =
- resource::PowerState::PoweringOn;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Starting;
- }
- else if (hostState ==
- "xyz.openbmc_project.State.Host.HostState.TransitioningToOff")
- {
- asyncResp->res.jsonValue["PowerState"] =
- resource::PowerState::PoweringOff;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Disabled;
- }
- else
- {
- asyncResp->res.jsonValue["PowerState"] = resource::PowerState::Off;
- asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Disabled;
- }
- });
+ BMCWEB_LOG_DEBUG("Host state: {}", hostState);
+ // Verify Host State
+ if (hostState == "xyz.openbmc_project.State.Host.HostState.Running")
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::On;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Enabled;
+ }
+ else if (hostState ==
+ "xyz.openbmc_project.State.Host.HostState.Quiesced")
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::On;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Quiesced;
+ }
+ else if (hostState ==
+ "xyz.openbmc_project.State.Host.HostState.DiagnosticMode")
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::On;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::InTest;
+ }
+ else if (
+ hostState ==
+ "xyz.openbmc_project.State.Host.HostState.TransitioningToRunning")
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::PoweringOn;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Starting;
+ }
+ else if (
+ hostState ==
+ "xyz.openbmc_project.State.Host.HostState.TransitioningToOff")
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::PoweringOff;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Disabled;
+ }
+ else
+ {
+ asyncResp->res.jsonValue["PowerState"] =
+ resource::PowerState::Off;
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Disabled;
+ }
+ });
}
/**
@@ -773,10 +775,9 @@
*
* @return Integer error code.
*/
-inline int
- assignBootParameters(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& rfSource, std::string& bootSource,
- std::string& bootMode)
+inline int assignBootParameters(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& rfSource, std::string& bootSource, std::string& bootMode)
{
bootSource = "xyz.openbmc_project.Control.Boot.Source.Sources.Default";
bootMode = "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular";
@@ -838,18 +839,18 @@
"xyz.openbmc_project.State.Boot.Progress", "BootProgress",
[asyncResp](const boost::system::error_code& ec,
const std::string& bootProgressStr) {
- if (ec)
- {
- // BootProgress is an optional object so just do nothing if
- // not found
- return;
- }
+ if (ec)
+ {
+ // BootProgress is an optional object so just do nothing if
+ // not found
+ return;
+ }
- BMCWEB_LOG_DEBUG("Boot Progress: {}", bootProgressStr);
+ BMCWEB_LOG_DEBUG("Boot Progress: {}", bootProgressStr);
- asyncResp->res.jsonValue["BootProgress"]["LastState"] =
- dbusToRfBootProgress(bootProgressStr);
- });
+ asyncResp->res.jsonValue["BootProgress"]["LastState"] =
+ dbusToRfBootProgress(bootProgressStr);
+ });
}
/**
@@ -868,22 +869,22 @@
"xyz.openbmc_project.State.Boot.Progress", "BootProgressLastUpdate",
[asyncResp](const boost::system::error_code& ec,
const uint64_t lastStateTime) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("D-BUS response error {}", ec);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("D-BUS response error {}", ec);
+ return;
+ }
- // BootProgressLastUpdate is the last time the BootProgress property
- // was updated. The time is the Epoch time, number of microseconds
- // since 1 Jan 1970 00::00::00 UTC."
- // https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/
- // yaml/xyz/openbmc_project/State/Boot/Progress.interface.yaml#L11
+ // BootProgressLastUpdate is the last time the BootProgress property
+ // was updated. The time is the Epoch time, number of microseconds
+ // since 1 Jan 1970 00::00::00 UTC."
+ // https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/
+ // yaml/xyz/openbmc_project/State/Boot/Progress.interface.yaml#L11
- // Convert to ISO 8601 standard
- asyncResp->res.jsonValue["BootProgress"]["LastStateTime"] =
- redfish::time_utils::getDateTimeUintUs(lastStateTime);
- });
+ // Convert to ISO 8601 standard
+ asyncResp->res.jsonValue["BootProgress"]["LastStateTime"] =
+ redfish::time_utils::getDateTimeUintUs(lastStateTime);
+ });
}
/**
@@ -903,28 +904,28 @@
"xyz.openbmc_project.Control.Boot.Type", "BootType",
[asyncResp](const boost::system::error_code& ec,
const std::string& bootType) {
- if (ec)
- {
- // not an error, don't have to have the interface
- return;
- }
+ if (ec)
+ {
+ // not an error, don't have to have the interface
+ return;
+ }
- BMCWEB_LOG_DEBUG("Boot type: {}", bootType);
+ BMCWEB_LOG_DEBUG("Boot type: {}", bootType);
- asyncResp->res
- .jsonValue["Boot"]
- ["BootSourceOverrideMode@Redfish.AllowableValues"] =
- nlohmann::json::array_t({"Legacy", "UEFI"});
+ asyncResp->res
+ .jsonValue["Boot"]
+ ["BootSourceOverrideMode@Redfish.AllowableValues"] =
+ nlohmann::json::array_t({"Legacy", "UEFI"});
- auto rfType = dbusToRfBootType(bootType);
- if (rfType.empty())
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ auto rfType = dbusToRfBootType(bootType);
+ if (rfType.empty())
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- asyncResp->res.jsonValue["Boot"]["BootSourceOverrideMode"] = rfType;
- });
+ asyncResp->res.jsonValue["Boot"]["BootSourceOverrideMode"] = rfType;
+ });
}
/**
@@ -944,39 +945,39 @@
"xyz.openbmc_project.Control.Boot.Mode", "BootMode",
[asyncResp](const boost::system::error_code& ec,
const std::string& bootModeStr) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
-
- BMCWEB_LOG_DEBUG("Boot mode: {}", bootModeStr);
-
- nlohmann::json::array_t allowed;
- allowed.emplace_back("None");
- allowed.emplace_back("Pxe");
- allowed.emplace_back("Hdd");
- allowed.emplace_back("Cd");
- allowed.emplace_back("Diags");
- allowed.emplace_back("BiosSetup");
- allowed.emplace_back("Usb");
-
- asyncResp->res
- .jsonValue["Boot"]
- ["BootSourceOverrideTarget@Redfish.AllowableValues"] =
- std::move(allowed);
- if (bootModeStr !=
- "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular")
- {
- auto rfMode = dbusToRfBootMode(bootModeStr);
- if (!rfMode.empty())
+ if (ec)
{
- asyncResp->res.jsonValue["Boot"]["BootSourceOverrideTarget"] =
- rfMode;
+ BMCWEB_LOG_ERROR("DBUS response error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
}
- }
- });
+
+ BMCWEB_LOG_DEBUG("Boot mode: {}", bootModeStr);
+
+ nlohmann::json::array_t allowed;
+ allowed.emplace_back("None");
+ allowed.emplace_back("Pxe");
+ allowed.emplace_back("Hdd");
+ allowed.emplace_back("Cd");
+ allowed.emplace_back("Diags");
+ allowed.emplace_back("BiosSetup");
+ allowed.emplace_back("Usb");
+
+ asyncResp->res
+ .jsonValue["Boot"]
+ ["BootSourceOverrideTarget@Redfish.AllowableValues"] =
+ std::move(allowed);
+ if (bootModeStr !=
+ "xyz.openbmc_project.Control.Boot.Mode.Modes.Regular")
+ {
+ auto rfMode = dbusToRfBootMode(bootModeStr);
+ if (!rfMode.empty())
+ {
+ asyncResp->res
+ .jsonValue["Boot"]["BootSourceOverrideTarget"] = rfMode;
+ }
+ }
+ });
}
/**
@@ -996,30 +997,30 @@
"xyz.openbmc_project.Control.Boot.Source", "BootSource",
[asyncResp](const boost::system::error_code& ec,
const std::string& bootSourceStr) {
- if (ec)
- {
- if (ec.value() == boost::asio::error::host_unreachable)
+ if (ec)
{
+ if (ec.value() == boost::asio::error::host_unreachable)
+ {
+ return;
+ }
+ BMCWEB_LOG_ERROR("DBUS response error {}", ec);
+ messages::internalError(asyncResp->res);
return;
}
- BMCWEB_LOG_ERROR("DBUS response error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- BMCWEB_LOG_DEBUG("Boot source: {}", bootSourceStr);
+ BMCWEB_LOG_DEBUG("Boot source: {}", bootSourceStr);
- auto rfSource = dbusToRfBootSource(bootSourceStr);
- if (!rfSource.empty())
- {
- asyncResp->res.jsonValue["Boot"]["BootSourceOverrideTarget"] =
- rfSource;
- }
+ auto rfSource = dbusToRfBootSource(bootSourceStr);
+ if (!rfSource.empty())
+ {
+ asyncResp->res.jsonValue["Boot"]["BootSourceOverrideTarget"] =
+ rfSource;
+ }
- // Get BootMode as BootSourceOverrideTarget is constructed
- // from both BootSource and BootMode
- getBootOverrideMode(asyncResp);
- });
+ // Get BootMode as BootSourceOverrideTarget is constructed
+ // from both BootSource and BootMode
+ getBootOverrideMode(asyncResp);
+ });
}
/**
@@ -1050,24 +1051,24 @@
"/xyz/openbmc_project/control/host0/boot/one_time",
"xyz.openbmc_project.Object.Enable", "Enabled",
[asyncResp](const boost::system::error_code& ec, bool oneTimeSetting) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (oneTimeSetting)
- {
- asyncResp->res.jsonValue["Boot"]["BootSourceOverrideEnabled"] =
- "Once";
- }
- else
- {
- asyncResp->res.jsonValue["Boot"]["BootSourceOverrideEnabled"] =
- "Continuous";
- }
- });
+ if (oneTimeSetting)
+ {
+ asyncResp->res.jsonValue["Boot"]["BootSourceOverrideEnabled"] =
+ "Once";
+ }
+ else
+ {
+ asyncResp->res.jsonValue["Boot"]["BootSourceOverrideEnabled"] =
+ "Continuous";
+ }
+ });
}
/**
@@ -1087,19 +1088,19 @@
"xyz.openbmc_project.Object.Enable", "Enabled",
[asyncResp](const boost::system::error_code& ec,
const bool bootOverrideEnable) {
- if (ec)
- {
- if (ec.value() == boost::asio::error::host_unreachable)
+ if (ec)
{
+ if (ec.value() == boost::asio::error::host_unreachable)
+ {
+ return;
+ }
+ BMCWEB_LOG_ERROR("DBUS response error {}", ec);
+ messages::internalError(asyncResp->res);
return;
}
- BMCWEB_LOG_ERROR("DBUS response error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- processBootOverrideEnable(asyncResp, bootOverrideEnable);
- });
+ processBootOverrideEnable(asyncResp, bootOverrideEnable);
+ });
}
/**
@@ -1142,20 +1143,20 @@
"xyz.openbmc_project.State.Chassis", "LastStateChangeTime",
[asyncResp](const boost::system::error_code& ec,
uint64_t lastResetTime) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("D-BUS response error {}", ec);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("D-BUS response error {}", ec);
+ return;
+ }
- // LastStateChangeTime is epoch time, in milliseconds
- // https://github.com/openbmc/phosphor-dbus-interfaces/blob/33e8e1dd64da53a66e888d33dc82001305cd0bf9/xyz/openbmc_project/State/Chassis.interface.yaml#L19
- uint64_t lastResetTimeStamp = lastResetTime / 1000;
+ // LastStateChangeTime is epoch time, in milliseconds
+ // https://github.com/openbmc/phosphor-dbus-interfaces/blob/33e8e1dd64da53a66e888d33dc82001305cd0bf9/xyz/openbmc_project/State/Chassis.interface.yaml#L19
+ uint64_t lastResetTimeStamp = lastResetTime / 1000;
- // Convert to ISO 8601 standard
- asyncResp->res.jsonValue["LastResetTime"] =
- redfish::time_utils::getDateTimeUint(lastResetTimeStamp);
- });
+ // Convert to ISO 8601 standard
+ asyncResp->res.jsonValue["LastResetTime"] =
+ redfish::time_utils::getDateTimeUint(lastResetTimeStamp);
+ });
}
/**
@@ -1182,42 +1183,42 @@
[asyncResp{asyncResp}](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& propertiesList) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec);
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec);
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- const uint32_t* attemptsLeft = nullptr;
- const uint32_t* retryAttempts = nullptr;
+ const uint32_t* attemptsLeft = nullptr;
+ const uint32_t* retryAttempts = nullptr;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), propertiesList, "AttemptsLeft",
- attemptsLeft, "RetryAttempts", retryAttempts);
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), propertiesList,
+ "AttemptsLeft", attemptsLeft, "RetryAttempts", retryAttempts);
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (attemptsLeft != nullptr)
- {
- asyncResp->res
- .jsonValue["Boot"]["RemainingAutomaticRetryAttempts"] =
- *attemptsLeft;
- }
+ if (attemptsLeft != nullptr)
+ {
+ asyncResp->res
+ .jsonValue["Boot"]["RemainingAutomaticRetryAttempts"] =
+ *attemptsLeft;
+ }
- if (retryAttempts != nullptr)
- {
- asyncResp->res.jsonValue["Boot"]["AutomaticRetryAttempts"] =
- *retryAttempts;
- }
- });
+ if (retryAttempts != nullptr)
+ {
+ asyncResp->res.jsonValue["Boot"]["AutomaticRetryAttempts"] =
+ *retryAttempts;
+ }
+ });
}
/**
@@ -1238,39 +1239,40 @@
"xyz.openbmc_project.Control.Boot.RebootPolicy", "AutoReboot",
[asyncResp](const boost::system::error_code& ec,
bool autoRebootEnabled) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec);
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec);
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- BMCWEB_LOG_DEBUG("Auto Reboot: {}", autoRebootEnabled);
- if (autoRebootEnabled)
- {
- asyncResp->res.jsonValue["Boot"]["AutomaticRetryConfig"] =
- "RetryAttempts";
- }
- else
- {
- asyncResp->res.jsonValue["Boot"]["AutomaticRetryConfig"] =
- "Disabled";
- }
- getAutomaticRebootAttempts(asyncResp);
+ BMCWEB_LOG_DEBUG("Auto Reboot: {}", autoRebootEnabled);
+ if (autoRebootEnabled)
+ {
+ asyncResp->res.jsonValue["Boot"]["AutomaticRetryConfig"] =
+ "RetryAttempts";
+ }
+ else
+ {
+ asyncResp->res.jsonValue["Boot"]["AutomaticRetryConfig"] =
+ "Disabled";
+ }
+ getAutomaticRebootAttempts(asyncResp);
- // "AutomaticRetryConfig" can be 3 values, Disabled, RetryAlways,
- // and RetryAttempts. OpenBMC only supports Disabled and
- // RetryAttempts.
- nlohmann::json::array_t allowed;
- allowed.emplace_back("Disabled");
- allowed.emplace_back("RetryAttempts");
- asyncResp->res
- .jsonValue["Boot"]["AutomaticRetryConfig@Redfish.AllowableValues"] =
- std::move(allowed);
- });
+ // "AutomaticRetryConfig" can be 3 values, Disabled, RetryAlways,
+ // and RetryAttempts. OpenBMC only supports Disabled and
+ // RetryAttempts.
+ nlohmann::json::array_t allowed;
+ allowed.emplace_back("Disabled");
+ allowed.emplace_back("RetryAttempts");
+ asyncResp->res
+ .jsonValue["Boot"]
+ ["AutomaticRetryConfig@Redfish.AllowableValues"] =
+ std::move(allowed);
+ });
}
/**
@@ -1337,21 +1339,21 @@
"xyz.openbmc_project.Control.Power.RestorePolicy", "PowerRestorePolicy",
[asyncResp](const boost::system::error_code& ec,
const std::string& policy) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
- return;
- }
- computer_system::PowerRestorePolicyTypes restore =
- redfishPowerRestorePolicyFromDbus(policy);
- if (restore == computer_system::PowerRestorePolicyTypes::Invalid)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
+ return;
+ }
+ computer_system::PowerRestorePolicyTypes restore =
+ redfishPowerRestorePolicyFromDbus(policy);
+ if (restore == computer_system::PowerRestorePolicyTypes::Invalid)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- asyncResp->res.jsonValue["PowerRestorePolicy"] = restore;
- });
+ asyncResp->res.jsonValue["PowerRestorePolicy"] = restore;
+ });
}
/**
@@ -1371,27 +1373,27 @@
"/xyz/openbmc_project/logging/settings",
"xyz.openbmc_project.Logging.Settings", "QuiesceOnHwError",
[asyncResp](const boost::system::error_code& ec, bool value) {
- if (ec)
- {
- if (ec.value() != EBADR)
+ if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error {}", ec);
- messages::internalError(asyncResp->res);
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR("DBUS response error {}", ec);
+ messages::internalError(asyncResp->res);
+ }
+ return;
}
- return;
- }
- if (value)
- {
- asyncResp->res.jsonValue["Boot"]["StopBootOnFault"] =
- computer_system::StopBootOnFault::AnyFault;
- }
- else
- {
- asyncResp->res.jsonValue["Boot"]["StopBootOnFault"] =
- computer_system::StopBootOnFault::Never;
- }
- });
+ if (value)
+ {
+ asyncResp->res.jsonValue["Boot"]["StopBootOnFault"] =
+ computer_system::StopBootOnFault::AnyFault;
+ }
+ else
+ {
+ asyncResp->res.jsonValue["Boot"]["StopBootOnFault"] =
+ computer_system::StopBootOnFault::Never;
+ }
+ });
}
/**
@@ -1412,72 +1414,72 @@
"/", 0, interfaces,
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error on TPM.Policy GetSubTree{}",
- ec);
- // This is an optional D-Bus object so just return if
- // error occurs
- return;
- }
- if (subtree.empty())
- {
- // As noted above, this is an optional interface so just return
- // if there is no instance found
- return;
- }
-
- /* When there is more than one TPMEnable object... */
- if (subtree.size() > 1)
- {
- BMCWEB_LOG_DEBUG(
- "DBUS response has more than 1 TPM Enable object:{}",
- subtree.size());
- // Throw an internal Error and return
- messages::internalError(asyncResp->res);
- return;
- }
-
- // Make sure the Dbus response map has a service and objectPath
- // field
- if (subtree[0].first.empty() || subtree[0].second.size() != 1)
- {
- BMCWEB_LOG_DEBUG("TPM.Policy mapper error!");
- messages::internalError(asyncResp->res);
- return;
- }
-
- const std::string& path = subtree[0].first;
- const std::string& serv = subtree[0].second.begin()->first;
-
- // Valid TPM Enable object found, now reading the current value
- sdbusplus::asio::getProperty<bool>(
- *crow::connections::systemBus, serv, path,
- "xyz.openbmc_project.Control.TPM.Policy", "TPMEnable",
- [asyncResp](const boost::system::error_code& ec2,
- bool tpmRequired) {
- if (ec2)
+ if (ec)
{
- BMCWEB_LOG_ERROR("D-BUS response error on TPM.Policy Get{}",
- ec2);
+ BMCWEB_LOG_DEBUG(
+ "DBUS response error on TPM.Policy GetSubTree{}", ec);
+ // This is an optional D-Bus object so just return if
+ // error occurs
+ return;
+ }
+ if (subtree.empty())
+ {
+ // As noted above, this is an optional interface so just return
+ // if there is no instance found
+ return;
+ }
+
+ /* When there is more than one TPMEnable object... */
+ if (subtree.size() > 1)
+ {
+ BMCWEB_LOG_DEBUG(
+ "DBUS response has more than 1 TPM Enable object:{}",
+ subtree.size());
+ // Throw an internal Error and return
messages::internalError(asyncResp->res);
return;
}
- if (tpmRequired)
+ // Make sure the Dbus response map has a service and objectPath
+ // field
+ if (subtree[0].first.empty() || subtree[0].second.size() != 1)
{
- asyncResp->res
- .jsonValue["Boot"]["TrustedModuleRequiredToBoot"] =
- "Required";
+ BMCWEB_LOG_DEBUG("TPM.Policy mapper error!");
+ messages::internalError(asyncResp->res);
+ return;
}
- else
- {
- asyncResp->res
- .jsonValue["Boot"]["TrustedModuleRequiredToBoot"] =
- "Disabled";
- }
+
+ const std::string& path = subtree[0].first;
+ const std::string& serv = subtree[0].second.begin()->first;
+
+ // Valid TPM Enable object found, now reading the current value
+ sdbusplus::asio::getProperty<bool>(
+ *crow::connections::systemBus, serv, path,
+ "xyz.openbmc_project.Control.TPM.Policy", "TPMEnable",
+ [asyncResp](const boost::system::error_code& ec2,
+ bool tpmRequired) {
+ if (ec2)
+ {
+ BMCWEB_LOG_ERROR(
+ "D-BUS response error on TPM.Policy Get{}", ec2);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ if (tpmRequired)
+ {
+ asyncResp->res
+ .jsonValue["Boot"]["TrustedModuleRequiredToBoot"] =
+ "Required";
+ }
+ else
+ {
+ asyncResp->res
+ .jsonValue["Boot"]["TrustedModuleRequiredToBoot"] =
+ "Disabled";
+ }
+ });
});
- });
}
/**
@@ -1500,55 +1502,56 @@
[asyncResp,
tpmRequired](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error on TPM.Policy GetSubTree{}",
- ec);
- messages::internalError(asyncResp->res);
- return;
- }
- if (subtree.empty())
- {
- messages::propertyValueNotInList(asyncResp->res, "ComputerSystem",
- "TrustedModuleRequiredToBoot");
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR(
+ "DBUS response error on TPM.Policy GetSubTree{}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (subtree.empty())
+ {
+ messages::propertyValueNotInList(asyncResp->res,
+ "ComputerSystem",
+ "TrustedModuleRequiredToBoot");
+ return;
+ }
- /* When there is more than one TPMEnable object... */
- if (subtree.size() > 1)
- {
- BMCWEB_LOG_DEBUG(
- "DBUS response has more than 1 TPM Enable object:{}",
- subtree.size());
- // Throw an internal Error and return
- messages::internalError(asyncResp->res);
- return;
- }
+ /* When there is more than one TPMEnable object... */
+ if (subtree.size() > 1)
+ {
+ BMCWEB_LOG_DEBUG(
+ "DBUS response has more than 1 TPM Enable object:{}",
+ subtree.size());
+ // Throw an internal Error and return
+ messages::internalError(asyncResp->res);
+ return;
+ }
- // Make sure the Dbus response map has a service and objectPath
- // field
- if (subtree[0].first.empty() || subtree[0].second.size() != 1)
- {
- BMCWEB_LOG_DEBUG("TPM.Policy mapper error!");
- messages::internalError(asyncResp->res);
- return;
- }
+ // Make sure the Dbus response map has a service and objectPath
+ // field
+ if (subtree[0].first.empty() || subtree[0].second.size() != 1)
+ {
+ BMCWEB_LOG_DEBUG("TPM.Policy mapper error!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- const std::string& path = subtree[0].first;
- const std::string& serv = subtree[0].second.begin()->first;
+ const std::string& path = subtree[0].first;
+ const std::string& serv = subtree[0].second.begin()->first;
- if (serv.empty())
- {
- BMCWEB_LOG_DEBUG("TPM.Policy service mapper error!");
- messages::internalError(asyncResp->res);
- return;
- }
+ if (serv.empty())
+ {
+ BMCWEB_LOG_DEBUG("TPM.Policy service mapper error!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- // Valid TPM Enable object found, now setting the value
- setDbusProperty(asyncResp, "Boot/TrustedModuleRequiredToBoot", serv,
- path, "xyz.openbmc_project.Control.TPM.Policy",
- "TPMEnable", tpmRequired);
- });
+ // Valid TPM Enable object found, now setting the value
+ setDbusProperty(asyncResp, "Boot/TrustedModuleRequiredToBoot", serv,
+ path, "xyz.openbmc_project.Control.TPM.Policy",
+ "TPMEnable", tpmRequired);
+ });
}
/**
@@ -1767,47 +1770,47 @@
[asyncResp,
assetTag](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("D-Bus response error on GetSubTree {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- if (subtree.empty())
- {
- BMCWEB_LOG_DEBUG("Can't find system D-Bus object!");
- messages::internalError(asyncResp->res);
- return;
- }
- // Assume only 1 system D-Bus object
- // Throw an error if there is more than 1
- if (subtree.size() > 1)
- {
- BMCWEB_LOG_DEBUG("Found more than 1 system D-Bus object!");
- messages::internalError(asyncResp->res);
- return;
- }
- if (subtree[0].first.empty() || subtree[0].second.size() != 1)
- {
- BMCWEB_LOG_DEBUG("Asset Tag Set mapper error!");
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("D-Bus response error on GetSubTree {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (subtree.empty())
+ {
+ BMCWEB_LOG_DEBUG("Can't find system D-Bus object!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ // Assume only 1 system D-Bus object
+ // Throw an error if there is more than 1
+ if (subtree.size() > 1)
+ {
+ BMCWEB_LOG_DEBUG("Found more than 1 system D-Bus object!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (subtree[0].first.empty() || subtree[0].second.size() != 1)
+ {
+ BMCWEB_LOG_DEBUG("Asset Tag Set mapper error!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- const std::string& path = subtree[0].first;
- const std::string& service = subtree[0].second.begin()->first;
+ const std::string& path = subtree[0].first;
+ const std::string& service = subtree[0].second.begin()->first;
- if (service.empty())
- {
- BMCWEB_LOG_DEBUG("Asset Tag Set service mapper error!");
- messages::internalError(asyncResp->res);
- return;
- }
+ if (service.empty())
+ {
+ BMCWEB_LOG_DEBUG("Asset Tag Set service mapper error!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- setDbusProperty(asyncResp, "AssetTag", service, path,
- "xyz.openbmc_project.Inventory.Decorator.AssetTag",
- "AssetTag", assetTag);
- });
+ setDbusProperty(asyncResp, "AssetTag", service, path,
+ "xyz.openbmc_project.Inventory.Decorator.AssetTag",
+ "AssetTag", assetTag);
+ });
}
/**
@@ -1974,60 +1977,62 @@
"/xyz/openbmc_project/pfr", "xyz.openbmc_project.PFR.Attributes",
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& propertiesList) {
- nlohmann::json& oemPFR =
- asyncResp->res.jsonValue["Oem"]["OpenBmc"]["FirmwareProvisioning"];
- asyncResp->res.jsonValue["Oem"]["OpenBmc"]["@odata.type"] =
- "#OpenBMCComputerSystem.v1_0_0.OpenBmc";
- oemPFR["@odata.type"] = "#OpenBMCComputerSystem.FirmwareProvisioning";
+ nlohmann::json& oemPFR =
+ asyncResp->res
+ .jsonValue["Oem"]["OpenBmc"]["FirmwareProvisioning"];
+ asyncResp->res.jsonValue["Oem"]["OpenBmc"]["@odata.type"] =
+ "#OpenBMCComputerSystem.v1_0_0.OpenBmc";
+ oemPFR["@odata.type"] =
+ "#OpenBMCComputerSystem.FirmwareProvisioning";
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
- // not an error, don't have to have the interface
- oemPFR["ProvisioningStatus"] = open_bmc_computer_system::
- FirmwareProvisioningStatus::NotProvisioned;
- return;
- }
-
- const bool* provState = nullptr;
- const bool* lockState = nullptr;
-
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), propertiesList, "UfmProvisioned",
- provState, "UfmLocked", lockState);
-
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- if ((provState == nullptr) || (lockState == nullptr))
- {
- BMCWEB_LOG_DEBUG("Unable to get PFR attributes.");
- messages::internalError(asyncResp->res);
- return;
- }
-
- if (*provState)
- {
- if (*lockState)
+ if (ec)
{
+ BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
+ // not an error, don't have to have the interface
oemPFR["ProvisioningStatus"] = open_bmc_computer_system::
- FirmwareProvisioningStatus::ProvisionedAndLocked;
+ FirmwareProvisioningStatus::NotProvisioned;
+ return;
+ }
+
+ const bool* provState = nullptr;
+ const bool* lockState = nullptr;
+
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), propertiesList,
+ "UfmProvisioned", provState, "UfmLocked", lockState);
+
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ if ((provState == nullptr) || (lockState == nullptr))
+ {
+ BMCWEB_LOG_DEBUG("Unable to get PFR attributes.");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ if (*provState)
+ {
+ if (*lockState)
+ {
+ oemPFR["ProvisioningStatus"] = open_bmc_computer_system::
+ FirmwareProvisioningStatus::ProvisionedAndLocked;
+ }
+ else
+ {
+ oemPFR["ProvisioningStatus"] = open_bmc_computer_system::
+ FirmwareProvisioningStatus::ProvisionedButNotLocked;
+ }
}
else
{
oemPFR["ProvisioningStatus"] = open_bmc_computer_system::
- FirmwareProvisioningStatus::ProvisionedButNotLocked;
+ FirmwareProvisioningStatus::NotProvisioned;
}
- }
- else
- {
- oemPFR["ProvisioningStatus"] = open_bmc_computer_system::
- FirmwareProvisioningStatus::NotProvisioned;
- }
- });
+ });
}
/**
@@ -2155,54 +2160,55 @@
"/", 0, interfaces,
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error on Power.Mode GetSubTree {}",
- ec);
- // This is an optional D-Bus object so just return if
- // error occurs
- return;
- }
- if (subtree.empty())
- {
- // As noted above, this is an optional interface so just return
- // if there is no instance found
- return;
- }
- if (subtree.size() > 1)
- {
- // More then one PowerMode object is not supported and is an
- // error
- BMCWEB_LOG_DEBUG(
- "Found more than 1 system D-Bus Power.Mode objects: {}",
- subtree.size());
- messages::internalError(asyncResp->res);
- return;
- }
- if ((subtree[0].first.empty()) || (subtree[0].second.size() != 1))
- {
- BMCWEB_LOG_DEBUG("Power.Mode mapper error!");
- messages::internalError(asyncResp->res);
- return;
- }
- const std::string& path = subtree[0].first;
- const std::string& service = subtree[0].second.begin()->first;
- if (service.empty())
- {
- BMCWEB_LOG_DEBUG("Power.Mode service mapper error!");
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG(
+ "DBUS response error on Power.Mode GetSubTree {}", ec);
+ // This is an optional D-Bus object so just return if
+ // error occurs
+ return;
+ }
+ if (subtree.empty())
+ {
+ // As noted above, this is an optional interface so just return
+ // if there is no instance found
+ return;
+ }
+ if (subtree.size() > 1)
+ {
+ // More then one PowerMode object is not supported and is an
+ // error
+ BMCWEB_LOG_DEBUG(
+ "Found more than 1 system D-Bus Power.Mode objects: {}",
+ subtree.size());
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if ((subtree[0].first.empty()) || (subtree[0].second.size() != 1))
+ {
+ BMCWEB_LOG_DEBUG("Power.Mode mapper error!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ const std::string& path = subtree[0].first;
+ const std::string& service = subtree[0].second.begin()->first;
+ if (service.empty())
+ {
+ BMCWEB_LOG_DEBUG("Power.Mode service mapper error!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- // Valid Power Mode object found, now read the mode properties
- sdbusplus::asio::getAllProperties(
- *crow::connections::systemBus, service, path,
- "xyz.openbmc_project.Control.Power.Mode",
- [asyncResp](const boost::system::error_code& ec2,
- const dbus::utility::DBusPropertiesMap& properties) {
- afterGetPowerMode(asyncResp, ec2, properties);
+ // Valid Power Mode object found, now read the mode properties
+ sdbusplus::asio::getAllProperties(
+ *crow::connections::systemBus, service, path,
+ "xyz.openbmc_project.Control.Power.Mode",
+ [asyncResp](
+ const boost::system::error_code& ec2,
+ const dbus::utility::DBusPropertiesMap& properties) {
+ afterGetPowerMode(asyncResp, ec2, properties);
+ });
});
- });
}
/**
@@ -2284,53 +2290,53 @@
[asyncResp,
powerMode](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("DBUS response error on Power.Mode GetSubTree {}",
- ec);
- // This is an optional D-Bus object, but user attempted to patch
- messages::internalError(asyncResp->res);
- return;
- }
- if (subtree.empty())
- {
- // This is an optional D-Bus object, but user attempted to patch
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- "PowerMode");
- return;
- }
- if (subtree.size() > 1)
- {
- // More then one PowerMode object is not supported and is an
- // error
- BMCWEB_LOG_DEBUG(
- "Found more than 1 system D-Bus Power.Mode objects: {}",
- subtree.size());
- messages::internalError(asyncResp->res);
- return;
- }
- if ((subtree[0].first.empty()) || (subtree[0].second.size() != 1))
- {
- BMCWEB_LOG_DEBUG("Power.Mode mapper error!");
- messages::internalError(asyncResp->res);
- return;
- }
- const std::string& path = subtree[0].first;
- const std::string& service = subtree[0].second.begin()->first;
- if (service.empty())
- {
- BMCWEB_LOG_DEBUG("Power.Mode service mapper error!");
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR(
+ "DBUS response error on Power.Mode GetSubTree {}", ec);
+ // This is an optional D-Bus object, but user attempted to patch
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (subtree.empty())
+ {
+ // This is an optional D-Bus object, but user attempted to patch
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ "PowerMode");
+ return;
+ }
+ if (subtree.size() > 1)
+ {
+ // More then one PowerMode object is not supported and is an
+ // error
+ BMCWEB_LOG_DEBUG(
+ "Found more than 1 system D-Bus Power.Mode objects: {}",
+ subtree.size());
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if ((subtree[0].first.empty()) || (subtree[0].second.size() != 1))
+ {
+ BMCWEB_LOG_DEBUG("Power.Mode mapper error!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ const std::string& path = subtree[0].first;
+ const std::string& service = subtree[0].second.begin()->first;
+ if (service.empty())
+ {
+ BMCWEB_LOG_DEBUG("Power.Mode service mapper error!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- BMCWEB_LOG_DEBUG("Setting power mode({}) -> {}", powerMode, path);
+ BMCWEB_LOG_DEBUG("Setting power mode({}) -> {}", powerMode, path);
- // Set the Power Mode property
- setDbusProperty(asyncResp, "PowerMode", service, path,
- "xyz.openbmc_project.Control.Power.Mode", "PowerMode",
- powerMode);
- });
+ // Set the Power Mode property
+ setDbusProperty(asyncResp, "PowerMode", service, path,
+ "xyz.openbmc_project.Control.Power.Mode",
+ "PowerMode", powerMode);
+ });
}
/**
@@ -2411,50 +2417,50 @@
"xyz.openbmc_project.State.Watchdog",
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& properties) {
- if (ec)
- {
- // watchdog service is stopped
- BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
- return;
- }
+ if (ec)
+ {
+ // watchdog service is stopped
+ BMCWEB_LOG_DEBUG("DBUS response error {}", ec);
+ return;
+ }
- BMCWEB_LOG_DEBUG("Got {} wdt prop.", properties.size());
+ BMCWEB_LOG_DEBUG("Got {} wdt prop.", properties.size());
- nlohmann::json& hostWatchdogTimer =
- asyncResp->res.jsonValue["HostWatchdogTimer"];
+ nlohmann::json& hostWatchdogTimer =
+ asyncResp->res.jsonValue["HostWatchdogTimer"];
- // watchdog service is running/enabled
- hostWatchdogTimer["Status"]["State"] = resource::State::Enabled;
+ // watchdog service is running/enabled
+ hostWatchdogTimer["Status"]["State"] = resource::State::Enabled;
- const bool* enabled = nullptr;
- const std::string* expireAction = nullptr;
+ const bool* enabled = nullptr;
+ const std::string* expireAction = nullptr;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), properties, "Enabled", enabled,
- "ExpireAction", expireAction);
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), properties, "Enabled",
+ enabled, "ExpireAction", expireAction);
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- if (enabled != nullptr)
- {
- hostWatchdogTimer["FunctionEnabled"] = *enabled;
- }
-
- if (expireAction != nullptr)
- {
- std::string action = dbusToRfWatchdogAction(*expireAction);
- if (action.empty())
+ if (!success)
{
messages::internalError(asyncResp->res);
return;
}
- hostWatchdogTimer["TimeoutAction"] = action;
- }
- });
+
+ if (enabled != nullptr)
+ {
+ hostWatchdogTimer["FunctionEnabled"] = *enabled;
+ }
+
+ if (expireAction != nullptr)
+ {
+ std::string action = dbusToRfWatchdogAction(*expireAction);
+ if (action.empty())
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ hostWatchdogTimer["TimeoutAction"] = action;
+ }
+ });
}
/**
@@ -2590,67 +2596,69 @@
"/", 0, interfaces,
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_ERROR(
- "DBUS response error on Power.IdlePowerSaver GetSubTree {}",
- ec);
- messages::internalError(asyncResp->res);
- return;
- }
- if (subtree.empty())
- {
- // This is an optional interface so just return
- // if there is no instance found
- BMCWEB_LOG_DEBUG("No instances found");
- return;
- }
- if (subtree.size() > 1)
- {
- // More then one PowerIdlePowerSaver object is not supported and
- // is an error
- BMCWEB_LOG_DEBUG("Found more than 1 system D-Bus "
- "Power.IdlePowerSaver objects: {}",
- subtree.size());
- messages::internalError(asyncResp->res);
- return;
- }
- if ((subtree[0].first.empty()) || (subtree[0].second.size() != 1))
- {
- BMCWEB_LOG_DEBUG("Power.IdlePowerSaver mapper error!");
- messages::internalError(asyncResp->res);
- return;
- }
- const std::string& path = subtree[0].first;
- const std::string& service = subtree[0].second.begin()->first;
- if (service.empty())
- {
- BMCWEB_LOG_DEBUG("Power.IdlePowerSaver service mapper error!");
- messages::internalError(asyncResp->res);
- return;
- }
-
- // Valid IdlePowerSaver object found, now read the current values
- sdbusplus::asio::getAllProperties(
- *crow::connections::systemBus, service, path,
- "xyz.openbmc_project.Control.Power.IdlePowerSaver",
- [asyncResp](const boost::system::error_code& ec2,
- const dbus::utility::DBusPropertiesMap& properties) {
- if (ec2)
+ if (ec)
{
BMCWEB_LOG_ERROR(
- "DBUS response error on IdlePowerSaver GetAll: {}", ec2);
+ "DBUS response error on Power.IdlePowerSaver GetSubTree {}",
+ ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (subtree.empty())
+ {
+ // This is an optional interface so just return
+ // if there is no instance found
+ BMCWEB_LOG_DEBUG("No instances found");
+ return;
+ }
+ if (subtree.size() > 1)
+ {
+ // More then one PowerIdlePowerSaver object is not supported and
+ // is an error
+ BMCWEB_LOG_DEBUG("Found more than 1 system D-Bus "
+ "Power.IdlePowerSaver objects: {}",
+ subtree.size());
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if ((subtree[0].first.empty()) || (subtree[0].second.size() != 1))
+ {
+ BMCWEB_LOG_DEBUG("Power.IdlePowerSaver mapper error!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ const std::string& path = subtree[0].first;
+ const std::string& service = subtree[0].second.begin()->first;
+ if (service.empty())
+ {
+ BMCWEB_LOG_DEBUG("Power.IdlePowerSaver service mapper error!");
messages::internalError(asyncResp->res);
return;
}
- if (!parseIpsProperties(asyncResp, properties))
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ // Valid IdlePowerSaver object found, now read the current values
+ sdbusplus::asio::getAllProperties(
+ *crow::connections::systemBus, service, path,
+ "xyz.openbmc_project.Control.Power.IdlePowerSaver",
+ [asyncResp](
+ const boost::system::error_code& ec2,
+ const dbus::utility::DBusPropertiesMap& properties) {
+ if (ec2)
+ {
+ BMCWEB_LOG_ERROR(
+ "DBUS response error on IdlePowerSaver GetAll: {}",
+ ec2);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ if (!parseIpsProperties(asyncResp, properties))
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ });
});
- });
BMCWEB_LOG_DEBUG("EXIT: Get idle power saver parameters");
}
@@ -2670,13 +2678,13 @@
*
* @return None.
*/
-inline void
- setIdlePowerSaver(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::optional<bool> ipsEnable,
- const std::optional<uint8_t> ipsEnterUtil,
- const std::optional<uint64_t> ipsEnterTime,
- const std::optional<uint8_t> ipsExitUtil,
- const std::optional<uint64_t> ipsExitTime)
+inline void setIdlePowerSaver(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::optional<bool> ipsEnable,
+ const std::optional<uint8_t> ipsEnterUtil,
+ const std::optional<uint64_t> ipsEnterTime,
+ const std::optional<uint8_t> ipsExitUtil,
+ const std::optional<uint64_t> ipsExitTime)
{
BMCWEB_LOG_DEBUG("Set idle power saver properties");
@@ -2688,88 +2696,90 @@
[asyncResp, ipsEnable, ipsEnterUtil, ipsEnterTime, ipsExitUtil,
ipsExitTime](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_ERROR(
- "DBUS response error on Power.IdlePowerSaver GetSubTree {}",
- ec);
- messages::internalError(asyncResp->res);
- return;
- }
- if (subtree.empty())
- {
- // This is an optional D-Bus object, but user attempted to patch
- messages::resourceNotFound(asyncResp->res, "ComputerSystem",
- "IdlePowerSaver");
- return;
- }
- if (subtree.size() > 1)
- {
- // More then one PowerIdlePowerSaver object is not supported and
- // is an error
- BMCWEB_LOG_DEBUG(
- "Found more than 1 system D-Bus Power.IdlePowerSaver objects: {}",
- subtree.size());
- messages::internalError(asyncResp->res);
- return;
- }
- if ((subtree[0].first.empty()) || (subtree[0].second.size() != 1))
- {
- BMCWEB_LOG_DEBUG("Power.IdlePowerSaver mapper error!");
- messages::internalError(asyncResp->res);
- return;
- }
- const std::string& path = subtree[0].first;
- const std::string& service = subtree[0].second.begin()->first;
- if (service.empty())
- {
- BMCWEB_LOG_DEBUG("Power.IdlePowerSaver service mapper error!");
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR(
+ "DBUS response error on Power.IdlePowerSaver GetSubTree {}",
+ ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (subtree.empty())
+ {
+ // This is an optional D-Bus object, but user attempted to patch
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ "IdlePowerSaver");
+ return;
+ }
+ if (subtree.size() > 1)
+ {
+ // More then one PowerIdlePowerSaver object is not supported and
+ // is an error
+ BMCWEB_LOG_DEBUG(
+ "Found more than 1 system D-Bus Power.IdlePowerSaver objects: {}",
+ subtree.size());
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if ((subtree[0].first.empty()) || (subtree[0].second.size() != 1))
+ {
+ BMCWEB_LOG_DEBUG("Power.IdlePowerSaver mapper error!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ const std::string& path = subtree[0].first;
+ const std::string& service = subtree[0].second.begin()->first;
+ if (service.empty())
+ {
+ BMCWEB_LOG_DEBUG("Power.IdlePowerSaver service mapper error!");
+ messages::internalError(asyncResp->res);
+ return;
+ }
- // Valid Power IdlePowerSaver object found, now set any values that
- // need to be updated
+ // Valid Power IdlePowerSaver object found, now set any values that
+ // need to be updated
- if (ipsEnable)
- {
- setDbusProperty(asyncResp, "IdlePowerSaver/Enabled", service, path,
- "xyz.openbmc_project.Control.Power.IdlePowerSaver",
- "Enabled", *ipsEnable);
- }
- if (ipsEnterUtil)
- {
- setDbusProperty(asyncResp, "IdlePowerSaver/EnterUtilizationPercent",
- service, path,
- "xyz.openbmc_project.Control.Power.IdlePowerSaver",
- "EnterUtilizationPercent", *ipsEnterUtil);
- }
- if (ipsEnterTime)
- {
- // Convert from seconds into milliseconds for DBus
- const uint64_t timeMilliseconds = *ipsEnterTime * 1000;
- setDbusProperty(asyncResp, "IdlePowerSaver/EnterDwellTimeSeconds",
- service, path,
- "xyz.openbmc_project.Control.Power.IdlePowerSaver",
- "EnterDwellTime", timeMilliseconds);
- }
- if (ipsExitUtil)
- {
- setDbusProperty(asyncResp, "IdlePowerSaver/ExitUtilizationPercent",
- service, path,
- "xyz.openbmc_project.Control.Power.IdlePowerSaver",
- "ExitUtilizationPercent", *ipsExitUtil);
- }
- if (ipsExitTime)
- {
- // Convert from seconds into milliseconds for DBus
- const uint64_t timeMilliseconds = *ipsExitTime * 1000;
- setDbusProperty(asyncResp, "IdlePowerSaver/ExitDwellTimeSeconds",
- service, path,
- "xyz.openbmc_project.Control.Power.IdlePowerSaver",
- "ExitDwellTime", timeMilliseconds);
- }
- });
+ if (ipsEnable)
+ {
+ setDbusProperty(
+ asyncResp, "IdlePowerSaver/Enabled", service, path,
+ "xyz.openbmc_project.Control.Power.IdlePowerSaver",
+ "Enabled", *ipsEnable);
+ }
+ if (ipsEnterUtil)
+ {
+ setDbusProperty(
+ asyncResp, "IdlePowerSaver/EnterUtilizationPercent",
+ service, path,
+ "xyz.openbmc_project.Control.Power.IdlePowerSaver",
+ "EnterUtilizationPercent", *ipsEnterUtil);
+ }
+ if (ipsEnterTime)
+ {
+ // Convert from seconds into milliseconds for DBus
+ const uint64_t timeMilliseconds = *ipsEnterTime * 1000;
+ setDbusProperty(
+ asyncResp, "IdlePowerSaver/EnterDwellTimeSeconds", service,
+ path, "xyz.openbmc_project.Control.Power.IdlePowerSaver",
+ "EnterDwellTime", timeMilliseconds);
+ }
+ if (ipsExitUtil)
+ {
+ setDbusProperty(
+ asyncResp, "IdlePowerSaver/ExitUtilizationPercent", service,
+ path, "xyz.openbmc_project.Control.Power.IdlePowerSaver",
+ "ExitUtilizationPercent", *ipsExitUtil);
+ }
+ if (ipsExitTime)
+ {
+ // Convert from seconds into milliseconds for DBus
+ const uint64_t timeMilliseconds = *ipsExitTime * 1000;
+ setDbusProperty(
+ asyncResp, "IdlePowerSaver/ExitDwellTimeSeconds", service,
+ path, "xyz.openbmc_project.Control.Power.IdlePowerSaver",
+ "ExitDwellTime", timeMilliseconds);
+ }
+ });
BMCWEB_LOG_DEBUG("EXIT: Set idle power saver parameters");
}
@@ -2823,29 +2833,29 @@
"xyz.openbmc_project.Network.SystemConfiguration", "HostName",
[asyncResp](const boost::system::error_code& ec2,
const std::string& /*hostName*/) {
- if (ec2)
- {
- return;
- }
- auto val = asyncResp->res.jsonValue.find("Members@odata.count");
- if (val == asyncResp->res.jsonValue.end())
- {
- BMCWEB_LOG_CRITICAL("Count wasn't found??");
- return;
- }
- int64_t* count = val->get_ptr<int64_t*>();
- if (count == nullptr)
- {
- BMCWEB_LOG_CRITICAL("Count wasn't found??");
- return;
- }
- *count = *count + 1;
- BMCWEB_LOG_DEBUG("Hypervisor is available");
- nlohmann::json& ifaceArray2 = asyncResp->res.jsonValue["Members"];
- nlohmann::json::object_t hypervisor;
- hypervisor["@odata.id"] = "/redfish/v1/Systems/hypervisor";
- ifaceArray2.emplace_back(std::move(hypervisor));
- });
+ if (ec2)
+ {
+ return;
+ }
+ auto val = asyncResp->res.jsonValue.find("Members@odata.count");
+ if (val == asyncResp->res.jsonValue.end())
+ {
+ BMCWEB_LOG_CRITICAL("Count wasn't found??");
+ return;
+ }
+ int64_t* count = val->get_ptr<int64_t*>();
+ if (count == nullptr)
+ {
+ BMCWEB_LOG_CRITICAL("Count wasn't found??");
+ return;
+ }
+ *count = *count + 1;
+ BMCWEB_LOG_DEBUG("Hypervisor is available");
+ nlohmann::json& ifaceArray2 = asyncResp->res.jsonValue["Members"];
+ nlohmann::json::object_t hypervisor;
+ hypervisor["@odata.id"] = "/redfish/v1/Systems/hypervisor";
+ ifaceArray2.emplace_back(std::move(hypervisor));
+ });
}
/**
@@ -2861,14 +2871,14 @@
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR(" Bad D-Bus request error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- messages::success(asyncResp->res);
- },
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR(" Bad D-Bus request error: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ messages::success(asyncResp->res);
+ },
serviceName, objectPath, interfaceName, method);
}
@@ -3114,15 +3124,15 @@
nlohmann::json::array_t({"KVMIP"});
}
- getMainChassisId(asyncResp,
- [](const std::string& chassisId,
- const std::shared_ptr<bmcweb::AsyncResp>& aRsp) {
- nlohmann::json::array_t chassisArray;
- nlohmann::json& chassis = chassisArray.emplace_back();
- chassis["@odata.id"] = boost::urls::format("/redfish/v1/Chassis/{}",
- chassisId);
- aRsp->res.jsonValue["Links"]["Chassis"] = std::move(chassisArray);
- });
+ getMainChassisId(
+ asyncResp, [](const std::string& chassisId,
+ const std::shared_ptr<bmcweb::AsyncResp>& aRsp) {
+ nlohmann::json::array_t chassisArray;
+ nlohmann::json& chassis = chassisArray.emplace_back();
+ chassis["@odata.id"] =
+ boost::urls::format("/redfish/v1/Chassis/{}", chassisId);
+ aRsp->res.jsonValue["Links"]["Chassis"] = std::move(chassisArray);
+ });
getSystemLocationIndicatorActive(asyncResp);
// TODO (Gunnar): Remove IndicatorLED after enough time has passed
@@ -3445,8 +3455,9 @@
"AllowedHostTransitions",
[asyncResp](const boost::system::error_code& ec,
const std::vector<std::string>& allowedHostTransitions) {
- afterGetAllowedHostTransitions(asyncResp, ec, allowedHostTransitions);
- });
+ afterGetAllowedHostTransitions(asyncResp, ec,
+ allowedHostTransitions);
+ });
}
/**
* SystemResetActionInfo derived class for delivering Computer Systems
diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp
index 084e561..78193bc 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -74,8 +74,8 @@
continue;
}
std::string header;
- header.reserve(field.name_string().size() + 2 +
- field.value().size());
+ header.reserve(
+ field.name_string().size() + 2 + field.value().size());
header += field.name_string();
header += ": ";
header += field.value();
@@ -97,8 +97,7 @@
std::function<bool(boost::system::error_code, sdbusplus::message_t&,
const std::shared_ptr<TaskData>&)>&& handler,
const std::string& matchIn, size_t idx) :
- callback(std::move(handler)),
- matchStr(matchIn), index(idx),
+ callback(std::move(handler)), matchStr(matchIn), index(idx),
startTime(std::chrono::system_clock::to_time_t(
std::chrono::system_clock::now())),
status("OK"), state("Running"), messages(nlohmann::json::array()),
@@ -181,26 +180,26 @@
timer.expires_after(timeout);
timer.async_wait(
[self = shared_from_this()](boost::system::error_code ec) {
- if (ec == boost::asio::error::operation_aborted)
- {
- return; // completed successfully
- }
- if (!ec)
- {
- // change ec to error as timer expired
- ec = boost::asio::error::operation_aborted;
- }
- self->match.reset();
- sdbusplus::message_t msg;
- self->finishTask();
- self->state = "Cancelled";
- self->status = "Warning";
- self->messages.emplace_back(
- messages::taskAborted(std::to_string(self->index)));
- // Send event :TaskAborted
- self->sendTaskEvent(self->state, self->index);
- self->callback(ec, msg, self);
- });
+ if (ec == boost::asio::error::operation_aborted)
+ {
+ return; // completed successfully
+ }
+ if (!ec)
+ {
+ // change ec to error as timer expired
+ ec = boost::asio::error::operation_aborted;
+ }
+ self->match.reset();
+ sdbusplus::message_t msg;
+ self->finishTask();
+ self->state = "Cancelled";
+ self->status = "Warning";
+ self->messages.emplace_back(
+ messages::taskAborted(std::to_string(self->index)));
+ // Send event :TaskAborted
+ self->sendTaskEvent(self->state, self->index);
+ self->callback(ec, msg, self);
+ });
}
static void sendTaskEvent(std::string_view state, size_t index)
@@ -272,25 +271,25 @@
static_cast<sdbusplus::bus_t&>(*crow::connections::systemBus),
matchStr,
[self = shared_from_this()](sdbusplus::message_t& message) {
- boost::system::error_code ec;
+ boost::system::error_code ec;
- // callback to return True if callback is done, callback needs
- // to update status itself if needed
- if (self->callback(ec, message, self) == task::completed)
- {
- self->timer.cancel();
- self->finishTask();
+ // callback to return True if callback is done, callback needs
+ // to update status itself if needed
+ if (self->callback(ec, message, self) == task::completed)
+ {
+ self->timer.cancel();
+ self->finishTask();
- // Send event
- self->sendTaskEvent(self->state, self->index);
+ // Send event
+ self->sendTaskEvent(self->state, self->index);
- // reset the match after the callback was successful
- boost::asio::post(
- crow::connections::systemBus->get_io_context(),
- [self] { self->match.reset(); });
- return;
- }
- });
+ // reset the match after the callback was successful
+ boost::asio::post(
+ crow::connections::systemBus->get_io_context(),
+ [self] { self->match.reset(); });
+ return;
+ }
+ });
extendTimer(timeout);
messages.emplace_back(messages::taskStarted(std::to_string(index)));
@@ -325,37 +324,39 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& strParam) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- auto find = std::ranges::find_if(
- task::tasks,
- [&strParam](const std::shared_ptr<task::TaskData>& task) {
- if (!task)
- {
- return false;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ auto find = std::ranges::find_if(
+ task::tasks,
+ [&strParam](const std::shared_ptr<task::TaskData>& task) {
+ if (!task)
+ {
+ return false;
+ }
- // we compare against the string version as on failure
- // strtoul returns 0
- return std::to_string(task->index) == strParam;
- });
+ // we compare against the string version as on failure
+ // strtoul returns 0
+ return std::to_string(task->index) == strParam;
+ });
- if (find == task::tasks.end())
- {
- messages::resourceNotFound(asyncResp->res, "Task", strParam);
- return;
- }
- std::shared_ptr<task::TaskData>& ptr = *find;
- // monitor expires after 204
- if (ptr->gave204)
- {
- messages::resourceNotFound(asyncResp->res, "Task", strParam);
- return;
- }
- ptr->populateResp(asyncResp->res);
- });
+ if (find == task::tasks.end())
+ {
+ messages::resourceNotFound(asyncResp->res, "Task",
+ strParam);
+ return;
+ }
+ std::shared_ptr<task::TaskData>& ptr = *find;
+ // monitor expires after 204
+ if (ptr->gave204)
+ {
+ messages::resourceNotFound(asyncResp->res, "Task",
+ strParam);
+ return;
+ }
+ ptr->populateResp(asyncResp->res);
+ });
}
inline void requestRoutesTask(App& app)
@@ -366,66 +367,75 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& strParam) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- auto find = std::ranges::find_if(
- task::tasks,
- [&strParam](const std::shared_ptr<task::TaskData>& task) {
- if (!task)
- {
- return false;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ auto find = std::ranges::find_if(
+ task::tasks,
+ [&strParam](const std::shared_ptr<task::TaskData>& task) {
+ if (!task)
+ {
+ return false;
+ }
- // we compare against the string version as on failure
- // strtoul returns 0
- return std::to_string(task->index) == strParam;
- });
+ // we compare against the string version as on failure
+ // strtoul returns 0
+ return std::to_string(task->index) == strParam;
+ });
- if (find == task::tasks.end())
- {
- messages::resourceNotFound(asyncResp->res, "Task", strParam);
- return;
- }
+ if (find == task::tasks.end())
+ {
+ messages::resourceNotFound(asyncResp->res, "Task",
+ strParam);
+ return;
+ }
- const std::shared_ptr<task::TaskData>& ptr = *find;
+ const std::shared_ptr<task::TaskData>& ptr = *find;
- asyncResp->res.jsonValue["@odata.type"] = "#Task.v1_4_3.Task";
- asyncResp->res.jsonValue["Id"] = strParam;
- asyncResp->res.jsonValue["Name"] = "Task " + strParam;
- asyncResp->res.jsonValue["TaskState"] = ptr->state;
- asyncResp->res.jsonValue["StartTime"] =
- redfish::time_utils::getDateTimeStdtime(ptr->startTime);
- if (ptr->endTime)
- {
- asyncResp->res.jsonValue["EndTime"] =
- redfish::time_utils::getDateTimeStdtime(*(ptr->endTime));
- }
- asyncResp->res.jsonValue["TaskStatus"] = ptr->status;
- asyncResp->res.jsonValue["Messages"] = ptr->messages;
- asyncResp->res.jsonValue["@odata.id"] =
- boost::urls::format("/redfish/v1/TaskService/Tasks/{}", strParam);
- if (!ptr->gave204)
- {
- asyncResp->res.jsonValue["TaskMonitor"] = boost::urls::format(
- "/redfish/v1/TaskService/TaskMonitors/{}", strParam);
- }
+ asyncResp->res.jsonValue["@odata.type"] = "#Task.v1_4_3.Task";
+ asyncResp->res.jsonValue["Id"] = strParam;
+ asyncResp->res.jsonValue["Name"] = "Task " + strParam;
+ asyncResp->res.jsonValue["TaskState"] = ptr->state;
+ asyncResp->res.jsonValue["StartTime"] =
+ redfish::time_utils::getDateTimeStdtime(ptr->startTime);
+ if (ptr->endTime)
+ {
+ asyncResp->res.jsonValue["EndTime"] =
+ redfish::time_utils::getDateTimeStdtime(
+ *(ptr->endTime));
+ }
+ asyncResp->res.jsonValue["TaskStatus"] = ptr->status;
+ asyncResp->res.jsonValue["Messages"] = ptr->messages;
+ asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
+ "/redfish/v1/TaskService/Tasks/{}", strParam);
+ if (!ptr->gave204)
+ {
+ asyncResp->res.jsonValue["TaskMonitor"] =
+ boost::urls::format(
+ "/redfish/v1/TaskService/TaskMonitors/{}",
+ strParam);
+ }
- asyncResp->res.jsonValue["HidePayload"] = !ptr->payload;
+ asyncResp->res.jsonValue["HidePayload"] = !ptr->payload;
- if (ptr->payload)
- {
- const task::Payload& p = *(ptr->payload);
- asyncResp->res.jsonValue["Payload"]["TargetUri"] = p.targetUri;
- asyncResp->res.jsonValue["Payload"]["HttpOperation"] =
- p.httpOperation;
- asyncResp->res.jsonValue["Payload"]["HttpHeaders"] = p.httpHeaders;
- asyncResp->res.jsonValue["Payload"]["JsonBody"] = p.jsonBody.dump(
- -1, ' ', true, nlohmann::json::error_handler_t::replace);
- }
- asyncResp->res.jsonValue["PercentComplete"] = ptr->percentComplete;
- });
+ if (ptr->payload)
+ {
+ const task::Payload& p = *(ptr->payload);
+ asyncResp->res.jsonValue["Payload"]["TargetUri"] =
+ p.targetUri;
+ asyncResp->res.jsonValue["Payload"]["HttpOperation"] =
+ p.httpOperation;
+ asyncResp->res.jsonValue["Payload"]["HttpHeaders"] =
+ p.httpHeaders;
+ asyncResp->res.jsonValue["Payload"]["JsonBody"] =
+ p.jsonBody.dump(
+ -1, ' ', true,
+ nlohmann::json::error_handler_t::replace);
+ }
+ asyncResp->res.jsonValue["PercentComplete"] =
+ ptr->percentComplete;
+ });
}
inline void requestRoutesTaskCollection(App& app)
@@ -435,31 +445,33 @@
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- asyncResp->res.jsonValue["@odata.type"] =
- "#TaskCollection.TaskCollection";
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TaskService/Tasks";
- asyncResp->res.jsonValue["Name"] = "Task Collection";
- asyncResp->res.jsonValue["Members@odata.count"] = task::tasks.size();
- nlohmann::json& members = asyncResp->res.jsonValue["Members"];
- members = nlohmann::json::array();
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#TaskCollection.TaskCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/TaskService/Tasks";
+ asyncResp->res.jsonValue["Name"] = "Task Collection";
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ task::tasks.size();
+ nlohmann::json& members = asyncResp->res.jsonValue["Members"];
+ members = nlohmann::json::array();
- for (const std::shared_ptr<task::TaskData>& task : task::tasks)
- {
- if (task == nullptr)
- {
- continue; // shouldn't be possible
- }
- nlohmann::json::object_t member;
- member["@odata.id"] =
- boost::urls::format("/redfish/v1/TaskService/Tasks/{}",
- std::to_string(task->index));
- members.emplace_back(std::move(member));
- }
- });
+ for (const std::shared_ptr<task::TaskData>& task : task::tasks)
+ {
+ if (task == nullptr)
+ {
+ continue; // shouldn't be possible
+ }
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ boost::urls::format("/redfish/v1/TaskService/Tasks/{}",
+ std::to_string(task->index));
+ members.emplace_back(std::move(member));
+ }
+ });
}
inline void requestRoutesTaskService(App& app)
@@ -469,27 +481,30 @@
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- asyncResp->res.jsonValue["@odata.type"] =
- "#TaskService.v1_1_4.TaskService";
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TaskService";
- asyncResp->res.jsonValue["Name"] = "Task Service";
- asyncResp->res.jsonValue["Id"] = "TaskService";
- asyncResp->res.jsonValue["DateTime"] =
- redfish::time_utils::getDateTimeOffsetNow().first;
- asyncResp->res.jsonValue["CompletedTaskOverWritePolicy"] =
- task_service::OverWritePolicy::Oldest;
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#TaskService.v1_1_4.TaskService";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/TaskService";
+ asyncResp->res.jsonValue["Name"] = "Task Service";
+ asyncResp->res.jsonValue["Id"] = "TaskService";
+ asyncResp->res.jsonValue["DateTime"] =
+ redfish::time_utils::getDateTimeOffsetNow().first;
+ asyncResp->res.jsonValue["CompletedTaskOverWritePolicy"] =
+ task_service::OverWritePolicy::Oldest;
- asyncResp->res.jsonValue["LifeCycleEventOnTaskStateChange"] = true;
+ asyncResp->res.jsonValue["LifeCycleEventOnTaskStateChange"] =
+ true;
- asyncResp->res.jsonValue["Status"]["State"] = resource::State::Enabled;
- asyncResp->res.jsonValue["ServiceEnabled"] = true;
- asyncResp->res.jsonValue["Tasks"]["@odata.id"] =
- "/redfish/v1/TaskService/Tasks";
- });
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Enabled;
+ asyncResp->res.jsonValue["ServiceEnabled"] = true;
+ asyncResp->res.jsonValue["Tasks"]["@odata.id"] =
+ "/redfish/v1/TaskService/Tasks";
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp
index 19eccba..cd051dc 100644
--- a/redfish-core/lib/telemetry_service.hpp
+++ b/redfish-core/lib/telemetry_service.hpp
@@ -42,54 +42,55 @@
"xyz.openbmc_project.Telemetry.ReportManager",
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& ret) {
- if (ec == boost::system::errc::host_unreachable)
- {
+ if (ec == boost::system::errc::host_unreachable)
+ {
+ asyncResp->res.jsonValue["Status"]["State"] =
+ resource::State::Absent;
+ return;
+ }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("respHandler DBus error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
asyncResp->res.jsonValue["Status"]["State"] =
- resource::State::Absent;
- return;
- }
- if (ec)
- {
- BMCWEB_LOG_ERROR("respHandler DBus error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ resource::State::Enabled;
- asyncResp->res.jsonValue["Status"]["State"] = resource::State::Enabled;
+ const size_t* maxReports = nullptr;
+ const uint64_t* minInterval = nullptr;
- const size_t* maxReports = nullptr;
- const uint64_t* minInterval = nullptr;
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), ret, "MaxReports", maxReports,
+ "MinInterval", minInterval);
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), ret, "MaxReports", maxReports,
- "MinInterval", minInterval);
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (maxReports != nullptr)
+ {
+ asyncResp->res.jsonValue["MaxReports"] = *maxReports;
+ }
- if (maxReports != nullptr)
- {
- asyncResp->res.jsonValue["MaxReports"] = *maxReports;
- }
+ if (minInterval != nullptr)
+ {
+ asyncResp->res.jsonValue["MinCollectionInterval"] =
+ time_utils::toDurationString(std::chrono::milliseconds(
+ static_cast<time_t>(*minInterval)));
+ }
+ nlohmann::json::array_t supportedCollectionFunctions;
+ supportedCollectionFunctions.emplace_back("Maximum");
+ supportedCollectionFunctions.emplace_back("Minimum");
+ supportedCollectionFunctions.emplace_back("Average");
+ supportedCollectionFunctions.emplace_back("Summation");
- if (minInterval != nullptr)
- {
- asyncResp->res.jsonValue["MinCollectionInterval"] =
- time_utils::toDurationString(std::chrono::milliseconds(
- static_cast<time_t>(*minInterval)));
- }
- nlohmann::json::array_t supportedCollectionFunctions;
- supportedCollectionFunctions.emplace_back("Maximum");
- supportedCollectionFunctions.emplace_back("Minimum");
- supportedCollectionFunctions.emplace_back("Average");
- supportedCollectionFunctions.emplace_back("Summation");
-
- asyncResp->res.jsonValue["SupportedCollectionFunctions"] =
- std::move(supportedCollectionFunctions);
- });
+ asyncResp->res.jsonValue["SupportedCollectionFunctions"] =
+ std::move(supportedCollectionFunctions);
+ });
}
inline void requestRoutesTelemetryService(App& app)
diff --git a/redfish-core/lib/thermal.hpp b/redfish-core/lib/thermal.hpp
index 84bf37a..7a5586f 100644
--- a/redfish-core/lib/thermal.hpp
+++ b/redfish-core/lib/thermal.hpp
@@ -32,18 +32,18 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& chassisName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
- asyncResp, chassisName, sensors::dbus::thermalPaths,
- sensors::node::thermal);
+ auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
+ asyncResp, chassisName, sensors::dbus::thermalPaths,
+ sensors::node::thermal);
- // TODO Need to get Chassis Redundancy information.
- getChassisData(sensorAsyncResp);
- });
+ // TODO Need to get Chassis Redundancy information.
+ getChassisData(sensorAsyncResp);
+ });
BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Thermal/")
.privileges(redfish::privileges::patchThermal)
@@ -51,44 +51,47 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& chassisName) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
- std::optional<std::vector<nlohmann::json::object_t>>
- temperatureCollections;
- std::optional<std::vector<nlohmann::json::object_t>> fanCollections;
- std::unordered_map<std::string, std::vector<nlohmann::json::object_t>>
- allCollections;
+ std::optional<std::vector<nlohmann::json::object_t>>
+ temperatureCollections;
+ std::optional<std::vector<nlohmann::json::object_t>>
+ fanCollections;
+ std::unordered_map<std::string,
+ std::vector<nlohmann::json::object_t>>
+ allCollections;
- auto sensorsAsyncResp = std::make_shared<SensorsAsyncResp>(
- asyncResp, chassisName, sensors::dbus::thermalPaths,
- sensors::node::thermal);
+ auto sensorsAsyncResp = std::make_shared<SensorsAsyncResp>(
+ asyncResp, chassisName, sensors::dbus::thermalPaths,
+ sensors::node::thermal);
- if (!json_util::readJsonPatch(req, sensorsAsyncResp->asyncResp->res,
- "Temperatures", temperatureCollections,
- "Fans", fanCollections))
- {
- return;
- }
- if (!temperatureCollections && !fanCollections)
- {
- messages::resourceNotFound(sensorsAsyncResp->asyncResp->res,
- "Thermal", "Temperatures / Voltages");
- return;
- }
- if (temperatureCollections)
- {
- allCollections.emplace("Temperatures",
- *std::move(temperatureCollections));
- }
- if (fanCollections)
- {
- allCollections.emplace("Fans", *std::move(fanCollections));
- }
- setSensorsOverride(sensorsAsyncResp, allCollections);
- });
+ if (!json_util::readJsonPatch(
+ req, sensorsAsyncResp->asyncResp->res, "Temperatures",
+ temperatureCollections, "Fans", fanCollections))
+ {
+ return;
+ }
+ if (!temperatureCollections && !fanCollections)
+ {
+ messages::resourceNotFound(sensorsAsyncResp->asyncResp->res,
+ "Thermal",
+ "Temperatures / Voltages");
+ return;
+ }
+ if (temperatureCollections)
+ {
+ allCollections.emplace("Temperatures",
+ *std::move(temperatureCollections));
+ }
+ if (fanCollections)
+ {
+ allCollections.emplace("Fans", *std::move(fanCollections));
+ }
+ setSensorsOverride(sensorsAsyncResp, allCollections);
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/thermal_metrics.hpp b/redfish-core/lib/thermal_metrics.hpp
index f254118..da4da01 100644
--- a/redfish-core/lib/thermal_metrics.hpp
+++ b/redfish-core/lib/thermal_metrics.hpp
@@ -48,15 +48,16 @@
asyncResp, chassisId,
[asyncResp,
chassisId](const std::optional<std::string>& validChassisPath) {
- if (!validChassisPath)
- {
- messages::resourceNotFound(asyncResp->res, "Chassis", chassisId);
- return;
- }
- asyncResp->res.addHeader(
- boost::beast::http::field::link,
- "</redfish/v1/JsonSchemas/ThermalMetrics/ThermalMetrics.json>; rel=describedby");
- });
+ if (!validChassisPath)
+ {
+ messages::resourceNotFound(asyncResp->res, "Chassis",
+ chassisId);
+ return;
+ }
+ asyncResp->res.addHeader(
+ boost::beast::http::field::link,
+ "</redfish/v1/JsonSchemas/ThermalMetrics/ThermalMetrics.json>; rel=describedby");
+ });
}
inline void
diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp
index 02885d2..8bfd632 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -322,9 +322,8 @@
}
};
-inline bool parseNumericThresholds(crow::Response& res,
- NumericThresholds& numericThresholds,
- Context& ctx)
+inline bool parseNumericThresholds(
+ crow::Response& res, NumericThresholds& numericThresholds, Context& ctx)
{
std::vector<NumericThresholdParams> parsedParams;
if (numericThresholds.upperCritical)
@@ -576,8 +575,8 @@
return false;
}
- std::string sensorPath = "/xyz/openbmc_project/sensors/" + split.first +
- '/' + split.second;
+ std::string sensorPath =
+ "/xyz/openbmc_project/sensors/" + split.first + '/' + split.second;
ctx.sensors.emplace_back(sensorPath, uriStr);
uriIdx++;
@@ -957,8 +956,8 @@
crow::connections::systemBus->async_method_call(
[asyncResp, id = ctx.id](const boost::system::error_code& ec,
const std::string& dbusPath) {
- afterCreateTrigger(ec, dbusPath, asyncResp, id);
- },
+ afterCreateTrigger(ec, dbusPath, asyncResp, id);
+ },
service, "/xyz/openbmc_project/Telemetry/Triggers",
"xyz.openbmc_project.Telemetry.TriggerManager", "AddTrigger",
"TelemetryService/" + ctx.id, ctx.name, ctx.actions, ctx.sensors,
@@ -974,23 +973,23 @@
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- asyncResp->res.jsonValue["@odata.type"] =
- "#TriggersCollection.TriggersCollection";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/TelemetryService/Triggers";
- asyncResp->res.jsonValue["Name"] = "Triggers Collection";
- constexpr std::array<std::string_view, 1> interfaces{
- telemetry::triggerInterface};
- collection_util::getCollectionMembers(
- asyncResp,
- boost::urls::url("/redfish/v1/TelemetryService/Triggers"),
- interfaces,
- "/xyz/openbmc_project/Telemetry/Triggers/TelemetryService");
- });
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#TriggersCollection.TriggersCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/TelemetryService/Triggers";
+ asyncResp->res.jsonValue["Name"] = "Triggers Collection";
+ constexpr std::array<std::string_view, 1> interfaces{
+ telemetry::triggerInterface};
+ collection_util::getCollectionMembers(
+ asyncResp,
+ boost::urls::url("/redfish/v1/TelemetryService/Triggers"),
+ interfaces,
+ "/xyz/openbmc_project/Telemetry/Triggers/TelemetryService");
+ });
BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/Triggers/")
.privileges(redfish::privileges::postTriggersCollection)
@@ -1006,36 +1005,40 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& id) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- sdbusplus::asio::getAllProperties(
- *crow::connections::systemBus, telemetry::service,
- telemetry::getDbusTriggerPath(id), telemetry::triggerInterface,
- [asyncResp,
- id](const boost::system::error_code& ec,
- const std::vector<std::pair<
- std::string, telemetry::TriggerGetParamsVariant>>& ret) {
- if (ec.value() == EBADR ||
- ec == boost::system::errc::host_unreachable)
- {
- messages::resourceNotFound(asyncResp->res, "Triggers", id);
- return;
- }
- if (ec)
- {
- BMCWEB_LOG_ERROR("respHandler DBus error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ sdbusplus::asio::getAllProperties(
+ *crow::connections::systemBus, telemetry::service,
+ telemetry::getDbusTriggerPath(id),
+ telemetry::triggerInterface,
+ [asyncResp,
+ id](const boost::system::error_code& ec,
+ const std::vector<std::pair<
+ std::string, telemetry::TriggerGetParamsVariant>>&
+ ret) {
+ if (ec.value() == EBADR ||
+ ec == boost::system::errc::host_unreachable)
+ {
+ messages::resourceNotFound(asyncResp->res,
+ "Triggers", id);
+ return;
+ }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("respHandler DBus error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (!telemetry::fillTrigger(asyncResp->res.jsonValue, id, ret))
- {
- messages::internalError(asyncResp->res);
- }
- });
- });
+ if (!telemetry::fillTrigger(asyncResp->res.jsonValue,
+ id, ret))
+ {
+ messages::internalError(asyncResp->res);
+ }
+ });
+ });
BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/Triggers/<str>/")
.privileges(redfish::privileges::deleteTriggers)
@@ -1043,32 +1046,35 @@
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& id) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp))
- {
- return;
- }
- const std::string triggerPath = telemetry::getDbusTriggerPath(id);
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ const std::string triggerPath =
+ telemetry::getDbusTriggerPath(id);
- crow::connections::systemBus->async_method_call(
- [asyncResp, id](const boost::system::error_code& ec) {
- if (ec.value() == EBADR)
- {
- messages::resourceNotFound(asyncResp->res, "Triggers", id);
- return;
- }
+ crow::connections::systemBus->async_method_call(
+ [asyncResp, id](const boost::system::error_code& ec) {
+ if (ec.value() == EBADR)
+ {
+ messages::resourceNotFound(asyncResp->res,
+ "Triggers", id);
+ return;
+ }
- if (ec)
- {
- BMCWEB_LOG_ERROR("respHandler DBus error {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("respHandler DBus error {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
- asyncResp->res.result(boost::beast::http::status::no_content);
- },
- telemetry::service, triggerPath,
- "xyz.openbmc_project.Object.Delete", "Delete");
- });
+ asyncResp->res.result(
+ boost::beast::http::status::no_content);
+ },
+ telemetry::service, triggerPath,
+ "xyz.openbmc_project.Object.Delete", "Delete");
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index f44615d..538b261 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -118,12 +118,12 @@
"xyz.openbmc_project.Software.Activation", "RequestedActivation",
"xyz.openbmc_project.Software.Activation.RequestedActivations.Active",
[](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("error_code = {}", ec);
- BMCWEB_LOG_DEBUG("error msg = {}", ec.message());
- }
- });
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG("error_code = {}", ec);
+ BMCWEB_LOG_DEBUG("error msg = {}", ec.message());
+ }
+ });
}
inline bool handleCreateTask(const boost::system::error_code& ec2,
@@ -270,40 +270,41 @@
const std::vector<
std::pair<std::string, std::vector<std::string>>>&
objInfo) mutable {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("error_code = {}", ec);
- BMCWEB_LOG_DEBUG("error msg = {}", ec.message());
- if (asyncResp)
+ if (ec)
{
- messages::internalError(asyncResp->res);
+ BMCWEB_LOG_DEBUG("error_code = {}", ec);
+ BMCWEB_LOG_DEBUG("error msg = {}", ec.message());
+ if (asyncResp)
+ {
+ messages::internalError(asyncResp->res);
+ }
+ cleanUp();
+ return;
}
- cleanUp();
- return;
- }
- // Ensure we only got one service back
- if (objInfo.size() != 1)
- {
- BMCWEB_LOG_ERROR("Invalid Object Size {}", objInfo.size());
- if (asyncResp)
+ // Ensure we only got one service back
+ if (objInfo.size() != 1)
{
- messages::internalError(asyncResp->res);
+ BMCWEB_LOG_ERROR("Invalid Object Size {}",
+ objInfo.size());
+ if (asyncResp)
+ {
+ messages::internalError(asyncResp->res);
+ }
+ cleanUp();
+ return;
}
- cleanUp();
- return;
- }
- // cancel timer only when
- // xyz.openbmc_project.Software.Activation interface
- // is added
- fwAvailableTimer = nullptr;
+ // cancel timer only when
+ // xyz.openbmc_project.Software.Activation interface
+ // is added
+ fwAvailableTimer = nullptr;
- activateImage(objPath.str, objInfo[0].first);
- if (asyncResp)
- {
- createTask(asyncResp, std::move(payload), objPath);
- }
- fwUpdateInProgress = false;
- });
+ activateImage(objPath.str, objInfo[0].first);
+ if (asyncResp)
+ {
+ createTask(asyncResp, std::move(payload), objPath);
+ }
+ fwUpdateInProgress = false;
+ });
break;
}
@@ -485,10 +486,9 @@
std::bind_front(afterUpdateErrorMatcher, asyncResp, url));
}
-inline std::optional<boost::urls::url>
- parseSimpleUpdateUrl(std::string imageURI,
- std::optional<std::string> transferProtocol,
- crow::Response& res)
+inline std::optional<boost::urls::url> parseSimpleUpdateUrl(
+ std::string imageURI, std::optional<std::string> transferProtocol,
+ crow::Response& res)
{
if (imageURI.find("://") == std::string::npos)
{
@@ -629,8 +629,8 @@
std::ofstream out(filepath, std::ofstream::out | std::ofstream::binary |
std::ofstream::trunc);
// set the permission of the file to 640
- std::filesystem::perms permission = std::filesystem::perms::owner_read |
- std::filesystem::perms::group_read;
+ std::filesystem::perms permission =
+ std::filesystem::perms::owner_read | std::filesystem::perms::group_read;
std::filesystem::permissions(filepath, permission);
out << body;
@@ -751,8 +751,8 @@
if (param.second == "UpdateParameters")
{
std::vector<std::string> tempTargets;
- nlohmann::json content = nlohmann::json::parse(formpart.content,
- nullptr, false);
+ nlohmann::json content =
+ nlohmann::json::parse(formpart.content, nullptr, false);
if (content.is_discarded())
{
return std::nullopt;
@@ -817,11 +817,10 @@
return multiRet;
}
-inline void
- handleStartUpdate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- task::Payload payload, const std::string& objectPath,
- const boost::system::error_code& ec,
- const sdbusplus::message::object_path& retPath)
+inline void handleStartUpdate(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, task::Payload payload,
+ const std::string& objectPath, const boost::system::error_code& ec,
+ const sdbusplus::message::object_path& retPath)
{
if (ec)
{
@@ -836,20 +835,18 @@
createTask(asyncResp, std::move(payload), retPath);
}
-inline void startUpdate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- task::Payload payload,
- const MemoryFileDescriptor& memfd,
- const std::string& applyTime,
- const std::string& objectPath,
- const std::string& serviceName)
+inline void startUpdate(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, task::Payload payload,
+ const MemoryFileDescriptor& memfd, const std::string& applyTime,
+ const std::string& objectPath, const std::string& serviceName)
{
crow::connections::systemBus->async_method_call(
[asyncResp, payload = std::move(payload),
objectPath](const boost::system::error_code& ec1,
const sdbusplus::message::object_path& retPath) mutable {
- handleStartUpdate(asyncResp, std::move(payload), objectPath, ec1,
- retPath);
- },
+ handleStartUpdate(asyncResp, std::move(payload), objectPath, ec1,
+ retPath);
+ },
serviceName, objectPath, "xyz.openbmc_project.Software.Update",
"StartUpdate", sdbusplus::message::unix_fd(memfd.fd), applyTime);
}
@@ -895,12 +892,11 @@
swEntry->second.first.str, swEntry->second.second);
}
-inline void
- handleBMCUpdate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- task::Payload payload, const MemoryFileDescriptor& memfd,
- const std::string& applyTime,
- const boost::system::error_code& ec,
- const dbus::utility::MapperEndPoints& functionalSoftware)
+inline void handleBMCUpdate(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, task::Payload payload,
+ const MemoryFileDescriptor& memfd, const std::string& applyTime,
+ const boost::system::error_code& ec,
+ const dbus::utility::MapperEndPoints& functionalSoftware)
{
if (ec)
{
@@ -921,11 +917,10 @@
functionalSoftware[0], "xyz.openbmc_project.Software.Manager");
}
-inline void
- processUpdateRequest(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- task::Payload&& payload, std::string_view body,
- const std::string& applyTime,
- std::vector<std::string>& targets)
+inline void processUpdateRequest(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ task::Payload&& payload, std::string_view body,
+ const std::string& applyTime, std::vector<std::string>& targets)
{
MemoryFileDescriptor memfd("update-image");
if (memfd.fd == -1)
@@ -955,9 +950,9 @@
applyTime](
const boost::system::error_code& ec,
const dbus::utility::MapperEndPoints& objectPaths) mutable {
- handleBMCUpdate(asyncResp, std::move(payload), memfd, applyTime, ec,
- objectPaths);
- });
+ handleBMCUpdate(asyncResp, std::move(payload), memfd, applyTime,
+ ec, objectPaths);
+ });
}
else
{
@@ -969,9 +964,9 @@
applyTime, targets](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse&
subtree) mutable {
- getSwInfo(asyncResp, std::move(payload), memfd, applyTime,
- targets[0], ec, subtree);
- });
+ getSwInfo(asyncResp, std::move(payload), memfd, applyTime,
+ targets[0], ec, subtree);
+ });
}
}
@@ -1109,8 +1104,8 @@
asyncResp->res.jsonValue["FirmwareInventory"]["@odata.id"] =
"/redfish/v1/UpdateService/FirmwareInventory";
// Get the MaxImageSizeBytes
- asyncResp->res.jsonValue["MaxImageSizeBytes"] = BMCWEB_HTTP_BODY_LIMIT *
- 1024 * 1024;
+ asyncResp->res.jsonValue["MaxImageSizeBytes"] =
+ BMCWEB_HTTP_BODY_LIMIT * 1024 * 1024;
// Update Actions object.
nlohmann::json& updateSvcSimpleUpdate =
@@ -1197,65 +1192,65 @@
[asyncResp,
swId](const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& propertiesList) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- const std::string* swInvPurpose = nullptr;
- const std::string* version = nullptr;
+ const std::string* swInvPurpose = nullptr;
+ const std::string* version = nullptr;
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), propertiesList, "Purpose",
- swInvPurpose, "Version", version);
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), propertiesList, "Purpose",
+ swInvPurpose, "Version", version);
- if (!success)
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ if (!success)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (swInvPurpose == nullptr)
- {
- BMCWEB_LOG_DEBUG("Can't find property \"Purpose\"!");
- messages::internalError(asyncResp->res);
- return;
- }
+ if (swInvPurpose == nullptr)
+ {
+ 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\"!");
+ if (version == nullptr)
+ {
+ BMCWEB_LOG_DEBUG("Can't find property \"Version\"!");
- messages::internalError(asyncResp->res);
+ messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["Version"] = *version;
- asyncResp->res.jsonValue["Id"] = swId;
+ return;
+ }
+ asyncResp->res.jsonValue["Version"] = *version;
+ asyncResp->res.jsonValue["Id"] = swId;
- // swInvPurpose is of format:
- // xyz.openbmc_project.Software.Version.VersionPurpose.ABC
- // Translate this to "ABC image"
- size_t endDesc = swInvPurpose->rfind('.');
- if (endDesc == std::string::npos)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- endDesc++;
- if (endDesc >= swInvPurpose->size())
- {
- messages::internalError(asyncResp->res);
- return;
- }
+ // swInvPurpose is of format:
+ // xyz.openbmc_project.Software.Version.VersionPurpose.ABC
+ // Translate this to "ABC image"
+ size_t endDesc = swInvPurpose->rfind('.');
+ if (endDesc == std::string::npos)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ endDesc++;
+ if (endDesc >= swInvPurpose->size())
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
- std::string formatDesc = swInvPurpose->substr(endDesc);
- asyncResp->res.jsonValue["Description"] = formatDesc + " image";
- getRelatedItems(asyncResp, *swInvPurpose);
- });
+ std::string formatDesc = swInvPurpose->substr(endDesc);
+ asyncResp->res.jsonValue["Description"] = formatDesc + " image";
+ getRelatedItems(asyncResp, *swInvPurpose);
+ });
}
inline void handleUpdateServiceFirmwareInventoryGet(
@@ -1279,53 +1274,54 @@
[asyncResp,
swId](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- BMCWEB_LOG_DEBUG("doGet callback...");
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
- // Ensure we find our input swId, otherwise return an error
- bool found = false;
- for (const std::pair<
- std::string,
- std::vector<std::pair<std::string, std::vector<std::string>>>>&
- obj : subtree)
- {
- if (!obj.first.ends_with(*swId))
+ BMCWEB_LOG_DEBUG("doGet callback...");
+ if (ec)
{
- continue;
+ messages::internalError(asyncResp->res);
+ return;
}
- if (obj.second.empty())
+ // Ensure we find our input swId, otherwise return an error
+ bool found = false;
+ for (const std::pair<std::string,
+ std::vector<std::pair<
+ std::string, std::vector<std::string>>>>&
+ obj : subtree)
{
- continue;
+ if (!obj.first.ends_with(*swId))
+ {
+ continue;
+ }
+
+ if (obj.second.empty())
+ {
+ continue;
+ }
+
+ found = true;
+ sw_util::getSwStatus(asyncResp, swId, obj.second[0].first);
+ getSoftwareVersion(asyncResp, obj.second[0].first, obj.first,
+ *swId);
}
+ if (!found)
+ {
+ BMCWEB_LOG_WARNING("Input swID {} not found!", *swId);
+ messages::resourceMissingAtURI(
+ asyncResp->res,
+ boost::urls::format(
+ "/redfish/v1/UpdateService/FirmwareInventory/{}",
+ *swId));
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#SoftwareInventory.v1_1_0.SoftwareInventory";
+ asyncResp->res.jsonValue["Name"] = "Software Inventory";
+ asyncResp->res.jsonValue["Status"]["HealthRollup"] =
+ resource::Health::OK;
- found = true;
- sw_util::getSwStatus(asyncResp, swId, obj.second[0].first);
- getSoftwareVersion(asyncResp, obj.second[0].first, obj.first,
- *swId);
- }
- if (!found)
- {
- BMCWEB_LOG_WARNING("Input swID {} not found!", *swId);
- messages::resourceMissingAtURI(
- asyncResp->res,
- boost::urls::format(
- "/redfish/v1/UpdateService/FirmwareInventory/{}", *swId));
- return;
- }
- asyncResp->res.jsonValue["@odata.type"] =
- "#SoftwareInventory.v1_1_0.SoftwareInventory";
- asyncResp->res.jsonValue["Name"] = "Software Inventory";
- asyncResp->res.jsonValue["Status"]["HealthRollup"] =
- resource::Health::OK;
-
- asyncResp->res.jsonValue["Updateable"] = false;
- sw_util::getSwUpdatableStatus(asyncResp, swId);
- });
+ asyncResp->res.jsonValue["Updateable"] = false;
+ sw_util::getSwUpdatableStatus(asyncResp, swId);
+ });
}
inline void requestRoutesUpdateService(App& app)
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index 76286ff..77c552c 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -43,9 +43,8 @@
Proxy
};
-inline VmMode
- parseObjectPathAndGetMode(const sdbusplus::message::object_path& itemPath,
- const std::string& resName)
+inline VmMode parseObjectPathAndGetMode(
+ const sdbusplus::message::object_path& itemPath, const std::string& resName)
{
std::string thisPath = itemPath.filename();
BMCWEB_LOG_DEBUG("Filename: {}, ThisPath: {}", itemPath.str, thisPath);
@@ -101,26 +100,26 @@
[service, resName, asyncResp, handler = std::move(handler)](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& subtree) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error");
-
- return;
- }
-
- for (const auto& item : subtree)
- {
- VmMode mode = parseObjectPathAndGetMode(item.first, resName);
- if (mode != VmMode::Invalid)
+ if (ec)
{
- handler(service, resName, asyncResp, item);
+ BMCWEB_LOG_DEBUG("DBUS response error");
+
return;
}
- }
- BMCWEB_LOG_DEBUG("Parent item not found");
- asyncResp->res.result(boost::beast::http::status::not_found);
- });
+ for (const auto& item : subtree)
+ {
+ VmMode mode = parseObjectPathAndGetMode(item.first, resName);
+ if (mode != VmMode::Invalid)
+ {
+ handler(service, resName, asyncResp, item);
+ return;
+ }
+ }
+
+ BMCWEB_LOG_DEBUG("Parent item not found");
+ asyncResp->res.result(boost::beast::http::status::not_found);
+ });
}
/**
@@ -281,29 +280,29 @@
[name, asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& subtree) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG("DBUS response error");
- return;
- }
- nlohmann::json& members = asyncResp->res.jsonValue["Members"];
- members = nlohmann::json::array();
-
- for (const auto& object : subtree)
- {
- nlohmann::json item;
- std::string path = object.first.filename();
- if (path.empty())
+ if (ec)
{
- continue;
+ BMCWEB_LOG_DEBUG("DBUS response error");
+ return;
}
+ nlohmann::json& members = asyncResp->res.jsonValue["Members"];
+ members = nlohmann::json::array();
- item["@odata.id"] = boost::urls::format(
- "/redfish/v1/Managers/{}/VirtualMedia/{}", name, path);
- members.emplace_back(std::move(item));
- }
- asyncResp->res.jsonValue["Members@odata.count"] = members.size();
- });
+ for (const auto& object : subtree)
+ {
+ nlohmann::json item;
+ std::string path = object.first.filename();
+ if (path.empty())
+ {
+ continue;
+ }
+
+ item["@odata.id"] = boost::urls::format(
+ "/redfish/v1/Managers/{}/VirtualMedia/{}", name, path);
+ members.emplace_back(std::move(item));
+ }
+ asyncResp->res.jsonValue["Members@odata.count"] = members.size();
+ });
}
inline void
@@ -415,9 +414,8 @@
* @brief Function extends URI with transfer protocol type.
*
*/
-inline std::string
- getUriWithTransferProtocol(const std::string& imageUri,
- const TransferProtocol& transferProtocol)
+inline std::string getUriWithTransferProtocol(
+ const std::string& imageUri, const TransferProtocol& transferProtocol)
{
if (transferProtocol == TransferProtocol::smb)
{
@@ -474,14 +472,14 @@
// Pass secret over pipe
secretPipe->asyncWrite(
std::move(userName), std::move(password),
- [asyncResp, secretPipe](const boost::system::error_code& ec,
- std::size_t) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Failed to pass secret: {}", ec);
- messages::internalError(asyncResp->res);
- }
- });
+ [asyncResp,
+ secretPipe](const boost::system::error_code& ec, std::size_t) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("Failed to pass secret: {}", ec);
+ messages::internalError(asyncResp->res);
+ }
+ });
}
dbus::utility::DbusVariantType unixFd(
@@ -491,20 +489,20 @@
"/xyz/openbmc_project/VirtualMedia/Legacy");
path /= name;
crow::connections::systemBus->async_method_call(
- [asyncResp, secretPipe](const boost::system::error_code& ec,
- bool success) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Bad D-Bus request error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- if (!success)
- {
- BMCWEB_LOG_ERROR("Service responded with error");
- messages::internalError(asyncResp->res);
- }
- },
+ [asyncResp,
+ secretPipe](const boost::system::error_code& ec, bool success) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("Bad D-Bus request error: {}", ec);
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (!success)
+ {
+ BMCWEB_LOG_ERROR("Service responded with error");
+ messages::internalError(asyncResp->res);
+ }
+ },
service, path.str, "xyz.openbmc_project.VirtualMedia.Legacy", "Mount",
imageUrl, rw, unixFd);
}
@@ -662,14 +660,14 @@
{
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Bad D-Bus request error: {}", ec);
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("Bad D-Bus request error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- },
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ },
service, "/xyz/openbmc_project/VirtualMedia/Legacy/" + name,
"xyz.openbmc_project.VirtualMedia.Legacy", "Unmount");
}
@@ -677,14 +675,14 @@
{
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("Bad D-Bus request error: {}", ec);
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("Bad D-Bus request error: {}", ec);
- messages::internalError(asyncResp->res);
- return;
- }
- },
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ },
service, "/xyz/openbmc_project/VirtualMedia/Proxy/" + name,
"xyz.openbmc_project.VirtualMedia.Proxy", "Unmount");
}
@@ -726,47 +724,51 @@
[asyncResp, action, actionParams,
resName](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& getObjectType) mutable {
- if (ec)
- {
- BMCWEB_LOG_ERROR("ObjectMapper::GetObject call failed: {}", ec);
- messages::resourceNotFound(asyncResp->res, action, resName);
-
- return;
- }
-
- std::string service = getObjectType.begin()->first;
- BMCWEB_LOG_DEBUG("GetObjectType: {}", service);
-
- sdbusplus::message::object_path path(
- "/xyz/openbmc_project/VirtualMedia");
- dbus::utility::getManagedObjects(
- service, path,
- [service, resName, action, actionParams, asyncResp](
- const boost::system::error_code& ec2,
- const dbus::utility::ManagedObjectType& subtree) mutable {
- if (ec2)
+ if (ec)
{
- // Not possible in proxy mode
- BMCWEB_LOG_DEBUG("InsertMedia not "
- "allowed in proxy mode");
+ BMCWEB_LOG_ERROR("ObjectMapper::GetObject call failed: {}", ec);
messages::resourceNotFound(asyncResp->res, action, resName);
return;
}
- for (const auto& object : subtree)
- {
- VmMode mode = parseObjectPathAndGetMode(object.first, resName);
- if (mode == VmMode::Legacy)
- {
- validateParams(asyncResp, service, resName, actionParams);
- return;
- }
- }
- BMCWEB_LOG_DEBUG("Parent item not found");
- messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName);
+ std::string service = getObjectType.begin()->first;
+ BMCWEB_LOG_DEBUG("GetObjectType: {}", service);
+
+ sdbusplus::message::object_path path(
+ "/xyz/openbmc_project/VirtualMedia");
+ dbus::utility::getManagedObjects(
+ service, path,
+ [service, resName, action, actionParams, asyncResp](
+ const boost::system::error_code& ec2,
+ const dbus::utility::ManagedObjectType& subtree) mutable {
+ if (ec2)
+ {
+ // Not possible in proxy mode
+ BMCWEB_LOG_DEBUG("InsertMedia not "
+ "allowed in proxy mode");
+ messages::resourceNotFound(asyncResp->res, action,
+ resName);
+
+ return;
+ }
+ for (const auto& object : subtree)
+ {
+ VmMode mode =
+ parseObjectPathAndGetMode(object.first, resName);
+ if (mode == VmMode::Legacy)
+ {
+ validateParams(asyncResp, service, resName,
+ actionParams);
+
+ return;
+ }
+ }
+ BMCWEB_LOG_DEBUG("Parent item not found");
+ messages::resourceNotFound(asyncResp->res, "VirtualMedia",
+ resName);
+ });
});
- });
}
inline void handleManagersVirtualMediaActionEject(
@@ -792,44 +794,48 @@
[asyncResp, action,
resName](const boost::system::error_code& ec2,
const dbus::utility::MapperGetObject& getObjectType) {
- if (ec2)
- {
- BMCWEB_LOG_ERROR("ObjectMapper::GetObject call failed: {}", ec2);
- messages::internalError(asyncResp->res);
-
- return;
- }
- std::string service = getObjectType.begin()->first;
- BMCWEB_LOG_DEBUG("GetObjectType: {}", service);
-
- sdbusplus::message::object_path path(
- "/xyz/openbmc_project/VirtualMedia");
- dbus::utility::getManagedObjects(
- service, path,
- [resName, service, action,
- asyncResp](const boost::system::error_code& ec,
- const dbus::utility::ManagedObjectType& subtree) {
- if (ec)
+ if (ec2)
{
- BMCWEB_LOG_ERROR("ObjectMapper : No Service found");
- messages::resourceNotFound(asyncResp->res, action, resName);
+ BMCWEB_LOG_ERROR("ObjectMapper::GetObject call failed: {}",
+ ec2);
+ messages::internalError(asyncResp->res);
+
return;
}
+ std::string service = getObjectType.begin()->first;
+ BMCWEB_LOG_DEBUG("GetObjectType: {}", service);
- for (const auto& object : subtree)
- {
- VmMode mode = parseObjectPathAndGetMode(object.first, resName);
- if (mode != VmMode::Invalid)
- {
- doEjectAction(asyncResp, service, resName,
- mode == VmMode::Legacy);
- return;
- }
- }
- BMCWEB_LOG_DEBUG("Parent item not found");
- messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName);
+ sdbusplus::message::object_path path(
+ "/xyz/openbmc_project/VirtualMedia");
+ dbus::utility::getManagedObjects(
+ service, path,
+ [resName, service, action,
+ asyncResp](const boost::system::error_code& ec,
+ const dbus::utility::ManagedObjectType& subtree) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("ObjectMapper : No Service found");
+ messages::resourceNotFound(asyncResp->res, action,
+ resName);
+ return;
+ }
+
+ for (const auto& object : subtree)
+ {
+ VmMode mode =
+ parseObjectPathAndGetMode(object.first, resName);
+ if (mode != VmMode::Invalid)
+ {
+ doEjectAction(asyncResp, service, resName,
+ mode == VmMode::Legacy);
+ return;
+ }
+ }
+ BMCWEB_LOG_DEBUG("Parent item not found");
+ messages::resourceNotFound(asyncResp->res, "VirtualMedia",
+ resName);
+ });
});
- });
}
inline void handleManagersVirtualMediaCollectionGet(
@@ -858,18 +864,18 @@
"/xyz/openbmc_project/VirtualMedia", {},
[asyncResp, name](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& getObjectType) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("ObjectMapper::GetObject call failed: {}", ec);
- messages::internalError(asyncResp->res);
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("ObjectMapper::GetObject call failed: {}", ec);
+ messages::internalError(asyncResp->res);
- return;
- }
- std::string service = getObjectType.begin()->first;
- BMCWEB_LOG_DEBUG("GetObjectType: {}", service);
+ return;
+ }
+ std::string service = getObjectType.begin()->first;
+ BMCWEB_LOG_DEBUG("GetObjectType: {}", service);
- getVmResourceList(asyncResp, service, name);
- });
+ getVmResourceList(asyncResp, service, name);
+ });
}
inline void
@@ -893,18 +899,18 @@
[asyncResp, name,
resName](const boost::system::error_code& ec,
const dbus::utility::MapperGetObject& getObjectType) {
- if (ec)
- {
- BMCWEB_LOG_ERROR("ObjectMapper::GetObject call failed: {}", ec);
- messages::internalError(asyncResp->res);
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR("ObjectMapper::GetObject call failed: {}", ec);
+ messages::internalError(asyncResp->res);
- return;
- }
- std::string service = getObjectType.begin()->first;
- BMCWEB_LOG_DEBUG("GetObjectType: {}", service);
+ return;
+ }
+ std::string service = getObjectType.begin()->first;
+ BMCWEB_LOG_DEBUG("GetObjectType: {}", service);
- getVmData(asyncResp, service, name, resName);
- });
+ getVmData(asyncResp, service, name, resName);
+ });
}
inline void requestNBDVirtualMediaRoutes(App& app)
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
index 205da96..fd55d89 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -226,21 +226,19 @@
* See header file for more information
* @endinternal
*/
-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)
{
- std::string arg1Str = arg1.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string arg1Str =
+ arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(
redfish::registries::base::Index::actionParameterValueFormatError,
std::to_array<std::string_view>({arg1Str, arg2, 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)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue,
@@ -254,9 +252,8 @@
* See header file for more information
* @endinternal
*/
-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)
{
return getLog(
redfish::registries::base::Index::actionParameterValueNotInList,
@@ -420,9 +417,8 @@
* See header file for more information
* @endinternal
*/
-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)
{
return getLog(redfish::registries::base::Index::resourceAlreadyExists,
std::to_array({arg1, arg2, arg3}));
@@ -488,8 +484,8 @@
nlohmann::json propertyValueFormatError(const nlohmann::json& arg1,
std::string_view arg2)
{
- std::string arg1Str = arg1.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string arg1Str =
+ arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(redfish::registries::base::Index::propertyValueFormatError,
std::to_array<std::string_view>({arg1Str, arg2}));
}
@@ -513,8 +509,8 @@
nlohmann::json propertyValueNotInList(const nlohmann::json& arg1,
std::string_view arg2)
{
- std::string arg1Str = arg1.dump(-1, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string arg1Str =
+ arg1.dump(-1, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(redfish::registries::base::Index::propertyValueNotInList,
std::to_array<std::string_view>({arg1Str, arg2}));
}
@@ -536,8 +532,8 @@
nlohmann::json propertyValueOutOfRange(const nlohmann::json& arg1,
std::string_view arg2)
{
- std::string arg1Str = arg1.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string arg1Str =
+ arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(redfish::registries::base::Index::propertyValueOutOfRange,
std::to_array<std::string_view>({arg1Str, arg2}));
}
@@ -813,13 +809,12 @@
* See header file for more information
* @endinternal
*/
-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)
{
- std::string arg2Str = arg2.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string arg2Str =
+ arg2.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(
redfish::registries::base::Index::propertyValueResourceConflict,
@@ -845,8 +840,8 @@
nlohmann::json propertyValueExternalConflict(std::string_view arg1,
const nlohmann::json& arg2)
{
- std::string arg2Str = arg2.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string arg2Str =
+ arg2.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(
redfish::registries::base::Index::propertyValueExternalConflict,
@@ -871,8 +866,8 @@
nlohmann::json propertyValueIncorrect(std::string_view arg1,
const nlohmann::json& arg2)
{
- std::string arg2Str = arg2.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string arg2Str =
+ arg2.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(redfish::registries::base::Index::propertyValueIncorrect,
std::to_array<std::string_view>({arg1, arg2Str}));
}
@@ -1005,8 +1000,8 @@
nlohmann::json propertyValueTypeError(const nlohmann::json& arg1,
std::string_view arg2)
{
- std::string arg1Str = arg1.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string arg1Str =
+ arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(redfish::registries::base::Index::propertyValueTypeError,
std::to_array<std::string_view>({arg1Str, arg2}));
}
@@ -1089,16 +1084,15 @@
nlohmann::json queryParameterValueTypeError(const nlohmann::json& arg1,
std::string_view arg2)
{
- std::string arg1Str = arg1.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string arg1Str =
+ arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(
redfish::registries::base::Index::queryParameterValueTypeError,
std::to_array<std::string_view>({arg1Str, 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)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue,
@@ -1173,9 +1167,8 @@
* See header file for more information
* @endinternal
*/
-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)
{
return getLog(
redfish::registries::base::Index::sourceDoesNotSupportProtocol,
@@ -1439,12 +1432,11 @@
* See header file for more information
* @endinternal
*/
-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)
{
- std::string arg1Str = arg1.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string arg1Str =
+ arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(
redfish::registries::base::Index::actionParameterValueTypeError,
std::to_array<std::string_view>({arg1Str, arg2, arg3}));
@@ -1469,8 +1461,8 @@
nlohmann::json actionParameterValueError(const nlohmann::json& arg1,
std::string_view arg2)
{
- std::string arg1Str = arg1.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string arg1Str =
+ arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(redfish::registries::base::Index::actionParameterValueError,
std::to_array<std::string_view>({arg1Str, arg2}));
}
@@ -1660,8 +1652,8 @@
nlohmann::json propertyValueModified(std::string_view arg1,
const nlohmann::json& arg2)
{
- std::string arg2Str = arg2.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string arg2Str =
+ arg2.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(redfish::registries::base::Index::propertyValueModified,
std::to_array<std::string_view>({arg1, arg2Str}));
}
@@ -1701,16 +1693,15 @@
nlohmann::json queryParameterValueFormatError(const nlohmann::json& arg1,
std::string_view arg2)
{
- std::string arg1Str = arg1.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
+ std::string arg1Str =
+ arg1.dump(2, ' ', true, nlohmann::json::error_handler_t::replace);
return getLog(
redfish::registries::base::Index::queryParameterValueFormatError,
std::to_array<std::string_view>({arg1Str, 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)
{
res.result(boost::beast::http::status::bad_request);
addMessageToErrorJson(res.jsonValue,
@@ -1781,9 +1772,8 @@
* See header file for more information
* @endinternal
*/
-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)
{
return getLog(redfish::registries::base::Index::queryParameterOutOfRange,
std::to_array({arg1, arg2, arg3}));
diff --git a/redfish-core/src/filter_expr_executor.cpp b/redfish-core/src/filter_expr_executor.cpp
index 1e2e41b..a1accaf 100644
--- a/redfish-core/src/filter_expr_executor.cpp
+++ b/redfish-core/src/filter_expr_executor.cpp
@@ -19,46 +19,46 @@
// The following is created by dumping all key names of type
// Edm.DateTimeOffset. While imperfect that it's a hardcoded list, these
// keys don't change that often
- static constexpr auto timeKeys =
- std::to_array<std::string_view>({"AccountExpiration",
- "CalibrationTime",
- "CoefficientUpdateTime",
- "Created",
- "CreatedDate",
- "CreatedTime",
- "CreateTime",
- "DateTime",
- "EndDateTime",
- "EndTime",
- "EventTimestamp",
- "ExpirationDate",
- "FirstOverflowTimestamp",
- "InitialStartTime",
- "InstallDate",
- "LastOverflowTimestamp",
- "LastResetTime",
- "LastStateTime",
- "LastUpdated",
- "LifetimeStartDateTime",
- "LowestReadingTime",
- "MaintenanceWindowStartTime",
- "Modified",
- "PasswordExpiration",
- "PeakReadingTime",
- "PresentedPublicHostKeyTimestamp",
- "ProductionDate",
- "ReadingTime",
- "ReleaseDate",
- "ReservationTime",
- "SensorResetTime",
- "ServicedDate",
- "SetPointUpdateTime",
- "StartDateTime",
- "StartTime",
- "Time",
- "Timestamp",
- "ValidNotAfter",
- "ValidNotBefore"});
+ static constexpr auto timeKeys = std::to_array<std::string_view>(
+ {"AccountExpiration",
+ "CalibrationTime",
+ "CoefficientUpdateTime",
+ "Created",
+ "CreatedDate",
+ "CreatedTime",
+ "CreateTime",
+ "DateTime",
+ "EndDateTime",
+ "EndTime",
+ "EventTimestamp",
+ "ExpirationDate",
+ "FirstOverflowTimestamp",
+ "InitialStartTime",
+ "InstallDate",
+ "LastOverflowTimestamp",
+ "LastResetTime",
+ "LastStateTime",
+ "LastUpdated",
+ "LifetimeStartDateTime",
+ "LowestReadingTime",
+ "MaintenanceWindowStartTime",
+ "Modified",
+ "PasswordExpiration",
+ "PeakReadingTime",
+ "PresentedPublicHostKeyTimestamp",
+ "ProductionDate",
+ "ReadingTime",
+ "ReleaseDate",
+ "ReservationTime",
+ "SensorResetTime",
+ "ServicedDate",
+ "SetPointUpdateTime",
+ "StartDateTime",
+ "StartTime",
+ "Time",
+ "Timestamp",
+ "ValidNotAfter",
+ "ValidNotBefore"});
explicit DateTimeString(std::string_view strvalue)
{
diff --git a/redfish-core/src/registries.cpp b/redfish-core/src/registries.cpp
index 61b27b5..a852f24 100644
--- a/redfish-core/src/registries.cpp
+++ b/redfish-core/src/registries.cpp
@@ -21,8 +21,8 @@
{
std::span<const MessageEntry>::iterator messageIt = std::ranges::find_if(
registry, [&messageKey](const MessageEntry& messageEntry) {
- return std::strcmp(messageEntry.first, messageKey.c_str()) == 0;
- });
+ return std::strcmp(messageEntry.first, messageKey.c_str()) == 0;
+ });
if (messageIt != registry.end())
{
return &messageIt->second;
diff --git a/redfish-core/src/utils/dbus_utils.cpp b/redfish-core/src/utils/dbus_utils.cpp
index b59088a..18535bc 100644
--- a/redfish-core/src/utils/dbus_utils.cpp
+++ b/redfish-core/src/utils/dbus_utils.cpp
@@ -21,11 +21,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)
{
if (ec)
{