Untitled diff
1 removal
35 lines
3 additions
37 lines
import ovirtsdk4 as sdk
import ovirtsdk4 as sdk
import ovirtsdk4.types as types
import ovirtsdk4.types as types
connection = sdk.Connection(
connection = sdk.Connection(
url='https://localhost.intern/ovirt-engine/api',
url='https://localhost.intern/ovirt-engine/api',
username='admin@internal',
username='admin@internal',
password='somepass',
password='somepass',
insecure=True,
insecure=True,
)
)
vms_service = connection.system_service().vms_service()
vms_service = connection.system_service().vms_service()
vms = vms_service.list()
vms = vms_service.list()
disks_service = connection.system_service().disks_service()
disks_service = connection.system_service().disks_service()
the_list = []
if len(vms) > 0:
if len(vms) > 0:
for vm_name in vms:
for vm_name in vms:
vm_service = vms_service.vm_service(vm_name.id)
vm_service = vms_service.vm_service(vm_name.id)
disk_attachments = vm_service.disk_attachments_service().list()
disk_attachments = vm_service.disk_attachments_service().list()
disk_size = 0
disk_size = 0
disks = []
disks = []
for disk_attachment in connection.follow_link(vm_name.disk_attachments):
for disk_attachment in connection.follow_link(vm_name.disk_attachments):
disk = disk_attachment.disk
disk = disk_attachment.disk
disk_service = disks_service.disk_service(disk_attachment.disk.id)
disk_service = disks_service.disk_service(disk_attachment.disk.id)
disk = disk_service.get()
disk = disk_service.get()
disk_size += (disk.provisioned_size / 1024 / 1024 / 1024)
disk_size += (disk.provisioned_size / 1024 / 1024 / 1024)
print("%-30s: %-10d %-10s" % (vm_name.name, disk_size, disk.id))
the_list.append("%-30s: %-10d %-10s" % (vm_name.name, disk_size, disk.id))
# Produces the following output
# Produces the following output
vm-prod01 : 32 28723709-bd28-4a09-9720-ba36d494a261
vm-prod01 : 32 28723709-bd28-4a09-9720-ba36d494a261
vm-prod02 : 100 119b1622-1453-4d4d-98ef-3f7cf82134da
vm-prod02 : 100 119b1622-1453-4d4d-98ef-3f7cf82134da
vm-prod03 : 142 deb90674-8b1b-48fc-a257-5234ac61169d
vm-prod03 : 142 deb90674-8b1b-48fc-a257-5234ac61169d