Maybe I'm missing something, but ... I tried 'openstack usage list' in a local devstack and for me it shows all projects, because of this code I think [1]: # Cache the project list project_cache = {} try: for p in self.app.client_manager.identity.projects.list(): project_cache[p.id] = p except Exception: # Just forget it if there's any trouble pass So if you run the command as an admin (or user who otherwise has permission to list projects 'openstack project list') then it will get a list of projects from Keystone and then call the Nova {tenant_id} API with each project. For example: (Note: I had to use version 6.0.0 because the fix for bug https://storyboard.openstack.org/#!/story/2010943 which Michel mentioned earlier is not released yet.) $ openstack --version openstack 6.0.0 $ openstack --os-cloud devstack-admin usage list Usage from 2023-11-01 to 2023-11-30: +---------+---------+--------------+-----------+---------------+ | Project | Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours | +---------+---------+--------------+-----------+---------------+ | demo | 1 | 172032.01 | 1344.0 | 1344.0 | | admin | 1 | 0.53 | 0.0 | 0.0 | +---------+---------+--------------+-----------+---------------+ I'm not sure what could be different between this example and problem being encountered. -melwitt [1] https://github.com/openstack/python-openstackclient/blob/6.0.0/openstackclie... On 11/28/23 10:27, smooney@redhat.com wrote:
so the openstack client is calling the nova simple tenant usage api
https://docs.openstack.org/python-openstackclient/latest/cli/command-objects... maps to https://docs.openstack.org/api-ref/compute/#show-usage-statistics-for-tenant
the openstack client does not have a --all-tenants flag or simplar to call
https://docs.openstack.org/api-ref/compute/#list-tenant-usage-statistics-for...
so the difference is the openstack client uses /os-simple-tenant-usage/{tenant_id} which is aviabel to anyone with the member or reader role in a given project
the all tenats version is /os-simple-tenant-usage and that endpoint is admin only.
osc has only ever support the tenant specific version so if you wantted to supprot the admin version you would need to modify osc to add a --all-tenant option to the cli.
horizon presumably support the multi tenant view as an admin usign the /os-simple-tenant-usage endpoint.
On Tue, 2023-11-28 at 18:47 +0100, Michel Jouvin wrote:
Hi,
I've been struggling today to understand the problem. I wrote a (Python) script that uses directly the API instead of going through the "openstack usage list". I had some hope of something related to the limit parameter but unfortunately it is not the case and the result using the API is the same as using the openstack client. Only horizon returns all the information.
Does somebody has any clue about what is done differently by Horizon compared to the openstack client (I assume it is using the API rather than the client)?
Any input would be very much appreciated as going month by month (we need a month-level detail) through the dashboard is not very sustainable and potentially very error prone...
Best regards,
Michel
Le 27/11/2023 à 18:39, Michel Jouvin a écrit :
Hi,
We are using "openstack usage list" to follow resource usage by projects at our cloud. We recently discovered that ~1/3 of the resource consumed (mostly "big projects") are missing from the JSON/CSV produced where the Admin Overview menu in the Horizon dashboard displays everything. Is there a trivial reason for this?
We tried both with a pretty old openstackclient (5.8) and the last one after applying the patch in https://github.com/openstack/python-openstackclient/commit/30462f57d48162d15... to fix the problem with date conversion. The result is the same.
Thank you in advance for any help. Cheers,
Michel