manta_server/backend_dispatcher/
pcs.rs

1//! `PCSTrait` (power control) impl for `StaticBackendDispatcher`.
2//!
3//! `POST /power` returns immediately with a transition id (via
4//! `pcs_transitions_post`); the CLI then polls `pcs_transitions_get`
5//! until the transition is `completed`. The older blocking
6//! `power_*_sync` trait methods (server-side polling loop) have been
7//! removed.
8
9use manta_backend_dispatcher::types::pcs::power_status::types::PowerStatusAll;
10
11use super::*;
12
13impl PCSTrait for StaticBackendDispatcher {
14  async fn power_status(
15    &self,
16    auth_token: &str,
17    nodes: &[String],
18    power_status_filter: Option<&str>,
19    management_state_filter: Option<&str>,
20  ) -> Result<PowerStatusAll, Error> {
21    dispatch!(
22      self,
23      power_status,
24      auth_token,
25      nodes,
26      power_status_filter,
27      management_state_filter
28    )
29  }
30
31  async fn pcs_transitions_post(
32    &self,
33    auth_token: &str,
34    operation: &str,
35    nodes: &[String],
36  ) -> Result<TransitionStartOutput, Error> {
37    // Same trait-vs-inherent name clash as `pcs_transitions_get`:
38    // disambiguate explicitly.
39    match self {
40      Self::CSM(b) => {
41        PCSTrait::pcs_transitions_post(b, auth_token, operation, nodes).await
42      }
43      Self::OCHAMI(b) => {
44        PCSTrait::pcs_transitions_post(b, auth_token, operation, nodes).await
45      }
46    }
47  }
48
49  async fn pcs_transitions_get(
50    &self,
51    auth_token: &str,
52    transition_id: &str,
53  ) -> Result<TransitionResponse, Error> {
54    // ShastaClient has an inherent `pcs_transitions_get` that takes
55    // only the token and returns a Vec. Disambiguate via the trait so
56    // the resolver picks the trait method (single transition by id),
57    // not the inherent one.
58    match self {
59      Self::CSM(b) => {
60        PCSTrait::pcs_transitions_get(b, auth_token, transition_id).await
61      }
62      Self::OCHAMI(b) => {
63        PCSTrait::pcs_transitions_get(b, auth_token, transition_id).await
64      }
65    }
66  }
67}