manta_server/service/
power.rs1use manta_backend_dispatcher::error::Error;
4use manta_backend_dispatcher::interfaces::pcs::PCSTrait;
5use manta_backend_dispatcher::types::pcs::transitions::types::TransitionResponse;
6
7use crate::server::common::app_context::InfraContext;
8pub use manta_shared::shared::params::power::{ApplyPowerParams, PowerAction};
9
10pub async fn apply_power(
15 infra: &InfraContext<'_>,
16 token: &str,
17 params: &ApplyPowerParams,
18) -> Result<TransitionResponse, Error> {
19 match params.action {
20 PowerAction::On => infra.backend.power_on_sync(token, ¶ms.xnames).await,
21 PowerAction::Off => {
22 infra
23 .backend
24 .power_off_sync(token, ¶ms.xnames, params.force)
25 .await
26 }
27 PowerAction::Reset => {
28 infra
29 .backend
30 .power_reset_sync(token, ¶ms.xnames, params.force)
31 .await
32 }
33 }
34}