Viewing Per-Tenant Block Storage Usage in OpenStack
Problem
Environment
Procedure
$ pip3 install openstacksdk$ source admin.rcimport 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}")Additional Information
Last updated
