Viewing Per-Tenant Block Storage Usage in OpenStack
Problem
How to retrieve per-tenant (project-wise) block storage usage in OpenStack using CLI, including total provisioned volume size summaries.
Environment
Platform9 Managed OpenStack - All Versions
Cinder
Procedure
Install SDK.
$ pip3 install openstacksdkExport admin.rc file.
$ source admin.rcScript: Per-Tenant Provisioned Storage Usage.
import openstack
conn = openstack.connect()
# Build a map of project_id -> project name
project_names = {p.id: p.name for p in conn.identity.projects()}
usage = {}
# Collect provisioned volume sizes
for vol in conn.block_storage.volumes(details=True, all_projects=True):
pid = vol.project_id
usage[pid] = usage.get(pid, 0) + vol.size # size in GB
# Print output
print(f"{'Project':<20} {'Provisioned (GB)':>16}")
for pid, size in sorted(usage.items()):
name = project_names.get(pid, pid[:8]) # fallback to short ID
print(f"{name:<20} {size:>16}")Run the Script.
Sample output:
Additional Information
This script reports provisioned sizes (logical volume size), not actual allocated backend usage.
Most OpenStack backends (e.g., Ceph, LVM, HPE 3PAR, NFS) do not expose physical allocation per volume unless the driver supports it.
Modify the script to include volume count, volume type, or export to CSV.
Last updated
