Skip to content

add omdb read and write method for bootstore #8476

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
49 changes: 49 additions & 0 deletions dev-tools/omdb/src/bin/omdb/sled_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ enum ZoneCommands {
enum BootstoreCommands {
/// Show the internal state of the local bootstore node
Status,

/// Read the network config
ReadNetworkConfigCache,
WriteNetworkConfig,
}

#[derive(Debug, Subcommand)]
Expand Down Expand Up @@ -105,6 +109,12 @@ impl SledAgentArgs {
SledAgentCommands::Bootstore(BootstoreCommands::Status) => {
cmd_bootstore_status(&client).await
}
SledAgentCommands::Bootstore(
BootstoreCommands::ReadNetworkConfigCache,
) => cmd_read_network_config_cache(&client).await,
SledAgentCommands::Bootstore(
BootstoreCommands::WriteNetworkConfig,
) => cmd_write_network_config(&client).await,
SledAgentCommands::ChickenSwitch(
ChickenSwitchCommands::DestroyOrphans(DestroyOrphansArgs {
command: DestroyOrphansCommands::Get,
Expand Down Expand Up @@ -151,11 +161,50 @@ async fn cmd_zones_list(
Ok(())
}

/// Runs `omdb sled-agent bootstore read-network-config-cache`
async fn cmd_read_network_config_cache(
client: &sled_agent_client::Client,
) -> Result<(), anyhow::Error> {
let config_cache = client
.read_network_bootstore_config_cache()
.await
.context("bootstore network config")?;

let out = serde_json::json!(*config_cache);

println!("{out}");

Ok(())
}

/// Runs `omdb sled-agent bootstore read-network-config-cache`
async fn cmd_write_network_config(
client: &sled_agent_client::Client,
) -> Result<(), anyhow::Error> {
let config = sled_agent_client::types::EarlyNetworkConfig {
body: todo!(),
generation: todo!(),
schema_version: todo!(),
};
let config_cache = client
.write_network_bootstore_config(&config)
.await
.context("bootstore network config")?;

println!("{config_cache:#?}");

Ok(())
}

/// Runs `omdb sled-agent bootstore status`
async fn cmd_bootstore_status(
client: &sled_agent_client::Client,
) -> Result<(), anyhow::Error> {
let status = client.bootstore_status().await.context("bootstore status")?;
let config_cache = client
.read_network_bootstore_config_cache()
.await
.context("bootstore network config")?;
println!("fsm ledger generation: {}", status.fsm_ledger_generation);
println!(
"network config ledger generation: {:?}",
Expand Down
Loading