worker_autoscaler_vm - OmniCloudOrg/OmniOrchestrator GitHub Wiki

vm (src/worker_autoscaler)

Path: src/worker_autoscaler/vm.rs

Table of Contents

Public Items

struct VM

Definition

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>,
}

Documentation

Represents a VM managed by the autoscaler

fn serialize

Definition

    pub fn serialize<S>(instant: &Instant, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: Serializer,
    {
    // ... function body
}

fn deserialize

Definition

    pub fn deserialize<'de, D>(deserializer: D) -> Result<Instant, D::Error>
    where
        D: Deserializer<'de>,
    {
    // ... function body
}

fn new

Definition

    pub fn new(id: String, name: String, node_id: String, cpu: u32, memory: u32, storage: u32) -> Self {
        let now = Instant::now();

Documentation

Create a new VM

enum VMState

Definition

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,
}

Documentation

Possible states for a VM

struct VMConfig

Definition

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>,
}

Documentation

Configuration for VM creation

struct VMTemplate

Definition

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>,
}

Documentation

Template for creating new VMs

⚠️ **GitHub.com Fallback** ⚠️