@@ -208,6 +208,7 @@ fn process_command(
208
208
Commands :: SledRemove ( args) => cmd_sled_remove ( sim, args) ,
209
209
Commands :: SledShow ( args) => cmd_sled_show ( sim, args) ,
210
210
Commands :: SledSetPolicy ( args) => cmd_sled_set_policy ( sim, args) ,
211
+ Commands :: SledUpdateSp ( args) => cmd_sled_update_sp ( sim, args) ,
211
212
Commands :: SiloList => cmd_silo_list ( sim) ,
212
213
Commands :: SiloAdd ( args) => cmd_silo_add ( sim, args) ,
213
214
Commands :: SiloRemove ( args) => cmd_silo_remove ( sim, args) ,
@@ -261,6 +262,8 @@ enum Commands {
261
262
SledShow ( SledArgs ) ,
262
263
/// set a sled's policy
263
264
SledSetPolicy ( SledSetPolicyArgs ) ,
265
+ /// simulate updating the sled's SP versions
266
+ SledUpdateSp ( SledUpdateSpArgs ) ,
264
267
265
268
/// list silos
266
269
SiloList ,
@@ -372,6 +375,20 @@ impl From<SledPolicyOpt> for SledPolicy {
372
375
}
373
376
}
374
377
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
+
375
392
#[ derive( Debug , Args ) ]
376
393
struct SledRemoveArgs {
377
394
/// id of the sled
@@ -885,18 +902,22 @@ fn cmd_sled_show(
885
902
args : SledArgs ,
886
903
) -> anyhow:: Result < Option < String > > {
887
904
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
891
910
. to_planning_input_builder ( )
892
911
. context ( "failed to generate planning_input builder" ) ?
893
912
. 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 ;
897
915
let mut s = String :: new ( ) ;
898
916
swriteln ! ( s, "sled {}" , sled_id) ;
917
+ swriteln ! ( s, "serial {}" , sled. baseboard_id. serial_number) ;
899
918
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) ;
900
921
swriteln ! ( s, "zpools ({}):" , sled_resources. zpools. len( ) ) ;
901
922
for ( zpool, disk) in & sled_resources. zpools {
902
923
swriteln ! ( s, " {:?}" , zpool) ;
@@ -924,6 +945,46 @@ fn cmd_sled_set_policy(
924
945
Ok ( Some ( format ! ( "set sled {} policy to {}" , args. sled_id, args. policy) ) )
925
946
}
926
947
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
+
927
988
fn cmd_inventory_list (
928
989
sim : & mut ReconfiguratorSim ,
929
990
) -> anyhow:: Result < Option < String > > {
0 commit comments