Skip to content
@deckyard/proxmox

proxmox cheatsheet

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

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

Every function that sends a request throws Error{kind: "proxmox"} when it fails. A guest argument is a Guest from proxmox.guests or proxmox.guest; an upid is the string an action returned.

Constants

ConstantValueMeaning
ERROR_KIND"proxmox"the kind of every error the deck throws
DEFAULT_PORT8006the port client adds to a bare host
MAX_POLL_FAILURES5failed checks in a row after which waitTask gives up
TICKET_LIFETIME7200seconds a ticket is valid

Types

Client

FieldMeaning
url as stringhttps://host:8006, no trailing slash
tokenId as stringAPI token id, user@realm!name; "" for none
secret as stringAPI token secret
ticket as stringticket from login; "" for none
csrf as stringCSRF prevention token that came with the ticket
tls as http.TlsOptionscertificate checking
timeoutMs as intidle timeout per request; 0 for the http default
retries as intretries of a GET answered 429 or 5xx
pollMs as intinterval of waitTask's status checks

Version

FieldMeaning
version as stringe.g. 8.2.4
release as stringe.g. 8.2
repoid as stringthe build's repository id

Node

FieldMeaning
node as stringnode name
status as stringonline, offline or unknown
cpu as floatCPU load, 0 to 1
maxcpu as intCPU count
mem as intmemory in use, bytes
maxmem as intmemory, bytes
uptime as intseconds

Guest

FieldMeaning
vmid as intguest id, unique in the cluster
name as stringguest name
node as stringthe node it lives on
kind as stringqemu or lxc
status as stringrunning, stopped, ...
template as boolwhether it is a template
cpu as floatCPU load, 0 to 1
maxcpu as intvirtual CPUs
mem as intmemory in use, bytes
maxmem as intmemory, bytes
disk as introot disk in use, bytes (containers only)
maxdisk as introot disk size, bytes
uptime as intseconds
tags as list of stringthe guest's tags

Snapshot

FieldMeaning
name as stringsnapshot name; current is the running state
description as stringits description
parent as stringthe snapshot before it; "" for the first
snaptime as intUnix time it was taken; 0 for current
vmstate as boolwhether it holds the RAM of a running VM

Storage

FieldMeaning
storage as stringstorage id
type as stringdir, lvmthin, zfspool, nfs, ...
content as list of stringimages, rootdir, iso, backup, ...
active as boolusable now
enabled as boolenabled
shared as boolevery node sees the same storage
total as intsize, bytes
used as intbytes in use
avail as intbytes free

Task

FieldMeaning
upid as stringthe task's id
node as stringnode it runs on
type as stringe.g. qmstart, vzdump
id as stringwhat it works on, often the guest id
user as stringwho started it
status as stringrunning or stopped; "" from parseUpid
exitStatus as stringOK or the error, once stopped

Interface

FieldMeaning
name as stringinterface name
mac as stringhardware address
addresses as list of stringaddresses with prefix, e.g. 10.0.0.5/24

Volume

FieldMeaning
volid as string<storage>:<path>
content as stringimages, rootdir, iso, vztmpl, backup
format as stringraw, qcow2, iso, vma.zst, ...
size as intbytes
ctime as intUnix time it was created
vmid as intits guest; 0 for none
notes as stringa backup's notes

Appliance

FieldMeaning
template as stringfile name, for downloadAppliance
section as stringsystem, turnkeylinux, mail
os as stringe.g. debian-12
version as stringtemplate version
headline as stringone-line description

CloudInit

FieldMeaning
user as stringuser to create
password as stringits password
sshKeys as list of stringpublic keys
ipConfig as list of stringper NIC: ip=dhcp, ip=10.0.0.5/24,gw=10.0.0.1
nameserver as stringDNS servers, space-separated
searchDomain as stringDNS search domain

Pool

FieldMeaning
poolid as stringpool id
comment as stringits comment

HaResource

FieldMeaning
sid as stringvm:<vmid> or ct:<vmid>
state as stringstarted, stopped, disabled, ignored
group as stringHA group; "" for none

FirewallRule

FieldMeaning
pos as intposition, 0 first
type as stringin, out, group
action as stringACCEPT, DROP, REJECT, or a security group
enable as boolactive
source as stringsource; "" for any
dest as stringdestination; "" for any
proto as stringtcp, udp, icmp, ...; "" for any
dport as stringdestination port or range
macro as stringpredefined service, e.g. SSH
comment as stringits comment

User

FieldMeaning
userid as stringuser@realm
enabled as boolmay log in
expire as intUnix time it expires; 0 for never
firstname as stringfirst name
lastname as stringlast name
email as stringe-mail address
comment as stringits comment

Acl

FieldMeaning
path as string/, /vms/101, /pool/lab, /storage/local, ...
type as stringuser, group or token
ugid as stringthe user, group or token
roleid as stringe.g. PVEVMUser
propagate as boolapplies below the path

Client

FunctionReturnsDoes
proxmox.client(address)Clienta client for host, host:port or a URL; a bare host gets https:// and port 8006
proxmox.withToken(c, tokenId, secret)Clientauthenticate with an API token
proxmox.withTicket(c, ticket, csrf)Clientuse a ticket kept from an earlier login
proxmox.withCaCert(c, pem)Clienttrust this PEM certificate too
proxmox.withInsecure(c)Clientaccept any certificate
proxmox.withTimeout(c, ms)Clientidle timeout per request
proxmox.withRetries(c, n)Clientretry a GET answered 429 or 5xx
proxmox.withPollInterval(c, ms)Clienthow often waitTask asks
proxmox.login(c, username, password)Clientget a ticket; throws for an account with a second factor
proxmox.loginTotp(c, username, password, code)Clientget a ticket with a TOTP code
proxmox.renew(c)Clienttrade the ticket for a fresh one
proxmox.fresh(c)Clientrenew a ticket older than an hour; anything else unchanged
proxmox.describe(c)stringthe client for a log line, without its secret

Any endpoint

path is under /api2/json; the result is the reply's data.

FunctionReturnsDoes
proxmox.call(c, method, path, params)json.Valueany method; params in the query (GET, DELETE) or as a form (POST, PUT)
proxmox.get(c, path, params)json.ValueGET
proxmox.post(c, path, params)json.ValuePOST
proxmox.put(c, path, params)json.ValuePUT
proxmox.delete(c, path, params)json.ValueDELETE

Cluster

FunctionReturnsDoes
proxmox.version(c)Versionthe API's version
proxmox.nodes(c)list of Nodethe nodes, by name
proxmox.storages(c, node)list of Storagethe storages a node sees, by id
proxmox.nextId(c)inta free guest id
proxmox.nodeStatus(c, node)json.ValueCPU, memory, disk, kernel, version, uptime
proxmox.nodeMetrics(c, node, timeframe)json.Valueload over hour, day, week, month or year
proxmox.recentTasks(c)list of Taskthe cluster's recent tasks

Pools, HA, firewall, access

FunctionReturnsDoes
proxmox.pools(c)list of Poolthe resource pools
proxmox.createPool(c, poolid, comment)nullcreate a pool
proxmox.addToPool(c, poolid, vmids)nulladd guests to it
proxmox.deletePool(c, poolid)nulldelete an empty pool
proxmox.haResources(c)list of HaResourceguests under HA
proxmox.enableHa(c, g, state)nullput a guest under HA
proxmox.disableHa(c, g)nulltake it out
proxmox.firewallRules(c, g)list of FirewallRulea guest's rules, in order
proxmox.addFirewallRule(c, g, rule)nulladd a rule at the top, enabled
proxmox.deleteFirewallRule(c, g, pos)nulldelete a rule
proxmox.users(c)list of Userthe accounts
proxmox.permissions(c)list of Aclthe access control list
proxmox.grant(c, acl)nullgrant a role on a path
proxmox.revoke(c, acl)nulltake it away

Guests

FunctionReturnsDoes
proxmox.guests(c)list of Guestevery VM and container, by id
proxmox.guest(c, vmid)Guestone guest; throws when there is none
proxmox.guestByName(c, name)Guestthe one guest with this name
proxmox.status(c, g)stringlive status: running, stopped, paused, ...
proxmox.start(c, g)stringstart; returns the UPID
proxmox.stop(c, g)stringstop at once
proxmox.shutdown(c, g, timeoutSec)stringshut down through the guest OS; 0 for the default timeout
proxmox.reboot(c, g)stringreboot through the guest OS
proxmox.suspend(c, g)stringpause a VM, freeze a container
proxmox.resume(c, g)stringresume
proxmox.config(c, g)json.Valuethe configuration
proxmox.setConfig(c, g, params)nullchange keys; {"delete": "a,b"} removes them
proxmox.clone(c, g, newid, name)stringfull clone
proxmox.linkedClone(c, g, newid, name)stringlinked clone of a template
proxmox.createVm(c, node, vmid, params)stringcreate a VM from Proxmox's configuration keys
proxmox.createContainer(c, node, vmid, params)stringcreate a container; params needs ostemplate
proxmox.destroy(c, g, purge)stringdelete a stopped guest and its disks
proxmox.toTemplate(c, g)stringturn a stopped guest into a template; "" for a container
proxmox.snapshots(c, g)list of Snapshotoldest first, current last
proxmox.snapshot(c, g, name, description)stringtake a snapshot
proxmox.rollback(c, g, name)stringroll back to a snapshot
proxmox.deleteSnapshot(c, g, name)stringdelete a snapshot
proxmox.interfaces(c, g)list of Interfacenetwork interfaces, through the guest agent for a VM
proxmox.ipAddresses(c, g)list of stringits addresses, without loopback and link-local
proxmox.migrate(c, g, target, online)stringmove to another node; live for a running VM
proxmox.resizeDisk(c, g, disk, size)stringgrow a disk: +10G or 64G; "" when done at once
proxmox.setCloudInit(c, g, ci)nullset a VM's cloud-init settings
proxmox.guestMetrics(c, g, timeframe)json.Valueload over hour, day, week, month or year

Backups and storage

FunctionReturnsDoes
proxmox.backup(c, g, storage, mode)stringvzdump in mode snapshot, suspend or stop
proxmox.backups(c, node, storage)list of Volumebackups on a storage, oldest first
proxmox.restore(c, node, vmid, volid, storage)stringrestore a backup; "" storage keeps the original
proxmox.contents(c, node, storage, content)list of Volumewhat a storage holds; "" for every kind
proxmox.deleteVolume(c, node, volid)stringdelete a backup, ISO, template or unused disk
proxmox.downloadUrl(c, node, storage, content, url, filename)stringfetch an iso or vztmpl from a URL
proxmox.appliances(c, node)list of Appliancecontainer templates on offer
proxmox.downloadAppliance(c, node, storage, template)stringfetch one

Tasks

FunctionReturnsDoes
proxmox.parseUpid(upid)Taskwhat the UPID says, without a request
proxmox.taskStatus(c, upid)Taskwhere the task stands
proxmox.waitTask(c, upid, timeoutMs)Taskwait until it stops; 0 waits for ever
proxmox.taskLog(c, upid)list of stringits log lines