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.

Ozone’s vmparser writer functions follow a read-merge-write pattern: each function reads the existing vms/<vmname>.json file, replaces only the target section with the new value, then serialises the full VM struct back to disk using json.MarshalIndent. This means calling VMParserWriterCPU to update CPU settings will never touch the disk, memory, or network sections of the same file.

Import

import "github.com/stratosphere-ve/ozone/vmparser"
Writer functions are safe to call in sequence. Because each one reads the current file before writing, successive calls accumulate changes — no section is silently reset by a later write.
The vms/ directory must exist before calling any writer function. The functions do not create the directory automatically. If it is absent, os.WriteFile will return an error and the write will fail.

Writing by resource

Update the vm identity section. The VM name is derived from info.Name, so the file path is vms/<info.Name>.json.
info := vmparser.VMInfo{
    Name:      "web-01",
    UUID:      "550e8400-e29b-41d4-a716-446655440000",
    CreatedAt: "2024-06-01T12:00:00Z",
}

if err := vmparser.VMParserWriterInfo(info); err != nil {
    log.Fatalf("failed to write VMInfo: %v", err)
}
Signature: VMParserWriterInfo(info VMInfo) errorNote that this writer takes a VMInfo value directly (not a vmname string) because the name is embedded in the struct.

Full working example

The following snippet provisions a new VM configuration from scratch by writing each resource section in sequence. Because each writer preserves unrelated fields, the order does not matter.
package main

import (
    "log"

    "github.com/stratosphere-ve/ozone/vmparser"
)

func main() {
    const vmname = "web-01"

    // 1. Write identity information
    if err := vmparser.VMParserWriterInfo(vmparser.VMInfo{
        Name:      vmname,
        UUID:      "550e8400-e29b-41d4-a716-446655440000",
        CreatedAt: "2024-06-01T12:00:00Z",
    }); err != nil {
        log.Fatalf("write VMInfo: %v", err)
    }

    // 2. Configure CPU
    if err := vmparser.VMParserWriterCPU(vmname, vmparser.CPU{
        Cores: 4,
        Type:  "host",
    }); err != nil {
        log.Fatalf("write CPU: %v", err)
    }

    // 3. Configure memory
    if err := vmparser.VMParserWriterMemory(vmname, vmparser.Memory{
        SizeMB: 2048,
    }); err != nil {
        log.Fatalf("write memory: %v", err)
    }

    // 4. Configure network
    if err := vmparser.VMParserWriterNetwork(vmname, vmparser.Network{
        Interface: "virbr0",
        Type:      "virtio",
        MAC:       "52:54:00:ab:cd:ef",
    }); err != nil {
        log.Fatalf("write network: %v", err)
    }

    // 5. Configure disk
    if err := vmparser.VMParserWriterDisk(vmname, vmparser.Disk{
        Name:   "web-01-disk",
        Path:   "/var/lib/ozone/images/web-01.qcow2",
        SizeGB: 20.0,
        Format: "qcow2",
    }); err != nil {
        log.Fatalf("write disk: %v", err)
    }

    log.Println("VM configuration written successfully.")
}

Build docs developers (and LLMs) love