@@ -13,9 +13,11 @@ use clap::Subcommand;
1313use futures:: StreamExt ;
1414use gateway_client:: types:: SpIgnition ;
1515use gateway_client:: types:: SpType ;
16+ use gateway_types:: rot:: RotSlot ;
1617use internal_dns_types:: names:: ServiceName ;
1718use nexus_mgs_updates:: ArtifactCache ;
1819use nexus_mgs_updates:: MgsUpdateDriver ;
20+ use nexus_types:: deployment:: ExpectedActiveRotSlot ;
1921use nexus_types:: deployment:: ExpectedVersion ;
2022use nexus_types:: deployment:: PendingMgsUpdate ;
2123use nexus_types:: deployment:: PendingMgsUpdateDetails ;
@@ -118,6 +120,7 @@ impl ReconfiguratorSpUpdater {
118120 . expect ( "we just waited for this condition" ) ;
119121 format ! ( "http://{}" , mgs_backend. address)
120122 } ;
123+
121124 let mgs_client = gateway_client:: Client :: new (
122125 & mgs_url,
123126 log. new ( o ! ( "mgs_url" => mgs_url. clone( ) ) ) ,
@@ -374,9 +377,40 @@ struct SetArgs {
374377#[ derive( Clone , Debug , Subcommand ) ]
375378enum Component {
376379 Sp {
380+ /// expected version of the active slot
381+ #[ arg( long, short = 'a' ) ]
377382 expected_active_version : ArtifactVersion ,
383+ /// expected version of the inactive slot
384+ #[ arg( long, short = 'i' ) ]
378385 expected_inactive_version : ExpectedVersion ,
379386 } ,
387+ Rot {
388+ /// whether we expect the "A" or "B" slot to be active
389+ #[ arg( long, short = 's' ) ]
390+ expected_active_slot : RotSlot ,
391+ /// expected version of the "A" slot
392+ #[ arg( long, short = 'a' ) ]
393+ expected_slot_a_version : ExpectedVersion ,
394+ /// expected version of the "B" slot
395+ #[ arg( long, short = 'b' ) ]
396+ expected_slot_b_version : ExpectedVersion ,
397+ /// the expected persistent boot preference written into the current
398+ /// authoritative CFPA page (ping or pong).
399+ /// Will default to the value of expected_active_version when not set
400+ #[ arg( long, short = 'p' ) ]
401+ expected_persistent_boot_preference : Option < RotSlot > ,
402+ /// the expected persistent boot preference written into the CFPA scratch
403+ /// page that will become the persistent boot preference in the authoritative
404+ /// CFPA page upon reboot, unless CFPA update of the authoritative page fails
405+ /// for some reason
406+ #[ arg( long, short = 'x' ) ]
407+ expected_pending_persistent_boot_preference : Option < RotSlot > ,
408+ // this field is not in use yet.
409+ //
410+ /// override persistent preference selection for a single boot
411+ #[ arg( long, short = 't' ) ]
412+ expected_transient_boot_preference : Option < RotSlot > ,
413+ } ,
380414}
381415
382416fn cmd_set (
@@ -397,6 +431,46 @@ fn cmd_set(
397431 expected_active_version,
398432 expected_inactive_version,
399433 } ,
434+ Component :: Rot {
435+ expected_active_slot,
436+ expected_slot_a_version,
437+ expected_slot_b_version,
438+ expected_persistent_boot_preference,
439+ expected_pending_persistent_boot_preference,
440+ expected_transient_boot_preference,
441+ } => {
442+ let ( active_version, expected_inactive_version) =
443+ match expected_active_slot {
444+ RotSlot :: A => {
445+ ( expected_slot_a_version, expected_slot_b_version)
446+ }
447+ RotSlot :: B => {
448+ ( expected_slot_b_version, expected_slot_a_version)
449+ }
450+ } ;
451+
452+ let expected_active_version = match active_version {
453+ ExpectedVersion :: Version ( v) => v,
454+ ExpectedVersion :: NoValidVersion => {
455+ return Err ( anyhow ! (
456+ "the expected active slot version must have a valid version"
457+ ) ) ;
458+ }
459+ } ;
460+
461+ PendingMgsUpdateDetails :: Rot {
462+ expected_active_slot : ExpectedActiveRotSlot {
463+ slot : expected_active_slot,
464+ version : expected_active_version,
465+ } ,
466+ expected_inactive_version,
467+ expected_persistent_boot_preference :
468+ expected_persistent_boot_preference
469+ . unwrap_or ( expected_active_slot) ,
470+ expected_pending_persistent_boot_preference,
471+ expected_transient_boot_preference,
472+ }
473+ }
400474 } ,
401475 artifact_hash : args. artifact_hash ,
402476 artifact_version : ArtifactVersion :: new ( args. version )
0 commit comments