Show Table of Contents
2.6. 例: Python を使用したホストコレクションの一覧表示
API クラスは、hosts という名前のホストコレクションへのアクセスを提供します。このコレクションには、環境内の全ホストが含まれます。
例2.5 Python を使用したホストコレクションの一覧表示
以下の Python の例は、
hosts コレクション内のホストを一覧表示します。
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")
h_list = api.hosts.list()
for h in h_list:
print "%s (%s)" % (h.get_name(), h.get_id())
api.disconnect()
except Exception as ex:
print "Unexpected error: %s" % ex
Atlantic という名前のホストが 1 台のみアタッチされた環境では、次のような出力が表示されます。
Atlantic (5b333c18-f224-11e1-9bdd-00163e77e2ed)

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.