diff options
Diffstat (limited to 'src/cmd/new.rs')
-rw-r--r-- | src/cmd/new.rs | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/src/cmd/new.rs b/src/cmd/new.rs index 0a4b3ab..0f7bc94 100644 --- a/src/cmd/new.rs +++ b/src/cmd/new.rs @@ -21,30 +21,32 @@ pub enum NewError { VirtInstallError(#[from] VirtInstallError), } -pub fn new(spec: &Specification) -> Result<(), NewError> { - info!("creating new VM {}", spec.name); - - info!("creating cloud-init config"); - let init = CloudInitConfig::from(&spec)?; - - info!( - "creating VM image {} from {}", - spec.image.display(), - spec.base.display() - ); - let image = VirtualMachineImage::new_from_base(&spec.base, &spec.image)?; - - info!("resizing image to {} GiB", spec.image_size_gib); - image.resize(spec.image_size_gib * GIB)?; - - info!("creating VM"); - let mut args = VirtInstallArgs::new(&spec.name, &image, &init); - args.set_memory(spec.memory_mib); - args.set_vcpus(spec.cpus); - virt_install(&args)?; - - info!("waiting for {} to open its SSH port", spec.name); - wait_for_port(&spec.name, SSH_PORT)?; +pub fn new(specs: &[Specification]) -> Result<(), NewError> { + for spec in specs { + info!("creating new VM {}", spec.name); + + info!("creating cloud-init config"); + let init = CloudInitConfig::from(&spec)?; + + info!( + "creating VM image {} from {}", + spec.image.display(), + spec.base.display() + ); + let image = VirtualMachineImage::new_from_base(&spec.base, &spec.image)?; + + info!("resizing image to {} GiB", spec.image_size_gib); + image.resize(spec.image_size_gib * GIB)?; + + info!("creating VM"); + let mut args = VirtInstallArgs::new(&spec.name, &image, &init); + args.set_memory(spec.memory_mib); + args.set_vcpus(spec.cpus); + virt_install(&args)?; + + info!("waiting for {} to open its SSH port", spec.name); + wait_for_port(&spec.name, SSH_PORT)?; + } Ok(()) } |