Skip to content

Commit 40c9f06

Browse files
committed
RBMC: Put Failover interface on D-Bus
Create an instance of the xyz.openbmc_project.Control.Failover interface on the /xyz/openbmc_project/state/bmc0 path. Its 'StartFailover' method will be used to start a failover. If at any time a failover can't be done the method will return the 'Unavailable' D-Bus error. In this commit, that's all it does to start with. The interface is always on D-Bus, regardless of the BMC's role, because: 1. Failovers need to be triggered from both active and passive BMCs. 2. The FailoverInProgress property spans BMC roles. It gets set to true while the BMC is passive and stays that way until a bit after the BMC goes to active. The main driver of the failover will be the passive BMC, so if called on the active BMC the command would need to propagate to the passive BMC. Tested: ``` $ busctl introspect xyz.openbmc_project.State.BMC.Redundancy /xyz/openbmc_project/state/bmc0 NAME TYPE SIGNATURE RESULT/VALUE FLAGS ... xyz.openbmc_project.Control.Failover interface - - - .StartFailover method a{sv} - - .FailoverInProgress property b false emits-change ... ``` Call it: ``` $ busctl call xyz.openbmc_project.State.BMC.Redundancy \ /xyz/openbmc_project/state/bmc0 \ xyz.openbmc_project.Control.Failover StartFailover a{sv} 0 Call failed: The service is temporarily unavailable. ``` Change-Id: I5f9cfd83d90d10dfc22f191f3d85756aa2614af5 Signed-off-by: Matt Spinler <[email protected]>
1 parent 3ee7930 commit 40c9f06

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

redundant-bmc/src/manager.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@
1111
namespace rbmc
1212
{
1313

14+
const std::string failoverPath =
15+
std::string{RedundancyInterface::namespace_path::value} + '/' +
16+
RedundancyInterface::namespace_path::bmc;
17+
1418
Manager::Manager(sdbusplus::async::context& ctx,
1519
std::unique_ptr<Providers>&& providers) :
20+
sdbusplus::aserver::xyz::openbmc_project::control::Failover<Manager>(
21+
ctx, failoverPath.c_str()),
1622
ctx(ctx), redundancyInterface(ctx, *this), providers(std::move(providers))
1723
{
1824
try
@@ -42,6 +48,9 @@ Manager::Manager(sdbusplus::async::context& ctx,
4248
"ERROR", e);
4349
}
4450

51+
// emit the Failover interfaces added signal
52+
emit_added();
53+
4554
ctx.spawn(startup());
4655
}
4756

@@ -267,4 +276,13 @@ void Manager::disableRedPropChanged(bool disable)
267276
handler->disableRedPropChanged(disable);
268277
}
269278

279+
// NOLINTNEXTLINE
280+
sdbusplus::async::task<> Manager::method_call(
281+
start_failover_t /* unused */, const FailoverOptions& /* options */)
282+
{
283+
// TODO: Implement the failover
284+
lg2::error("Failovers are not implemented yet");
285+
throw sdbusplus::xyz::openbmc_project::Common::Error::Unavailable();
286+
}
287+
270288
} // namespace rbmc

redundant-bmc/src/manager.hpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@
77
#include "role_handler.hpp"
88

99
#include <sdbusplus/async.hpp>
10+
#include <xyz/openbmc_project/Control/Failover/aserver.hpp>
1011

1112
namespace rbmc
1213
{
1314

15+
using FailoverOptions = std::map<std::string, std::variant<bool>>;
16+
1417
/**
1518
* @class Manager
1619
*
1720
* Manages the high level operations of the redundant
1821
* BMC functionality.
1922
*/
20-
class Manager
23+
class Manager :
24+
public sdbusplus::aserver::xyz::openbmc_project::control::Failover<Manager>
2125
{
2226
public:
23-
Manager() = delete;
2427
~Manager() = default;
2528
Manager(const Manager&) = delete;
2629
Manager& operator=(const Manager&) = delete;
@@ -46,6 +49,14 @@ class Manager
4649
*/
4750
void disableRedPropChanged(bool disable);
4851

52+
/**
53+
* @brief Implements the StartFailover D-Bus method.
54+
*
55+
* @param[in] options - The failover options
56+
*/
57+
sdbusplus::async::task<> method_call(start_failover_t /* unused */,
58+
const FailoverOptions& options);
59+
4960
private:
5061
/**
5162
* @brief Kicks off the Manager startup

0 commit comments

Comments
 (0)