From 373f5f25375d6eb563e5c75f432d78ee7d37672c Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Sun, 12 Jun 2022 11:04:41 -0400 Subject: planet: Include status in struct Closes #2 --- src/planet.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') 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>, } @@ -99,6 +101,8 @@ impl TryFrom 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 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, -- cgit v1.2.3