Skip to content

[25/n] [reconfigurator-cli] rename sled-set-policy to sled-set ... policy #8495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 34 additions & 16 deletions dev-tools/reconfigurator-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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<Option<String>> {
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Loading