Skip to content

Commit 1845a3c

Browse files
committed
well here's some turbo jank that vaguely works
1 parent e3e2d77 commit 1845a3c

File tree

7 files changed

+258
-137
lines changed

7 files changed

+258
-137
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nexus/fm/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ schemars.workspace = true
1717
serde.workspace = true
1818
serde_json.workspace = true
1919
slog.workspace = true
20+
slog-error-chain.workspace = true
2021
typed-rng.workspace = true
2122

2223
omicron-workspace-hack.workspace = true

nexus/fm/src/alert.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
//! Alert messages.
66
7+
use crate::ereport_analysis::Baseboard;
78
use nexus_types::fm::AlertClass;
89
use schemars::JsonSchema;
910
use serde::{Deserialize, Serialize};
@@ -16,7 +17,14 @@ pub trait Alert: Serialize + JsonSchema + std::fmt::Debug {
1617

1718
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
1819
pub struct VpdIdentity {
19-
pub part_number: Option<String>,
20-
pub revision: Option<String>,
21-
pub serial_number: Option<String>,
20+
pub part_number: String,
21+
pub revision: String,
22+
pub serial_number: String,
23+
}
24+
25+
impl From<Baseboard> for VpdIdentity {
26+
fn from(baseboard: Baseboard) -> Self {
27+
let Baseboard { part_number, serial_number, rev } = baseboard;
28+
Self { part_number, revision: rev.to_string(), serial_number }
29+
}
2230
}

nexus/fm/src/alert/power_shelf.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! Power shelf alerts.
66
77
use super::{Alert, VpdIdentity};
8+
use chrono::{DateTime, Utc};
89
use nexus_types::fm::AlertClass;
910
use schemars::JsonSchema;
1011
use serde::{Deserialize, Serialize};
@@ -15,6 +16,7 @@ pub enum PsuInserted {
1516
V0 {
1617
#[serde(flatten)]
1718
psc_psu: PscPsu,
19+
time: DateTime<Utc>,
1820
},
1921
}
2022

@@ -28,16 +30,17 @@ pub enum PsuRemoved {
2830
V0 {
2931
#[serde(flatten)]
3032
psc_psu: PscPsu,
33+
time: DateTime<Utc>,
3134
},
3235
}
3336

3437
impl Alert for PsuRemoved {
35-
const CLASS: AlertClass = AlertClass::PsuInserted;
38+
const CLASS: AlertClass = AlertClass::PsuRemoved;
3639
}
3740

3841
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
3942
pub struct PscPsu {
40-
pub psc_id: VpdIdentity,
43+
pub psc_id: Option<VpdIdentity>,
4144
pub psc_slot: u16,
4245
pub psu_id: PsuIdentity,
4346
pub psu_slot: Option<u16>,

nexus/fm/src/builder/case.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ impl CaseBuilder {
120120
rng: rng::CaseBuilderRng,
121121
) -> Self {
122122
let log = log.new(slog::o!(
123-
"case_id" => format!("{:?}", case.id),
123+
"case_id" => case.id.to_string(),
124124
"de" => case.de.to_string(),
125-
"created_sitrep_id" => format!("{:?}", case.created_sitrep_id),
125+
"created_sitrep_id" => case.created_sitrep_id.to_string(),
126126
));
127127
Self { log, case, sitrep_id, rng }
128128
}
@@ -150,7 +150,7 @@ impl CaseBuilder {
150150
slog::info!(
151151
&self.log,
152152
"requested an alert";
153-
"alert_id" => ?id,
153+
"alert_id" => %id,
154154
"alert_class" => ?class,
155155
);
156156

@@ -178,15 +178,15 @@ impl CaseBuilder {
178178
slog::info!(
179179
self.log,
180180
"assigned ereport {} to case", report.id();
181-
"ereport_id" => ?report.id(),
181+
"ereport_id" => %report.id(),
182182
"ereport_class" => ?report.class,
183183
);
184184
}
185185
Err(_) => {
186186
slog::warn!(
187187
self.log,
188188
"ereport {} already assigned to case", report.id();
189-
"ereport_id" => ?report.id(),
189+
"ereport_id" => %report.id(),
190190
"ereport_class" => ?report.class,
191191
);
192192
}

0 commit comments

Comments
 (0)