summaryrefslogtreecommitdiff
path: root/src/cmd/delete.rs
blob: 66eb23f66031d20e41f7e750920d7bb10bae2be5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! The `delete` sub-command.

use crate::libvirt::{Libvirt, VirtError};
use crate::spec::Specification;
use log::info;

/// Delete VMs corresponding to specifications.
///
/// Delete the VM corresponding to each specification provided by the caller.
pub fn delete(specs: &[Specification]) -> Result<(), VirtError> {
    let libvirt = Libvirt::connect("qemu:///system")?;
    for spec in specs {
        info!("deleting virtual machine {}", spec.name);
        libvirt.delete(&spec.name, &spec.image)?;
    }
    Ok(())
}