Skip to main content
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

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.
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.