diff --git a/dev-tools/reconfigurator-cli/src/lib.rs b/dev-tools/reconfigurator-cli/src/lib.rs index 5345d74c6b..6060184a1e 100644 --- a/dev-tools/reconfigurator-cli/src/lib.rs +++ b/dev-tools/reconfigurator-cli/src/lib.rs @@ -220,7 +220,7 @@ fn process_command( Commands::SledAdd(args) => cmd_sled_add(sim, args), Commands::SledRemove(args) => cmd_sled_remove(sim, args), Commands::SledShow(args) => cmd_sled_show(sim, args), - Commands::SledSetPolicy(args) => cmd_sled_set_policy(sim, args), + Commands::SledSet(args) => cmd_sled_set(sim, args), Commands::SledUpdateInstallDataset(args) => { cmd_sled_update_install_dataset(sim, args) } @@ -277,8 +277,8 @@ enum Commands { SledRemove(SledRemoveArgs), /// show details about one sled SledShow(SledArgs), - /// set a sled's policy - SledSetPolicy(SledSetPolicyArgs), + /// set a value on a sled + SledSet(SledSetArgs), /// update the install dataset on a sled, simulating a mupdate SledUpdateInstallDataset(SledUpdateInstallDatasetArgs), /// simulate updating the sled's SP versions @@ -361,11 +361,24 @@ struct SledArgs { } #[derive(Debug, Args)] -struct SledSetPolicyArgs { +struct SledSetArgs { /// id of the sled sled_id: SledOpt, - /// The policy to set for the sled + /// the command to set on the sled + #[clap(subcommand)] + command: SledSetCommand, +} + +#[derive(Debug, Subcommand)] +enum SledSetCommand { + /// set the policy for this sled + Policy(SledSetPolicyArgs), +} + +#[derive(Debug, Args)] +struct SledSetPolicyArgs { + /// the policy to set #[clap(value_enum)] policy: SledPolicyOpt, } @@ -1194,22 +1207,27 @@ fn cmd_sled_show( Ok(Some(s)) } -fn cmd_sled_set_policy( +fn cmd_sled_set( sim: &mut ReconfiguratorSim, - args: SledSetPolicyArgs, + args: SledSetArgs, ) -> anyhow::Result> { let mut state = sim.current_state().to_mut(); let system = state.system_mut(); let sled_id = args.sled_id.to_sled_id(system.description())?; - system.description_mut().sled_set_policy(sled_id, args.policy.into())?; - sim.commit_and_bump( - format!( - "reconfigurator-cli sled-set-policy: {} to {}", - sled_id, args.policy, - ), - state, - ); - Ok(Some(format!("set sled {} policy to {}", sled_id, args.policy))) + + match args.command { + SledSetCommand::Policy(SledSetPolicyArgs { policy }) => { + system.description_mut().sled_set_policy(sled_id, policy.into())?; + sim.commit_and_bump( + format!( + "reconfigurator-cli sled-set policy: {} to {}", + sled_id, policy + ), + state, + ); + Ok(Some(format!("set sled {sled_id} policy to {policy}"))) + } + } } fn cmd_sled_update_install_dataset( diff --git a/dev-tools/reconfigurator-cli/tests/input/cmds-noop-image-source.txt b/dev-tools/reconfigurator-cli/tests/input/cmds-noop-image-source.txt index f945938d88..9691c9b577 100644 --- a/dev-tools/reconfigurator-cli/tests/input/cmds-noop-image-source.txt +++ b/dev-tools/reconfigurator-cli/tests/input/cmds-noop-image-source.txt @@ -40,7 +40,7 @@ sled-update-install-dataset serial4 --from-repo repo-2.0.0.zip # On the sixth sled, update to the target release (so it shows up in inventory). # Then, mark the sled expunged (in the planning input). sled-update-install-dataset serial5 --to-target-release -sled-set-policy serial5 expunged +sled-set serial5 policy expunged # Generate an inventory and run a blueprint planning step. inventory-generate diff --git a/dev-tools/reconfigurator-cli/tests/output/cmds-noop-image-source-stdout b/dev-tools/reconfigurator-cli/tests/output/cmds-noop-image-source-stdout index 11fd49b79a..a9071945a1 100644 --- a/dev-tools/reconfigurator-cli/tests/output/cmds-noop-image-source-stdout +++ b/dev-tools/reconfigurator-cli/tests/output/cmds-noop-image-source-stdout @@ -135,7 +135,7 @@ sled b82ede02-399c-48c6-a1de-411df4fa49a7: install dataset updated: from repo at > sled-update-install-dataset serial5 --to-target-release sled 9a867dc9-d505-427f-9eff-cdb1d4d9bd73: install dataset updated: to target release (system version 1.0.0) -> sled-set-policy serial5 expunged +> sled-set serial5 policy expunged set sled 9a867dc9-d505-427f-9eff-cdb1d4d9bd73 policy to expunged