manta_server/backend_dispatcher/sat.rs
1//! [`SatTrait`] impl for [`StaticBackendDispatcher`].
2//!
3//! Forwards the SAT-file (Site Activation Template) orchestration —
4//! the per-section helpers that the `manta sat apply` pipeline calls
5//! one entry at a time, plus the all-in-one [`SatTrait::apply_sat_file`]
6//! entry point. The CSM backend implements each method by composing
7//! CFS, IMS, and BOS calls; Ochami's `impl SatTrait for Ochami {}` is
8//! empty, so every method on the Ochami branch returns
9//! [`Error::Message`] from the trait default ("not implemented for
10//! this backend").
11
12use super::*;
13
14impl SatTrait for StaticBackendDispatcher {
15 /// Apply an entire SAT file (`configurations`, `images`,
16 /// `session_templates`, optional `sessions`) in one call. Returns
17 /// the tuple `(configurations, images, session_templates, sessions)`
18 /// of what was created — empty vectors when a section is absent.
19 async fn apply_sat_file(
20 &self,
21 params: ApplySatFileParams<'_>,
22 ) -> Result<
23 (
24 Vec<CfsConfigurationResponse>,
25 Vec<Image>,
26 Vec<BosSessionTemplate>,
27 Vec<BosSession>,
28 ),
29 Error,
30 > {
31 dispatch!(self, apply_sat_file, params)
32 }
33
34 /// Apply a single SAT `configurations[]` entry — resolve any
35 /// `product:`/`git:` layers, POST the resulting
36 /// `CfsConfigurationRequest` to CFS, return the persisted
37 /// configuration (or a mock in `params.dry_run`).
38 async fn apply_configuration(
39 &self,
40 params: ApplyConfigurationParams<'_>,
41 ) -> Result<CfsConfigurationResponse, Error> {
42 dispatch!(self, apply_configuration, params)
43 }
44
45 /// Apply a single SAT `images[]` entry synchronously: kick off the
46 /// CFS image-build session and wait for it to complete, stamping
47 /// `manta.image_session.*` provenance metadata onto the produced
48 /// IMS image before returning. For non-blocking flow, drive
49 /// [`apply_sat_image_create_session`](Self::apply_sat_image_create_session)
50 /// and
51 /// [`apply_sat_image_stamp_from_session`](Self::apply_sat_image_stamp_from_session)
52 /// directly.
53 async fn apply_image(
54 &self,
55 params: ApplyImageParams<'_>,
56 ) -> Result<Image, Error> {
57 dispatch!(self, apply_image, params)
58 }
59
60 /// First half of the split image-apply flow: validate, resolve
61 /// `base.image_ref`, POST the CFS image-build session. Returns the
62 /// created session record without waiting for it to finish.
63 async fn apply_sat_image_create_session(
64 &self,
65 params: ApplyImageCreateSessionParams<'_>,
66 ) -> Result<CfsSessionGetResponse, Error> {
67 dispatch!(self, apply_sat_image_create_session, params)
68 }
69
70 /// Second half of the split image-apply flow: read the (assumed
71 /// completed) CFS session referenced by `params`, locate the IMS
72 /// image it produced, stamp `manta.image_session.*` provenance
73 /// metadata, and return the stamped image.
74 async fn apply_sat_image_stamp_from_session(
75 &self,
76 params: ApplyImageStampParams<'_>,
77 ) -> Result<Image, Error> {
78 dispatch!(self, apply_sat_image_stamp_from_session, params)
79 }
80
81 /// Apply a single SAT `session_templates[]` entry — PUT the BOS
82 /// session template, then (when `params.reboot` is true) POST a
83 /// BOS session derived from it. Returns
84 /// `(persisted_template, Some(session))` when a reboot session was
85 /// kicked off, `(persisted_template, None)` otherwise.
86 async fn apply_session_template(
87 &self,
88 params: ApplySessionTemplateParams<'_>,
89 ) -> Result<(BosSessionTemplate, Option<BosSession>), Error> {
90 dispatch!(self, apply_session_template, params)
91 }
92}