diff options
author | Cara Salter <cara@devcara.com> | 2022-06-09 15:12:41 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2022-06-09 15:12:41 -0400 |
commit | f73eb90d830df1a0881447d918985e315aed6fb7 (patch) | |
tree | fc6830885a96bdcc077b95f207c7062ff5317317 /src | |
parent | bddaf3af81b836ac8d25199f154fc59a95848dab (diff) | |
download | solarlib-f73eb90d830df1a0881447d918985e315aed6fb7.tar.gz solarlib-f73eb90d830df1a0881447d918985e315aed6fb7.zip |
planet: Add further state management1.4.1
- Force shutdown/reboot
- resume
Closes #1
Diffstat (limited to 'src')
-rw-r--r-- | src/planet.rs | 52 |
1 files changed, 52 insertions, 0 deletions
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)] |