@@ -19,7 +19,9 @@ use nexus_reconfigurator_blippy::BlippyReportSortKey;
19
19
use nexus_reconfigurator_planning:: blueprint_builder:: BlueprintBuilder ;
20
20
use nexus_reconfigurator_planning:: example:: ExampleSystemBuilder ;
21
21
use nexus_reconfigurator_planning:: planner:: Planner ;
22
- use nexus_reconfigurator_planning:: system:: { SledBuilder , SystemDescription } ;
22
+ use nexus_reconfigurator_planning:: system:: {
23
+ SledBuilder , SledInventoryVisibility , SystemDescription ,
24
+ } ;
23
25
use nexus_reconfigurator_simulation:: { BlueprintId , SimState } ;
24
26
use nexus_reconfigurator_simulation:: { SimStateBuilder , SimTufRepoSource } ;
25
27
use nexus_reconfigurator_simulation:: { SimTufRepoDescription , Simulator } ;
@@ -374,6 +376,8 @@ struct SledSetArgs {
374
376
enum SledSetCommand {
375
377
/// set the policy for this sled
376
378
Policy ( SledSetPolicyArgs ) ,
379
+ #[ clap( flatten) ]
380
+ Visibility ( SledSetVisibilityCommand ) ,
377
381
}
378
382
379
383
#[ derive( Debug , Args ) ]
@@ -383,6 +387,27 @@ struct SledSetPolicyArgs {
383
387
policy : SledPolicyOpt ,
384
388
}
385
389
390
+ #[ derive( Debug , Subcommand ) ]
391
+ enum SledSetVisibilityCommand {
392
+ /// mark a sled hidden from inventory
393
+ InventoryHidden ,
394
+ /// mark a sled visible in inventory
395
+ InventoryVisible ,
396
+ }
397
+
398
+ impl SledSetVisibilityCommand {
399
+ fn to_visibility ( & self ) -> SledInventoryVisibility {
400
+ match self {
401
+ SledSetVisibilityCommand :: InventoryHidden => {
402
+ SledInventoryVisibility :: Hidden
403
+ }
404
+ SledSetVisibilityCommand :: InventoryVisible => {
405
+ SledInventoryVisibility :: Visible
406
+ }
407
+ }
408
+ }
409
+ }
410
+
386
411
#[ derive( Clone , Copy , Debug , ValueEnum ) ]
387
412
enum SledPolicyOpt {
388
413
InService ,
@@ -1227,6 +1252,30 @@ fn cmd_sled_set(
1227
1252
) ;
1228
1253
Ok ( Some ( format ! ( "set sled {sled_id} policy to {policy}" ) ) )
1229
1254
}
1255
+ SledSetCommand :: Visibility ( command) => {
1256
+ let new = command. to_visibility ( ) ;
1257
+ let prev = system
1258
+ . description_mut ( )
1259
+ . sled_set_inventory_visibility ( sled_id, new) ?;
1260
+ if prev == new {
1261
+ Ok ( Some ( format ! (
1262
+ "sled {sled_id} inventory visibility was already set to \
1263
+ {new}, so no changes were performed",
1264
+ ) ) )
1265
+ } else {
1266
+ sim. commit_and_bump (
1267
+ format ! (
1268
+ "reconfigurator-cli sled-set inventory visibility: {} \
1269
+ from {} to {}",
1270
+ sled_id, prev, new,
1271
+ ) ,
1272
+ state,
1273
+ ) ;
1274
+ Ok ( Some ( format ! (
1275
+ "set sled {sled_id} inventory visibility: {prev} -> {new}"
1276
+ ) ) )
1277
+ }
1278
+ }
1230
1279
}
1231
1280
}
1232
1281
0 commit comments