diff --git a/api/admin/admin.proto b/api/admin/admin.proto index c1057b0..f692119 100644 --- a/api/admin/admin.proto +++ b/api/admin/admin.proto @@ -50,6 +50,10 @@ message QueryListItem { string Description = 2; string VmStatus = 3; string TrustLevel = 4; + string VmType = 5; + string ServiceType = 6; + optional string VmName = 7; // None for host running services + optional string AgentName = 8; // None for agents } message QueryListResponse { diff --git a/common/src/query.rs b/common/src/query.rs index f107cea..d437d0b 100644 --- a/common/src/query.rs +++ b/common/src/query.rs @@ -1,4 +1,5 @@ // Types related to QueryList and Watch API +use super::types::{ServiceType, VmType}; use crate::pb; use pb::admin::watch_item::Status; @@ -33,6 +34,10 @@ pub struct QueryResult { pub description: String, //App name, some details pub status: VMStatus, pub trust_level: TrustLevel, + pub vm_type: VmType, + pub service_type: ServiceType, + pub vm_name: Option, + pub agent_name: Option, } impl QueryResult { @@ -51,6 +56,12 @@ impl TryFrom for QueryResult { .with_context(|| format!("While parsing vm_status {}", item.vm_status))?, trust_level: TrustLevel::from_str(item.trust_level.as_str()) .with_context(|| format!("While parsing trust_level {}", item.trust_level))?, + vm_type: VmType::from_str(item.vm_type.as_str()) + .with_context(|| format!("While parsing vm_type {}", item.vm_type))?, + service_type: ServiceType::from_str(item.service_type.as_str()) + .with_context(|| format!("While parsing service_type {}", item.service_type))?, + agent_name: item.agent_name, + vm_name: item.vm_name, }) } } @@ -62,6 +73,10 @@ impl From for pb::QueryListItem { description: val.description, vm_status: val.status.to_string(), trust_level: val.trust_level.to_string(), + vm_type: val.vm_type.to_string(), + service_type: val.service_type.to_string(), + agent_name: val.agent_name, + vm_name: val.vm_name, } } } diff --git a/common/src/types.rs b/common/src/types.rs index 0d4061a..dec80de 100644 --- a/common/src/types.rs +++ b/common/src/types.rs @@ -5,6 +5,8 @@ use crate::pb; use std::convert::{Into, TryFrom}; use anyhow::bail; +use serde::Serialize; +use strum::{Display, EnumString}; use tokio_vsock::VsockAddr; #[derive(Debug, Copy, Clone, PartialEq)] @@ -13,7 +15,7 @@ pub struct UnitType { pub service: ServiceType, } -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq, Serialize, EnumString, Display)] pub enum VmType { Host, AdmVM, @@ -21,7 +23,7 @@ pub enum VmType { AppVM, } -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq, Serialize, EnumString, Display)] pub enum ServiceType { Mgr, Svc, diff --git a/src/admin/entry.rs b/src/admin/entry.rs index 30f2b87..8cf8c68 100644 --- a/src/admin/entry.rs +++ b/src/admin/entry.rs @@ -108,6 +108,10 @@ impl From for QueryResult { description: val.status.description, status, trust_level: TrustLevel::default(), + vm_type: val.r#type.vm, + service_type: val.r#type.service, + vm_name: Some("FIXME".into()), + agent_name: Some("FIXME".into()), } } }