Show Table of Contents
2.8. 例: 仮想マシンのサイズの表示
API クラスは、vms という名前の仮想マシンコレクションへのアクセスを提供します。同様に、このコレクションには仮想マシンにアタッチされた各ディスクの詳細を記述する disks コレクションが含まれています。
例2.7 仮想マシンのサイズの表示
以下の Python の例は、Red Hat Virtualization 環境の仮想マシンとその合計ディスクサイズ (バイト単位) を一覧で出力します。
from ovirtsdk.api import API
from ovirtsdk.xml import params
try:
api = API (url="https://HOST",
username="USER@DOMAIN",
password="PASS",
ca_file="ca.crt")
virtual_machines = api.vms.list()
if len(virtual_machines) > 0:
print("%-30s %s" % ("Name","Disk Size"))
print("==================================================")
for virtual_machine in virtual_machines:
disks = virtual_machine.disks.list()
disk_size = 0
for disk in disks:
disk_size += disk.get_size()
print("%-30s: %d" % (virtual_machine.get_name(), disk_size))
api.disconnect()
except Exception as ex:
print "Unexpected error: %s" % ex
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.