blob: fbb6ab51aaa0385ea5d306ba62168fd7c642a321 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
//! 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!("asking virtual machine {} to shutdown", spec.name);
libvirt.trigger_shutdown(&spec.name)?;
}
for spec in specs {
info!("deleting virtual machine {}", spec.name);
libvirt.shutdown(&spec.name)?;
libvirt.delete(&spec.name, &spec.image)?;
}
Ok(())
}
|