@@ -208,6 +208,7 @@ fn process_command(
208208 Commands :: SledRemove ( args) => cmd_sled_remove ( sim, args) ,
209209 Commands :: SledShow ( args) => cmd_sled_show ( sim, args) ,
210210 Commands :: SledSetPolicy ( args) => cmd_sled_set_policy ( sim, args) ,
211+ Commands :: SledUpdateSp ( args) => cmd_sled_update_sp ( sim, args) ,
211212 Commands :: SiloList => cmd_silo_list ( sim) ,
212213 Commands :: SiloAdd ( args) => cmd_silo_add ( sim, args) ,
213214 Commands :: SiloRemove ( args) => cmd_silo_remove ( sim, args) ,
@@ -261,6 +262,8 @@ enum Commands {
261262 SledShow ( SledArgs ) ,
262263 /// set a sled's policy
263264 SledSetPolicy ( SledSetPolicyArgs ) ,
265+ /// simulate updating the sled's SP versions
266+ SledUpdateSp ( SledUpdateSpArgs ) ,
264267
265268 /// list silos
266269 SiloList ,
@@ -372,6 +375,20 @@ impl From<SledPolicyOpt> for SledPolicy {
372375 }
373376}
374377
378+ #[ derive( Debug , Args ) ]
379+ struct SledUpdateSpArgs {
380+ /// id of the sled
381+ sled_id : SledUuid ,
382+
383+ /// sets the version reported for the SP active slot
384+ #[ clap( long, required_unless_present_any = & [ "inactive" ] ) ]
385+ active : Option < ArtifactVersion > ,
386+
387+ /// sets the version reported for the SP inactive slot
388+ #[ clap( long, required_unless_present_any = & [ "active" ] ) ]
389+ inactive : Option < ExpectedVersion > ,
390+ }
391+
375392#[ derive( Debug , Args ) ]
376393struct SledRemoveArgs {
377394 /// id of the sled
@@ -885,18 +902,22 @@ fn cmd_sled_show(
885902 args : SledArgs ,
886903) -> anyhow:: Result < Option < String > > {
887904 let state = sim. current_state ( ) ;
888- let planning_input = state
889- . system ( )
890- . description ( )
905+ let description = state. system ( ) . description ( ) ;
906+ let sled_id = args. sled_id ;
907+ let sp_active_version = description. sled_sp_active_version ( sled_id) ?;
908+ let sp_inactive_version = description. sled_sp_inactive_version ( sled_id) ?;
909+ let planning_input = description
891910 . to_planning_input_builder ( )
892911 . context ( "failed to generate planning_input builder" ) ?
893912 . build ( ) ;
894- let sled_id = args. sled_id ;
895- let sled_resources =
896- & planning_input. sled_lookup ( args. filter , sled_id) ?. resources ;
913+ let sled = planning_input. sled_lookup ( args. filter , sled_id) ?;
914+ let sled_resources = & sled. resources ;
897915 let mut s = String :: new ( ) ;
898916 swriteln ! ( s, "sled {}" , sled_id) ;
917+ swriteln ! ( s, "serial {}" , sled. baseboard_id. serial_number) ;
899918 swriteln ! ( s, "subnet {}" , sled_resources. subnet. net( ) ) ;
919+ swriteln ! ( s, "SP active version: {:?}" , sp_active_version) ;
920+ swriteln ! ( s, "SP inactive version: {:?}" , sp_inactive_version) ;
900921 swriteln ! ( s, "zpools ({}):" , sled_resources. zpools. len( ) ) ;
901922 for ( zpool, disk) in & sled_resources. zpools {
902923 swriteln ! ( s, " {:?}" , zpool) ;
@@ -924,6 +945,46 @@ fn cmd_sled_set_policy(
924945 Ok ( Some ( format ! ( "set sled {} policy to {}" , args. sled_id, args. policy) ) )
925946}
926947
948+ fn cmd_sled_update_sp (
949+ sim : & mut ReconfiguratorSim ,
950+ args : SledUpdateSpArgs ,
951+ ) -> anyhow:: Result < Option < String > > {
952+ let mut labels = Vec :: new ( ) ;
953+ if let Some ( active) = & args. active {
954+ labels. push ( format ! ( "active -> {}" , active) ) ;
955+ }
956+ if let Some ( inactive) = & args. inactive {
957+ labels. push ( format ! ( "inactive -> {}" , inactive) ) ;
958+ }
959+
960+ assert ! (
961+ !labels. is_empty( ) ,
962+ "clap configuration requires that at least one argument is specified"
963+ ) ;
964+
965+ let mut state = sim. current_state ( ) . to_mut ( ) ;
966+ state. system_mut ( ) . description_mut ( ) . sled_update_sp_versions (
967+ args. sled_id ,
968+ args. active ,
969+ args. inactive ,
970+ ) ?;
971+
972+ sim. commit_and_bump (
973+ format ! (
974+ "reconfigurator-cli sled-update-sp: {}: {}" ,
975+ args. sled_id,
976+ labels. join( ", " ) ,
977+ ) ,
978+ state,
979+ ) ;
980+
981+ Ok ( Some ( format ! (
982+ "set sled {} SP versions: {}" ,
983+ args. sled_id,
984+ labels. join( ", " )
985+ ) ) )
986+ }
987+
927988fn cmd_inventory_list (
928989 sim : & mut ReconfiguratorSim ,
929990) -> anyhow:: Result < Option < String > > {
0 commit comments