Skip to content

Commit

Permalink
Yield more information about services to client
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander V. Nikolaev <[email protected]>
  • Loading branch information
avnik committed Nov 13, 2024
1 parent 995738c commit f45e6f8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions api/admin/admin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions common/src/query.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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<String>,
pub agent_name: Option<String>,
}

impl QueryResult {
Expand All @@ -51,6 +56,12 @@ impl TryFrom<pb::QueryListItem> 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,
})
}
}
Expand All @@ -62,6 +73,10 @@ impl From<QueryResult> 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,
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions common/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -13,15 +15,15 @@ pub struct UnitType {
pub service: ServiceType,
}

#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Serialize, EnumString, Display)]
pub enum VmType {
Host,
AdmVM,
SysVM,
AppVM,
}

#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Serialize, EnumString, Display)]
pub enum ServiceType {
Mgr,
Svc,
Expand Down
4 changes: 4 additions & 0 deletions src/admin/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ impl From<RegistryEntry> 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()),
}
}
}

0 comments on commit f45e6f8

Please sign in to comment.