Documentation Index
Fetch the complete documentation index at: https://mintlify.com/stratosphere-ve/ozone/llms.txt
Use this file to discover all available pages before exploring further.
The vmparser package provides a suite of functions for reading VM configuration from vms/<vmname>.json. Every function accepts a VM name string, resolves the file path automatically, and returns a typed Go value. You can read the entire VM struct in one call, or use the targeted getter functions to retrieve a specific resource section or even a single field.
Import
import "github.com/stratosphere-ve/ozone/vmparser"
Error handling
Every read function returns an error as its second return value. Always check it — the error wraps the underlying os or encoding/json failure with context about which file was being read.
vm, err := vmparser.VMParser("web-01")
if err != nil {
log.Fatalf("failed to read VM config: %v", err)
}
Every read function opens and parses the full JSON file on each call. There is no in-memory cache. If you need multiple fields from the same VM in a tight loop, call VMParser or GetVM once and read from the returned struct directly.
Reading by resource
Full VM
VMInfo
CPU
Memory
Network
Disk
Use VMParser or its alias GetVM to load the entire VM configuration into a *VM struct.// Using VMParser
vm, err := vmparser.VMParser("web-01")
if err != nil {
return err
}
fmt.Println(vm.VM.Name) // "web-01"
fmt.Println(vm.CPU.Cores) // 4
fmt.Println(vm.Memory.SizeMB) // 2048
// Using the GetVM alias (identical behaviour)
vm, err = vmparser.GetVM("web-01")
if err != nil {
return err
}
Both functions return (*VM, error). GetVM is a thin wrapper that calls VMParser internally. Retrieve just the identity section of a VM using VMParserVMInfo or GetVMInfo. Individual field getters are also available.// Full VMInfo struct
info, err := vmparser.VMParserVMInfo("web-01")
if err != nil {
return err
}
fmt.Println(info.Name) // "web-01"
fmt.Println(info.UUID) // "550e8400-..."
fmt.Println(info.CreatedAt) // "2024-06-01T12:00:00Z"
// GetVMInfo alias
info, err = vmparser.GetVMInfo("web-01")
// Individual field getters
name, err := vmparser.GetVMName("web-01") // (string, error)
uuid, err := vmparser.GetVMUUID("web-01") // (string, error)
Retrieve the CPU section or individual CPU fields.// Full CPU struct
cpu, err := vmparser.VMParserCPU("web-01")
if err != nil {
return err
}
fmt.Println(cpu.Cores) // 4
fmt.Println(cpu.Type) // "host"
// GetCPU alias
cpu, err = vmparser.GetCPU("web-01") // (*CPU, error)
// Individual field getters
cores, err := vmparser.GetCPUCores("web-01") // (int, error)
cpuType, err := vmparser.GetCPUType("web-01") // (string, error)
Retrieve the memory section or the size field directly.// Full Memory struct
mem, err := vmparser.VMParserMemory("web-01")
if err != nil {
return err
}
fmt.Println(mem.SizeMB) // 2048
// GetMemory alias
mem, err = vmparser.GetMemory("web-01") // (*Memory, error)
// Individual field getter
sizeMB, err := vmparser.GetMemorySizeMB("web-01") // (int, error)
Retrieve the network section or individual network fields.// Full Network struct
net, err := vmparser.VMParserNetwork("web-01")
if err != nil {
return err
}
fmt.Println(net.Interface) // "eth0"
fmt.Println(net.Type) // "virtio"
fmt.Println(net.MAC) // "52:54:00:ab:cd:ef"
// GetNetwork alias
net, err = vmparser.GetNetwork("web-01") // (*Network, error)
// Individual field getters
mac, err := vmparser.GetMAC("web-01") // (string, error)
iface, err := vmparser.GetInterface("web-01") // (string, error)
Retrieve the disk section or individual disk fields.// Full Disk struct
disk, err := vmparser.VMParserDisk("web-01")
if err != nil {
return err
}
fmt.Println(disk.Name) // "web-01-disk"
fmt.Println(disk.Path) // "/var/lib/ozone/images/web-01.qcow2"
fmt.Println(disk.SizeGB) // 20.0
fmt.Println(disk.Format) // "qcow2"
// GetDisk alias
disk, err = vmparser.GetDisk("web-01") // (*Disk, error)
// Individual field getters
sizeGB, err := vmparser.GetDiskSizeGB("web-01") // (float64, error)
path, err := vmparser.GetDiskPath("web-01") // (string, error)