From 34af52c58daae7ad75c0871e88e7b937fcd078fb Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Tue, 12 Apr 2022 12:22:19 -0400 Subject: Initial commit --- src/vm.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/vm.rs (limited to 'src/vm.rs') diff --git a/src/vm.rs b/src/vm.rs new file mode 100644 index 0000000..8e17659 --- /dev/null +++ b/src/vm.rs @@ -0,0 +1,31 @@ +use std::convert::TryFrom; +use virt::{connect::Connect, domain::Domain;}; + +use crate::errors::Error; + + +/** + * Represents a virtual machine, that's active on some server + */ +pub struct VirtualMachine { + /// The assigned name of the VM + pub name: String, + /// The network address of the physical machine that's hosting this machine + pub host_server: String, + /// Whether or not the VM is active + pub is_active: bool, + /// The libvirtd-assigned UUID + pub uuid: String, + /// The network address of the VM + pub addr: Option, + /// How much RAM (in MB) is assigned to the VM + pub assigned_mem_mb: u64, + /// How many vCPUs are assigned to the VM + pub assigned_cpus: u64, +} + +impl TryFrom for VirtualMachine { + type Error = Error; + + fn try_from(d: Domain) -> Result { + -- cgit v1.2.3