Skip to content
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

omdb: add "mgs sensors" and "mgs dashboard" commands #4973

Merged
merged 24 commits into from
Feb 6, 2024
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
39 changes: 37 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ crossterm = { version = "0.27.0", features = ["event-stream"] }
crucible-agent-client = { git = "https://github.com/oxidecomputer/crucible", rev = "2d4bc11232d53f177c286383926fa5f8c1b2a938" }
crucible-pantry-client = { git = "https://github.com/oxidecomputer/crucible", rev = "2d4bc11232d53f177c286383926fa5f8c1b2a938" }
crucible-smf = { git = "https://github.com/oxidecomputer/crucible", rev = "2d4bc11232d53f177c286383926fa5f8c1b2a938" }
csv = "1.3.0"
curve25519-dalek = "4"
datatest-stable = "0.2.3"
display-error-chain = "0.2.0"
Expand All @@ -197,6 +198,7 @@ dns-server = { path = "dns-server" }
dns-service-client = { path = "clients/dns-service-client" }
dpd-client = { path = "clients/dpd-client" }
dropshot = { git = "https://github.com/oxidecomputer/dropshot", branch = "main", features = [ "usdt-probes" ] }
dyn-clone = "1.0.16"
either = "1.9.0"
expectorate = "1.1.0"
fatfs = "0.3.6"
Expand Down Expand Up @@ -248,6 +250,7 @@ mime_guess = "2.0.4"
mockall = "0.12"
newtype_derive = "0.1.6"
mg-admin-client = { path = "clients/mg-admin-client" }
multimap = "0.8.1"
nexus-blueprint-execution = { path = "nexus/blueprint-execution" }
nexus-client = { path = "clients/nexus-client" }
nexus-db-model = { path = "nexus/db-model" }
Expand Down
5 changes: 5 additions & 0 deletions dev-tools/omdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ anyhow.workspace = true
async-bb8-diesel.workspace = true
chrono.workspace = true
clap.workspace = true
crossterm.workspace = true
crucible-agent-client.workspace = true
csv.workspace = true
diesel.workspace = true
dropshot.workspace = true
dyn-clone.workspace = true
futures.workspace = true
gateway-client.workspace = true
gateway-messages.workspace = true
Expand All @@ -29,6 +32,7 @@ omicron-common.workspace = true
oximeter-client.workspace = true
# See omicron-rpaths for more about the "pq-sys" dependency.
pq-sys = "*"
ratatui.workspace = true
serde.workspace = true
serde_json.workspace = true
sled-agent-client.workspace = true
Expand All @@ -43,6 +47,7 @@ uuid.workspace = true
ipnetwork.workspace = true
omicron-workspace-hack.workspace = true
nexus-test-utils.workspace = true
multimap.workspace = true

[dev-dependencies]
expectorate.workspace = true
Expand Down
39 changes: 34 additions & 5 deletions dev-tools/omdb/src/bin/omdb/mgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ use gateway_client::types::SpState;
use gateway_client::types::SpType;
use tabled::Tabled;

mod dashboard;
mod sensors;

use dashboard::DashboardArgs;
use sensors::SensorsArgs;

/// Arguments to the "omdb mgs" subcommand
#[derive(Debug, Args)]
pub struct MgsArgs {
Expand All @@ -35,19 +41,25 @@ pub struct MgsArgs {

#[derive(Debug, Subcommand)]
enum MgsCommands {
/// Dashboard of SPs
Dashboard(DashboardArgs),

/// Show information about devices and components visible to MGS
Inventory(InventoryArgs),

/// Show information about sensors, as gleaned by MGS
Sensors(SensorsArgs),
}

#[derive(Debug, Args)]
struct InventoryArgs {}

impl MgsArgs {
pub(crate) async fn run_cmd(
async fn mgs_client(
&self,
omdb: &Omdb,
log: &slog::Logger,
) -> Result<(), anyhow::Error> {
) -> Result<gateway_client::Client, anyhow::Error> {
let mgs_url = match &self.mgs_url {
Some(cli_or_env_url) => cli_or_env_url.clone(),
None => {
Expand All @@ -68,11 +80,24 @@ impl MgsArgs {
}
};
eprintln!("note: using MGS URL {}", &mgs_url);
let mgs_client = gateway_client::Client::new(&mgs_url, log.clone());
Ok(gateway_client::Client::new(&mgs_url, log.clone()))
}

pub(crate) async fn run_cmd(
&self,
omdb: &Omdb,
log: &slog::Logger,
) -> Result<(), anyhow::Error> {
match &self.command {
MgsCommands::Inventory(inventory_args) => {
cmd_mgs_inventory(&mgs_client, inventory_args).await
MgsCommands::Dashboard(args) => {
dashboard::cmd_mgs_dashboard(omdb, log, self, args).await
}
MgsCommands::Inventory(args) => {
let mgs_client = self.mgs_client(omdb, log).await?;
cmd_mgs_inventory(&mgs_client, args).await
}
MgsCommands::Sensors(args) => {
sensors::cmd_mgs_sensors(omdb, log, self, args).await
}
}
}
Expand Down Expand Up @@ -156,6 +181,10 @@ fn sp_type_to_str(s: &SpType) -> &'static str {
}
}

fn sp_to_string(s: &SpIdentifier) -> String {
format!("{} {}", sp_type_to_str(&s.type_), s.slot)
}

fn show_sp_ids(sp_ids: &[SpIdentifier]) -> Result<(), anyhow::Error> {
#[derive(Tabled)]
#[tabled(rename_all = "SCREAMING_SNAKE_CASE")]
Expand Down
Loading
Loading