Can get domain info
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
use crate::controllers::{HttpResult, LibVirtReq};
|
||||
use crate::libvirt_lib_structures::DomainXMLUuid;
|
||||
use crate::libvirt_rest_structures::VMInfo;
|
||||
use actix_web::{web, HttpResponse};
|
||||
|
||||
@ -15,3 +16,21 @@ pub async fn create(client: LibVirtReq, req: web::Json<VMInfo>) -> HttpResult {
|
||||
|
||||
Ok(HttpResponse::Ok().json(id))
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct SingleVMUUidReq {
|
||||
uid: DomainXMLUuid,
|
||||
}
|
||||
|
||||
/// Get the information about a single VM
|
||||
pub async fn get_single(client: LibVirtReq, id: web::Path<SingleVMUUidReq>) -> HttpResult {
|
||||
let info = match client.get_single_domain(id.uid).await {
|
||||
Ok(i) => i,
|
||||
Err(e) => {
|
||||
log::error!("Failed to get domain info! {e}");
|
||||
return Ok(HttpResponse::InternalServerError().json(e.to_string()));
|
||||
}
|
||||
};
|
||||
|
||||
Ok(HttpResponse::Ok().json(VMInfo::from_domain(info)?))
|
||||
}
|
||||
|
Reference in New Issue
Block a user