Libvirt

Struct Libvirt 

Source
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: String

SSH hostname or IP of the hypervisor.

§hypervisor_user: String

SSH user on the hypervisor (default: root).

§hypervisor_key: Option<String>

Optional SSH private key for the hypervisor connection.

§vcpus: u32

Number of vCPUs (default: 2).

§memory_mib: u32

RAM in MiB (default: 2048).

§disk_gib: u32

Disk size in GiB (default: 20).

§image_url: String

Cloud image URL to download on the hypervisor.

§network: NetworkMode

Network mode (default: NAT).

§storage_dir: String

Directory on the hypervisor for VM disk images.

§vm_ssh_key: String

Local SSH private key whose .pub sibling is injected via cloud-init. Used to SSH into the VM after creation.

§os_variant: String

os-variant passed to virt-install.

Implementations§

Source§

impl Libvirt

Source

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 host
  • vm_ssh_key - path to the local SSH private key; the matching .pub file is read and injected into the VM via cloud-init
Source

pub fn hypervisor_user(self, user: &str) -> Self

Source

pub fn hypervisor_key(self, key: &str) -> Self

Source

pub const fn vcpus(self, n: u32) -> Self

Source

pub const fn memory_mib(self, mib: u32) -> Self

Source

pub const fn disk_gib(self, gib: u32) -> Self

Source

pub fn image_url(self, url: &str) -> Self

Source

pub fn network(self, mode: NetworkMode) -> Self

Source

pub fn storage_dir(self, dir: &str) -> Self

Source

pub fn os_variant(self, variant: &str) -> Self

Trait Implementations§

Source§

impl Provisioner for Libvirt

Source§

fn check_prerequisites(&self) -> DeployResult<()>

Check that all prerequisites are installed and authenticated.
Source§

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>

Create a new server and return its info.
Source§

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

Get an existing server by name.
Source§

fn destroy_server(&self, name: &str) -> DeployResult<()>

Destroy a server by name.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more