Skip to content

systems.hpp - initial multi-host implementation #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7066dc5
Implement LocationIndicatorActive for PowerSupplies
baemyung Aug 20, 2024
fc28234
meson: fix nlohmann json wrap
pointbazaar Apr 10, 2025
3498f48
Sort get_response_code names
baemyung Apr 9, 2025
7f84d8c
Return forbidden return code for RestrictedRole operations
baemyung Mar 14, 2023
177612a
Add async_method_call to utility
edtanous Feb 14, 2025
69addd9
ssl: Switch to use_certificate_chain for certificate loading
bpeled Apr 7, 2025
fdf51f5
Avoid http request copy in OEM handler
rohitpai Apr 4, 2025
e51df0b
Fix OEM Json payload in OEM Fragment handler
rohitpai Apr 14, 2025
84aad24
Redfish OEM Patch Route Handling
rohitpai Jan 28, 2025
38b3b6f
Fix watchdog timeout variable
Wewannado Apr 16, 2025
34b7ca4
Add support for intermediate certificate chains in mTLS auth
bpeled Apr 8, 2025
6f5be43
sensor_utils: Support upper/lower fatal threshold
potinlai Apr 7, 2025
d1a3caa
Add TypeDefinition support for enumeration generation
chandramohan83 Apr 17, 2025
079fbcf
http_client: Fixing invalid log
abhilashraju Apr 24, 2025
5ffbc9a
Use SPDX identifiers everywhere
gtmills Apr 24, 2025
99ff0dd
Fix race condition between subscription deletions
baemyung Apr 22, 2025
761cdfa
Fix more moves
edtanous Apr 15, 2024
d0a341b
Remove is_object
edtanous Oct 18, 2024
70cef4e
Temporarily disable include-fixer
edtanous May 6, 2025
7fe6d53
Look for OperationalStatus for the memory Health
lxwinspur Mar 6, 2024
86e41a8
fix: resolve incorrect key on bmcweb persistent file
malikrafsan May 6, 2025
fc5ae94
Introducing systems_utils.hpp and getSystemCollectionMembers
Aug 12, 2024
3d15864
Fix the build
edtanous May 12, 2025
a6597fc
replace_logs: remove scripts per timeframe
williamspatrick May 9, 2025
18bf4bf
Remove ResetToDefaultsType since time
gtmills May 9, 2025
e246046
Return 200 OK for all dumps in LogService.ClearLog
AmyChang-yh May 6, 2025
0c814aa
Separate endpoint for MultipartHttpPushUri Update
rajeeranjan Mar 25, 2025
6136e85
Fix inconsistent persistent subscription load
baemyung May 14, 2025
19fab29
Authenticate expand query parameter
chandramohan83 Feb 12, 2025
d39a8c2
Fix error handling in system route handler
aishwaryjoshi31 May 8, 2025
5a3d934
RFA - Use EM name property of Satellite config as prefix
rohitpai Apr 26, 2025
c48317f
Update AGGREGATION.md
rohitpai Apr 28, 2025
5bfed26
Make Registry description optional
ifel Feb 21, 2025
4a102cd
registries: make registration dynamic
williamspatrick Feb 27, 2025
376b0ac
Add multi-host support in systems.hpp
mox669 Nov 16, 2024
4311129
Add multi-host support for LogServices collection
mox669 Dec 2, 2024
1cbbee4
Add multi-host support for PostCodes LogService
mox669 Dec 2, 2024
4002c6b
WIP: systems_logservices_hostlogger.hpp - support for multi-host
mox669 Mar 7, 2025
d04fcb9
WIP: managers.hpp - support for multi-host
mox669 Mar 7, 2025
d9a7fc7
Refactor boost::urls usage in system collection handler
mox669 May 14, 2025
b1c1668
Add copyright comment to systems_utils.hpp
mox669 May 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ google-explicit-constructor,
misc-coroutine-hostile-raii,
misc-definitions-in-headers,
misc-header-include-cycle,
misc-include-cleaner,
misc-misleading-bidirectional,
misc-misleading-identifier,
misc-misplaced-const,
Expand Down
48 changes: 24 additions & 24 deletions AGGREGATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ reject satellite configs that do not comply with these requirements.

## Satellite BMC Restrictions

- Can only aggregate a single satellite BMC
- HTTP only connection to satellite BMC
- No authentication on satellite BMC
- Each satellite BMC must have a unique "Name" property in its configuration

## Supported Resources

Expand Down Expand Up @@ -79,18 +79,19 @@ not appear when querying the Service Root.

Aggregated resources will have a prefix appended to their URIs in order to
distinguish them from resources that are local to the aggregating BMC. The
aggregation prefix is planned to be derived from the uuid of the aggregating
BMC. This should result in the aggregation prefix being unique to each
aggregating BMC.
prefix is derived from the "Name" property specified in the satellite BMC's
configuration in Entity Manager. This allows for meaningful and unique prefixes
for each satellite BMC.

The general URI format for aggregated resources is

```bash
/redfish/v1/<resource_collection>/<prefix>_<resource_id>
/redfish/v1/<resource_collection>/<name>_<resource_id>
```

When support is added for aggregating more than one satellite BMC, then each
satellite will be assigned its own unique satellite prefix.
Where `<name>` is the value of the "Name" property from the satellite's
configuration. For example, if a satellite is configured with `"Name": "sat0"`,
its resources would appear as `/redfish/v1/Systems/sat0_system`.

### Aggregating Collections

Expand Down Expand Up @@ -122,10 +123,13 @@ curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Systems
"@odata.id": "/redfish/v1/Systems/system"
},
{
"@odata.id": "/redfish/v1/Systems/5B247A_system"
"@odata.id": "/redfish/v1/Systems/sat0_system"
},
{
"@odata.id": "/redfish/v1/Systems/sat1_system"
}
],
"Members@odata.count": 2,
"Members@odata.count": 3,
"Name": "Computer System Collection"
}
```
Expand All @@ -150,18 +154,16 @@ The following steps are used to retrieve the requested aggregated resource:
5. Return the updated response from the satellite BMC

```bash
curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Systems/5B247A_system
{
"@odata.id": "/redfish/v1/Systems/5B247A_system",
...
"LogServices": {
"@odata.id": "/redfish/v1/Systems/5B247A_system/LogServices"
},
"Memory": {
"@odata.id": "/redfish/v1/Systems/5B247A_system/Memory"
},
...
}
curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Systems/sat0_system
{
"@odata.id" :
"/redfish/v1/Systems/sat0_system",
... "LogServices" :
{"@odata.id" : "/redfish/v1/Systems/sat0_system/LogServices"},
"Memory" :
{"@odata.id" : "/redfish/v1/Systems/sat0_system/Memory"},
...
}
```

We consider any response to be a valid response code from the satellite BMC. The
Expand All @@ -179,9 +181,7 @@ are some features that must still be implemented before that can happen.

1. Add links to satellite only collections in responses from service root and
other appropriate locations
2. Generate aggregation prefix from uuid
3. Aggregate more than one satellite BMC
4. Support HTTPS connection to satellite BMC
2. Support HTTPS connection to satellite BMC

Support for the following items should be added as well. However, their
implementation is not a requirement to being able to enable Redfish aggregation
Expand Down
6 changes: 3 additions & 3 deletions COMMON_ERRORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ whole.
```cpp
BMCWEB_ROUTE("/myendpoint/<str>",
[](Request& req, Response& res, const std::string& id){
crow::connections::systemBus->async_method_call(
dbus::utility::async_method_call(
[asyncResp](const boost::system::error_code& ec,
const std::string& myProperty) {
if (ec)
Expand Down Expand Up @@ -244,7 +244,7 @@ An implementation of the above that handles 404 would look like:
```cpp
BMCWEB_ROUTE("/myendpoint/<str>",
[](Request& req, Response& res, const std::string& id){
crow::connections::systemBus->async_method_call(
dbus::utility::async_method_call(
[asyncResp](const boost::system::error_code& ec,
const std::string& myProperty) {
if (ec == <error code that gets returned by not found>){
Expand Down Expand Up @@ -374,7 +374,7 @@ recommendation is aligned with the C++ Core Guidelines.
## 15. Using async_method_call where there are existing helper methods

```cpp
crow::connections::systemBus->async_method_call(
dbus::utility::async_method_call(
respHandler, "xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
Expand Down
2 changes: 2 additions & 0 deletions Redfish.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ Fields common to all schemas
- EfficiencyPercent
- FirmwareVersion
- Location
- LocationIndicatorActive
- Manufacturer
- Model
- PartNumber
Expand Down Expand Up @@ -1119,6 +1120,7 @@ other.
- HttpPushUri
- HttpPushUriOptions
- MaxImageSizeBytes
- MultipartHttpPushUri
- ServiceEnabled

### /redfish/v1/UpdateService/FirmwareInventory/
Expand Down
2 changes: 1 addition & 1 deletion config/bmcweb.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ExecStart=@MESON_INSTALL_PREFIX@/libexec/bmcwebd
Type=simple
WorkingDirectory=/home/root
SyslogLevelPrefix=true
WatchdogSec=@WATCHDOG_TIMEOUT@s
WatchdogSec=@BMCWEB_WATCHDOG_TIMEOUT_SECONDS@s

[Install]
WantedBy=network.target
4 changes: 3 additions & 1 deletion config/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ configure_file(
configuration: configuration_data(
{
'MESON_INSTALL_PREFIX': get_option('prefix'),
'WATCHDOG_TIMEOUT_SECONDS': get_option('watchdog-timeout-seconds'),
'BMCWEB_WATCHDOG_TIMEOUT_SECONDS': get_option(
'watchdog-timeout-seconds',
),
},
),
)
Expand Down
12 changes: 6 additions & 6 deletions http/http_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo>
if (ec)
{
BMCWEB_LOG_ERROR("Connect {}:{}, id: {} failed: {}",
endpoint.address().to_string(), endpoint.port(),
connId, ec.message());
host.encoded_host_address(), host.port(), connId,
ec.message());
state = ConnState::connectFailed;
waitAndRetry();
return;
Expand All @@ -243,13 +243,13 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo>
{
return;
}
auto& ssl = *sslConn;
state = ConnState::handshakeInProgress;
timer.expires_after(std::chrono::seconds(30));
timer.async_wait(std::bind_front(onTimeout, weak_from_this()));
sslConn->async_handshake(
boost::asio::ssl::stream_base::client,
std::bind_front(&ConnectionInfo::afterSslHandshake, this,
shared_from_this()));
ssl.async_handshake(boost::asio::ssl::stream_base::client,
std::bind_front(&ConnectionInfo::afterSslHandshake,
this, shared_from_this()));
}

void afterSslHandshake(const std::shared_ptr<ConnectionInfo>& /*self*/,
Expand Down
18 changes: 10 additions & 8 deletions http/http_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,16 +630,17 @@ class Connection :
BMCWEB_LOG_ERROR("Parser was unexpectedly null");
return;
}
auto& parse = *parser;
const auto& value = parser->get();

if (authenticationEnabled)
{
boost::beast::http::verb method = parser->get().method();
boost::beast::http::verb method = value.method();
userSession = authentication::authenticate(
ip, res, method, parser->get().base(), mtlsSession);
ip, res, method, value.base(), mtlsSession);
}

std::string_view expect =
parser->get()[boost::beast::http::field::expect];
std::string_view expect = value[boost::beast::http::field::expect];
if (bmcweb::asciiIEquals(expect, "100-continue"))
{
res.result(boost::beast::http::status::continue_);
Expand All @@ -652,9 +653,9 @@ class Connection :
return;
}

parser->body_limit(getContentLengthLimit());
parse.body_limit(getContentLengthLimit());

if (parser->is_done())
if (parse.is_done())
{
handle();
return;
Expand Down Expand Up @@ -749,18 +750,19 @@ class Connection :
{
return;
}
auto& parse = *parser;
startDeadline();
if (httpType == HttpType::HTTP)
{
boost::beast::http::async_read_some(
adaptor.next_layer(), buffer, *parser,
adaptor.next_layer(), buffer, parse,
std::bind_front(&self_type::afterRead, this,
shared_from_this()));
}
else
{
boost::beast::http::async_read_some(
adaptor, buffer, *parser,
adaptor, buffer, parse,
std::bind_front(&self_type::afterRead, this,
shared_from_this()));
}
Expand Down
2 changes: 1 addition & 1 deletion http/http_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct Request
std::shared_ptr<persistent_data::UserSession> session;

std::string userRole;
Request(Body reqIn, std::error_code& ec) : req(std::move(reqIn))
Request(Body&& reqIn, std::error_code& ec) : req(std::move(reqIn))
{
if (!setUrlInfo())
{
Expand Down
4 changes: 2 additions & 2 deletions include/async_resolve.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright OpenBMC Authors
#pragma once
#include "dbus_singleton.hpp"
#include "dbus_utility.hpp"
#include "logging.hpp"

#include <sys/socket.h>
Expand Down Expand Up @@ -90,7 +90,7 @@ class Resolver
}

uint64_t flag = 0;
crow::connections::systemBus->async_method_call(
dbus::utility::async_method_call(
[host{std::string(host)}, portNum,
handler = std::forward<ResolveHandler>(handler)](
const boost::system::error_code& ec,
Expand Down
3 changes: 1 addition & 2 deletions include/authentication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ inline bool isOnAllowlist(std::string_view url, boost::beast::http::verb method)
{
return true;
}
if (crow::webroutes::routes.find(std::string(url)) !=
crow::webroutes::routes.end())
if (crow::webroutes::routes.contains(std::string(url)))
{
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions include/dbus_privileges.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#pragma once

#include "async_resp.hpp"
#include "dbus_singleton.hpp"
#include "dbus_utility.hpp"
#include "error_messages.hpp"
#include "http_request.hpp"
Expand Down Expand Up @@ -139,7 +138,8 @@ inline void requestUserInfo(
std::move_only_function<void(const dbus::utility::DBusPropertiesMap&)>&&
callback)
{
crow::connections::systemBus->async_method_call(
dbus::utility::async_method_call(
asyncResp,
[asyncResp, callback = std::move(callback)](
const boost::system::error_code& ec,
const dbus::utility::DBusPropertiesMap& userInfoMap) mutable {
Expand Down
25 changes: 25 additions & 0 deletions include/dbus_utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-FileCopyrightText: Copyright 2018 Intel Corporation
#pragma once

#include "async_resp.hpp"
#include "boost_formatters.hpp"
#include "dbus_singleton.hpp"

Expand All @@ -14,6 +15,7 @@
#include <cstddef>
#include <cstdint>
#include <functional>
#include <memory>
#include <span>
#include <string>
#include <string_view>
Expand Down Expand Up @@ -99,6 +101,29 @@ void getAllProperties(const std::string& service, const std::string& objectPath,
std::function<void(const boost::system::error_code&,
const DBusPropertiesMap&)>&& callback);

template <typename MessageHandler, typename... InputArgs>
// NOLINTNEXTLINE(readability-identifier-naming)
void async_method_call(MessageHandler&& handler, const std::string& service,
const std::string& objpath, const std::string& interf,
const std::string& method, const InputArgs&... a)
{
crow::connections::systemBus->async_method_call(
std::forward<MessageHandler>(handler), service, objpath, interf, method,
a...);
}

template <typename MessageHandler, typename... InputArgs>
// NOLINTNEXTLINE(readability-identifier-naming)
void async_method_call(const std::shared_ptr<bmcweb::AsyncResp>& /*asyncResp*/,
MessageHandler&& handler, const std::string& service,
const std::string& objpath, const std::string& interf,
const std::string& method, const InputArgs&... a)
{
crow::connections::systemBus->async_method_call(
std::forward<MessageHandler>(handler), service, objpath, interf, method,
a...);
}

template <typename PropertyType>
void getProperty(const std::string& service, const std::string& objectPath,
const std::string& interface, const std::string& propertyName,
Expand Down
4 changes: 2 additions & 2 deletions include/google/google_service_root.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "app.hpp"
#include "async_resp.hpp"
#include "dbus_singleton.hpp"
#include "dbus_utility.hpp"
#include "error_messages.hpp"
#include "http_request.hpp"
Expand Down Expand Up @@ -188,7 +187,8 @@ inline void invokeRoTCommand(
return;
}

crow::connections::systemBus->async_method_call(
dbus::utility::async_method_call(
asyncResp,
[asyncResp{asyncResp}](const boost::system::error_code& ec,
const std::vector<uint8_t>& responseBytes) {
invocationCallback(asyncResp, ec, responseBytes);
Expand Down
2 changes: 1 addition & 1 deletion include/hostname_monitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static std::unique_ptr<sdbusplus::bus::match_t> hostnameSignalMonitor;

inline void installCertificate(const std::filesystem::path& certPath)
{
crow::connections::systemBus->async_method_call(
dbus::utility::async_method_call(
[certPath](const boost::system::error_code& ec) {
if (ec)
{
Expand Down
Loading