Skip to content

Commit 8d4cbae

Browse files
authored
[25/n] [reconfigurator-cli] rename sled-set-policy to sled-set ... policy (#8495)
We're going to add other knobs to set on sleds, e.g. mupdate-override and whether the sled is temporarily hidden from inventory. Moving all of them to being subcommands of sled-set makes sense.
1 parent 80a9e91 commit 8d4cbae

File tree

3 files changed

+36
-18
lines changed

3 files changed

+36
-18
lines changed

dev-tools/reconfigurator-cli/src/lib.rs

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn process_command(
220220
Commands::SledAdd(args) => cmd_sled_add(sim, args),
221221
Commands::SledRemove(args) => cmd_sled_remove(sim, args),
222222
Commands::SledShow(args) => cmd_sled_show(sim, args),
223-
Commands::SledSetPolicy(args) => cmd_sled_set_policy(sim, args),
223+
Commands::SledSet(args) => cmd_sled_set(sim, args),
224224
Commands::SledUpdateInstallDataset(args) => {
225225
cmd_sled_update_install_dataset(sim, args)
226226
}
@@ -277,8 +277,8 @@ enum Commands {
277277
SledRemove(SledRemoveArgs),
278278
/// show details about one sled
279279
SledShow(SledArgs),
280-
/// set a sled's policy
281-
SledSetPolicy(SledSetPolicyArgs),
280+
/// set a value on a sled
281+
SledSet(SledSetArgs),
282282
/// update the install dataset on a sled, simulating a mupdate
283283
SledUpdateInstallDataset(SledUpdateInstallDatasetArgs),
284284
/// simulate updating the sled's SP versions
@@ -361,11 +361,24 @@ struct SledArgs {
361361
}
362362

363363
#[derive(Debug, Args)]
364-
struct SledSetPolicyArgs {
364+
struct SledSetArgs {
365365
/// id of the sled
366366
sled_id: SledOpt,
367367

368-
/// The policy to set for the sled
368+
/// the command to set on the sled
369+
#[clap(subcommand)]
370+
command: SledSetCommand,
371+
}
372+
373+
#[derive(Debug, Subcommand)]
374+
enum SledSetCommand {
375+
/// set the policy for this sled
376+
Policy(SledSetPolicyArgs),
377+
}
378+
379+
#[derive(Debug, Args)]
380+
struct SledSetPolicyArgs {
381+
/// the policy to set
369382
#[clap(value_enum)]
370383
policy: SledPolicyOpt,
371384
}
@@ -1194,22 +1207,27 @@ fn cmd_sled_show(
11941207
Ok(Some(s))
11951208
}
11961209

1197-
fn cmd_sled_set_policy(
1210+
fn cmd_sled_set(
11981211
sim: &mut ReconfiguratorSim,
1199-
args: SledSetPolicyArgs,
1212+
args: SledSetArgs,
12001213
) -> anyhow::Result<Option<String>> {
12011214
let mut state = sim.current_state().to_mut();
12021215
let system = state.system_mut();
12031216
let sled_id = args.sled_id.to_sled_id(system.description())?;
1204-
system.description_mut().sled_set_policy(sled_id, args.policy.into())?;
1205-
sim.commit_and_bump(
1206-
format!(
1207-
"reconfigurator-cli sled-set-policy: {} to {}",
1208-
sled_id, args.policy,
1209-
),
1210-
state,
1211-
);
1212-
Ok(Some(format!("set sled {} policy to {}", sled_id, args.policy)))
1217+
1218+
match args.command {
1219+
SledSetCommand::Policy(SledSetPolicyArgs { policy }) => {
1220+
system.description_mut().sled_set_policy(sled_id, policy.into())?;
1221+
sim.commit_and_bump(
1222+
format!(
1223+
"reconfigurator-cli sled-set policy: {} to {}",
1224+
sled_id, policy
1225+
),
1226+
state,
1227+
);
1228+
Ok(Some(format!("set sled {sled_id} policy to {policy}")))
1229+
}
1230+
}
12131231
}
12141232

12151233
fn cmd_sled_update_install_dataset(

dev-tools/reconfigurator-cli/tests/input/cmds-noop-image-source.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ sled-update-install-dataset serial4 --from-repo repo-2.0.0.zip
4040
# On the sixth sled, update to the target release (so it shows up in inventory).
4141
# Then, mark the sled expunged (in the planning input).
4242
sled-update-install-dataset serial5 --to-target-release
43-
sled-set-policy serial5 expunged
43+
sled-set serial5 policy expunged
4444

4545
# Generate an inventory and run a blueprint planning step.
4646
inventory-generate

dev-tools/reconfigurator-cli/tests/output/cmds-noop-image-source-stdout

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ sled b82ede02-399c-48c6-a1de-411df4fa49a7: install dataset updated: from repo at
135135
> sled-update-install-dataset serial5 --to-target-release
136136
sled 9a867dc9-d505-427f-9eff-cdb1d4d9bd73: install dataset updated: to target release (system version 1.0.0)
137137

138-
> sled-set-policy serial5 expunged
138+
> sled-set serial5 policy expunged
139139
set sled 9a867dc9-d505-427f-9eff-cdb1d4d9bd73 policy to expunged
140140

141141

0 commit comments

Comments
 (0)