@@ -43,10 +43,24 @@ impl SimTufRepoDescription {
4343 Self { source : Err ( message. clone ( ) ) , message }
4444 }
4545
46- /// Generates a simulated [`ManifestBootInventory`] or an error.
47- pub fn to_boot_inventory ( & self ) -> Result < ManifestBootInventory , String > {
46+ /// Generates a simulated [`ManifestBootInventory`] for zones or an error.
47+ pub fn to_zone_boot_inventory (
48+ & self ,
49+ ) -> Result < ManifestBootInventory , String > {
4850 match & self . source {
49- Ok ( source) => Ok ( source. to_boot_inventory ( ) ) ,
51+ Ok ( source) => Ok ( source. to_zone_boot_inventory ( ) ) ,
52+ Err ( error) => {
53+ Err ( format ! ( "reconfigurator-sim simulated error: {error}" ) )
54+ }
55+ }
56+ }
57+
58+ /// Generates a simulated [`ManifestBootInventory`] for measurements or an error.
59+ pub fn to_measurement_boot_inventory (
60+ & self ,
61+ ) -> Result < ManifestBootInventory , String > {
62+ match & self . source {
63+ Ok ( source) => Ok ( source. to_measurement_boot_inventory ( ) ) ,
5064 Err ( error) => {
5165 Err ( format ! ( "reconfigurator-sim simulated error: {error}" ) )
5266 }
@@ -59,7 +73,8 @@ impl SimTufRepoDescription {
5973#[ derive( Clone , Debug ) ]
6074pub struct SimTufRepoSource {
6175 description : TufRepoDescription ,
62- manifest_source : OmicronInstallManifestSource ,
76+ zone_manifest_source : OmicronInstallManifestSource ,
77+ measurement_manifest_source : OmicronInstallManifestSource ,
6378 message : String ,
6479 known_artifact_id_names : BTreeSet < String > ,
6580 error_artifact_id_names : BTreeSet < String > ,
@@ -71,7 +86,8 @@ impl SimTufRepoSource {
7186 /// The message should be of the form "from repo at ..." or "to target release".
7287 pub fn new (
7388 description : TufRepoDescription ,
74- manifest_source : OmicronInstallManifestSource ,
89+ zone_manifest_source : OmicronInstallManifestSource ,
90+ measurement_manifest_source : OmicronInstallManifestSource ,
7591 message : String ,
7692 ) -> anyhow:: Result < Self > {
7793 let mut unknown = BTreeSet :: new ( ) ;
@@ -106,7 +122,8 @@ impl SimTufRepoSource {
106122 }
107123 Ok ( Self {
108124 description,
109- manifest_source,
125+ zone_manifest_source,
126+ measurement_manifest_source,
110127 message,
111128 known_artifact_id_names : known,
112129 error_artifact_id_names : BTreeSet :: new ( ) ,
@@ -141,8 +158,47 @@ impl SimTufRepoSource {
141158 Ok ( ( ) )
142159 }
143160
144- /// Generates a simulated [`ManifestBootInventory`].
145- pub fn to_boot_inventory ( & self ) -> ManifestBootInventory {
161+ /// Generates a simulated [`ManifestBootInventory`] from the measurement manifest.
162+ pub fn to_measurement_boot_inventory ( & self ) -> ManifestBootInventory {
163+ let artifacts = self
164+ . description
165+ . artifacts
166+ . iter ( )
167+ . filter_map ( |artifact| {
168+ if artifact. id . kind . to_known ( )
169+ != Some ( KnownArtifactKind :: MeasurementCorpus )
170+ {
171+ return None ;
172+ }
173+
174+ let file_name = artifact. id . name . to_string ( ) ;
175+ let path = Utf8Path :: new ( "/fake/path/install" ) . join ( & file_name) ;
176+ let status =
177+ if self . error_artifact_id_names . contains ( & artifact. id . name )
178+ {
179+ Err ( "reconfigurator-sim: simulated error \
180+ validating zone image"
181+ . to_owned ( ) )
182+ } else {
183+ Ok ( ( ) )
184+ } ;
185+ Some ( ZoneArtifactInventory {
186+ file_name,
187+ path,
188+ expected_size : artifact. size ,
189+ expected_hash : artifact. hash ,
190+ status,
191+ } )
192+ } )
193+ . collect ( ) ;
194+ ManifestBootInventory {
195+ source : self . measurement_manifest_source ,
196+ artifacts,
197+ }
198+ }
199+
200+ /// Generates a simulated [`ManifestBootInventory`] from the zone manifest.
201+ pub fn to_zone_boot_inventory ( & self ) -> ManifestBootInventory {
146202 let artifacts = self
147203 . description
148204 . artifacts
@@ -178,7 +234,7 @@ impl SimTufRepoSource {
178234 } )
179235 } )
180236 . collect ( ) ;
181- ManifestBootInventory { source : self . manifest_source , artifacts }
237+ ManifestBootInventory { source : self . zone_manifest_source , artifacts }
182238 }
183239
184240 /// Returns a message including the system version and the number of zone
0 commit comments