Skip to content
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
321 changes: 160 additions & 161 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,9 @@ gateway-client = { path = "clients/gateway-client" }
# compatibility, but will mean that faux-mgs might be missing new
# functionality.)
#
gateway-ereport-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "77e316c812aa057b9714d0d99c4a7bdd36d45be2", default-features = false, features = ["debug-impls"] }
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "77e316c812aa057b9714d0d99c4a7bdd36d45be2", default-features = false, features = ["std"] }
gateway-sp-comms = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "77e316c812aa057b9714d0d99c4a7bdd36d45be2" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also bump this hash in package-manifest.toml where pull in package.omicron-faux-mgs. (Always shipping an up-to-date faux-mgs is not critical, but it's nice to have.)

gateway-ereport-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "6bd2660d651332f38949cdfd3d23d751ca54b120", default-features = false, features = ["debug-impls"] }
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "6bd2660d651332f38949cdfd3d23d751ca54b120", default-features = false, features = ["std"] }
gateway-sp-comms = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "6bd2660d651332f38949cdfd3d23d751ca54b120" }
gateway-test-utils = { path = "gateway-test-utils" }
gateway-types = { path = "gateway-types" }
gethostname = "0.5.0"
Expand Down
3 changes: 3 additions & 0 deletions dev-tools/omdb/src/bin/omdb/mgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ fn show_sps_from_ignition(
id: SpIgnitionSystemType::Gimlet,
..
} => "Gimlet".to_string(),
SpIgnition::Yes {
id: SpIgnitionSystemType::Cosmo, ..
} => "Cosmo".to_string(),
SpIgnition::Yes {
id: SpIgnitionSystemType::Sidecar,
..
Expand Down
35 changes: 35 additions & 0 deletions gateway-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use gateway_types::{
},
component_details::SpComponentDetails,
host::{ComponentFirmwareHashStatus, HostStartupOptions},
ignition,
ignition::{IgnitionCommand, SpIgnitionInfo},
rot::{RotCfpa, RotCfpaSlot, RotCmpa, RotState},
sensor::SpSensorReading,
Expand Down Expand Up @@ -45,6 +46,7 @@ api_versions!([
// | example for the next person.
// v
// (next_int, IDENT),
(2, COSMO),
(1, INITIAL),
]);

Expand Down Expand Up @@ -407,6 +409,22 @@ pub trait GatewayApi {
#[endpoint {
method = GET,
path = "/ignition",
operation_id = "ignition_list",
versions = VERSION_INITIAL..VERSION_COSMO
}]
async fn ignition_list_v1(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<Vec<ignition::v1::SpIgnitionInfo>>, HttpError>;

/// List SPs via Ignition
///
/// Retreive information for all SPs via the Ignition controller. This is
/// lower latency and has fewer possible failure modes than querying the SP
/// over the management network.
#[endpoint {
method = GET,
path = "/ignition",
versions = VERSION_COSMO..
}]
async fn ignition_list(
rqctx: RequestContext<Self::Context>,
Expand All @@ -420,6 +438,23 @@ pub trait GatewayApi {
#[endpoint {
method = GET,
path = "/ignition/{type}/{slot}",
operation_id = "ignition_get",
versions = VERSION_INITIAL..VERSION_COSMO
}]
async fn ignition_get_v1(
rqctx: RequestContext<Self::Context>,
path: Path<PathSp>,
) -> Result<HttpResponseOk<ignition::v1::SpIgnitionInfo>, HttpError>;

/// Get SP info via Ignition
///
/// Retreive information for an SP via the Ignition controller. This is
/// lower latency and has fewer possible failure modes than querying the SP
/// over the management network.
#[endpoint {
method = GET,
path = "/ignition/{type}/{slot}",
versions = VERSION_COSMO..
}]
async fn ignition_get(
rqctx: RequestContext<Self::Context>,
Expand Down
2 changes: 1 addition & 1 deletion gateway-test-utils/src/sim_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub async fn current_simulator_state(simrack: &SimRack) -> Vec<SpInfo> {
};
let typ = match target_state.system_type {
SystemType::Sidecar => SpType::Switch,
SystemType::Gimlet => SpType::Sled,
SystemType::Gimlet | SystemType::Cosmo => SpType::Sled,
SystemType::Psc => {
todo!("testing simulated PSC not yet implemented")
}
Expand Down
38 changes: 38 additions & 0 deletions gateway-types/src/ignition/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

pub mod v1;
pub mod v2;

pub use v2::*;

/// Ignition command.
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, JsonSchema,
)]
#[serde(rename_all = "snake_case")]
pub enum IgnitionCommand {
PowerOn,
PowerOff,
PowerReset,
}

impl From<IgnitionCommand> for gateway_messages::IgnitionCommand {
fn from(cmd: IgnitionCommand) -> Self {
match cmd {
IgnitionCommand::PowerOn => {
gateway_messages::IgnitionCommand::PowerOn
}
IgnitionCommand::PowerOff => {
gateway_messages::IgnitionCommand::PowerOff
}
IgnitionCommand::PowerReset => {
gateway_messages::IgnitionCommand::PowerReset
}
}
}
}
29 changes: 2 additions & 27 deletions gateway-types/src/ignition.rs → gateway-types/src/ignition/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,33 +79,6 @@ impl From<gateway_messages::IgnitionState> for SpIgnition {
}
}

/// Ignition command.
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, JsonSchema,
)]
#[serde(rename_all = "snake_case")]
pub enum IgnitionCommand {
PowerOn,
PowerOff,
PowerReset,
}

impl From<IgnitionCommand> for gateway_messages::IgnitionCommand {
fn from(cmd: IgnitionCommand) -> Self {
match cmd {
IgnitionCommand::PowerOn => {
gateway_messages::IgnitionCommand::PowerOn
}
IgnitionCommand::PowerOff => {
gateway_messages::IgnitionCommand::PowerOff
}
IgnitionCommand::PowerReset => {
gateway_messages::IgnitionCommand::PowerReset
}
}
}
}

/// TODO: Do we want to bake in specific board names, or use raw u16 ID numbers?
#[derive(
Debug,
Expand Down Expand Up @@ -135,6 +108,8 @@ impl From<gateway_messages::ignition::SystemType> for SpIgnitionSystemType {
SystemType::Sidecar => Self::Sidecar,
SystemType::Psc => Self::Psc,
SystemType::Unknown(id) => Self::Unknown { id },
// `0x4` is the ignition value per RFD 142
SystemType::Cosmo => Self::Unknown { id: 0x4 },
}
}
}
164 changes: 164 additions & 0 deletions gateway-types/src/ignition/v2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::component::SpIdentifier;

#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Deserialize,
Serialize,
JsonSchema,
)]
pub struct SpIgnitionInfo {
pub id: SpIdentifier,
pub details: SpIgnition,
}

impl From<SpIgnitionInfo> for crate::ignition::v1::SpIgnitionInfo {
fn from(s: SpIgnitionInfo) -> Self {
Self { id: s.id, details: s.details.into() }
}
}

/// State of an ignition target.
//
// TODO: Ignition returns much more information than we're reporting here: do
// we want to expand this?
#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Deserialize,
Serialize,
JsonSchema,
)]
#[serde(tag = "present")]
pub enum SpIgnition {
#[serde(rename = "no")]
Absent,
#[serde(rename = "yes")]
Present {
id: SpIgnitionSystemType,
power: bool,
ctrl_detect_0: bool,
ctrl_detect_1: bool,
/// Fault from the A3 power domain
flt_a3: bool,
/// Fault from the A2 power domain
flt_a2: bool,
/// Fault from the RoT
flt_rot: bool,
/// Fault from the SP
flt_sp: bool,
},
}

impl From<gateway_messages::IgnitionState> for SpIgnition {
fn from(state: gateway_messages::IgnitionState) -> Self {
use gateway_messages::ignition::SystemPowerState;

if let Some(target_state) = state.target {
Self::Present {
id: target_state.system_type.into(),
power: matches!(
target_state.power_state,
SystemPowerState::On | SystemPowerState::PoweringOn
),
ctrl_detect_0: target_state.controller0_present,
ctrl_detect_1: target_state.controller1_present,
flt_a3: target_state.faults.power_a3,
flt_a2: target_state.faults.power_a2,
flt_rot: target_state.faults.rot,
flt_sp: target_state.faults.sp,
}
} else {
Self::Absent
}
}
}

impl From<SpIgnition> for crate::ignition::v1::SpIgnition {
fn from(state: SpIgnition) -> Self {
match state {
SpIgnition::Absent => Self::Absent,
SpIgnition::Present {
id,
power,
ctrl_detect_0,
ctrl_detect_1,
flt_a3,
flt_a2,
flt_rot,
flt_sp,
} => Self::Present {
id: id.into(),
power,
ctrl_detect_0,
ctrl_detect_1,
flt_a3,
flt_a2,
flt_rot,
flt_sp,
},
}
}
}

#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Ord,
Deserialize,
Serialize,
JsonSchema,
)]
#[serde(tag = "system_type", rename_all = "snake_case")]
pub enum SpIgnitionSystemType {
Gimlet,
Sidecar,
Psc,
Unknown { id: u16 },
Cosmo,
}

impl From<gateway_messages::ignition::SystemType> for SpIgnitionSystemType {
fn from(st: gateway_messages::ignition::SystemType) -> Self {
use gateway_messages::ignition::SystemType;
match st {
SystemType::Gimlet => Self::Gimlet,
SystemType::Sidecar => Self::Sidecar,
SystemType::Psc => Self::Psc,
SystemType::Unknown(id) => Self::Unknown { id },
SystemType::Cosmo => Self::Cosmo,
}
}
}

impl From<SpIgnitionSystemType> for crate::ignition::v1::SpIgnitionSystemType {
fn from(st: SpIgnitionSystemType) -> Self {
match st {
SpIgnitionSystemType::Gimlet => Self::Gimlet,
SpIgnitionSystemType::Sidecar => Self::Sidecar,
SpIgnitionSystemType::Psc => Self::Psc,
// Cosmo system id is 0x4
SpIgnitionSystemType::Cosmo => Self::Unknown { id: 0x4 },
SpIgnitionSystemType::Unknown { id } => Self::Unknown { id },
}
}
}
22 changes: 22 additions & 0 deletions gateway/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use gateway_types::component::SpState;
use gateway_types::component_details::SpComponentDetails;
use gateway_types::host::ComponentFirmwareHashStatus;
use gateway_types::host::HostStartupOptions;
use gateway_types::ignition;
use gateway_types::ignition::SpIgnitionInfo;
use gateway_types::rot::RotCfpa;
use gateway_types::rot::RotCfpaSlot;
Expand Down Expand Up @@ -825,6 +826,19 @@ impl GatewayApi for GatewayImpl {
apictx.latencies.instrument_dropshot_handler(&rqctx, handler).await
}

async fn ignition_list_v1(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<Vec<ignition::v1::SpIgnitionInfo>>, HttpError>
{
let HttpResponseOk(v2_info) = Self::ignition_list(rqctx).await?;
Ok(HttpResponseOk(
v2_info
.into_iter()
.map(|x| ignition::v1::SpIgnitionInfo::from(x))
.collect(),
))
}

async fn ignition_list(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<Vec<SpIgnitionInfo>>, HttpError> {
Expand All @@ -845,6 +859,14 @@ impl GatewayApi for GatewayImpl {
apictx.latencies.instrument_dropshot_handler(&rqctx, handler).await
}

async fn ignition_get_v1(
rqctx: RequestContext<Self::Context>,
path: Path<PathSp>,
) -> Result<HttpResponseOk<ignition::v1::SpIgnitionInfo>, HttpError> {
let HttpResponseOk(v2_info) = Self::ignition_get(rqctx, path).await?;
Ok(HttpResponseOk(ignition::v1::SpIgnitionInfo::from(v2_info)))
}

async fn ignition_get(
rqctx: RequestContext<Self::Context>,
path: Path<PathSp>,
Expand Down
2 changes: 1 addition & 1 deletion gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn start_dropshot_server(
.version_policy(dropshot::VersionPolicy::Dynamic(Box::new(
dropshot::ClientSpecifiesVersionInHeader::new(
omicron_common::api::VERSION_HEADER,
gateway_api::VERSION_INITIAL,
gateway_api::VERSION_COSMO,
),
)))
.start()
Expand Down
Loading
Loading