VAST Cluster User Quota Management

Prev Next

Overview

This wiki page provides a complete guide for managing user quotas on VAST clusters using two approaches:

  • The command-line tool: vastpy-cli.

  • Direct curl API requests.

Included are installation instructions, examples for listing and patching quotas, and reusable shell commands to automate operations.

Prerequisites

Before running the script, ensure that:

  • Python 3.6+ is installed

  • You have network access to the VAST Cluster API (https://<VMS_IP>)

  • You possess API credentials (admin username and password)

  • pip is installed

Install vastpy and vastpy-cli

pip install vastpy

This installs both the Python SDK and vastpy-cli tool.

Authentication

Set the following environment variables:

export VMS_USER=admin
export VMS_PASSWORD=your_password
export VMS_ADDRESS=VMS_IP

1. Using vastpy-cli

Create a User Quota

Prerequisites

  • The directory quota must already exist.

  • You have the username and identifier type.

Step 1: Create a Directory Quota

vastpy-cli post quotas path=/quota-test-2 name=quota-test-2 is_user_quota=true

Step 2: Identify the Directory Quota (quota_id)

vastpy-cli get quotas page_size=0 fields=entity_identifier,path,soft_limit,hard_limit,id

Step 3: Create User Quota

ℹ️ Info

In this example, I used quota_user_2

vastpy-cli post userquotas quota_id=8 identifier_type=username identifier=quota_user_2 \
  soft_limit=161061273600 hard_limit=214748364800 is_group=false grace_period="1 00:00:00"

Optional: Create the JSON Payload

{
  "quota_id": 8,
  "identifier_type": "username",
  "identifier": "quota_user_2",
  "is_group": false,
  "soft_limit": 161061273600,
  "hard_limit": 214748364800,
  "grace_period": "1 00:00:00"
}
vastpy-cli post userquotas --file-input new_user_quota.json

Verify Quota Creation

vastpy-cli get userquotas page_size=0 fields=entity_identifier,path,soft_limit,hard_limit,id

List User Quotas

vastpy-cli get userquotas page_size=0 fields=entity_identifier,path,soft_limit,hard_limit,id

ℹ️ Info

For optional ways to query user/group quota, see the examples in the appendix at the end of the article.

Update User Quotas

Option A: One-liner Update

vastpy-cli patch userquotas/50 soft_limit=161061273600 hard_limit=214748364800

Option B: Patch via File

export NEW_SOFT_GB=160
export NEW_HARD_GB=200
cat <<EOF > quota_update.json
{
  "soft_limit": $((NEW_SOFT_GB * 1073741824)),
  "hard_limit": $((NEW_HARD_GB * 1073741824)),
  "grace_period": "1 00:00:00"
}
EOF
vastpy-cli patch userquotas/ID --file-input quota_update.json

Delete User Quota

vastpy-cli delete userquotas/<id>

2. Using curl

Authentication

export VMS_IP=your_vms_ip
export VMS_USER=admin
export VMS_PASSWORD=your_password
export ACCESS_TOKEN=$(curl -sk -X POST https://$VMS_IP/api/v5/token/ \
  -H "Content-Type: application/json" \
  -d '{"username": "$VMS_USER", "password": "$VMS_PASSWORD"}' | jq -r '.access')

List User Quotas

curl -sk -X GET https://$VMS_IP/api/userquotas \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Accept: application/json" | jq '.results[] | {id, entity_identifier, path}'

Update User Quotas - Step-by-Step with All Variables

# === CONFIG ===
export VMS_IP=VMS_IP
export VMS_USER=admin
export VMS_PASSWORD=PASSWORD
export USER_QUOTA_ID=QUOTA_ID

# Set limits in GB
export SOFT_LIMIT_GB=150
export HARD_LIMIT_GB=200

# Convert limits to bytes and export as strings
export SOFT_LIMIT_BYTES=$(($SOFT_LIMIT_GB * 1024 * 1024 * 1024))
export HARD_LIMIT_BYTES=$(($HARD_LIMIT_GB * 1024 * 1024 * 1024))

# Optional inodes and grace
export SOFT_INODES=0
export HARD_INODES=0
export GRACE_PERIOD="1d"

# === LOGIN AND TOKEN EXTRACTION ===
export ACCESS_TOKEN=$(curl -sk -X POST https://$VMS_IP/api/v5/token/ \
  -H "Content-Type: application/json" \
  -d "{\"username\": \"$VMS_USER\", \"password\": \"$VMS_PASSWORD\"}" | jq -r '.access')

# Check if token is valid
if [[ "$ACCESS_TOKEN" == "null" || -z "$ACCESS_TOKEN" ]]; then
  echo "Failed to retrieve access token"
  exit 1
fi

# === PATCH USER QUOTA ===
curl -sk -X PATCH https://$VMS_IP/api/v5/userquotas/$USER_QUOTA_ID/ \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d "{
    \"soft_limit\": \"$SOFT_LIMIT_BYTES\",
    \"hard_limit\": \"$HARD_LIMIT_BYTES\",
    \"soft_limit_inodes\": $SOFT_INODES,
    \"hard_limit_inodes\": $HARD_INODES,
    \"grace_period\": \"$GRACE_PERIOD\"
  }"

Delete User Quotas

curl -sk -X DELETE https://$VMS_IP/api/userquotas/<id> \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Accept: application/json"

Reference

All commands are based on the official VAST API documentation:

Appendix: Extended Quota Listing Script

vastpy-cli get userquotas --json | jq -r '
  (["ID", "Identifier", "Type", "IsGroup", "Path", "SoftLimit_GB", "HardLimit_GB"]),
  (.results[] | [
    .id,
    (.entity.identifier // "N/A"),
    (.entity.identifier_type // "N/A"),
    (.entity.is_group // false),
    (.path // "N/A"),
    ((.soft_limit // 0) / 1073741824 | tostring + " GB"),
    ((.hard_limit // 0) / 1073741824 | tostring + " GB")
  ]) | @tsv' | column -t -s $'\t'

Sample Output:

ID  Identifier    Type       IsGroup  Path        SoftLimit_GB          HardLimit_GB
84  quota_user_1  username   false    /prodquota  93.13225746154785 GB  111.75870895385742 GB
85  0             uid        false    /prodquota  0 GB                  0 GB
86  root          groupname  true     /prodquota  0 GB                  0 GB
87  quotagrp-1    groupname  true     /prodquota  93.13225746154785 GB  186.2645149230957 GB