5
5
//! Types for representing the deployed software and configuration in the
6
6
//! database
7
7
8
- use crate :: inventory:: { SpMgsSlot , SpType , ZoneType } ;
8
+ use crate :: inventory:: { HwRotSlot , SpMgsSlot , SpType , ZoneType } ;
9
9
use crate :: omicron_zone_config:: { self , OmicronZoneNic } ;
10
10
use crate :: typed_uuid:: DbTypedUuid ;
11
11
use crate :: {
@@ -22,8 +22,8 @@ use nexus_db_schema::schema::{
22
22
bp_clickhouse_keeper_zone_id_to_node_id,
23
23
bp_clickhouse_server_zone_id_to_node_id, bp_omicron_dataset,
24
24
bp_omicron_physical_disk, bp_omicron_zone, bp_omicron_zone_nic,
25
- bp_oximeter_read_policy, bp_pending_mgs_update_sp , bp_sled_metadata ,
26
- bp_target,
25
+ bp_oximeter_read_policy, bp_pending_mgs_update_rot ,
26
+ bp_pending_mgs_update_sp , bp_sled_metadata , bp_target,
27
27
} ;
28
28
use nexus_sled_agent_shared:: inventory:: OmicronZoneDataset ;
29
29
use nexus_types:: deployment:: BlueprintHostPhase2DesiredContents ;
@@ -36,6 +36,7 @@ use nexus_types::deployment::BlueprintZoneDisposition;
36
36
use nexus_types:: deployment:: BlueprintZoneType ;
37
37
use nexus_types:: deployment:: ClickhouseClusterConfig ;
38
38
use nexus_types:: deployment:: CockroachDbPreserveDowngrade ;
39
+ use nexus_types:: deployment:: ExpectedActiveRotSlot ;
39
40
use nexus_types:: deployment:: PendingMgsUpdate ;
40
41
use nexus_types:: deployment:: PendingMgsUpdateDetails ;
41
42
use nexus_types:: deployment:: {
@@ -1302,6 +1303,14 @@ impl BpOximeterReadPolicy {
1302
1303
}
1303
1304
}
1304
1305
1306
+ pub trait BpPendingMgsUpdateComponent {
1307
+ /// Converts a BpMgsUpdate into a PendingMgsUpdate
1308
+ fn into_generic ( self , baseboard_id : Arc < BaseboardId > ) -> PendingMgsUpdate ;
1309
+
1310
+ /// Retrieves the baseboard ID
1311
+ fn hw_baseboard_id ( & self ) -> & Uuid ;
1312
+ }
1313
+
1305
1314
#[ derive( Queryable , Clone , Debug , Selectable , Insertable ) ]
1306
1315
#[ diesel( table_name = bp_pending_mgs_update_sp) ]
1307
1316
pub struct BpPendingMgsUpdateSp {
@@ -1315,11 +1324,12 @@ pub struct BpPendingMgsUpdateSp {
1315
1324
pub expected_inactive_version : Option < DbArtifactVersion > ,
1316
1325
}
1317
1326
1318
- impl BpPendingMgsUpdateSp {
1319
- pub fn into_generic (
1320
- self ,
1321
- baseboard_id : Arc < BaseboardId > ,
1322
- ) -> PendingMgsUpdate {
1327
+ impl BpPendingMgsUpdateComponent for BpPendingMgsUpdateSp {
1328
+ fn hw_baseboard_id ( & self ) -> & Uuid {
1329
+ & self . hw_baseboard_id
1330
+ }
1331
+
1332
+ fn into_generic ( self , baseboard_id : Arc < BaseboardId > ) -> PendingMgsUpdate {
1323
1333
PendingMgsUpdate {
1324
1334
baseboard_id,
1325
1335
sp_type : self . sp_type . into ( ) ,
@@ -1338,3 +1348,55 @@ impl BpPendingMgsUpdateSp {
1338
1348
}
1339
1349
}
1340
1350
}
1351
+
1352
+ #[ derive( Queryable , Clone , Debug , Selectable , Insertable ) ]
1353
+ #[ diesel( table_name = bp_pending_mgs_update_rot) ]
1354
+ pub struct BpPendingMgsUpdateRot {
1355
+ pub blueprint_id : DbTypedUuid < BlueprintKind > ,
1356
+ pub hw_baseboard_id : Uuid ,
1357
+ pub sp_type : SpType ,
1358
+ pub sp_slot : SpMgsSlot ,
1359
+ pub artifact_sha256 : ArtifactHash ,
1360
+ pub artifact_version : DbArtifactVersion ,
1361
+ pub expected_active_slot : HwRotSlot ,
1362
+ pub expected_active_version : DbArtifactVersion ,
1363
+ pub expected_inactive_version : Option < DbArtifactVersion > ,
1364
+ pub expected_persistent_boot_preference : HwRotSlot ,
1365
+ pub expected_pending_persistent_boot_preference : Option < HwRotSlot > ,
1366
+ pub expected_transient_boot_preference : Option < HwRotSlot > ,
1367
+ }
1368
+
1369
+ impl BpPendingMgsUpdateComponent for BpPendingMgsUpdateRot {
1370
+ fn hw_baseboard_id ( & self ) -> & Uuid {
1371
+ & self . hw_baseboard_id
1372
+ }
1373
+
1374
+ fn into_generic ( self , baseboard_id : Arc < BaseboardId > ) -> PendingMgsUpdate {
1375
+ PendingMgsUpdate {
1376
+ baseboard_id,
1377
+ sp_type : self . sp_type . into ( ) ,
1378
+ slot_id : * * self . sp_slot ,
1379
+ artifact_hash : self . artifact_sha256 . into ( ) ,
1380
+ artifact_version : ( * self . artifact_version ) . clone ( ) ,
1381
+ details : PendingMgsUpdateDetails :: Rot {
1382
+ expected_active_slot : ExpectedActiveRotSlot {
1383
+ slot : self . expected_active_slot . into ( ) ,
1384
+ version : ( * self . expected_active_version ) . clone ( ) ,
1385
+ } ,
1386
+ expected_inactive_version : self
1387
+ . expected_inactive_version
1388
+ . map ( |v| ExpectedVersion :: Version ( v. into ( ) ) )
1389
+ . unwrap_or ( ExpectedVersion :: NoValidVersion ) ,
1390
+ expected_persistent_boot_preference : self
1391
+ . expected_persistent_boot_preference
1392
+ . into ( ) ,
1393
+ expected_pending_persistent_boot_preference : self
1394
+ . expected_pending_persistent_boot_preference
1395
+ . map ( |s| s. into ( ) ) ,
1396
+ expected_transient_boot_preference : self
1397
+ . expected_transient_boot_preference
1398
+ . map ( |s| s. into ( ) ) ,
1399
+ } ,
1400
+ }
1401
+ }
1402
+ }
0 commit comments