Issue tokens to initialize VNC connections
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
use crate::actors::vnc_tokens_actor::VNCTokensManager;
|
||||
use crate::controllers::{HttpResult, LibVirtReq};
|
||||
use crate::libvirt_lib_structures::{DomainState, DomainXMLUuid};
|
||||
use crate::libvirt_rest_structures::VMInfo;
|
||||
@ -208,3 +209,25 @@ pub async fn screenshot(client: LibVirtReq, id: web::Path<SingleVMUUidReq>) -> H
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct IssueVNCTokenResponse {
|
||||
token: String,
|
||||
}
|
||||
|
||||
/// Issue a VNC connection token
|
||||
pub async fn vnc_token(
|
||||
manager: web::Data<VNCTokensManager>,
|
||||
id: web::Path<SingleVMUUidReq>,
|
||||
) -> HttpResult {
|
||||
Ok(match manager.issue_token(id.uid).await {
|
||||
Ok(token) => HttpResponse::Ok().json(IssueVNCTokenResponse { token }),
|
||||
Err(e) => {
|
||||
log::error!(
|
||||
"Failed to issue a token for a domain domain {:?} ! {e}",
|
||||
id.uid
|
||||
);
|
||||
HttpResponse::InternalServerError().json("Failed to issue a token for the domain!")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user