tftsr-devops_investigation/src-tauri/src/proxmox/ha.rs

63 lines
1.6 KiB
Rust
Raw Normal View History

// HA (High Availability) groups management module
// Provides operations for managing Proxmox HA groups
use serde::{Deserialize, Serialize};
/// HA group information
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HaGroup {
pub group: String,
pub nodes: Vec<String>,
pub max_failures: u32,
pub max_relocate: u32,
pub state: String,
}
/// HA resource information
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HaResource {
pub resource: String,
pub group: Option<String>,
pub node: Option<String>,
pub state: String,
pub enabled: bool,
}
/// List HA groups
pub async fn list_ha_groups(
_client: &crate::proxmox::client::ProxmoxClient,
_ticket: &str,
) -> Result<Vec<HaGroup>, String> {
Err("Not implemented yet".to_string())
}
/// List HA resources
pub async fn list_ha_resources(
_client: &crate::proxmox::client::ProxmoxClient,
_ticket: &str,
) -> Result<Vec<HaResource>, String> {
Err("Not implemented yet".to_string())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_ha_group_serialization() {
let group = HaGroup {
group: "primary".to_string(),
nodes: vec!["pve-node-1".to_string(), "pve-node-2".to_string()],
max_failures: 2,
max_relocate: 1,
state: "enabled".to_string(),
};
let json = serde_json::to_string(&group).unwrap();
let deserialized: HaGroup = serde_json::from_str(&json).unwrap();
assert_eq!(group.group, deserialized.group);
assert_eq!(group.state, "enabled");
}
}