Created first domain

This commit is contained in:
2023-10-04 11:18:50 +02:00
parent 7073b9b7f1
commit 2bc64442f4
12 changed files with 314 additions and 28 deletions

View File

@ -0,0 +1,17 @@
use crate::controllers::{HttpResult, LibVirtReq};
use crate::libvirt_rest_structures::VMInfo;
use actix_web::{web, HttpResponse};
/// Create a new VM
pub async fn create(client: LibVirtReq, req: web::Json<VMInfo>) -> HttpResult {
let domain = match req.0.to_domain() {
Ok(d) => d,
Err(e) => {
log::error!("Failed to extract domain info! {e}");
return Ok(HttpResponse::BadRequest().body(e.to_string()));
}
};
let id = client.update_domain(domain).await?;
Ok(HttpResponse::Ok().json(id))
}