5. Global Options
This chapter covers the following topics.
5.1 Persistent Flags
These flags are available on every PanCTL command:
| Flag | Purpose |
|---|---|
--profile <name> |
Use a specific profile for this command only |
--format, -o <format> |
Set the output format (see below) |
--no-color |
Disable colored table output (the NO_COLOR environment variable is honored too) |
--no-header |
Drop the column header row from plain and table list output, for piping into awk or cut. get output keeps its KEY: labels; json, raw, and jsonpath never had a header. |
--no-pager |
Never page output. By default, long output on a terminal goes through a pager. |
--request-timeout <n> |
How long one API request may take before it is abandoned: seconds, or a duration such as 30s. The default is 30 seconds; -1 removes the limit. |
--token <value> |
Use a pre-issued API token for this command |
--token-stdin |
Read a pre-issued API token from standard input |
--as-tenant-admin <tenant> |
Run this command inside another tenant (platform administrators only; see below) |
--yes, -y |
Proceed through the confirmation that destructive commands ask for, without prompting |
--version, -V |
Print the version and exit |
Acting in another tenant. --as-tenant-admin <tenant> (a tenant UUID or name) is the PanCTL form of the tenant switcher. It makes one command run inside that tenant, which is how a platform administrator creates or deletes a tenant’s volumes. PanCTL exchanges your token for a short-lived one scoped to the tenant (30 minutes to 12 hours), once per command, and saves nothing to your profile. Only a platform-admin can use it (it requires the tenants:switch permission), and it cannot be combined with --tenant. The flag is global and works on any command except auth login, which refuses it. It assumes that tenant’s platform-support role, not its admin role. Commands that name the tenant in the path, such as subnets create, subnets mount-info, and attachments, take --tenant instead, and switching tenants does not help there. What the switched identity may do is set by the tenant’s own policy, so check with panctl auth whoami --as-tenant-admin <tenant> before you rely on it for a write.
5.2 Environment Variables
The following table lists each environment variable and its effect.
| Variable | Effect |
|---|---|
PANCTL_PROFILE |
Selects the active profile for one invocation without changing the saved default |
PANCTL_API_SERVER |
Appliance address (used as a fallback in login mode, required in token mode) |
PANCTL_USERNAME |
Default username for auth login |
PANCTL_PASSWORD |
Default password for auth login (prefer --password-stdin; environment variables can leak via process listings) |
PANCTL_API_TOKEN |
Pre-issued token for the whole session (requires PANCTL_API_SERVER) |
PANCTL_API_INSECURE |
Set to 1/true/yes/on to skip TLS verification. auth login persists the effective value to the profile; this variable is the only way to set it in token mode. |
PANCTL_CONFIG_DIR |
The directory that holds profiles.toml and the OpenAPI cache. The default is ~/.panctl. A relocated directory starts empty, which is how two shells can drive two realms with no shared state. |
PANCTL_REQUEST_TIMEOUT |
Default for --request-timeout (30 seconds; -1 removes the limit) |
PANCTL_PAGER, PAGER |
The pager for terminal output, checked in that order, then less -FRX. An empty value for either disables paging. |
PANCTL_NO_PAGER |
Set to any non-empty value to never page output |
NO_COLOR |
Suppresses ANSI styling. An unset or dumb TERM does the same. |
PANCTL_WAIT_TIMEOUT |
Default for --wait-timeout (30 minutes); see 5.9 |
PANCTL_WAIT_CHECK_INTERVAL |
Default for --wait-check-interval (5 seconds); see 5.9 |
PANCTL_PROMPT |
The prompt format of an interactive session, with the fields {profile}, {username}, {server}, and {marker}; see 2.3 |
5.3 Output Formats
Use --format (or the shorter -o) to control how results are printed:
| Format | Description |
|---|---|
table |
Aligned, bolded-header columns. Default when output goes to a terminal. |
plain |
Aligned columns without color. Default when output is piped or redirected. |
raw |
The API’s response body, unmodified. |
json |
The response body, pretty-printed with 2-space indentation. |
jsonpath=<expression> |
Extracts specific fields using kubectl-style JSONPath, ideal for scripting. |
Control characters are escaped. The table and plain formats, and the key and value layout of get, never print a control character that came from the API. A value such as a username, display name, description, or volume path can contain one, and a terminal would obey it instead of showing it. PanCTL prints a short escape instead:
| Characters | Printed as |
|---|---|
| Bell, backspace, form feed, newline, carriage return, tab, vertical tab | \a, \b, \f, \n, \r, \t, \v |
Other characters from U+0000 to U+001F, and DEL |
\xNN in lowercase hex, for example \x1b for ESC |
Characters from U+0080 to U+009F |
\u00NN in lowercase hex, for example \u009b |
The escaping cannot be reversed because a backslash in the data is printed as it is. To read a value exactly as stored, use raw, json, or jsonpath, which are not escaped.
JSONPath examples:
panctl volumes list --format 'jsonpath={.volumes[*].pathname}'
panctl volumes list --format \
'jsonpath={range .volumes[*]}{.id}{"\t"}{.pathname}{"\n"}{end}'
panctl nodes list --format \
'jsonpath={.nodes[?(@.role=="vosd" || @.role=="vhost" && @.storageset_id==0)].dataserial}'Supported JSONPath features include field access, bracket-quoted keys (for hyphenated names, e.g. {.['storage-admin']}), array indices including [-1], wildcards, filter expressions (==, !=, <, <=, >, >=, joined with &&/||), and {range ...}{end} loops. It does not support recursive descent (..) or listing an object’s keys; for that, pipe --format json into jq 'keys'.
5.4 Command Aliases
Most command groups have one or more short aliases (spelled out exactly, no partial-name matching):
| Group | Aliases |
|---|---|
auth |
au, a |
profiles |
profile, pr, p |
realm |
rlm |
roles |
role, ro, r |
volumes |
volume, vol, v |
nodes |
node, no, n |
storagesets |
storageset, ss, s |
tenants |
tenant, tn, tx, t |
users |
user, us, u |
service-accounts |
sa |
fs-users |
fs-user, fsu |
log-collections |
log-collection, lc |
s3 |
(none) |
events |
ev, e |
alerts |
al |
subnets |
subnet, sub, sn |
audit |
aud, ad |
5.5 Exit Codes
The following table lists each exit code and its meaning.
| Code | Meaning |
|---|---|
0 |
Success, including a JSONPath expression that matched nothing |
1 |
Operational failure: the command was written correctly and the operation failed. Examples are an API refusal at any status, a missing object, a transport error, an expired session, and a declined confirmation. |
2 |
Usage error, and nothing was sent. Examples are an unknown command or flag, a wrong flag type, an out-of-range value, a missing required flag or argument, an unknown --format, a malformed JSONPath expression, and a missing --yes when there is no terminal. |
3 |
A pre-issued API token was rejected |
Every exit 2 also means nothing was sent, so a script can tell its own bug from a condition it is meant to handle. For example, panctl volumes get "$ID" || handle_missing_volume takes the handle_missing_volume branch only when the volume is genuinely absent, and a mistyped flag gives 2.
Breaking change: seven kinds of input error used to exit
1alongside API refusals. A script that branches on1for those now gets2. This changed under SWIFT-1793.
5.6 Naming Items
The argument of an item command takes either a name or an ID, so panctl volumes get /vol1 and panctl volumes get 3 both work, as do panctl tenants get acme and panctl storagesets get "Demo Set". A value that is already in the ID form is used as it stands, and anything else costs one lookup. An unknown name fails before the request is sent, so a typo never reaches the appliance as part of a path.
| Resource | The argument accepts | Matched against |
|---|---|---|
tenants |
Short name or UUID | name |
storagesets |
Name or integer ID | name |
volumes |
Path or integer ID | pathname |
subnets |
Name or UUID | name |
users |
Username or UUID | username |
service-accounts |
Name or UUID | name |
nodes |
Dataserial only | No name is accepted |
log-collections |
Collection ID only | No name is accepted |
fs-users, auth tokens |
Id only | No name is accepted |
A human label is never matched; the display_name of a tenant or a service account resolves nothing. On service-accounts, the --service-account flag resolves a name too, but on users the --user flag does not, so panctl users get alice works while panctl users get-roles --user alice does not.
Wherever a command takes --tenant, it accepts the tenant’s UUID or its short name. On the users commands, omitting it takes the tenant from the prefix of your profile’s username.
5.7 Request Bodies
Create and update commands that accept field flags take those flags, a JSON document with -f <file|->, or both. When both are given, the flags override the matching fields of the document. With no field flags, the bytes of -f are sent unchanged; with at least one, the document is parsed, the flags are layered over it, and the result is re-serialized, so key order and formatting are not kept. A field whose flag you did not give is left out of the request, never sent as null.
Before sending a body, PanCTL checks it against the cached OpenAPI document where it can (see 1.2), so a missing required field or a value of the wrong type is reported with no request made. The same document feeds --help; each command’s help ends with the operation’s summary and an example request body.
5.8 Narrowing a List (--filter)
Every list command takes --filter, which keeps only the matching rows and renders them normally, columns and headers included. It does not change the request, so it narrows what you see and not what is fetched. get commands have no --filter.
panctl nodes list --filter '.role==vosd && .state!=online'
panctl audit list --filter '.action==/create|delete/'
panctl log-collections list --filter '.status==failed'A filter is a path on the left, one of ==, !=, <, <=, >, >= on the right, and terms joined by && and ||. Terms are folded left to right with no precedence and no grouping, so a && b || c means (a && b) || c. A leading @ is optional, and a field that a row lacks makes its term false instead of failing.
The right-hand side can be a bare word (ready), a quoted string ("with spaces"), a number (42, 3.5), true, false, null, or a regular expression between slashes. A regular expression accepts only == and !=. A path with no operator is an existence test, so --filter '.reason' keeps the rows that have a reason at all. Because of that, a single = is refused with a message listing the valid operators; otherwise .action=delete would be read as an existence test on a field with that odd name, match nothing, and exit 0.
A value written between slashes is a regular expression, and it must match the whole value. This matters because states nest inside each other (online inside going_online, delete inside finalize-delete, offline inside going_offline), so an unanchored pattern would answer the opposite question. For a substring, write it out, as in /.*offline/. A regular expression tests strings only, so a number, boolean, or null never matches one.
A malformed expression, an invalid regular expression, or an unsupported operator is refused before any request is made, with exit 2. --filter works with every output format. With a filter, json and raw output come back with their keys in alphabetical order; without one, raw is still the API’s bytes exactly.
On audit list and events list, the appliance applies its window of recent records first, so --limit 5 --filter '.action==delete' finds the deletes among the five most recent records and not the five most recent deletes. PanCTL warns about this. Pair the filter with --only, --skip, --since, and --until, which narrow the records on the appliance before the window is applied.
There is no --sort. To sort or reshape results, pipe --format json into a tool such as jq.
5.9 Waiting for a Condition (--wait-for)
Provisioning is asynchronous. A StorageSet takes a while to finish joining, a tenant is not usable until its subnet has been issued an address, and a deletion completes some time after the request returns. Every list and get command takes --wait-for, which re-issues the read until a condition holds, so a script does not need a polling loop of its own.
The selector selects, and the condition compares. -o jsonpath= picks a value out of the response, and --wait-for compares that one value. Everything structural, such as fields, indexes, filters, &&, and ||, belongs in the selector. In a condition, it stands for what the selector matched. It is not a path, so it.name and it[0] are errors.
panctl tenants get finch -o jsonpath='{.tenant.status}' --wait-for=active
panctl volumes list -o jsonpath='{.volumes[?(@.pathname == "/v1")].id}' --wait-for='it != null'
panctl volumes list -o jsonpath='{.volumes[?(@.pathname == "/v1")].id}' --wait-for=null # waits for a deletion
panctl storagesets get 1 -o jsonpath='{.storageset.nodes_total}' --wait-for='it >= 6' --wait-timeout=60m
panctl nodes get-drain 1cc2673e772f58 -o jsonpath='{.state}' \
--wait-for=not_draining --wait-timeout=4h --wait-check-interval=30s| Condition | Holds when | Short form |
|---|---|---|
it != null |
The selector matched anything | None |
it == null |
The selector matched nothing | --wait-for=null |
it == "active" |
The value is active |
--wait-for=active |
it != "active" |
The value is anything else | None |
it >= 6 |
A numeric comparison; <, <=, >, and >= all work |
None |
A bare word is a string, so it == active and it == "active" are the same condition. Quote a value that would otherwise read as a number or as null.
| Flag | Default | Meaning |
|---|---|---|
--wait-for |
None | The condition; the read is re-issued until it holds |
--wait-timeout |
30m |
0 checks once without waiting, and -1 waits without limit |
--wait-check-interval |
5s |
How often the read is re-issued |
A time is seconds when written bare and a duration when it carries a unit, so 3600, 3600s, and 1h are the same hour. PANCTL_WAIT_TIMEOUT and PANCTL_WAIT_CHECK_INTERVAL set defaults for the two flags, and a flag on the command line wins. A wait with --wait-timeout=0 turns the condition into an assertion about the state right now; it exits 0 if the condition holds and 1 if it does not.
What you see. Progress goes to standard error, so a captured result holds only the value. A condition that already holds on the first check prints just its result. A wait that has to sleep prints a line whenever the value changes and a heartbeat at most every 30 seconds with the time left. A timeout exits 1 and names the condition and the last value seen.
Things to know
- Quote the condition. An unquoted
>is a shell redirection, so--wait-for=>2creates a file named2and loses the comparison. PanCTL refuses an empty condition and says so. --wait-forneeds a selector (-o jsonpath=). Without one it is refused before any request is made.- Any condition other than
it == nullorit != nullcompares one value, so the selector must match exactly one. A selector that matches several is refused. - A failing request does not end the wait because an appliance that is still starting answers with errors, and the timeout is what bounds the wait. An error that will never clear, such as a rejected credential, therefore costs the whole timeout.
- Only
listandgetaccept the wait flags. A write has nothing to wait for, and re-issuing it could create a second resource. --as-tenant-admincosts a token exchange on every check, so raise--wait-check-intervalwhen you combine them.s3 instances get <iid> --wait-for-observed=<state>is the one command-specific form; it builds the selector for you.
5.10 Destructive Commands Ask First
These commands ask for confirmation before they act. The default answer is no, and the prompt names the target:
- Every
delete, for tenants, StorageSets, volumes, subnets, subnet attachments, users, service accounts, PanFS users, and log collections, pluss3 instances delete,s3 instances delete-all,s3 buckets delete,s3 buckets delete-policy, ands3 delete-config auth tokens revokeandservice-accounts tokens revokeusers set-rolesandservice-accounts set-rolesnodes rebootandnodes draintenants unassign-storagesets
nodes stop-drain does not ask. When no terminal is attached there is nobody to answer, so pass --yes (or -y). Without it, the command exits 2 having sent nothing.
5.11 Across Tenants
Two flags answer different questions, and they cannot be combined.
| Flag | The question it answers | Cost |
|---|---|---|
--tenant |
Whose records do I want to see? It filters a read and travels as a query parameter. | One request |
--as-tenant-admin |
Who is asking? It swaps your token for one scoped to that tenant, so a write lands there. | Two requests: a token exchange, then the command |
Volume writes (volumes create, update, and delete) have no tenant parameter, so there the identity has to change instead. Subnets are the exception to both; every scoped subnet route names its tenant in the path, so --tenant carries it on reads and writes alike, and --as-tenant-admin loses access instead of gaining it.
--all-tenants is the other end of the read axis. It widens volumes list, events list, alerts list, and audit list to every tenant, and giving it together with --tenant is a usage error. On volumes list, events list, and alerts list it renders a tenant column. --tenant and --all-tenants are the platform tenant’s; the API refuses any other caller that passes either, even one naming its own tenant.
# Read: filter, one request
panctl volumes list --tenant=acme
panctl volumes list --all-tenants
# Write: act as that tenant, two requests
panctl volumes create --as-tenant-admin=acme --name=/vol1 --storageset-id=1 --hard-quota=1GB
# Subnets: --tenant, not --as-tenant-admin
panctl subnets delete storage-net --tenant=acmeCombining --as-tenant-admin with --tenant fails with error: --as-tenant-admin and --tenant are mutually exclusive: one is the tenant you act as, the other filters what you read, exit 2, before any request is sent. See 5.1 for what the delegated identity may do.
5.12 Output Streams and Paging
Only a command’s result reaches standard output, so a redirect captures data and nothing else. Prompts, progress lines, the login banner, and the session-renewal notice all go to standard error.
On a terminal, long output goes through a pager: $PANCTL_PAGER, else $PAGER, else less -FRX. Short output, pipes, redirects, and errors are never paged. --no-pager turns paging off for one command, and any non-empty PANCTL_NO_PAGER turns it off for a whole shell, which matters for scripts run from an interactive terminal.