diff --git a/crates/admin-cli/src/redfish/args.rs b/crates/admin-cli/src/redfish/args.rs index 5b6d18bec9..fd43d1802e 100644 --- a/crates/admin-cli/src/redfish/args.rs +++ b/crates/admin-cli/src/redfish/args.rs @@ -231,6 +231,21 @@ Clear the UEFI password (supply the current one): ClearNvram, /// Set BIOS options SetBios(SetBios), + /// Reset BIOS settings to factory defaults. Returns once the BMC accepts + /// the reset request. A system restart is required for the settings to + /// take effect. + #[command(after_long_help = "\ +EXAMPLES: + +Reset BIOS settings to factory defaults: + $ nico-admin-cli redfish --address 192.0.2.10 --username admin --password mypassword reset-bios + +Reset BIOS settings and restart the system to apply the change: + $ nico-admin-cli redfish --address 192.0.2.10 --username admin --password mypassword \ + reset-bios --reboot + +")] + ResetBios(ResetBiosArgs), /// Get DPU mode GetNicMode, /// Is infinite boot enable @@ -524,6 +539,16 @@ pub struct MachineSetupStatusArgs { pub boot_interface_mac: Option, } +#[derive(Parser, Debug, PartialEq, Clone)] +pub struct ResetBiosArgs { + #[clap( + short, + long, + help = "Perform a forced restart after the BMC accepts the BIOS reset request" + )] + pub reboot: bool, +} + #[derive(Parser, Debug, PartialEq, Clone)] pub struct SetBootOrderDpuFirstArgs { #[clap(long, help = "boot_interface_mac")] diff --git a/crates/admin-cli/src/redfish/cmds.rs b/crates/admin-cli/src/redfish/cmds.rs index 0fd8123b5c..4d162255c1 100644 --- a/crates/admin-cli/src/redfish/cmds.rs +++ b/crates/admin-cli/src/redfish/cmds.rs @@ -476,6 +476,14 @@ pub async fn action(action: RedfishAction) -> color_eyre::Result<()> { redfish.set_bios(attrmap).await?; println!("success"); } + ResetBios(args) => { + redfish.reset_bios().await?; + if args.reboot { + redfish.power(SystemPowerControl::ForceRestart).await?; + } else { + println!("BIOS changes require a system restart to take effect."); + } + } GetNicMode => { let is_dpu_in_nic_mode = redfish.get_nic_mode().await?; println!("{is_dpu_in_nic_mode:#?}"); diff --git a/crates/admin-cli/src/redfish/tests.rs b/crates/admin-cli/src/redfish/tests.rs index d179d02ac8..37bb510565 100644 --- a/crates/admin-cli/src/redfish/tests.rs +++ b/crates/admin-cli/src/redfish/tests.rs @@ -173,6 +173,33 @@ fn parse_create_bmc_user() { ); } +#[test] +fn parse_reset_bios() { + scenarios!( + run = |argv| { + RedfishAction::try_parse_from(argv.iter().copied()) + .map(|a| match a.command { + Cmd::ResetBios(args) => args.reboot, + _ => panic!("expected ResetBios variant"), + }) + .map_err(drop) + }; + "without reboot" { + &["redfish", "--address", "192.0.2.10", "reset-bios"][..] => Yields(false), + } + + "with reboot" { + &[ + "redfish", + "--address", + "192.0.2.10", + "reset-bios", + "--reboot", + ][..] => Yields(true), + } + ); +} + // `dpu firmware status` parses through the nested DpuOperations / FwCommand // subcommands to the Dpu Firmware Status variant. #[test] diff --git a/docs/manuals/nico-admin-cli/commands/redfish/redfish-reset-bios.md b/docs/manuals/nico-admin-cli/commands/redfish/redfish-reset-bios.md new file mode 100644 index 0000000000..50b4d7810d --- /dev/null +++ b/docs/manuals/nico-admin-cli/commands/redfish/redfish-reset-bios.md @@ -0,0 +1,55 @@ +# `nico-admin-cli redfish reset-bios` + +_[Hardware commands](../../hardware.md) › [redfish](./redfish.md) › **reset-bios**_ + +## NAME + +nico-admin-cli-redfish-reset-bios - Reset BIOS settings to factory +defaults + +## SYNOPSIS + +**nico-admin-cli redfish reset-bios** \[**-r**\|**--reboot**\] +\[**--extended**\] \[**--sort-by** *\*\] \[**-h**\|**--help**\] + +## DESCRIPTION + +Reset BIOS settings to factory defaults. Returns once the BMC accepts +the reset request. A system restart is required for the settings to take +effect. + +## OPTIONS + +**-r**, **--reboot** +Perform a forced restart after the BMC accepts the BIOS reset request + +**--extended** +Extended result output. + +This is used by measured boot, where basic output contains just what you +probably care about, and "extended" output also dumps out all the +internal UUIDs that are used to associate instances. + +**--sort-by** *\* \[default: primary-id\] +Sort output by specified field\ + +\ +*Possible values:* + +- primary-id: Sort by the primary id + +- state: Sort by state + +**-h**, **--help** +Print help (see a summary with -h) + +## Examples + +```sh +nico-admin-cli redfish --address 192.0.2.10 --username admin --password mypassword reset-bios +nico-admin-cli redfish --address 192.0.2.10 --username admin --password mypassword reset-bios --reboot +``` + +--- + +**See also:** [Hardware commands](../../hardware.md) · [CLI reference index](../../README.md) diff --git a/docs/manuals/nico-admin-cli/commands/redfish/redfish.md b/docs/manuals/nico-admin-cli/commands/redfish/redfish.md index 384aeb226e..0d3ba24f31 100644 --- a/docs/manuals/nico-admin-cli/commands/redfish/redfish.md +++ b/docs/manuals/nico-admin-cli/commands/redfish/redfish.md @@ -117,6 +117,7 @@ nico-admin-cli redfish --address 192.0.2.10 --username admin --password mypasswo | [`get-base-mac-address`](./redfish-get-base-mac-address.md) | Get Base Mac Address (DPU only) | | [`clear-nvram`](./redfish-clear-nvram.md) | Clear Nvram (Viking only) | | [`set-bios`](./redfish-set-bios.md) | Set BIOS options | +| [`reset-bios`](./redfish-reset-bios.md) | Reset BIOS settings to factory defaults | | [`get-nic-mode`](./redfish-get-nic-mode.md) | Get DPU mode | | [`is-infinite-boot-enabled`](./redfish-is-infinite-boot-enabled.md) | Is infinite boot enable | | [`enable-infinite-boot`](./redfish-enable-infinite-boot.md) | Enable infinite boot |