In modern CSP and Kubernetes environments, storage provisioning needs to be fast, secure, and automated. VAST’s REST API, exposed through the vastpy SDK enables programmatic control over tenant creation, access policy enforcement, capacity quotas, and data path configuration. This section walks through the automation flow, starting from basic object queries to full onboarding of a multi-tenant environment.
VASTPY is a Python SDK for interacting with the VAST Management System (VMS) REST API. Reference:
Using your VMS address:
https://<vast-vms-hostname>/docs.
1. Installation
pip install vastpyThe package is available on PyPI: https://pypi.org/project/vastpy/
Requirements:
Python 3.6 or higher
urllib3 1.2 or higher
2. Basic Operations
import vastpy
client = vastpy.VASTClient("admin", "123456", "vast-file-server-vms-kfs2")
# List all CNodes
for node in client.cnodes.get():
print("CNode:", node["title"], node["ip"])
# List all DNodes
for node in client.dnodes.get():
print("DNode:", node["title"], node["ip"])
# List all tenants
for tenant in client.tenants.get():
print("Tenant:", tenant["id"], tenant["name"])
# List all views
for view in client.views.get():
print("View:", view["id"], view["path"])
# List all active VIPs
for vip in client.vips.get():
print("VIP:", vip["ip"], "on", vip["cnode"])
3. Advanced Operations
import vastpy
# Create a new tenant
tenant = client.tenants.post(name="tenant123")
# Select an existing view policy
policy = next(p for p in client.viewpolicies.get() if p["name"] == "default")
# Create a view under that tenant
view = client.views.post(
path="/k8s/tenant123",
policy_id=policy["id"],
create_dir=True,
tenant_id=tenant["id"]
)
# Apply a 5 TiB hard quota
client.quotas.post(
name="tenant123-quota",
path="/k8s/tenant123",
hard_limit=5 * 1024**4,
tenant_id=tenant["id"]
)
# Assign a VIP from a pool to a CNode
vip_pool = next(p for p in client.vippools.get() if p["name"] == "default")
cnode = client.cnodes.get()[0]
client.vips.post(ip="10.101.127.55", cnode_id=cnode["id"], vippool_id=vip_pool["id"])
4. Example: Automation Script for onboarding a new tenant
4.1 - Create file vast_onboard.py below:
#!/usr/bin/env python3
"""
Automate onboarding of a Kubernetes tenant in VAST using vastpy.
All parameters are passed as CLI flags so the script can be reused
for any tenant or cluster.
"""
import argparse
import vastpy
# ── CLI argument parsing ──────────────────────────────────────
def get_args():
p = argparse.ArgumentParser(
description="Onboard a tenant (tenant, view, quota, VIP) in VAST."
)
p.add_argument("--vms-host", required=True, help="VMS host or IP")
p.add_argument("--user", required=True, help="API username")
p.add_argument("--password", required=True, help="API password")
p.add_argument("--tenant", required=True, help="Tenant name to create")
p.add_argument("--view-path", required=True, help="Full view path (e.g. /k8s/tenant)")
p.add_argument("--policy", default="default", help="View-policy name")
p.add_argument("--vip-pool", default="default", help="VIP pool name to use")
p.add_argument("--vip-ip", required=True, help="VIP address to assign")
p.add_argument("--quota-gib", type=int, default=5000,
help="Hard quota in GiB (default 5000)")
return p.parse_args()
# ── Main automation flow ─────────────────────────────────────
def main():
args = get_args()
# Connect
client = vastpy.VASTClient(args.user, args.password, args.vms_host)
# 1. Tenant
tenant = client.tenants.post(name=args.tenant)
# print(f"Tenant created: {tenant['name']} (ID {tenant['id']})")
# 2. View policy
policy = next(p for p in client.viewpolicies.get() if p["name"] == args.policy)
# print(f"Policy selected: {policy['name']} (ID {policy['id']})")
# 3. View
view = client.views.post(
path=args.view_path,
policy_id=policy["id"],
create_dir=True,
tenant_id=tenant["id"]
)
# print(f"View created: {view['path']} (ID {view['id']})")
# 4. Quota
quota = client.quotas.post(
name=f"{args.tenant}-quota",
path=args.view_path,
hard_limit=args.quota_gib * 1024**3,
tenant_id=tenant["id"]
)
# print(f"Quota applied: {args.quota_gib} GiB")
# 5. VIP
vip_pool = next(vp for vp in client.vippools.get() if vp["name"] == args.vip_pool)
cnode = client.cnodes.get()[0] # pick first CNode
vip = client.vips.post(
ip=args.vip_ip,
cnode_id=cnode["id"],
vippool_id=vip_pool["id"]
)
# print(f"VIP {vip['ip']} assigned to {cnode['title']} (pool {vip_pool['name']})")
# 6. Validation summary
# print("\n🔎 Validation Summary")
# print("Tenants:", [t["name"] for t in client.tenants.get()])
# print("Views:", [v["path"] for v in client.views.get() if v["tenant_id"] == tenant["id"]])
# print("VIPs:", [v["ip"] for v in client.vips.get() if v["ip"] == args.vip_ip])
# print("\nAutomation complete.")
if __name__ == "__main__":
main()
4.2 - How to Run
pip install vastpy # one-time setup
python3 vast_onboard.py --vms-host vast-file-server-vms-kfs2 --user admin --password XXXXX --tenant tenant123 --view-path /k8s/tenant123 --vip-ip 10.101.127.55 --quota-gib 5000