blob: 18a5c1912c5d2aaa571f4b60ee6988e9e5d92d71 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
use std::path::PathBuf;
use vmadm::cloudinit::CloudInitConfig;
use vmadm::image::VirtualMachineImage;
use vmadm::install::{virt_install, VirtInstallArgs};
const BASE_PATH: &'static str = "/home/liw/tmp/debian-10-openstack-amd64.qcow2";
const IMAGE_PATH: &'static str = "/home/liw/tmp/try-vm.qcow2";
fn main() -> anyhow::Result<()> {
let mut init = CloudInitConfig::default();
init.set_hostname("toy-vm");
init.set_authorized_keys("xxx liw-openpgp xxx");
println!("init: {:#?}", init);
let base = PathBuf::from(BASE_PATH);
let image = PathBuf::from(IMAGE_PATH);
let image = VirtualMachineImage::new_from_base(&base, &image)?;
image.resize(1024 * 1024 * 1024 * 10)?;
let args = VirtInstallArgs::new("toy-vm", &image, &init);
println!("{:#?}", args);
virt_install(&args)?;
println!("OK");
Ok(())
}
|