Hi,
No I meant something like this:
$ openstack resource provider list
+--------------------------------------+-------+------------+--------------------------------------+----------------------+
| uuid                                 | name  | generation | root_provider_uuid                   | parent_provider_uuid |
+--------------------------------------+-------+------------+--------------------------------------+----------------------+
| 0f916a23-403f-43c3-ac57-e109bc371dba | jammy |          2 | 0f916a23-403f-43c3-ac57-e109bc371dba | None                 |
+--------------------------------------+-------+------------+--------------------------------------+----------------------+
$ openstack resource provider inventory list 0f916a23-403f-43c3-ac57-e109bc371dba
+----------------+------------------+----------+----------+----------+-----------+-------+------+
| resource_class | allocation_ratio | min_unit | max_unit | reserved | step_size | total | used |
+----------------+------------------+----------+----------+----------+-----------+-------+------+
| VCPU           |              4.0 |        1 |        6 |        0 |         1 |     6 |    0 |
| MEMORY_MB      |              1.0 |        1 |     7936 |      512 |         1 |  7936 |    0 |
| DISK_GB        |              1.0 |        1 |       28 |        0 |         1 |    28 |    0 |
+----------------+------------------+----------+----------+----------+-----------+-------+------+
$ openstack resource provider inventory list 0f916a23-403f-43c3-ac57-e109bc371dba
+----------------+------------------+----------+----------+----------+-----------+-------+------+
| resource_class | allocation_ratio | min_unit | max_unit | reserved | step_size | total | used |
+----------------+------------------+----------+----------+----------+-----------+-------+------+
| VCPU           |              4.0 |        1 |        6 |        0 |         1 |     6 |    1 |
| MEMORY_MB      |              1.0 |        1 |     7936 |      512 |         1 |  7936 |  256 |
| DISK_GB        |              1.0 |        1 |       28 |        0 |         1 |    28 |    1 |
+----------------+------------------+----------+----------+----------+-----------+-------+------+

Recently this API was also added to Horizon (the web gui for Openstack) as hypervisor API and the compute db behind it is 
not preferred.

Best wishes
Lajos Katona (lajoskatona)

Saeed <s.fazl73@gmail.com> ezt írta (időpont: 2024. máj. 10., P, 13:12):
Hello,

Thanks a lot, but I didn't find the proper way for this.

In CLI, I run openstack hypervisor show hypervisor.domain.com, it then shows all the needed information and data.
I run openstack service list, I see this:

+----------------------------------+------------------+-------------------------+
| ID                               | Name             | Type                    |
+----------------------------------+------------------+-------------------------+
| 0a289a58588d4d00ac27ef92da8128de | keystone         | identity                |
| 2cdf38eca0c0467fa856f1f1d91f8de3 | heat             | orchestration           |
| 44393da92532478abd2dc1bdba1454ce | nova_legacy      | compute_legacy          |
| 4cee55fd6c524134b010c65a7d406857 | ironic           | baremetal               |
| 4f47c9bd69a34b5a9e0ef149823b7785 | neutron          | network                 |
| 59053bba36ed4944aaac7e8eb0f9ac01 | freezer          | backup                  |
| 670cb0faa6c64f8f82f0d19315e085a5 | trove            | database                |
| 828ba6c2709349d597e469bf7fa55766 | glance           | image                   |
| 8c2671e5ddde47e4ae1accd2ce2eb696 | placement        | placement               |
| 8c6357e12abb40e5a46b10be5f950c79 | heat-cfn         | cloudformation          |
| c211ea65a3d440d1bb2add6f74423056 | watcher          | infra-optim             |
| ceba54fa82f543579b245569b9fc127e | masakari         | instance-ha             |
| d5c2952cc6904a0385cb20e5d39d1afe | nova             | compute                 |
| e238634b10db492a942e27714ee9d9b1 | gnocchi          | metric                  |
| f545381f4aa649a39122a258f48833fc | ironic-inspector | baremetal-introspection |
+----------------------------------+------------------+-------------------------+

If I do understand your reply correctly, you mean I should run a single command for each server to find its free memory or CPU? For example if I have 100 servers, I should run 100 times a command with different server names?

On Fri, 10 May 2024 at 10:33, Lajos Katona <katonalala@gmail.com> wrote:
Hi,
Instead of Compute API, Placement is used for such statistics, see the API reference:

You have to follow the resource providers on your compute, and resource providers can be in a tree with a root provider. 
For the available resources (resource classes) you have to list the resource provider inventories, and for 
the used resource you have to follow the allocations.
Check the API ref and see the possibilities with CLI first perhaps. Be careful Placement API is microversioned like Compute API.

From python SDK you can find the relevant methods here:

Best wishes
Lajos Katona (lajoskatona)

Saeed <s.fazl73@gmail.com> ezt írta (időpont: 2024. máj. 9., Cs, 19:06):
Hello,

This is my python code:
import openstack
openstack.enable_logging(debug=False)
hypervisors = []
conn = openstack.connect(cloud='region1')
for hypervisor in conn.compute.hypervisors(details=True):
    hypervisors.append(hypervisor.to_dict())

I also run this:
for hypervisor in hypervisors: 
     print(hypervisor)

This is the last result (other results are similar this):
{'cpu_info': None, 'host_ip': '1.1.1.1', 'hypervisor_type': 'QEMU', 'hypervisor_version': 6002000, 'name': 'some.fqdn.com', 'service_details': {'id': 'some-random-id', 'host': 'some.fqdn.com', 'disabled_reason': 'test'}, 'servers': None, 'state': 'up', 'status': 'disabled', 'uptime': ' 00:27:11 up 31 days, 10:14,  2 users,  load average: 3.52, 3.20, 3.36\n', 'current_workload': None, 'disk_available': None, 'local_disk_used': None, 'local_disk_size': None, 'local_disk_free': None, 'memory_used': None, 'memory_size': None, 'memory_free': None, 'running_vms': None, 'vcpus_used': None, 'vcpus': None, 'id': 'some-random-id', 'location': Munch({'cloud': 'region1', 'region_name': 'Region1', 'zone': None, 'project': Munch({'id': 'somerandomid', 'name': None, 'domain_id': None, 'domain_name': None})})}

 As you see, values like cpu_info, disk_availablelocal_disk_usedlocal_disk_sizelocal_disk_freememory_used, etc are None.

How can I have the following values? In the Openstack UI I see it says the free available disk, memory and CPU, but I don't know how to have them in python.

I see here the above values, but for me all are None.

Regards,
Saeed