diff --git a/dev-tools/omdb/src/bin/omdb/db.rs b/dev-tools/omdb/src/bin/omdb/db.rs index 5e83cb38cb4..ac70666664b 100644 --- a/dev-tools/omdb/src/bin/omdb/db.rs +++ b/dev-tools/omdb/src/bin/omdb/db.rs @@ -84,6 +84,7 @@ enum DbCommands { Services(ServicesArgs), /// Print information about sleds Sleds, + /// Print information about the network Network(NetworkArgs), } @@ -166,6 +167,7 @@ struct NetworkArgs { #[command(subcommand)] command: NetworkCommands, + /// Print out raw data structures from the data store. #[clap(long)] verbose: bool, } @@ -960,14 +962,18 @@ async fn cmd_db_eips( owner: Owner, } + if verbose { + for ip in &ips { + if verbose { + println!("{ip:#?}"); + } + } + return Ok(()); + } + let mut rows = Vec::new(); for ip in &ips { - if verbose { - println!("{ip:#?}"); - continue; - } - let owner = if let Some(owner_id) = ip.parent_id { if ip.is_service { let service = LookupPath::new(opctx, datastore) @@ -985,7 +991,7 @@ async fn cmd_db_eips( .await .context("loading requested instance")? .pop() - .context("loading requested instance")?; + .context("requested instance not found")?; use db::schema::project::dsl as project_dsl; let project = project_dsl::project @@ -996,7 +1002,7 @@ async fn cmd_db_eips( .await .context("loading requested project")? .pop() - .context("loading requested instance")?; + .context("requested project not found")?; Owner::Instance { project: project.name().to_string(), @@ -1019,14 +1025,12 @@ async fn cmd_db_eips( rows.push(row); } - if !verbose { - rows.sort_by(|a, b| a.ip.cmp(&b.ip)); - let table = tabled::Table::new(rows) - .with(tabled::settings::Style::empty()) - .to_string(); + rows.sort_by(|a, b| a.ip.cmp(&b.ip)); + let table = tabled::Table::new(rows) + .with(tabled::settings::Style::empty()) + .to_string(); - println!("{}", table); - } + println!("{}", table); Ok(()) } diff --git a/dev-tools/omdb/tests/successes.out b/dev-tools/omdb/tests/successes.out index 7532e9b61e0..c935d4ba982 100644 --- a/dev-tools/omdb/tests/successes.out +++ b/dev-tools/omdb/tests/successes.out @@ -84,6 +84,24 @@ stderr: note: using database URL postgresql://root@[::1]:REDACTED_PORT/omicron?sslmode=disable note: database schema version matches expected (4.0.0) ============================================= +EXECUTING COMMAND: omdb ["db", "network"] +termination: Exited(2) +--------------------------------------------- +stdout: +--------------------------------------------- +stderr: +Print information about the network + +Usage: omdb db network [OPTIONS] + +Commands: + list-eips List external IPs + help Print this message or the help of the given subcommand(s) + +Options: + --verbose Print out raw data structures from the data store + -h, --help Print help +============================================= EXECUTING COMMAND: omdb ["nexus", "background-tasks", "doc"] termination: Exited(0) --------------------------------------------- diff --git a/dev-tools/omdb/tests/test_all_output.rs b/dev-tools/omdb/tests/test_all_output.rs index 0eddcb492cc..7028ec57106 100644 --- a/dev-tools/omdb/tests/test_all_output.rs +++ b/dev-tools/omdb/tests/test_all_output.rs @@ -69,6 +69,7 @@ async fn test_omdb_success_cases(cptestctx: &ControlPlaneTestContext) { &["db", "services", "list-instances"], &["db", "services", "list-by-sled"], &["db", "sleds"], + &["db", "network"], &["nexus", "background-tasks", "doc"], &["nexus", "background-tasks", "show"], // We can't easily test the sled agent output because that's only diff --git a/dev-tools/omdb/tests/usage_errors.out b/dev-tools/omdb/tests/usage_errors.out index 8afcf13fb1b..d17e16f0683 100644 --- a/dev-tools/omdb/tests/usage_errors.out +++ b/dev-tools/omdb/tests/usage_errors.out @@ -90,6 +90,7 @@ Commands: dns Print information about internal and external DNS services Print information about control plane services sleds Print information about sleds + network Print information about the network help Print this message or the help of the given subcommand(s) Options: @@ -110,6 +111,7 @@ Commands: dns Print information about internal and external DNS services Print information about control plane services sleds Print information about sleds + network Print information about the network help Print this message or the help of the given subcommand(s) Options: