Field Notes
Tips & Tricks
Field-tested practices, common gotchas, and expert shortcuts collected from real NetApp automation work.
01 ONTAP CLI Tips
CLI Tip
Use
-fields * to discover available fields
Not sure what fields a command supports? Run
volume show -fields ? to see all
available field names for that object. Then narrow your query with only the fields you need.
Efficiency
Use
set -privilege advanced to unlock more commands
Many diagnostic and low-level commands are hidden at the default privilege level. Use
set -privilege advanced to access them. Remember to return to
set -privilege admin when done to avoid accidental destructive changes.
Shortcut
Tab completion and
? work everywhere in ONTAP CLI
Press Tab to auto-complete command names, flags, and even values like volume names or
vserver names. Append
? to any partial command to see available options.
This alone saves significant time during operations.
Danger
Test destructive operations in ONTAP Simulator first
Before running scripts that delete snapshots, move volumes, or break SnapMirror relationships
in production, test them in ONTAP Select or the ONTAP Simulator. Many operations are
irreversible or require lengthy recovery if run incorrectly.
Filtering
Master wildcard patterns with
*, ?, and !* matches any characters (e.g., vol* matches volume, vol123).
? matches single character. ! negates (e.g., !root* excludes root).
Combine: vserver show -vserver !*root* lists all non-root vservers.
Advanced Filtering Examples
bash ยท ONTAP CLI filtering patterns
/* List all non-root vservers */
vserver show -vserver !*root*
/* List only root vservers */
vserver show -vserver *root*
/* Show volumes larger than 10GB */
volume show -size >10GB
/* Show volumes smaller than 5GB */
volume show -size <5GB
/* Show volumes between 5GB and 100GB */
volume show -size >=5GB -size <=100GB
/* List volumes matching pattern (vol_prod_*) */
volume show -vserver * -volume vol_prod_*
/* Show only online volumes */
volume show -state online
/* Show all aggregates NOT containing "ssd" in the name */
storage aggregate show -aggregate !*ssd*
/* List volumes with guarantee type of volume */
volume show -guarantee volume
/* Show snapshots created after specific date (YYYY-MM-DD) */
snapshot show -volume * -creation-time >2024-01-01
/* List all LIFs on specific node */
network interface show -node node-01* -role data
/* Show all SnapMirror relationships in idle state */
snapmirror show -status idle
/* List exports NOT matching admin share pattern */
vserver export-policy rule show -policyname * -clientmatch !*admin*
/* Count volumes by vserver (with fields) */
volume show -fields vserver,volume,size -vserver *
Combining Multiple Filters
bash ยท Complex filter chains
/* Find all data vservers with prod volumes larger than 50GB */
volume show -vserver *data* -volume *prod* -size >50GB -state online
/* List all SnapMirror destinations that are NOT idle */
snapmirror show -type DP -status !idle
/* Show non-root vservers NOT in administrative state */
vserver show -vserver !*root* -state !running
/* Find volumes on SSD aggregates larger than 100GB */
volume show -size >100GB -aggregate *ssd*
/* List snapshots older than 30 days (manual calculation) */
snapshot show -volume * -creation-time <2023-12-01
/* Find all NAS volumes with guarantee and online state */
volume show -type RW -guarantee volume -state online -vserver !*root*
/* Show failed or initializing SnapMirror relationships */
snapmirror show -status !healthy,!idle
02 REST API Tips
Best Practice
Always use
-fields to filter API responses
ONTAP REST API returns all fields by default, which can be massive. Specifying
?fields=name,size,state dramatically reduces payload size and response time.
This also reduces load on the cluster for bulk operations.
Heads Up
Handle pagination โ default limit is 1000 records
The ONTAP REST API caps records per response. Check for
_links.next.href in the
response body and loop until it's absent. Miss this and you silently get incomplete data in
large clusters.
Important
Poll async jobs โ don't assume POST = done
Many ONTAP REST operations (volume create, move, SnapMirror) return a job object instead of waiting.
Always check for
job.uuid in the response and poll /api/cluster/jobs/{uuid}
until state == "success" before proceeding.
Security
Never hardcode credentials in scripts
Use environment variables (
os.getenv() in Python, $env:VAR in PowerShell)
or a secrets manager like HashiCorp Vault or AWS Secrets Manager. Credentials committed to
Git are a significant security incident waiting to happen.
Migration
Migrate from ZAPI to REST โ ZAPI is deprecated
NetApp has deprecated ZAPI (ZAPIs). All new automation should use the ONTAP REST API.
ONTAP 9.12.1+ restricts ZAPI in some contexts. The
netapp-ontap Python library and PSTK both now default to REST. Use the
ONTAP API Explorer (https://<cluster>/docs/api) to explore endpoints.
02 Python-Specific Tips
Pattern
Use
get_collection(fields=...) not get_all()Volume.get_collection(fields="name,size") is lazy โ it pages automatically.
Avoid list(Volume.get_collection()) without filters on large clusters as it fetches
everything into memory.
Pattern
Use
hydrate=True after POST to get UUID back
When calling
.post(hydrate=True), the library automatically fetches the created
resource back so you have access to server-assigned fields like uuid and
create_time immediately after creation.
Gotcha
Size values are in bytes, not GB
All size fields in the ONTAP REST API and
netapp-ontap library use bytes.
Always convert: 10 * 1024 ** 3 for 10 GB. When printing, divide accordingly.
Forgetting this will create a 10-byte volume.
Tip
Use the ONTAP API Explorer for discovery
Browse to
https://<your-cluster>/docs/api for an interactive Swagger UI
of all available REST endpoints. You can try requests live and see the exact JSON structures
before coding.
03 PowerShell-Specific Tips
PSTK
Use
-Query to filter server-side, not client-side
Instead of
Get-NcVol | Where-Object {$_.State -eq 'online'}, use
Get-NcVol -Query @{State="online"}. The latter filters on the cluster,
reducing data transfer significantly on large environments.
PSTK
Store the controller object for multi-cluster scripts
$ctrl = Connect-NcController ... then pass -Controller $ctrl
to every cmdlet. This lets you manage multiple clusters in the same script without
accidentally running commands on the wrong cluster.
Reporting
Pipe to
Export-Csv for instant reportsGet-NcVol | Select Name,TotalSize,Used | Export-Csv report.csv -NoTypeInformation
is a fast way to produce capacity reports. Combine with ConvertTo-Html for
email-ready HTML reports.
05 Quick Environment Checklist
bash ยท pre-flight checklist
# Verify ONTAP REST API is reachable
curl -sk -u admin:password https://<cluster>/api/cluster | python3 -m json.tool
# Check ONTAP version (must be 9.6+ for REST)
curl -sk -u admin:password https://<cluster>/api/cluster?fields=version
# Verify Python library version
python3 -c "import netapp_ontap; print(netapp_ontap.__version__)"
# Verify PSTK version
(Get-Module NetApp.ONTAP).Version
# Check API Explorer (open in browser)
echo "Open: https://<cluster>/docs/api"