From f64edeb631bfdefcd757483d7dfbe204daabf1ab Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Thu, 9 Jun 2022 15:20:17 -0400 Subject: state: Force reboot/shutdown Closes #1 --- src/handlers/planets.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/handlers') diff --git a/src/handlers/planets.rs b/src/handlers/planets.rs index ede7b2b..06773bc 100644 --- a/src/handlers/planets.rs +++ b/src/handlers/planets.rs @@ -76,3 +76,27 @@ pub async fn reboot(Path(uuid): Path) -> NoneResult { Ok(()) } + +pub async fn force_reboot(Path(uuid): Path) -> NoneResult { + let mut s = get_star()?; + + if let Ok(p) = s.find_planet(uuid) { + p.hard_reboot()?; + } else { + return Err(ServiceError::NotFound); + } + + Ok(()) +} + +pub async fn force_shutdown(Path(uuid): Path) -> NoneResult { + let mut s = get_star()?; + + if let Ok(p) = s.find_planet(uuid) { + p.hard_shutdown()?; + } else { + return Err(ServiceError::NotFound); + } + + Ok(()) +} -- cgit v1.2.3