Skip to content
@deckyard/virtualboxws

virtualboxws cheatsheet

Every export of @deckyard/virtualboxws. Guides are listed in the introduction.

jennifer
import "@deckyard/virtualboxws/" as virtualboxws;

Every failure is Error{kind: "virtualboxws"}. A c argument is a Config, an s a Session, a vm a machine's name or UUID.

Constants

ConstantValueMeaning
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

FunctionReturnsDoes
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)stringthe VBOX_E_* / E_* / 0x... / INVALID_OBJECT code of a caught error

Machines and power

FunctionReturnsDoes
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 them
virtualboxws.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

FunctionReturnsDoes
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

FunctionReturnsDoes
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

FieldMeaning
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

FieldMeaning
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

Vm

FieldMeaning
name as stringthe machine's name, <inaccessible> if VirtualBox cannot read it
uuid as stringits UUID

VmInfo

FieldMeaning
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, Unlocking
currentSnapshot as stringthe current snapshot's name
snapshotCount as inthow many snapshots it has

Snapshot

FieldMeaning
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