44 lines
1.2 KiB
Plaintext
44 lines
1.2 KiB
Plaintext
// Clean VM Launch Script
|
|
// Creates a VM using builder pattern with concise output
|
|
|
|
let vm_id = "vm-clean-test";
|
|
|
|
// Phase 1: Host check
|
|
let hc = host_check();
|
|
if !(hc.ok == true) {
|
|
throw "Host check failed: missing dependencies";
|
|
}
|
|
|
|
// Phase 2: Create VM using fluent builder pattern
|
|
let vm_id_actual = "";
|
|
try {
|
|
vm_id_actual = cloudhv_builder(vm_id)
|
|
.disk_from_flavor("ubuntu")
|
|
.network_default_nat()
|
|
.memory_mb(4096)
|
|
.vcpus(2)
|
|
.launch();
|
|
} catch (e) {
|
|
throw "VM launch failed: " + e.to_string();
|
|
}
|
|
|
|
// Phase 3: Wait for VM to boot and get network configuration
|
|
wait_for_vm_boot(10);
|
|
|
|
// Phase 4: Discover VM IP addresses
|
|
let mac_addr = "a2:26:1e:ac:96:3a"; // This should be derived from vm_id_actual
|
|
let ipv4 = cloudhv_discover_ipv4_from_leases("/var/lib/misc/dnsmasq-hero-br-hero.leases", mac_addr, 30);
|
|
let ipv6 = cloudhv_discover_ipv6_on_bridge("br-hero", mac_addr);
|
|
|
|
// Phase 5: Display connection info
|
|
cloudhv_display_network_info(vm_id_actual, ipv4, ipv6);
|
|
|
|
/*
|
|
try {
|
|
cloudhv_vm_stop(vm_id_actual, false);
|
|
cloudhv_vm_delete(vm_id_actual, true);
|
|
print("VM stopped and cleaned up.");
|
|
} catch (e) {
|
|
print("Warning: cleanup failed: " + e.to_string());
|
|
}
|
|
*/ |