fix(proxmox): resolve 7 dashboard and AI chat issues #129
@ -716,7 +716,10 @@ pub async fn list_proxmox_datastores(
|
||||
format!("storage/{}/{}", node_name, storage_name)
|
||||
};
|
||||
if storage_name.is_empty() {
|
||||
tracing::warn!(node = node_name, "storage entry has empty storage name — skipping");
|
||||
tracing::warn!(
|
||||
node = node_name,
|
||||
"storage entry has empty storage name — skipping"
|
||||
);
|
||||
return None;
|
||||
}
|
||||
tracing::debug!(storage_id = %storage_id, "generated storage ID");
|
||||
@ -744,10 +747,7 @@ pub async fn list_proxmox_datastores(
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
normalized.insert(
|
||||
"content".to_string(),
|
||||
serde_json::Value::String(content),
|
||||
);
|
||||
normalized.insert("content".to_string(), serde_json::Value::String(content));
|
||||
|
||||
normalized.insert(
|
||||
"node".to_string(),
|
||||
@ -759,9 +759,18 @@ pub async fn list_proxmox_datastores(
|
||||
let disk_total = obj.get("maxdisk").and_then(|v| v.as_u64()).unwrap_or(0);
|
||||
let disk_avail = disk_total.saturating_sub(disk_used);
|
||||
|
||||
normalized.insert("used".to_string(), serde_json::Value::Number(disk_used.into()));
|
||||
normalized.insert("size".to_string(), serde_json::Value::Number(disk_total.into()));
|
||||
normalized.insert("available".to_string(), serde_json::Value::Number(disk_avail.into()));
|
||||
normalized.insert(
|
||||
"used".to_string(),
|
||||
serde_json::Value::Number(disk_used.into()),
|
||||
);
|
||||
normalized.insert(
|
||||
"size".to_string(),
|
||||
serde_json::Value::Number(disk_total.into()),
|
||||
);
|
||||
normalized.insert(
|
||||
"available".to_string(),
|
||||
serde_json::Value::Number(disk_avail.into()),
|
||||
);
|
||||
|
||||
let status = obj
|
||||
.get("status")
|
||||
|
||||
@ -45,10 +45,22 @@ pub async fn list_firewall_rules(
|
||||
let rule_num = rule.get("pos").and_then(|v| v.as_u64()).unwrap_or(0) as u32;
|
||||
let action = rule.get("action").and_then(|v| v.as_str())?.to_string();
|
||||
// PVE uses "proto" not "protocol"
|
||||
let protocol = rule.get("proto").and_then(|v| v.as_str()).unwrap_or("").to_string();
|
||||
let protocol = rule
|
||||
.get("proto")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
// source and dest are optional fields
|
||||
let source = rule.get("source").and_then(|v| v.as_str()).unwrap_or("").to_string();
|
||||
let destination = rule.get("dest").and_then(|v| v.as_str()).unwrap_or("").to_string();
|
||||
let source = rule
|
||||
.get("source")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
let destination = rule
|
||||
.get("dest")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
let port = rule
|
||||
.get("dport")
|
||||
.or_else(|| rule.get("sport"))
|
||||
@ -57,11 +69,7 @@ pub async fn list_firewall_rules(
|
||||
// PVE uses "enable" as integer (1=enabled, 0=disabled), not "enabled" bool
|
||||
let enabled = rule
|
||||
.get("enable")
|
||||
.and_then(|e| {
|
||||
e.as_i64()
|
||||
.map(|n| n != 0)
|
||||
.or_else(|| e.as_bool())
|
||||
})
|
||||
.and_then(|e| e.as_i64().map(|n| n != 0).or_else(|| e.as_bool()))
|
||||
.unwrap_or(true);
|
||||
|
||||
Some(FirewallRule {
|
||||
@ -225,9 +233,21 @@ pub async fn get_firewall_status(
|
||||
.filter_map(|rule| {
|
||||
let rule_num = rule.get("pos").and_then(|v| v.as_u64()).unwrap_or(0) as u32;
|
||||
let action = rule.get("action").and_then(|v| v.as_str())?.to_string();
|
||||
let protocol = rule.get("proto").and_then(|v| v.as_str()).unwrap_or("").to_string();
|
||||
let source = rule.get("source").and_then(|v| v.as_str()).unwrap_or("").to_string();
|
||||
let destination = rule.get("dest").and_then(|v| v.as_str()).unwrap_or("").to_string();
|
||||
let protocol = rule
|
||||
.get("proto")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
let source = rule
|
||||
.get("source")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
let destination = rule
|
||||
.get("dest")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
let port = rule
|
||||
.get("dport")
|
||||
.or_else(|| rule.get("sport"))
|
||||
@ -235,11 +255,7 @@ pub async fn get_firewall_status(
|
||||
.map(|s| s.to_string());
|
||||
let enabled = rule
|
||||
.get("enable")
|
||||
.and_then(|e| {
|
||||
e.as_i64()
|
||||
.map(|n| n != 0)
|
||||
.or_else(|| e.as_bool())
|
||||
})
|
||||
.and_then(|e| e.as_i64().map(|n| n != 0).or_else(|| e.as_bool()))
|
||||
.unwrap_or(true);
|
||||
|
||||
Some(FirewallRule {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user