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 /// Pre-flight check: validate `params` against live backend state
35 /// without mutating anything. Returns `Ok(())` if the SAT file
36 /// would apply cleanly, fail-fast on the first detected mismatch.
37 async fn validate_sat_file(
38 &self,
39 params: ValidateSatFileParams<'_>,
40 ) -> Result<(), Error> {
41 dispatch!(self, validate_sat_file, params)
42 }
43
44 /// Apply a single SAT `configurations[]` entry — resolve any
45 /// `product:`/`git:` layers, POST the resulting
46 /// `CfsConfigurationRequest` to CFS, return the persisted
47 /// configuration (or a mock in `params.dry_run`).
48 async fn apply_configuration(
49 &self,
50 params: ApplyConfigurationParams<'_>,
51 ) -> Result<CfsConfigurationResponse, Error> {
52 dispatch!(self, apply_configuration, params)
53 }
54
55 /// Apply a single SAT `images[]` entry synchronously: kick off the
56 /// CFS image-build session and wait for it to complete, stamping
57 /// `manta.image_session.*` provenance metadata onto the produced
58 /// IMS image before returning. For non-blocking flow, drive
59 /// [`apply_sat_image_create_session`](Self::apply_sat_image_create_session)
60 /// and
61 /// [`apply_sat_image_stamp_from_session`](Self::apply_sat_image_stamp_from_session)
62 /// directly.
63 async fn apply_image(
64 &self,
65 params: ApplyImageParams<'_>,
66 ) -> Result<Image, Error> {
67 dispatch!(self, apply_image, params)
68 }
69
70 /// First half of the split image-apply flow: validate, resolve
71 /// `base.image_ref`, POST the CFS image-build session. Returns the
72 /// created session record without waiting for it to finish.
73 async fn apply_sat_image_create_session(
74 &self,
75 params: ApplyImageCreateSessionParams<'_>,
76 ) -> Result<CfsSessionGetResponse, Error> {
77 dispatch!(self, apply_sat_image_create_session, params)
78 }
79
80 /// Second half of the split image-apply flow: read the (assumed
81 /// completed) CFS session referenced by `params`, locate the IMS
82 /// image it produced, stamp `manta.image_session.*` provenance
83 /// metadata, and return the stamped image.
84 async fn apply_sat_image_stamp_from_session(
85 &self,
86 params: ApplyImageStampParams<'_>,
87 ) -> Result<Image, Error> {
88 dispatch!(self, apply_sat_image_stamp_from_session, params)
89 }
90
91 /// Apply a single SAT `session_templates[]` entry — PUT the BOS
92 /// session template, then (when `params.reboot` is true) POST a
93 /// BOS session derived from it. Returns
94 /// `(persisted_template, Some(session))` when a reboot session was
95 /// kicked off, `(persisted_template, None)` otherwise.
96 async fn apply_session_template(
97 &self,
98 params: ApplySessionTemplateParams<'_>,
99 ) -> Result<(BosSessionTemplate, Option<BosSession>), Error> {
100 dispatch!(self, apply_session_template, params)
101 }
102}