manta_server/backend_dispatcher/
apply_hw_cluster_pin.rs

1//! [`ApplyHwClusterPin`] impl for [`StaticBackendDispatcher`].
2//!
3//! Forwards to the CSM backend's hardware-cluster-pin orchestration
4//! (HSM group create/delete + member migration driven by an xname
5//! pattern). Ochami's `Ochami` type uses the trait's default body —
6//! calls routed there return [`Error::Message`] with a
7//! "not implemented for this backend" payload.
8
9use super::*;
10
11impl ApplyHwClusterPin for StaticBackendDispatcher {
12  /// Pin nodes matching `pattern` from `parent_group_name` into
13  /// `target_group_name`.
14  ///
15  /// Forwards to the backend's `apply_hw_cluster_pin`. When
16  /// `nodryrun` is false the backend short-circuits before any HSM
17  /// mutation. `create_target_group` controls whether the target is
18  /// created when missing; `delete_empty_parent_group` removes the
19  /// source after migration when it is empty.
20  ///
21  /// # Errors
22  ///
23  /// Returns [`Error::InvalidPattern`] when `pattern` does not match
24  /// the backend's pattern grammar, [`Error::InsufficientResources`]
25  /// when the pattern selects fewer nodes than required,
26  /// [`Error::CsmError`] / [`Error::RequestError`] for HSM call
27  /// failures, and the Ochami default
28  /// [`Error::Message`] for the unsupported backend.
29  async fn apply_hw_cluster_pin(
30    &self,
31    token: &str,
32    target_group_name: &str,
33    parent_group_name: &str,
34    pattern: &str,
35    nodryrun: bool,
36    create_target_group: bool,
37    delete_empty_parent_group: bool,
38  ) -> Result<(), Error> {
39    dispatch!(
40      self,
41      apply_hw_cluster_pin,
42      token,
43      target_group_name,
44      parent_group_name,
45      pattern,
46      nodryrun,
47      create_target_group,
48      delete_empty_parent_group
49    )
50  }
51}