Recipes & tips
Worked examples that combine the pieces from the previous pages, followed by a grab-bag of things worth knowing.
Recipes
Switch between environments safely
Set up a profile per instance once, then pin one for a whole terminal session so you can't fire a command at the wrong place:
1 2 3 4 5 6 7 | |
Build a report from a shell loop
--format tsv is made for while read loops — no jq, no header to skip:
1 2 3 | |
For anything structured, --format json piped to jq — or --jmespath to skip jq
entirely:
1 2 3 | |
Provision a VPC end-to-end
A complete, CLI-only lifecycle for an OpenStack tenant (VPC):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
Instances need a few things a VPC doesn't
An instance order references a flavor, an image, and a subnet, which live inside a
tenant. The CLI can provision the instance and list/get the tenant's networks, subnets,
and security groups — but it doesn't expose flavor/image browsing or network creation,
so those URLs come from the API or the Waldur UI. Provision a tenant without the
skip_creation_of_default_* attributes to get a default network + subnet you can point an
instance at.
Feed live inventory to an LLM
Minimise tokens: fetch only the fields that matter, and render as TOON.
1 2 3 | |
Tips & tricks
-
--generate-skeletonis the fastest way to learn a request body. Before writing anycreate/update/provisionJSON, generate the skeleton — it lists every writable field with a typed placeholder, straight from the live schema. -
Filter on the server, shape on the client.
--filtercuts bytes over the wire;--jmespathrestructures what's left. Reach for--filterfirst (it's cheaper), then--jmespathfor the exact shape. -
--fieldsspeeds up big lists. For a resource with large objects,--fields uuid,namecan dramatically cut transfer time — the server sends only what you ask for. -
--format ndjsonfor big lists. It streams -- printing each page as it arrives -- so a largeliststarts producing output immediately instead of going quiet until every page is fetched. Pipes straight intojq -c, a shellwhile readloop, or an agent processing results incrementally. -
--filter query=<text>is full-text search. On resources that support it (customers, projects, users, …), thequeryfilter searches across fields, unlike the exact-match field filters. -
schemaemits an OpenAPI-for-the-CLI. If you're building an LLM agent that driveswaldur-cli, parsing--helptext is fragile.waldur-cli schemaoutputs a complete JSON description of the command surface — paths, parameters, typed filter keys, and request skeletons — that frameworks can directly ingest as a tool specification. Use--compactif you have a tight context budget and only need paths and descriptions. -
whoamibefore anything destructive. One command confirms which instance and identity your credentials currently resolve to — cheap insurance before adelete/terminate. -
--dry-runbefore a mutation you're unsure of. It validates and prints the exact request (with any defaults filled in) without sending it — see Managing resources. Great for building up acreate/provisionbody iteratively, or confirming a scripteddeletetargets what you think it does. -
--debugshows the actual requests. One line per HTTP call (method, URL, status, timing) on stderr, regardless of--format— invaluable for understanding what a command does or diagnosing a server-side rejection. See Troubleshooting. -
stdout is always clean. Errors and
--debuggo to stderr; stdout only ever carries successful output. So... 2>/dev/nullor... > out.jsonalways gives you exactly the result, and a failed command never pollutes a pipe with half a result. -
Install shell completions. Tab-completion for groups, resources, verbs, and flags makes the three-level command tree far quicker to navigate — see Troubleshooting.
-
Update easily. Run
waldur-cli updateto seamlessly download and install the latest release from GitHub, avoiding manual un-tarring or re-running installer scripts. -
--no-waitfor fire-and-forget provisioning. Submitting many orders?--no-waitreturns each order immediately;marketplace order wait <uuid> --jmespath "state=='done'"(or any resource's ownwait) picks up the polling later, from the same script or a different one entirely -- see Waiting on anything, not just orders.