Ready to implement groups web ui integration
This commit is contained in:
@ -2,7 +2,7 @@ use crate::app_config::AppConfig;
|
||||
use crate::controllers::HttpResult;
|
||||
use crate::extractors::auth_extractor::AuthExtractor;
|
||||
use crate::virtweb_client;
|
||||
use crate::virtweb_client::{GroupID, VMInfo};
|
||||
use crate::virtweb_client::{GroupID, VMCaps, VMInfo};
|
||||
use actix_web::HttpResponse;
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
@ -29,28 +29,16 @@ pub struct Rights {
|
||||
pub struct GroupInfo {
|
||||
id: GroupID,
|
||||
vms: Vec<VMInfo>,
|
||||
can_get_state: bool,
|
||||
can_start: bool,
|
||||
can_shutdown: bool,
|
||||
can_kill: bool,
|
||||
can_reset: bool,
|
||||
can_suspend: bool,
|
||||
can_resume: bool,
|
||||
can_screenshot: bool,
|
||||
#[serde(flatten)]
|
||||
caps: VMCaps,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
pub struct VMInfoAndCaps {
|
||||
#[serde(flatten)]
|
||||
info: VMInfo,
|
||||
can_get_state: bool,
|
||||
can_start: bool,
|
||||
can_shutdown: bool,
|
||||
can_kill: bool,
|
||||
can_reset: bool,
|
||||
can_suspend: bool,
|
||||
can_resume: bool,
|
||||
can_screenshot: bool,
|
||||
#[serde(flatten)]
|
||||
caps: VMCaps,
|
||||
}
|
||||
|
||||
pub async fn rights() -> HttpResult {
|
||||
@ -68,14 +56,16 @@ pub async fn rights() -> HttpResult {
|
||||
res.groups.push(GroupInfo {
|
||||
id: g.clone(),
|
||||
vms: group_vms,
|
||||
can_get_state: rights.is_route_allowed("GET", &g.route_vm_state(None)),
|
||||
can_start: rights.is_route_allowed("GET", &g.route_vm_start(None)),
|
||||
can_shutdown: rights.is_route_allowed("GET", &g.route_vm_shutdown(None)),
|
||||
can_kill: rights.is_route_allowed("GET", &g.route_vm_kill(None)),
|
||||
can_reset: rights.is_route_allowed("GET", &g.route_vm_reset(None)),
|
||||
can_suspend: rights.is_route_allowed("GET", &g.route_vm_suspend(None)),
|
||||
can_resume: rights.is_route_allowed("GET", &g.route_vm_resume(None)),
|
||||
can_screenshot: rights.is_route_allowed("GET", &g.route_vm_screenshot(None)),
|
||||
caps: VMCaps {
|
||||
can_get_state: rights.is_route_allowed("GET", &g.route_vm_state(None)),
|
||||
can_start: rights.is_route_allowed("GET", &g.route_vm_start(None)),
|
||||
can_shutdown: rights.is_route_allowed("GET", &g.route_vm_shutdown(None)),
|
||||
can_kill: rights.is_route_allowed("GET", &g.route_vm_kill(None)),
|
||||
can_reset: rights.is_route_allowed("GET", &g.route_vm_reset(None)),
|
||||
can_suspend: rights.is_route_allowed("GET", &g.route_vm_suspend(None)),
|
||||
can_resume: rights.is_route_allowed("GET", &g.route_vm_resume(None)),
|
||||
can_screenshot: rights.is_route_allowed("GET", &g.route_vm_screenshot(None)),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@ -84,14 +74,16 @@ pub async fn rights() -> HttpResult {
|
||||
|
||||
res.vms.push(VMInfoAndCaps {
|
||||
info: vm_info,
|
||||
can_get_state: rights.is_route_allowed("GET", &v.route_state()),
|
||||
can_start: rights.is_route_allowed("GET", &v.route_start()),
|
||||
can_shutdown: rights.is_route_allowed("GET", &v.route_shutdown()),
|
||||
can_kill: rights.is_route_allowed("GET", &v.route_kill()),
|
||||
can_reset: rights.is_route_allowed("GET", &v.route_reset()),
|
||||
can_suspend: rights.is_route_allowed("GET", &v.route_suspend()),
|
||||
can_resume: rights.is_route_allowed("GET", &v.route_resume()),
|
||||
can_screenshot: rights.is_route_allowed("GET", &v.route_screenshot()),
|
||||
caps: VMCaps {
|
||||
can_get_state: rights.is_route_allowed("GET", &v.route_state()),
|
||||
can_start: rights.is_route_allowed("GET", &v.route_start()),
|
||||
can_shutdown: rights.is_route_allowed("GET", &v.route_shutdown()),
|
||||
can_kill: rights.is_route_allowed("GET", &v.route_kill()),
|
||||
can_reset: rights.is_route_allowed("GET", &v.route_reset()),
|
||||
can_suspend: rights.is_route_allowed("GET", &v.route_suspend()),
|
||||
can_resume: rights.is_route_allowed("GET", &v.route_resume()),
|
||||
can_screenshot: rights.is_route_allowed("GET", &v.route_screenshot()),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -176,6 +176,18 @@ pub struct VMInfo {
|
||||
pub number_vcpu: usize,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, serde::Serialize, Debug)]
|
||||
pub struct VMCaps {
|
||||
pub can_get_state: bool,
|
||||
pub can_start: bool,
|
||||
pub can_shutdown: bool,
|
||||
pub can_kill: bool,
|
||||
pub can_reset: bool,
|
||||
pub can_suspend: bool,
|
||||
pub can_resume: bool,
|
||||
pub can_screenshot: bool,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, serde::Serialize, Debug)]
|
||||
pub struct VMState {
|
||||
pub state: String,
|
||||
|
Reference in New Issue
Block a user