Quick usage report - nova usage

Bug #1400796 reported by Tim Bell
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-openstackclient
Fix Released
Low
Steve Martinelli

Bug Description

The nova usage report can be an easy way to get information on the current usage of resources for a non-admin user who is also not ceilometer aware (or has the time to understand the meters :-)

Can we find a way to add something like 'nova usage' to the current command set in a consistent fashion ?

Changed in python-openstackclient:
status: New → Confirmed
Revision history for this message
Dean Troyer (dtroyer) wrote :

 $ nova usage
 Usage from 2014-11-17 to 2014-12-16:
 +---------+--------------+-----------+---------------+
 | Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
 +---------+--------------+-----------+---------------+
 | 23 | 14816700.13 | 7429.00 | 144694.34 |
 +---------+--------------+-----------+---------------+

Revision history for this message
Dean Troyer (dtroyer) wrote :

This should be handled similar to how we did the quotas, in that all APIs get combined into a single command. I would also change from the list-style to a show-style output as this does not appear to be an admin-level command where multiple rows would be returned. That will help readability if/when additional resource types are added.

Changed in python-openstackclient:
importance: Undecided → Low
Revision history for this message
Steve Martinelli (stevemar) wrote :

FWIW there is also usage-list which is very similar

steve:keystone$ nova usage-list
Usage from 2014-11-18 to 2014-12-17:
+----------------------------------+---------+--------------+-----------+---------------+
| Tenant ID | Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+----------------------------------+---------+--------------+-----------+---------------+
| 7390ee47b3c642cf86ed2e0501cab352 | 1 | 8.60 | 0.02 | 0.02 |
+----------------------------------+---------+--------------+-----------+---------------+

Revision history for this message
Steve Martinelli (stevemar) wrote :

Seems like there are actually a few variants to this,

steve:keystone$ nova usage-list
Usage from 2014-11-18 to 2014-12-17:
+----------------------------------+---------+--------------+-----------+---------------+
| Tenant ID | Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+----------------------------------+---------+--------------+-----------+---------------+
| 7390ee47b3c642cf86ed2e0501cab352 | 1 | 384.43 | 0.75 | 0.75 |
| ebab58588b9046a699057a51ac43133f | 1 | 57.88 | 0.11 | 0.11 |
+----------------------------------+---------+--------------+-----------+---------------+

steve:keystone$ nova usage
Usage from 2014-11-18 to 2014-12-17:
+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1 | 384.84 | 0.75 | 0.75 |
+---------+--------------+-----------+---------------+

steve:keystone$ nova usage --tenant ebab58588b9046a699057a51ac43133f
Usage from 2014-11-18 to 2014-12-17:
+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1 | 60.23 | 0.12 | 0.12 |
+---------+--------------+-----------+---------------+

I vote we just implement 'nova usage' and have it default to the current auth project, or have a flag for a specific project Id, and another flag to list all projects (it takes priority over the specified one). This way we always have the project id in the returned data.

+1 on making this show command instead of list.

Revision history for this message
Steve Martinelli (stevemar) wrote :

Also note that there is once again different behaviour if a user has admin role for this command, the non-admin user can just specify their own project, it seems.

steve:devstack$ nova usage-list
ERROR (Forbidden): Policy doesn't allow compute_extension:simple_tenant_usage:list to be performed. (HTTP 403)

steve:devstack$ nova usage --tenant 7390ee47b3c642cf86ed2e0501cab352
ERROR (Forbidden): Policy doesn't allow compute_extension:simple_tenant_usage:show to be performed.

steve:devstack$ nova usage
Usage from 2014-11-18 to 2014-12-17:
+---------+--------------+-----------+---------------+
| Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
+---------+--------------+-----------+---------------+
| 1 | 104.50 | 0.20 | 0.20 |
+---------+--------------+-----------+---------------+

All run as 'demo' user with 'demo' project

Revision history for this message
Steve Martinelli (stevemar) wrote :

Apparently I added this over a year ago: https://github.com/openstack/python-openstackclient/blob/master/openstackclient/compute/v2/usage.py

@Tim, can you try `openstack project usage list` and let me know what you get? I suspect it won't work nicely for non-admins.

It seems to be missing the column that indicates the number of servers anyway

Revision history for this message
Steve Martinelli (stevemar) wrote :

FWIW, this is what I've got working for `openstack usage show`

steve:devstack$ openstack usage show
Usage from 2014-11-19 to 2014-12-18 on project ebab58588b9046a699057a51ac43133f:
+---------------+---------+
| Field | Value |
+---------------+---------+
| CPU Hours | 3.95 |
| Disk GB-Hours | 3.95 |
| RAM MB-Hours | 2024.62 |
| Servers | 1 |
+---------------+---------+

Changed in python-openstackclient:
assignee: nobody → Steve Martinelli (stevemar)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-openstackclient (master)

Reviewed: https://review.openstack.org/142318
Committed: https://git.openstack.org/cgit/openstack/python-openstackclient/commit/?id=5761a0f0b75277140c081ab61b7f3c41edc82e31
Submitter: Jenkins
Branch: master

commit 5761a0f0b75277140c081ab61b7f3c41edc82e31
Author: Steve Martinelli <email address hidden>
Date: Tue Dec 16 22:25:01 2014 -0500

    Add usage show command

    Should show basic usage by project id, if not specified then
    use the project id the user is authN'ing with.

    Change-Id: I0284a5efd84075b18e1a7117cc9f8f7fecf16274
    Closes-Bug: #1400796

Changed in python-openstackclient:
status: In Progress → Fix Committed
Dean Troyer (dtroyer)
Changed in python-openstackclient:
milestone: none → m7
Dean Troyer (dtroyer)
Changed in python-openstackclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.