From f73eb90d830df1a0881447d918985e315aed6fb7 Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Thu, 9 Jun 2022 15:12:41 -0400 Subject: planet: Add further state management - Force shutdown/reboot - resume Closes #1 --- src/planet.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src') diff --git a/src/planet.rs b/src/planet.rs index 210de5a..be81e7e 100644 --- a/src/planet.rs +++ b/src/planet.rs @@ -244,6 +244,58 @@ impl Planet { d.suspend()?; Ok(()) } + + pub fn resume(&self) -> Result<(), Error> { + let d = match &self.domain { + Some(d) => d, + None => { + return Err(Error::Other(String::from("No domain connection found"))); + } + }; + + d.resume()?; + Ok(()) + } + + pub fn reboot(&self) -> Result<(), Error> { + let d = match &self.domain { + Some(d) => d, + None => { + return Err(Error::Other(String::from("No domain connection found"))); + }, + }; + + d.reboot(0)?; + + Ok(()) + } + + pub fn hard_shutdown(&self) -> Result<(), Error> { + let d = match &self.domain { + Some(d) => d, + None => { + return Err(Error::Other(String::from("No domain connection found"))); + } + }; + + d.destroy()?; + + Ok(()) + } + + pub fn hard_reboot(&self) -> Result<(), Error> { + let d = match &self.domain { + Some(d) => d, + None => { + return Err(Error::Other(String::from("No domain connection found"))); + } + }; + + d.destroy()?; + d.create()?; + + Ok(()) + } } #[cfg(test)] -- cgit v1.2.3