@@ -190,6 +190,31 @@ impl ConfigReconcilerInventory {
190
190
/// look at the actual `last_reconciliation` value from the parent
191
191
/// [`Inventory`].
192
192
pub fn debug_assume_success ( config : OmicronSledConfig ) -> Self {
193
+ let mut ret = Self {
194
+ // These fields will be filled in by `debug_update_assume_success`.
195
+ last_reconciled_config : OmicronSledConfig :: default ( ) ,
196
+ external_disks : BTreeMap :: new ( ) ,
197
+ datasets : BTreeMap :: new ( ) ,
198
+ orphaned_datasets : IdOrdMap :: new ( ) ,
199
+ zones : BTreeMap :: new ( ) ,
200
+ remove_mupdate_override : None ,
201
+
202
+ // These fields will not.
203
+ boot_partitions : BootPartitionContents :: debug_assume_success ( ) ,
204
+ } ;
205
+
206
+ ret. debug_update_assume_success ( config) ;
207
+
208
+ ret
209
+ }
210
+
211
+ /// Given a sled config, update an existing reconciler result to simulate an
212
+ /// output that sled-agent could have emitted if reconciliation succeeded.
213
+ ///
214
+ /// This method should only be used by tests and dev tools; real code should
215
+ /// look at the actual `last_reconciliation` value from the parent
216
+ /// [`Inventory`].
217
+ pub fn debug_update_assume_success ( & mut self , config : OmicronSledConfig ) {
193
218
let external_disks = config
194
219
. disks
195
220
. iter ( )
@@ -212,50 +237,17 @@ impl ConfigReconcilerInventory {
212
237
RemoveMupdateOverrideBootSuccessInventory :: Removed ,
213
238
) ,
214
239
non_boot_message : "mupdate override successfully removed \
215
- on non-boot disks"
240
+ on non-boot disks"
216
241
. to_owned ( ) ,
217
242
}
218
243
} ) ;
219
244
220
- Self {
221
- last_reconciled_config : config,
222
- external_disks,
223
- datasets,
224
- orphaned_datasets : IdOrdMap :: new ( ) ,
225
- zones,
226
- boot_partitions : {
227
- BootPartitionContents {
228
- boot_disk : Ok ( M2Slot :: A ) ,
229
- slot_a : Ok ( BootPartitionDetails {
230
- header : BootImageHeader {
231
- flags : 0 ,
232
- data_size : 1000 ,
233
- image_size : 1000 ,
234
- target_size : 1000 ,
235
- sha256 : [ 0 ; 32 ] ,
236
- image_name : "fake from debug_assume_success()"
237
- . to_string ( ) ,
238
- } ,
239
- artifact_hash : ArtifactHash ( [ 0x0a ; 32 ] ) ,
240
- artifact_size : 1000 ,
241
- } ) ,
242
- slot_b : Ok ( BootPartitionDetails {
243
- header : BootImageHeader {
244
- flags : 0 ,
245
- data_size : 1000 ,
246
- image_size : 1000 ,
247
- target_size : 1000 ,
248
- sha256 : [ 1 ; 32 ] ,
249
- image_name : "fake from debug_assume_success()"
250
- . to_string ( ) ,
251
- } ,
252
- artifact_hash : ArtifactHash ( [ 0x0b ; 32 ] ) ,
253
- artifact_size : 1000 ,
254
- } ) ,
255
- }
256
- } ,
257
- remove_mupdate_override,
258
- }
245
+ self . last_reconciled_config = config;
246
+ self . external_disks = external_disks;
247
+ self . datasets = datasets;
248
+ self . orphaned_datasets = IdOrdMap :: new ( ) ;
249
+ self . zones = zones;
250
+ self . remove_mupdate_override = remove_mupdate_override;
259
251
}
260
252
}
261
253
@@ -286,6 +278,36 @@ impl BootPartitionContents {
286
278
M2Slot :: B => & self . slot_b ,
287
279
}
288
280
}
281
+
282
+ pub fn debug_assume_success ( ) -> Self {
283
+ Self {
284
+ boot_disk : Ok ( M2Slot :: A ) ,
285
+ slot_a : Ok ( BootPartitionDetails {
286
+ header : BootImageHeader {
287
+ flags : 0 ,
288
+ data_size : 1000 ,
289
+ image_size : 1000 ,
290
+ target_size : 1000 ,
291
+ sha256 : [ 0 ; 32 ] ,
292
+ image_name : "fake from debug_assume_success()" . to_string ( ) ,
293
+ } ,
294
+ artifact_hash : ArtifactHash ( [ 0x0a ; 32 ] ) ,
295
+ artifact_size : 1000 ,
296
+ } ) ,
297
+ slot_b : Ok ( BootPartitionDetails {
298
+ header : BootImageHeader {
299
+ flags : 0 ,
300
+ data_size : 1000 ,
301
+ image_size : 1000 ,
302
+ target_size : 1000 ,
303
+ sha256 : [ 1 ; 32 ] ,
304
+ image_name : "fake from debug_assume_success()" . to_string ( ) ,
305
+ } ,
306
+ artifact_hash : ArtifactHash ( [ 0x0b ; 32 ] ) ,
307
+ artifact_size : 1000 ,
308
+ } ) ,
309
+ }
310
+ }
289
311
}
290
312
291
313
#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , JsonSchema , Serialize ) ]
0 commit comments