Automatically backup source network and VM configuration
This commit is contained in:
@ -10,7 +10,7 @@ pub struct NetworkID {
|
||||
|
||||
/// Create a new network
|
||||
pub async fn create(client: LibVirtReq, req: web::Json<NetworkInfo>) -> HttpResult {
|
||||
let network = match req.0.to_virt_network() {
|
||||
let network = match req.0.as_virt_network() {
|
||||
Ok(d) => d,
|
||||
Err(e) => {
|
||||
log::error!("Failed to extract network info! {e}");
|
||||
@ -20,7 +20,7 @@ pub async fn create(client: LibVirtReq, req: web::Json<NetworkInfo>) -> HttpResu
|
||||
}
|
||||
};
|
||||
|
||||
let uid = match client.update_network(network).await {
|
||||
let uid = match client.update_network(req.0, network).await {
|
||||
Ok(u) => u,
|
||||
Err(e) => {
|
||||
log::error!("Failed to update network! {e}");
|
||||
@ -71,7 +71,7 @@ pub async fn update(
|
||||
path: web::Path<NetworkID>,
|
||||
body: web::Json<NetworkInfo>,
|
||||
) -> HttpResult {
|
||||
let mut network = match body.0.to_virt_network() {
|
||||
let mut network = match body.0.as_virt_network() {
|
||||
Ok(n) => n,
|
||||
Err(e) => {
|
||||
log::error!("Failed to extract network info! {e}");
|
||||
@ -82,7 +82,7 @@ pub async fn update(
|
||||
};
|
||||
network.uuid = Some(path.uid);
|
||||
|
||||
if let Err(e) = client.update_network(network).await {
|
||||
if let Err(e) = client.update_network(body.0, network).await {
|
||||
log::error!("Failed to update network! {e}");
|
||||
return Ok(
|
||||
HttpResponse::InternalServerError().json(format!("Failed to update network!\n${e}"))
|
||||
|
@ -20,7 +20,7 @@ struct VMUuid {
|
||||
|
||||
/// Create a new VM
|
||||
pub async fn create(client: LibVirtReq, req: web::Json<VMInfo>) -> HttpResult {
|
||||
let domain = match req.0.to_domain() {
|
||||
let domain = match req.0.as_tomain() {
|
||||
Ok(d) => d,
|
||||
Err(e) => {
|
||||
log::error!("Failed to extract domain info! {e}");
|
||||
@ -29,7 +29,7 @@ pub async fn create(client: LibVirtReq, req: web::Json<VMInfo>) -> HttpResult {
|
||||
);
|
||||
}
|
||||
};
|
||||
let id = match client.update_domain(domain).await {
|
||||
let id = match client.update_domain(req.0, domain).await {
|
||||
Ok(i) => i,
|
||||
Err(e) => {
|
||||
log::error!("Failed to update domain info! {e}");
|
||||
@ -111,13 +111,13 @@ pub async fn update(
|
||||
id: web::Path<SingleVMUUidReq>,
|
||||
req: web::Json<VMInfo>,
|
||||
) -> HttpResult {
|
||||
let mut domain = req.0.to_domain().map_err(|e| {
|
||||
let mut domain = req.0.as_tomain().map_err(|e| {
|
||||
log::error!("Failed to extract domain info! {e}");
|
||||
HttpResponse::BadRequest().json(format!("Failed to extract domain info! {e}"))
|
||||
})?;
|
||||
|
||||
domain.uuid = Some(id.uid);
|
||||
if let Err(e) = client.update_domain(domain).await {
|
||||
if let Err(e) = client.update_domain(req.0, domain).await {
|
||||
log::error!("Failed to update domain info! {e}");
|
||||
return Ok(HttpResponse::BadRequest().json(format!("Failed to update domain info!\n{e}")));
|
||||
}
|
||||
|
Reference in New Issue
Block a user