Created first domain
This commit is contained in:
17
virtweb_backend/src/controllers/vm_controller.rs
Normal file
17
virtweb_backend/src/controllers/vm_controller.rs
Normal 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))
|
||||
}
|
Reference in New Issue
Block a user