Skip to content

Commit 9746114

Browse files
committed
RBMC: Add rbmctool redundancy override options
Add options to set or clear the `DisableRedundancyOverride` D-Bus property that manually disables redundancy: ``` -s,--set-disable-redundancy-override Excludes: --clear-disable-redundancy-override Set override to disable redundancy -c,--clear-disable-redundancy-override Excludes: --set-disable-redundancy-override Clear override to disable redundancy ``` Also refactor the CLI11 argument handling to add option groups to make it more explicit that only one argument can be handled at a time. This changes the help text a bit. It now looks like: ``` $ ./rbmctool -h RBMC Tool [Exactly 1 of the following options is required] Usage: ./rbmctool [OPTIONS] Options: -h,--help Print this help message and exit [Option Group: Display RBMC information] Options: -d Display basic RBMC information -e Needs: -d Add in extended details [Option Group: Modify the redundancy override] Options: -s,--set-disable-redundancy-override Excludes: --clear-disable-redundancy-override Set override to disable redundancy -c,--clear-disable-redundancy-override Excludes: --set-disable-redundancy-override Clear override to disable redundancy [Option Group: Reset sibling BMC] Options: --reset-sibling Reset the sibling BMC ``` Finally, it also does some small clean up to remove some unnecessary co_return statements and also return nonzero if the sibling reset option fails. Testing: When it works: ``` $ ./rbmctool -s <6> Setting disable redundancy override to True $ ./rbmctool -d | grep Enabled Redundancy Enabled: false $ ./rbmctool -c <6> Setting disable redundancy override to False $ ./rbmctool -d | grep Enabled Redundancy Enabled: true ``` When it fails: ``` $ ./rbmctool -s <6> Setting disable redundancy override to True Error: Setting cannot be modified now (see journal for details) ``` Change-Id: I89b26bd6b744ee282ae643094adca4cf891098ae Signed-off-by: Matt Spinler <spinler@us.ibm.com>
1 parent 8d1ea13 commit 9746114

File tree

1 file changed

+68
-7
lines changed

1 file changed

+68
-7
lines changed

redundant-bmc/src/rbmc_tool.cpp

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ sdbusplus::async::task<> displayLocalBMCInfo(sdbusplus::async::context& ctx,
148148
std::cout << "Cannot get to Redundancy interface on D-Bus: " << e.what()
149149
<< "\n";
150150
}
151-
152-
co_return;
153151
}
154152

155153
// NOLINTBEGIN
@@ -222,7 +220,6 @@ sdbusplus::async::task<> displayInfo(sdbusplus::async::context& ctx,
222220
std::cout << "\n";
223221
co_await displaySiblingBMCInfo(ctx, extended);
224222
std::cout << "\n";
225-
co_return;
226223
}
227224

228225
void resetSiblingBMC()
@@ -236,7 +233,7 @@ void resetSiblingBMC()
236233
catch (const std::exception& e)
237234
{
238235
lg2::error("Failed asserting sibling reset: {ERROR}", "ERROR", e);
239-
return;
236+
exit(EXIT_FAILURE);
240237
}
241238

242239
using namespace std::chrono_literals;
@@ -249,6 +246,43 @@ void resetSiblingBMC()
249246
catch (const std::exception& e)
250247
{
251248
lg2::error("Failed releasing sibling reset: {ERROR}", "ERROR", e);
249+
exit(EXIT_FAILURE);
250+
}
251+
}
252+
253+
// NOLINTNEXTLINE
254+
sdbusplus::async::task<> modifyRedundancyOverride(
255+
sdbusplus::async::context& ctx, bool disable)
256+
{
257+
auto path =
258+
sdbusplus::message::object_path{Redundancy::namespace_path::value} /
259+
Redundancy::namespace_path::bmc;
260+
261+
try
262+
{
263+
// Use lg2 so it shows up in the journal as coming from rbmctool.
264+
lg2::info("Setting disable redundancy override to {DISABLED}",
265+
"DISABLED", disable);
266+
267+
co_await Redundancy(ctx)
268+
.service(Redundancy::interface)
269+
.path(path.str)
270+
.disable_redundancy_override(disable);
271+
}
272+
catch (const sdbusplus::exception_t& e)
273+
{
274+
if (std::string{"xyz.openbmc_project.Common.Error.Unavailable"} ==
275+
e.name())
276+
{
277+
std::cout
278+
<< "Error: Setting cannot be modified now (see journal for details)\n";
279+
}
280+
else
281+
{
282+
std::cout << "Unexpected error: " << e.what() << '\n';
283+
}
284+
285+
exit(EXIT_FAILURE);
252286
}
253287
}
254288

@@ -258,13 +292,32 @@ int main(int argc, char** argv)
258292
bool info{};
259293
bool extended{};
260294
bool resetSibling{};
295+
bool disableRedundancy{};
296+
bool enableRedundancy{};
261297
sdbusplus::async::context ctx;
262298

263-
auto* flag = app.add_flag("-d", info, "Display RBMC Information");
264-
app.add_flag("-e", extended, "Add extended RBMC details to the display")
299+
auto* displayGroup = app.add_option_group("Display RBMC information");
300+
auto* flag =
301+
displayGroup->add_flag("-d", info, "Display basic RBMC information");
302+
displayGroup->add_flag("-e", extended, "Add in extended details")
265303
->needs(flag);
266304

267-
app.add_flag("--reset-sibling", resetSibling, "Reset the sibling BMC");
305+
auto* overrideGroup =
306+
app.add_option_group("Modify the redundancy override");
307+
auto* disable = overrideGroup->add_flag(
308+
"-s, --set-disable-redundancy-override", disableRedundancy,
309+
"Set override to disable redundancy");
310+
311+
overrideGroup
312+
->add_flag("-c, --clear-disable-redundancy-override", enableRedundancy,
313+
"Clear override to disable redundancy")
314+
->excludes(disable);
315+
316+
auto* resetGroup = app.add_option_group("Reset sibling BMC");
317+
resetGroup->add_flag("--reset-sibling", resetSibling,
318+
"Reset the sibling BMC");
319+
320+
app.require_option(1);
268321

269322
CLI11_PARSE(app, argc, argv);
270323

@@ -276,6 +329,14 @@ int main(int argc, char** argv)
276329
{
277330
resetSiblingBMC();
278331
}
332+
else if (disableRedundancy)
333+
{
334+
ctx.spawn(modifyRedundancyOverride(ctx, true));
335+
}
336+
else if (enableRedundancy)
337+
{
338+
ctx.spawn(modifyRedundancyOverride(ctx, false));
339+
}
279340
else
280341
{
281342
std::cout << app.help();

0 commit comments

Comments
 (0)