pub struct Libvirt {
pub hypervisor_host: String,
pub hypervisor_user: String,
pub hypervisor_key: Option<String>,
pub vcpus: u32,
pub memory_mib: u32,
pub disk_gib: u32,
pub image_url: String,
pub network: NetworkMode,
pub storage_dir: String,
pub vm_ssh_key: String,
pub os_variant: String,
}Expand description
Libvirt/KVM provisioner for local or remote hypervisors.
Manages virtual machines via virsh and virt-install over
SSH. Cloud images are provisioned with cloud-init (NoCloud
datasource).
Fields§
§hypervisor_host: StringSSH hostname or IP of the hypervisor.
hypervisor_user: StringSSH user on the hypervisor (default: root).
hypervisor_key: Option<String>Optional SSH private key for the hypervisor connection.
vcpus: u32Number of vCPUs (default: 2).
memory_mib: u32RAM in MiB (default: 2048).
disk_gib: u32Disk size in GiB (default: 20).
image_url: StringCloud image URL to download on the hypervisor.
network: NetworkModeNetwork mode (default: NAT).
storage_dir: StringDirectory on the hypervisor for VM disk images.
vm_ssh_key: StringLocal SSH private key whose .pub sibling is injected
via cloud-init. Used to SSH into the VM after creation.
os_variant: Stringos-variant passed to virt-install.
Implementations§
Source§impl Libvirt
impl Libvirt
Sourcepub fn new(hypervisor_host: &str, vm_ssh_key: &str) -> Self
pub fn new(hypervisor_host: &str, vm_ssh_key: &str) -> Self
Create a new Libvirt provisioner.
§Arguments
hypervisor_host- SSH-reachable hostname of the KVM hostvm_ssh_key- path to the local SSH private key; the matching.pubfile is read and injected into the VM via cloud-init
pub fn hypervisor_user(self, user: &str) -> Self
pub fn hypervisor_key(self, key: &str) -> Self
pub const fn vcpus(self, n: u32) -> Self
pub const fn memory_mib(self, mib: u32) -> Self
pub const fn disk_gib(self, gib: u32) -> Self
pub fn image_url(self, url: &str) -> Self
pub fn network(self, mode: NetworkMode) -> Self
pub fn storage_dir(self, dir: &str) -> Self
pub fn os_variant(self, variant: &str) -> Self
Trait Implementations§
Source§impl Provisioner for Libvirt
impl Provisioner for Libvirt
Source§fn check_prerequisites(&self) -> DeployResult<()>
fn check_prerequisites(&self) -> DeployResult<()>
Check that all prerequisites are installed and
authenticated.
Source§fn detect_ssh_keys(&self) -> DeployResult<Vec<(String, String)>>
fn detect_ssh_keys(&self) -> DeployResult<Vec<(String, String)>>
Detect SSH keys to use for provisioning. Read more
Source§fn create_server(
&self,
name: &str,
_region: &str,
_ssh_key_ids: &[String],
) -> DeployResult<ServerInfo>
fn create_server( &self, name: &str, _region: &str, _ssh_key_ids: &[String], ) -> DeployResult<ServerInfo>
Create a new server and return its info.
Source§fn setup_server(
&self,
server: &ServerInfo,
domain: Option<&str>,
) -> DeployResult<()>
fn setup_server( &self, server: &ServerInfo, domain: Option<&str>, ) -> DeployResult<()>
Install Docker, configure firewall, start Caddy
placeholder.
Source§fn get_server(&self, name: &str) -> DeployResult<Option<ServerInfo>>
fn get_server(&self, name: &str) -> DeployResult<Option<ServerInfo>>
Get an existing server by name.
Source§fn destroy_server(&self, name: &str) -> DeployResult<()>
fn destroy_server(&self, name: &str) -> DeployResult<()>
Destroy a server by name.
Auto Trait Implementations§
impl Freeze for Libvirt
impl RefUnwindSafe for Libvirt
impl Send for Libvirt
impl Sync for Libvirt
impl Unpin for Libvirt
impl UnwindSafe for Libvirt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more