Skip to content

Commit a3dc674

Browse files
committed
openapi
1 parent b867be7 commit a3dc674

File tree

4 files changed

+80
-7
lines changed

4 files changed

+80
-7
lines changed

dev-tools/omdb/src/bin/omdb/db.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7579,8 +7579,8 @@ fn inv_collection_print_sled_config(label: &str, config: &OmicronSledConfig) {
75797579
HostPhase2DesiredContents::CurrentContents => {
75807580
Cow::Borrowed("keep existing current contents")
75817581
}
7582-
HostPhase2DesiredContents::Artifact(artifact) => {
7583-
Cow::Owned(format!("artifact {artifact}"))
7582+
HostPhase2DesiredContents::Artifact { hash } => {
7583+
Cow::Owned(format!("artifact {hash}"))
75847584
}
75857585
};
75867586
println!(

nexus-sled-agent-shared/src/inventory.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ pub enum SledRole {
581581
#[derive(
582582
Clone, Copy, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq,
583583
)]
584+
#[serde(tag = "type", rename_all = "snake_case")]
584585
pub enum HostPhase2DesiredContents {
585586
/// Do not change the current contents.
586587
///
@@ -593,11 +594,12 @@ pub enum HostPhase2DesiredContents {
593594
/// Set the phase 2 slot to the given artifact.
594595
///
595596
/// The artifact will come from an unpacked and distributed TUF repo.
596-
Artifact(ArtifactHash),
597+
Artifact { hash: ArtifactHash },
597598
}
598599

599600
/// Describes the desired contents for both host phase 2 slots.
600601
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq)]
602+
#[serde(rename_all = "snake_case")]
601603
pub struct HostPhase2DesiredSlots {
602604
pub slot_a: HostPhase2DesiredContents,
603605
pub slot_b: HostPhase2DesiredContents,

nexus/db-model/src/inventory.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,8 +1980,8 @@ impl From<HostPhase2DesiredSlots> for DbHostPhase2DesiredSlots {
19801980
fn from(value: HostPhase2DesiredSlots) -> Self {
19811981
let remap = |desired| match desired {
19821982
HostPhase2DesiredContents::CurrentContents => None,
1983-
HostPhase2DesiredContents::Artifact(artifact) => {
1984-
Some(ArtifactHash(artifact))
1983+
HostPhase2DesiredContents::Artifact { hash } => {
1984+
Some(ArtifactHash(hash))
19851985
}
19861986
};
19871987
Self {
@@ -1995,8 +1995,8 @@ impl From<DbHostPhase2DesiredSlots> for HostPhase2DesiredSlots {
19951995
fn from(value: DbHostPhase2DesiredSlots) -> Self {
19961996
let remap = |maybe_artifact| match maybe_artifact {
19971997
None => HostPhase2DesiredContents::CurrentContents,
1998-
Some(ArtifactHash(artifact)) => {
1999-
HostPhase2DesiredContents::Artifact(artifact)
1998+
Some(ArtifactHash(hash)) => {
1999+
HostPhase2DesiredContents::Artifact { hash }
20002000
}
20012001
};
20022002
Self {

openapi/sled-agent.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4722,6 +4722,62 @@
47224722
}
47234723
]
47244724
},
4725+
"HostPhase2DesiredContents": {
4726+
"description": "Describes the desired contents of a host phase 2 slot (i.e., the boot partition on one of the internal M.2 drives).",
4727+
"oneOf": [
4728+
{
4729+
"description": "Do not change the current contents.\n\nWe use this value when we've detected a sled has been mupdated (and we don't want to overwrite phase 2 images until we understand how to recover from that mupdate) and as the default value when reading an [`OmicronSledConfig`] that was ledgered before this concept existed.",
4730+
"type": "object",
4731+
"properties": {
4732+
"type": {
4733+
"type": "string",
4734+
"enum": [
4735+
"current_contents"
4736+
]
4737+
}
4738+
},
4739+
"required": [
4740+
"type"
4741+
]
4742+
},
4743+
{
4744+
"description": "Set the phase 2 slot to the given artifact.\n\nThe artifact will come from an unpacked and distributed TUF repo.",
4745+
"type": "object",
4746+
"properties": {
4747+
"hash": {
4748+
"type": "string",
4749+
"format": "hex string (32 bytes)"
4750+
},
4751+
"type": {
4752+
"type": "string",
4753+
"enum": [
4754+
"artifact"
4755+
]
4756+
}
4757+
},
4758+
"required": [
4759+
"hash",
4760+
"type"
4761+
]
4762+
}
4763+
]
4764+
},
4765+
"HostPhase2DesiredSlots": {
4766+
"description": "Describes the desired contents for both host phase 2 slots.",
4767+
"type": "object",
4768+
"properties": {
4769+
"slot_a": {
4770+
"$ref": "#/components/schemas/HostPhase2DesiredContents"
4771+
},
4772+
"slot_b": {
4773+
"$ref": "#/components/schemas/HostPhase2DesiredContents"
4774+
}
4775+
},
4776+
"required": [
4777+
"slot_a",
4778+
"slot_b"
4779+
]
4780+
},
47254781
"HostPortConfig": {
47264782
"type": "object",
47274783
"properties": {
@@ -5874,6 +5930,21 @@
58745930
"generation": {
58755931
"$ref": "#/components/schemas/Generation"
58765932
},
5933+
"host_phase_2": {
5934+
"default": {
5935+
"slot_a": {
5936+
"type": "current_contents"
5937+
},
5938+
"slot_b": {
5939+
"type": "current_contents"
5940+
}
5941+
},
5942+
"allOf": [
5943+
{
5944+
"$ref": "#/components/schemas/HostPhase2DesiredSlots"
5945+
}
5946+
]
5947+
},
58775948
"remove_mupdate_override": {
58785949
"nullable": true,
58795950
"allOf": [

0 commit comments

Comments
 (0)