Skip to main content

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 is the configuration backbone of Ozone. It reads, deserializes, and writes JSON-based VM definition files stored under the vms/ directory, exposing a structured Go API for every field of a virtual machine’s configuration — from CPU topology and memory allocation through network identity and disk layout.
import "github.com/stratosphere-ve/ozone/vmparser"

Types

VM

VM is the top-level struct that represents a complete virtual machine configuration. It is the root object stored in each vms/<name>.json file and is returned by the full-parse functions.
VM
VMInfo
Identity and metadata for the virtual machine. Maps to the "vm" JSON key.
CPU
CPU
CPU topology configuration. Maps to the "cpu" JSON key.
Memory
Memory
Memory allocation configuration. Maps to the "memory" JSON key.
Network
Network
Network interface configuration. Maps to the "network" JSON key.
Disk
Disk
Primary disk configuration. Maps to the "disk" JSON key.

VMInfo

VMInfo holds the identifying metadata for a VM.
Name
string
Human-readable name of the virtual machine. Also used as the filename stem (vms/<Name>.json). Maps to the "name" JSON key.
UUID
string
Universally unique identifier for the VM. Maps to the "uuid" JSON key.
CreatedAt
string
ISO 8601 timestamp recording when the VM was created. Maps to the "created_at" JSON key.

CPU

CPU describes the processor configuration presented to the guest.
Cores
int
Number of virtual CPU cores allocated to the VM. Maps to the "cores" JSON key.
Type
string
CPU model string passed to QEMU (e.g. "host", "qemu64"). Maps to the "type" JSON key.

Memory

Memory describes the RAM allocation for the VM.
SizeMB
int
Amount of memory in mebibytes (MiB) allocated to the VM. Maps to the "size_mb" JSON key.

Network

Network describes the virtual network interface attached to the VM.
Interface
string
Host network interface name (e.g. "eth0", "virbr0") bridged to the VM. Maps to the "interface" JSON key.
Type
string
QEMU network device model (e.g. "virtio-net-pci", "e1000"). Maps to the "type" JSON key.
MAC
string
MAC address assigned to the VM’s network interface (e.g. "52:54:00:ab:cd:ef"). Maps to the "mac" JSON key.

Disk

Disk describes the primary block device attached to the VM.
Name
string
Logical name for the disk (e.g. "primary"). Maps to the "name" JSON key.
Path
string
Filesystem path to the disk image file (e.g. "images/myvm.qcow2"). Maps to the "path" JSON key.
SizeGB
float64
Provisioned size of the disk in gibibytes (GiB). Maps to the "size_gb" JSON key.
Format
string
Disk image format string (e.g. "qcow2", "raw"). Maps to the "format" JSON key.

Parser Functions

Parser functions each open vms/<vmname>.json, unmarshal the full VM document, and return only the requested section. They return a pointer to the relevant struct together with an error; the error is non-nil if the file cannot be read or the JSON is malformed.

VMParser

func VMParser(vmname string) (*VM, error)
Reads vms/<vmname>.json and deserializes the entire document into a VM struct. Returns a pointer to the populated struct, or an error if the file is missing or the JSON cannot be parsed. This is the primary entry point used by most other functions in the package.

VMParserVMInfo

func VMParserVMInfo(vmname string) (*VMInfo, error)
Reads the VM config file and returns only the VMInfo section (name, UUID, creation timestamp), leaving all other fields unpopulated in the caller’s scope.

VMParserCPU

func VMParserCPU(vmname string) (*CPU, error)
Reads the VM config file and returns only the CPU section (core count and CPU type string).

VMParserMemory

func VMParserMemory(vmname string) (*Memory, error)
Reads the VM config file and returns only the Memory section (size in MiB).

VMParserNetwork

func VMParserNetwork(vmname string) (*Network, error)
Reads the VM config file and returns only the Network section (interface name, device type, and MAC address).

VMParserDisk

func VMParserDisk(vmname string) (*Disk, error)
Reads the VM config file and returns only the Disk section (name, path, size, and format).

Getter Shortcuts

Getter functions are thin convenience wrappers around VMParser. Each calls VMParser internally, checks the error, and returns either the requested value or a zero value alongside the propagated error. Use these when you need a single scalar field without constructing the full VM struct yourself.

GetVM

func GetVM(vmname string) (*VM, error)
Returns the full VM struct for the named machine. Equivalent to calling VMParser directly.

GetCPU

func GetCPU(vmname string) (*CPU, error)
Returns a pointer to the CPU struct for the named VM.

GetCPUCores

func GetCPUCores(vmname string) (int, error)
Returns the integer core count configured for the named VM.

GetCPUType

func GetCPUType(vmname string) (string, error)
Returns the CPU model string configured for the named VM.

GetMemory

func GetMemory(vmname string) (*Memory, error)
Returns a pointer to the Memory struct for the named VM.

GetMemorySizeMB

func GetMemorySizeMB(vmname string) (int, error)
Returns the allocated memory in MiB for the named VM.

GetNetwork

func GetNetwork(vmname string) (*Network, error)
Returns a pointer to the Network struct for the named VM.

GetMAC

func GetMAC(vmname string) (string, error)
Returns the MAC address string configured for the named VM’s network interface.

GetInterface

func GetInterface(vmname string) (string, error)
Returns the host network interface name configured for the named VM.

GetDisk

func GetDisk(vmname string) (*Disk, error)
Returns a pointer to the Disk struct for the named VM.

GetDiskSizeGB

func GetDiskSizeGB(vmname string) (float64, error)
Returns the provisioned disk size in GiB for the named VM.

GetDiskPath

func GetDiskPath(vmname string) (string, error)
Returns the filesystem path to the disk image for the named VM.

GetVMInfo

func GetVMInfo(vmname string) (*VMInfo, error)
Returns a pointer to the VMInfo struct (name, UUID, creation timestamp) for the named VM.

GetVMName

func GetVMName(vmname string) (string, error)
Returns the human-readable name stored inside the VM’s config file. Useful for verifying the filename matches the declared name.

GetVMUUID

func GetVMUUID(vmname string) (string, error)
Returns the UUID string stored in the VM’s config file.

Writer Functions

Writer functions perform a read-modify-write cycle: they load the existing vms/<vmname>.json (if it exists), replace only the targeted section with the supplied value, re-serialize the full VM struct with two-space indentation, and write the result back to disk. All sections not explicitly targeted are preserved unchanged.

VMParserWriterInfo

func VMParserWriterInfo(info VMInfo) error
Merges the supplied VMInfo value into the existing config file for the VM identified by info.Name, then writes the updated document back to vms/<info.Name>.json. All other sections (CPU, Memory, Network, Disk) are left intact. Returns an error if marshaling or the write operation fails.

VMParserWriterCPU

func VMParserWriterCPU(vmname string, cpu CPU) error
Replaces the CPU section of vms/<vmname>.json with the provided CPU value. All other sections are preserved. Returns an error if marshaling or the write operation fails.

VMParserWriterMemory

func VMParserWriterMemory(vmname string, memory Memory) error
Replaces the Memory section of vms/<vmname>.json with the provided Memory value. All other sections are preserved. Returns an error if marshaling or the write operation fails.

VMParserWriterDisk

func VMParserWriterDisk(vmname string, disk Disk) error
Replaces the Disk section of vms/<vmname>.json with the provided Disk value. All other sections are preserved. Returns an error if marshaling or the write operation fails.

VMParserWriterNetwork

func VMParserWriterNetwork(vmname string, network Network) error
Replaces the Network section of vms/<vmname>.json with the provided Network value. All other sections are preserved. Returns an error if marshaling or the write operation fails.

Build docs developers (and LLMs) love