Revision history [back]

click to hide/show revision 1
initial version

How to get quota usage from nova API?

How do I determine how much of a tenant's quota has been used through the nova APIs? I know about the novaclient.v1_1.client.usage module, which provides the following function:

now =
later = now + datetime.timedelta(hour=1)
usage_data =  novaclient.usage(tenant_id, now, later)

But there is an impedance mismatch between usage_data and a tenant's quota settings. usage_data["total_hours"] is approximately instance_count for a one hour window starting from now, but not exactly. total_hours is floating point where instance_count is an integer.

Also, the CLI function $ nova usage-list returns values for the last month by default (and does not support sub-day level --start and --end offsets.

How does Horizon calculate usage in the boot dialog? Should I submit a blueprint for expose that calculation over the API?