# virtualboxws cheatsheet
Every export of @skiffyard/virtualboxws. Guides are listed in the introduction .
jennifer import "@skiffyard/virtualboxws/" as virtualboxws;
Every failure is a VirtualboxwsError (kind "virtualboxws"), except a reply over maxBytes (kind "limit"), a cancelled task (kind "cancelled") and a service that cannot be reached (a net.NetError, kind "net"). A c argument is a Config, an s a Session, a vm a machine's name or UUID.
# Constants
Constant Value Meaning DEFAULT_URL"http://localhost:18083/"the web service on this machine, with its defaults DEFAULT_TIMEOUT_MS60000how long an ordinary request may take DEFAULT_LONG_TIMEOUT_MS3600000how long a start, power-off, snapshot, clone, import or export may take DEFAULT_MAX_BYTES1048576the largest reply read; a full reply takes about 40 MiB to parse MIN_MAJOR7the oldest VirtualBox™ major version logon accepts
# Connecting
Function Returns Does virtualboxws.endpoint(url)Configthe service at a URL; plain http only to this machine virtualboxws.withTls(c, tls)Configcertificate options (caCert, skipVerify) for https virtualboxws.withPlainHttp(c)Configallow plain http to another machine (the password in clear) virtualboxws.withTimeout(c, ms)Configthe deadline of an ordinary request, 1000 to 86400000 ms virtualboxws.withLongTimeout(c, ms)Configthe deadline of the long operations virtualboxws.withMaxBytes(c, most)Configthe largest reply, 65536 to 67108864 bytes virtualboxws.logon(c, username, password)Sessionlog on; refuse VirtualBox older than 7 virtualboxws.logoff(s)nullend the session; the service frees everything it held virtualboxws.call(s, method, args)map of string to list of stringany other web-service method virtualboxws.releaseRef(s, ref)nullrelease a reference call returned virtualboxws.errorCode(e)stringa VirtualboxwsError's code: VBOX_E_* / E_* / 0x... / INVALID_OBJECT (read $e.code directly)
# Machines and power
Function Returns Does virtualboxws.vms(s)list of Vmevery registered machine virtualboxws.runningVms(s)list of Vmthe running ones (running, paused, starting, ...) virtualboxws.hasVm(s, vm)boolwhether a machine is registered virtualboxws.info(s, vm)VmInfostate, type, memory, processors, snapshots virtualboxws.state(s, vm)stringpoweroff, running, paused, saved, ... as VBoxManage™ names themvirtualboxws.start(s, vm)nullstart without a window and wait virtualboxws.startWith(s, vm, mode)nullstart headless, gui or separate virtualboxws.powerOff(s, vm)nullpull the plug and wait virtualboxws.acpiShutdown(s, vm)nullpress the power button virtualboxws.pause(s, vm)nullpause virtualboxws.resume(s, vm)nullresume virtualboxws.reset(s, vm)nullpress reset virtualboxws.saveState(s, vm)nullsave the state to disk, stop, and wait
# Snapshots, clones, appliances
Function Returns Does virtualboxws.snapshots(s, vm)list of Snapshotthe snapshot tree, parents first virtualboxws.takeSnapshot(s, vm, name, description)stringtake one and wait; its UUID virtualboxws.restoreSnapshot(s, vm, name)nullgo back to one (machine off) virtualboxws.deleteSnapshot(s, vm, name)nulldelete one virtualboxws.clone(s, vm, newName)stringa full, registered copy; its UUID virtualboxws.linkedClone(s, vm, snapshot, newName)stringa copy on difference disks from a snapshot; its UUID virtualboxws.importOva(s, path)list of stringimport an .ova / .ovf on the host; the machines' UUIDs virtualboxws.importAs(s, path, name)list of stringthe same, naming the first machine virtualboxws.exportOva(s, vm, path)nullexport to an .ova / .ovf on the host
# The guest
Function Returns Does virtualboxws.guestProperty(s, vm, key)stringa guest property, "" when unset virtualboxws.setGuestProperty(s, vm, key, value)nullset one virtualboxws.unsetGuestProperty(s, vm, key)nullremove one virtualboxws.guestIp(s, vm, nic)stringthe IPv4 address of guest interface nic (from 0), "" if none yet virtualboxws.waitForIp(s, vm, nic, timeoutMs)stringwait for that address
# Types
# Config
Field Meaning url as stringthe service's URL tls as http.TlsOptionscertificate checks for https allowPlainHttp as boolplain http to another machine allowed timeoutMs as intthe deadline of an ordinary request longTimeoutMs as intthe deadline of the long operations maxBytes as intthe largest reply read
# Session
Field Meaning config as Confighow the service is reached vbox as stringthe session's IVirtualBox reference version as stringVirtualBox's version, such as 7.1.4 major as intits major version minor as intits minor version
Field Meaning name as stringthe machine's name, <inaccessible> if VirtualBox cannot read it uuid as stringits UUID
# VmInfo
Field Meaning name as stringthe machine's name uuid as stringits UUID osType as stringits guest OS type id state as stringpoweroff, running, ...memoryMb as intmemory in MiB cpus as intprocessors description as stringits description configFile as stringits .vbox file on the host sessionState as stringUnlocked, Locked, Spawning, UnlockingcurrentSnapshot as stringthe current snapshot's name snapshotCount as inthow many snapshots it has
# Snapshot
Field Meaning name as stringits name uuid as stringits UUID description as stringits description depth as int0 for a first snapshot, 1 below it, ... current as boolthe machine runs from it
# VirtualboxwsError
Every error of kind "virtualboxws".
Field Meaning kind as stringalways "virtualboxws" message as stringvirtualboxws: and what went wrongreason as string"fault", "http", "timeout", "unreachable" (no complete reply), "reply" (not the expected SOAP), "operation" (a long operation failed), "" otherwisecode as stringthe fault's or operation's code: VBOX_E_* / E_* / 0x... / INVALID_OBJECT, "" if none status as intthe reply's HTTP status, 0 if there was none