Return VM state
This commit is contained in:
@ -1,8 +1,15 @@
|
||||
use crate::controllers::{HttpResult, LibVirtReq};
|
||||
use crate::libvirt_lib_structures::DomainXMLUuid;
|
||||
use crate::libvirt_lib_structures::{DomainState, DomainXMLUuid};
|
||||
use crate::libvirt_rest_structures::VMInfo;
|
||||
use actix_web::{web, HttpResponse};
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct VMInfoAndState {
|
||||
#[serde(flatten)]
|
||||
info: VMInfo,
|
||||
state: DomainState,
|
||||
}
|
||||
|
||||
/// Create a new VM
|
||||
pub async fn create(client: LibVirtReq, req: web::Json<VMInfo>) -> HttpResult {
|
||||
let domain = match req.0.to_domain() {
|
||||
@ -32,5 +39,10 @@ pub async fn get_single(client: LibVirtReq, id: web::Path<SingleVMUUidReq>) -> H
|
||||
}
|
||||
};
|
||||
|
||||
Ok(HttpResponse::Ok().json(VMInfo::from_domain(info)?))
|
||||
let state = client.get_domain_state(id.uid).await?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(VMInfoAndState {
|
||||
info: VMInfo::from_domain(info)?,
|
||||
state,
|
||||
}))
|
||||
}
|
||||
|
Reference in New Issue
Block a user