Signed-off-by: Daniel Kral <[email protected]>
---
 proxmox-resource-scheduling/src/lib.rs        |  1 +
 .../src/pve_dynamic.rs                        | 53 +++++++++++++++++++
 2 files changed, 54 insertions(+)
 create mode 100644 proxmox-resource-scheduling/src/pve_dynamic.rs

diff --git a/proxmox-resource-scheduling/src/lib.rs 
b/proxmox-resource-scheduling/src/lib.rs
index c73e7b1e..2c22dbce 100644
--- a/proxmox-resource-scheduling/src/lib.rs
+++ b/proxmox-resource-scheduling/src/lib.rs
@@ -3,4 +3,5 @@ pub mod topsis;
 
 pub mod scheduler;
 
+pub mod pve_dynamic;
 pub mod pve_static;
diff --git a/proxmox-resource-scheduling/src/pve_dynamic.rs 
b/proxmox-resource-scheduling/src/pve_dynamic.rs
new file mode 100644
index 00000000..4f480612
--- /dev/null
+++ b/proxmox-resource-scheduling/src/pve_dynamic.rs
@@ -0,0 +1,53 @@
+use serde::{Deserialize, Serialize};
+
+use crate::scheduler::{NodeStats, ServiceStats};
+
+#[derive(Clone, Copy, Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
+/// Dynamic usage stats of a node.
+pub struct DynamicNodeStats {
+    /// CPU utilization in CPU cores.
+    pub cpu: f64,
+    /// Total number of CPU cores.
+    pub maxcpu: usize,
+    /// Used memory in bytes.
+    pub mem: usize,
+    /// Total memory in bytes.
+    pub maxmem: usize,
+}
+
+impl From<DynamicNodeStats> for NodeStats {
+    fn from(value: DynamicNodeStats) -> Self {
+        Self {
+            cpu: value.cpu,
+            maxcpu: value.maxcpu,
+            mem: value.mem,
+            maxmem: value.maxmem,
+        }
+    }
+}
+
+#[derive(Clone, Copy, Default, Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
+/// Dynamic usage stats of an HA resource.
+pub struct DynamicServiceStats {
+    /// CPU utilization in CPU cores.
+    pub cpu: f64,
+    /// Number of assigned CPUs or CPU limit.
+    pub maxcpu: f64,
+    /// Used memory in bytes.
+    pub mem: usize,
+    /// Maximum assigned memory in bytes.
+    pub maxmem: usize,
+}
+
+impl From<DynamicServiceStats> for ServiceStats {
+    fn from(value: DynamicServiceStats) -> Self {
+        Self {
+            cpu: value.cpu,
+            maxcpu: value.maxcpu,
+            mem: value.mem,
+            maxmem: value.maxmem,
+        }
+    }
+}
-- 
2.47.3




Reply via email to