Can create VM from UI

This commit is contained in:
2023-10-16 19:00:15 +02:00
parent 7ef5afb978
commit fbfe4f00c5
12 changed files with 420 additions and 10 deletions

View File

@ -10,6 +10,11 @@ struct VMInfoAndState {
state: DomainState,
}
#[derive(serde::Serialize)]
struct VMUuid {
uuid: DomainXMLUuid,
}
/// Create a new VM
pub async fn create(client: LibVirtReq, req: web::Json<VMInfo>) -> HttpResult {
let domain = match req.0.to_domain() {
@ -21,7 +26,7 @@ pub async fn create(client: LibVirtReq, req: web::Json<VMInfo>) -> HttpResult {
};
let id = client.update_domain(domain).await?;
Ok(HttpResponse::Ok().json(id))
Ok(HttpResponse::Ok().json(VMUuid { uuid: id }))
}
/// Get the list of domains