55//! Types for representing the deployed software and configuration in the
66//! database
77
8- use crate :: inventory:: ZoneType ;
8+ use crate :: inventory:: { SpMgsSlot , SpType , ZoneType } ;
99use crate :: omicron_zone_config:: { self , OmicronZoneNic } ;
1010use crate :: typed_uuid:: DbTypedUuid ;
1111use crate :: {
12- ArtifactHash , ByteCount , DbOximeterReadMode , Generation , MacAddr , Name ,
13- SledState , SqlU8 , SqlU16 , SqlU32 , TufArtifact , impl_enum_type, ipv6,
12+ ArtifactHash , ByteCount , DbArtifactVersion , DbOximeterReadMode , Generation ,
13+ MacAddr , Name , SledState , SqlU8 , SqlU16 , SqlU32 , TufArtifact ,
14+ impl_enum_type, ipv6,
1415} ;
1516use anyhow:: { Context , Result , anyhow, bail} ;
1617use chrono:: { DateTime , Utc } ;
@@ -21,10 +22,10 @@ use nexus_db_schema::schema::{
2122 bp_clickhouse_keeper_zone_id_to_node_id,
2223 bp_clickhouse_server_zone_id_to_node_id, bp_omicron_dataset,
2324 bp_omicron_physical_disk, bp_omicron_zone, bp_omicron_zone_nic,
24- bp_oximeter_read_policy, bp_sled_metadata, bp_target,
25+ bp_oximeter_read_policy, bp_pending_mgs_update_sp, bp_sled_metadata,
26+ bp_target,
2527} ;
2628use nexus_sled_agent_shared:: inventory:: OmicronZoneDataset ;
27- use nexus_types:: deployment:: BlueprintDatasetDisposition ;
2829use nexus_types:: deployment:: BlueprintPhysicalDiskConfig ;
2930use nexus_types:: deployment:: BlueprintPhysicalDiskDisposition ;
3031use nexus_types:: deployment:: BlueprintTarget ;
@@ -33,14 +34,18 @@ use nexus_types::deployment::BlueprintZoneDisposition;
3334use nexus_types:: deployment:: BlueprintZoneType ;
3435use nexus_types:: deployment:: ClickhouseClusterConfig ;
3536use nexus_types:: deployment:: CockroachDbPreserveDowngrade ;
37+ use nexus_types:: deployment:: PendingMgsUpdate ;
38+ use nexus_types:: deployment:: PendingMgsUpdateDetails ;
3639use nexus_types:: deployment:: {
3740 BlueprintDatasetConfig , BlueprintZoneImageVersion , OximeterReadMode ,
3841} ;
42+ use nexus_types:: deployment:: { BlueprintDatasetDisposition , ExpectedVersion } ;
3943use nexus_types:: deployment:: { BlueprintZoneImageSource , blueprint_zone_type} ;
4044use nexus_types:: deployment:: {
4145 OmicronZoneExternalFloatingAddr , OmicronZoneExternalFloatingIp ,
4246 OmicronZoneExternalSnatIp ,
4347} ;
48+ use nexus_types:: inventory:: BaseboardId ;
4449use omicron_common:: api:: internal:: shared:: NetworkInterface ;
4550use omicron_common:: disk:: DiskIdentity ;
4651use omicron_common:: zpool_name:: ZpoolName ;
@@ -50,6 +55,7 @@ use omicron_uuid_kinds::{
5055 PhysicalDiskKind , SledKind , SledUuid , ZpoolKind , ZpoolUuid ,
5156} ;
5257use std:: net:: { IpAddr , SocketAddrV6 } ;
58+ use std:: sync:: Arc ;
5359use uuid:: Uuid ;
5460
5561/// See [`nexus_types::deployment::Blueprint`].
@@ -1245,3 +1251,40 @@ impl BpOximeterReadPolicy {
12451251 }
12461252 }
12471253}
1254+
1255+ #[ derive( Queryable , Clone , Debug , Selectable , Insertable ) ]
1256+ #[ diesel( table_name = bp_pending_mgs_update_sp) ]
1257+ pub struct BpPendingMgsUpdateSp {
1258+ pub blueprint_id : DbTypedUuid < BlueprintKind > ,
1259+ pub hw_baseboard_id : Uuid ,
1260+ pub sp_type : SpType ,
1261+ pub sp_slot : SpMgsSlot ,
1262+ pub artifact_sha256 : ArtifactHash ,
1263+ pub artifact_version : DbArtifactVersion ,
1264+ pub expected_active_version : DbArtifactVersion ,
1265+ pub expected_inactive_version : Option < DbArtifactVersion > ,
1266+ }
1267+
1268+ impl BpPendingMgsUpdateSp {
1269+ pub fn into_generic (
1270+ self ,
1271+ baseboard_id : Arc < BaseboardId > ,
1272+ ) -> PendingMgsUpdate {
1273+ PendingMgsUpdate {
1274+ baseboard_id,
1275+ sp_type : self . sp_type . into ( ) ,
1276+ slot_id : u32:: from ( * * self . sp_slot ) ,
1277+ artifact_hash : self . artifact_sha256 . into ( ) ,
1278+ artifact_version : ( * self . artifact_version ) . clone ( ) ,
1279+ details : PendingMgsUpdateDetails :: Sp {
1280+ expected_active_version : ( * self . expected_active_version )
1281+ . clone ( ) ,
1282+ expected_inactive_version : match self . expected_inactive_version
1283+ {
1284+ Some ( v) => ExpectedVersion :: Version ( ( * v) . clone ( ) ) ,
1285+ None => ExpectedVersion :: NoValidVersion ,
1286+ } ,
1287+ } ,
1288+ }
1289+ }
1290+ }
0 commit comments