Hi,
Instead of Compute API, Placement is used for such statistics, see the API reference:
https://docs.openstack.org/api-ref/placement/

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:
https://opendev.org/openstack/openstacksdk/src/branch/master/openstack/placement/v1/_proxy.py

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