Configure CI (#2)
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #2
Co-authored-by: Pierre HUBERT <pierre.git@communiquons.org>
Co-committed-by: Pierre HUBERT <pierre.git@communiquons.org>
This commit is contained in:
Pierre HUBERT 2024-04-05 18:58:30 +00:00 committed by Pierre Hubert
parent 9b55f1f29c
commit 1ed23317cb
9 changed files with 3097 additions and 3534 deletions

52
.drone.yml Normal file
View File

@ -0,0 +1,52 @@
---
kind: pipeline
type: docker
name: default
steps:
- name: web_build
image: node:20
volumes:
- name: web_app
path: /tmp/web_build
commands:
- cd virtweb_frontend
- npm install
- npm run build
- mv dist /tmp/web_build
- name: backend_check
image: rust
volumes:
- name: rust_registry
path: /usr/local/cargo/registry
commands:
- apt update && apt install -y libvirt-dev
- rustup component add clippy
- cd virtweb_backend
- cargo clippy -- -D warnings
- cargo test
- name: backend_compile
image: rust
volumes:
- name: rust_registry
path: /usr/local/cargo/registry
- name: web_app
path: /tmp/web_build
depends_on:
- backend_check
- web_build
commands:
- apt update && apt install -y libvirt-dev
- cd virtweb_backend
- mv /tmp/web_build/dist static
- cargo build --release
- ls -lah target/release/virtweb_backend
volumes:
- name: rust_registry
temp: {}
- name: web_app
temp: {}

File diff suppressed because it is too large Load Diff

View File

@ -6,42 +6,42 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
log = "0.4.19" log = "0.4.21"
env_logger = "0.10.1" env_logger = "0.11.3"
clap = { version = "4.4.11", features = ["derive", "env"] } clap = { version = "4.5.4", features = ["derive", "env"] }
light-openid = { version = "1.0.1", features = ["crypto-wrapper"] } light-openid = { version = "1.0.2", features = ["crypto-wrapper"] }
lazy_static = "1.4.0" lazy_static = "1.4.0"
actix = "0.13.1" actix = "0.13.3"
actix-web = "4" actix-web = "4.5.1"
actix-remote-ip = "0.1.0" actix-remote-ip = "0.1.0"
actix-session = { version = "0.8.0", features = ["cookie-session"] } actix-session = { version = "0.9.0", features = ["cookie-session"] }
actix-identity = "0.6.0" actix-identity = "0.7.1"
actix-cors = "0.6.5" actix-cors = "0.7.0"
actix-files = "0.6.2" actix-files = "0.6.5"
actix-web-actors = "4.2.0" actix-web-actors = "4.3.0"
actix-http = "3.4.0" actix-http = "3.6.0"
serde = { version = "1.0.193", features = ["derive"] } serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.108" serde_json = "1.0.108"
quick-xml = { version = "0.31.0", features = ["serialize", "overlapped-lists"] } quick-xml = { version = "0.31.0", features = ["serialize", "overlapped-lists"] }
futures-util = "0.3.28" futures-util = "0.3.28"
anyhow = "1.0.75" anyhow = "1.0.81"
actix-multipart = "0.6.1" actix-multipart = "0.6.1"
tempfile = "3.8.1" tempfile = "3.10.1"
reqwest = { version = "0.11.23", features = ["stream"] } reqwest = { version = "0.12.3", features = ["stream"] }
url = "2.5.0" url = "2.5.0"
virt = "0.3.1" virt = "0.3.1"
sysinfo = { version = "0.29.11", features = ["serde"] } sysinfo = { version = "0.30.8", features = ["serde"] }
uuid = { version = "1.6.1", features = ["v4", "serde"] } uuid = { version = "1.8.0", features = ["v4", "serde"] }
lazy-regex = "3.1.0" lazy-regex = "3.1.0"
thiserror = "1.0.51" thiserror = "1.0.58"
image = "0.24.7" image = "0.25.1"
rand = "0.8.5" rand = "0.8.5"
bytes = "1.5.0" bytes = "1.6.0"
tokio = "1.35.0" tokio = "1.37.0"
futures = "0.3.29" futures = "0.3.30"
ipnetwork = "0.20.0" ipnetwork = "0.20.0"
num = "0.4.1" num = "0.4.1"
rust-embed = { version = "8.1.0" } rust-embed = { version = "8.3.0" }
mime_guess = "2.0.4" mime_guess = "2.0.4"
dotenvy = "0.15.7" dotenvy = "0.15.7"
nix = { version = "0.27.1", features = ["net"] } nix = { version = "0.28.0", features = ["net"] }

View File

@ -9,7 +9,7 @@ use crate::libvirt_rest_structures::nw_filter::{NetworkFilter, NetworkFilterName
use crate::libvirt_rest_structures::vm::*; use crate::libvirt_rest_structures::vm::*;
use crate::nat::nat_lib; use crate::nat::nat_lib;
use actix::{Actor, Context, Handler, Message}; use actix::{Actor, Context, Handler, Message};
use image::ImageOutputFormat; use image::ImageFormat;
use std::io::Cursor; use std::io::Cursor;
use virt::connect::Connect; use virt::connect::Connect;
use virt::domain::Domain; use virt::domain::Domain;
@ -337,7 +337,7 @@ impl Handler<ScreenshotDomainReq> for LibVirtActor {
let image = image::load_from_memory(&screen_out)?; let image = image::load_from_memory(&screen_out)?;
let mut png_out = Cursor::new(Vec::new()); let mut png_out = Cursor::new(Vec::new());
image.write_to(&mut png_out, ImageOutputFormat::Png)?; image.write_to(&mut png_out, ImageFormat::Png)?;
Ok(png_out.into_inner()) Ok(png_out.into_inner())
} }

View File

@ -8,7 +8,7 @@ use crate::libvirt_rest_structures::hypervisor::HypervisorInfo;
use crate::nat::nat_hook; use crate::nat::nat_hook;
use crate::utils::net_utils; use crate::utils::net_utils;
use actix_web::{HttpResponse, Responder}; use actix_web::{HttpResponse, Responder};
use sysinfo::{System, SystemExt}; use sysinfo::{Components, Disks, Networks, System};
#[derive(serde::Serialize)] #[derive(serde::Serialize)]
struct StaticConfig { struct StaticConfig {
@ -106,18 +106,33 @@ pub async fn static_config(local_auth: LocalAuthEnabled) -> impl Responder {
struct ServerInfo { struct ServerInfo {
hypervisor: HypervisorInfo, hypervisor: HypervisorInfo,
system: System, system: System,
components: Components,
disks: Disks,
networks: Networks,
} }
pub async fn server_info(client: LibVirtReq) -> HttpResult { pub async fn server_info(client: LibVirtReq) -> HttpResult {
let mut system = System::new(); let mut system = System::new();
system.refresh_disks_list();
system.refresh_components_list();
system.refresh_networks_list();
system.refresh_all(); system.refresh_all();
let mut components = Components::new();
components.refresh_list();
components.refresh();
let mut disks = Disks::new();
disks.refresh_list();
disks.refresh();
let mut networks = Networks::new();
networks.refresh_list();
networks.refresh();
Ok(HttpResponse::Ok().json(ServerInfo { Ok(HttpResponse::Ok().json(ServerInfo {
hypervisor: client.get_info().await?, hypervisor: client.get_info().await?,
system, system,
components,
disks,
networks,
})) }))
} }

View File

@ -2,7 +2,7 @@ use nix::sys::socket::{AddressFamily, SockaddrLike};
use std::collections::HashMap; use std::collections::HashMap;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::str::FromStr; use std::str::FromStr;
use sysinfo::{NetworksExt, System, SystemExt}; use sysinfo::Networks;
pub fn extract_ipv4(ip: IpAddr) -> Ipv4Addr { pub fn extract_ipv4(ip: IpAddr) -> Ipv4Addr {
match ip { match ip {
@ -56,11 +56,11 @@ pub fn is_net_interface_name_valid<D: AsRef<str>>(int: D) -> bool {
/// Get the list of available network interfaces /// Get the list of available network interfaces
pub fn net_list() -> Vec<String> { pub fn net_list() -> Vec<String> {
let mut system = System::new(); let mut networks = Networks::new();
system.refresh_networks_list(); networks.refresh_list();
system networks
.networks() .list()
.iter() .iter()
.map(|n| n.0.to_string()) .map(|n| n.0.to_string())
.collect::<Vec<_>>() .collect::<Vec<_>>()

File diff suppressed because it is too large Load Diff

View File

@ -39,6 +39,9 @@ let config: ServerConfig | null = null;
export interface ServerSystemInfo { export interface ServerSystemInfo {
hypervisor: HypervisorInfo; hypervisor: HypervisorInfo;
system: SystemInfo; system: SystemInfo;
components: SysComponent;
disks: DiskInfo[];
networks: NetworkInfo[];
} }
interface HypervisorInfo { interface HypervisorInfo {
@ -77,10 +80,6 @@ interface SystemInfo {
total_swap: number; total_swap: number;
free_swap: number; free_swap: number;
used_swap: number; used_swap: number;
components: SysComponent;
users: [];
disks: DiskInfo[];
networks: NetworkInfo[];
uptime: number; uptime: number;
boot_time: number; boot_time: number;
load_average: SysLoadAverage; load_average: SysLoadAverage;

View File

@ -51,7 +51,7 @@ export function SysInfoRoute(): React.ReactElement {
export function SysInfoRouteInner(p: { export function SysInfoRouteInner(p: {
info: ServerSystemInfo; info: ServerSystemInfo;
}): React.ReactElement { }): React.ReactElement {
const sumDiskUsage = p.info.system.disks.reduce( const sumDiskUsage = p.info.disks.reduce(
(prev, disk) => { (prev, disk) => {
return { return {
used: prev.used + disk.total_space - disk.available_space, used: prev.used + disk.total_space - disk.available_space,
@ -227,8 +227,8 @@ export function SysInfoRouteInner(p: {
]} ]}
/> />
<DiskDetailsTable disks={p.info.system.disks} /> <DiskDetailsTable disks={p.info.disks} />
<NetworksDetailsTable networks={p.info.system.networks} /> <NetworksDetailsTable networks={p.info.networks} />
</VirtWebRouteContainer> </VirtWebRouteContainer>
); );
} }