worker_autoscaler_vm - OmniCloudOrg/OmniOrchestrator GitHub Wiki
Path: src/worker_autoscaler/vm.rs
pub struct VM {
/// Unique identifier for the VM
pub id: String,
/// Human-readable name for the VM
pub name: String,
/// ID of the node hosting this VM
pub node_id: String,
/// CPU cores allocated to this VM
pub cpu: u32,
/// Memory in MB allocated to this VM
pub memory: u32,
/// Storage in GB allocated to this VM
pub storage: u32,
/// Current state of the VM
pub state: VMState,
/// When the VM was created (as milliseconds since UNIX epoch)
#[serde(with = "timestamp_serde")]
pub created_at: Instant,
/// Last time the VM state was updated (as milliseconds since UNIX epoch)
#[serde(with = "timestamp_serde")]
pub updated_at: Instant,
/// Additional properties specific to this VM
pub properties: HashMap<String, String>,
}
Represents a VM managed by the autoscaler
pub fn serialize<S>(instant: &Instant, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
// ... function body
}
pub fn deserialize<'de, D>(deserializer: D) -> Result<Instant, D::Error>
where
D: Deserializer<'de>,
{
// ... function body
}
pub fn new(id: String, name: String, node_id: String, cpu: u32, memory: u32, storage: u32) -> Self {
let now = Instant::now();
Create a new VM
pub enum VMState {
/// VM is being created
Creating,
/// VM is running
Running,
/// VM is stopped
Stopped,
/// VM is being terminated
Terminating,
/// VM has been terminated
Terminated,
/// VM is in error state
Error,
}
Possible states for a VM
pub struct VMConfig {
/// CPU cores for each VM
pub cpu: u32,
/// Memory in MB for each VM
pub memory: u32,
/// Storage in GB for each VM
pub storage: u32,
/// Additional configuration options
pub options: HashMap<String, String>,
}
Configuration for VM creation
pub struct VMTemplate {
/// Base name for VMs created from this template
pub base_name: String,
/// VM configuration
pub config: VMConfig,
/// Additional tags to apply to VMs
pub tags: HashMap<String, String>,
}
Template for creating new VMs