diff options
author | Cara Salter <cara@devcara.com> | 2022-06-12 11:04:41 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2022-06-12 11:08:51 -0400 |
commit | 373f5f25375d6eb563e5c75f432d78ee7d37672c (patch) | |
tree | 6acb2b9b50b98700a58e46973c94676ec5c0dca6 /src | |
parent | 36cb8b5e4ead9316883810d99ee4f9fdaeddac1b (diff) | |
download | solarlib-373f5f25375d6eb563e5c75f432d78ee7d37672c.tar.gz solarlib-373f5f25375d6eb563e5c75f432d78ee7d37672c.zip |
planet: Include status in struct
Closes #2
Diffstat (limited to 'src')
-rw-r--r-- | src/planet.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/planet.rs b/src/planet.rs index 6ba795f..b5905ec 100644 --- a/src/planet.rs +++ b/src/planet.rs @@ -60,6 +60,8 @@ pub struct Planet { /// Whether the planet is "orbiting" (running) pub orbiting: bool, + pub status: Health, + #[serde(skip)] domain: Option<Arc<Domain>>, } @@ -99,6 +101,8 @@ impl TryFrom<Domain> for Planet { None }; + let health = d.get_state()?.0.try_into()?; + Ok(Self { name: d.get_name()?, host: c.get_hostname()?, @@ -107,6 +111,7 @@ impl TryFrom<Domain> for Planet { mem: d.get_max_memory()?.into(), cpu_count: d.get_max_vcpus()?.into(), orbiting: d.is_active()?, + status: health, domain: Some(Arc::new(d)), }) } @@ -144,6 +149,8 @@ impl TryFrom<&Domain> for Planet { let new_d = Domain::lookup_by_uuid_string(&c, &d.get_uuid_string()?)?; + let health = d.get_state()?.0.try_into()?; + Ok(Self { name: d.get_name()?, host: c.get_hostname()?, @@ -152,12 +159,13 @@ impl TryFrom<&Domain> for Planet { mem: d.get_max_memory()?.into(), cpu_count: d.get_max_vcpus()?.into(), orbiting: d.is_active()?, + status: health, domain: Some(Arc::new(new_d)), }) } } -#[derive(Serialize, Deserialize, Debug, PartialEq)] +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub enum Health { Unknown = 0, Running = 1, |