Show Table of Contents
2.3. 例: Python を使用したデータセンターコレクションの一覧表示
API クラスは、datacenters という名前のデータセンターコレクションへのアクセスを提供します。このコレクションには、環境内の全データセンターが含まれます。
例2.2 Python を使用したデータセンターコレクションの一覧表示
以下の Python の例は、
datacenters コレクション内のデータセンターを一覧表示します。また、コレクション内の各データセンターの基本的な情報も出力します。
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")
dc_list = api.datacenters.list()
for dc in dc_list:
print "%s (%s)" % (dc.get_name(), dc.get_id())
api.disconnect()
except Exception as ex:
print "Unexpected error: %s" % exDefault データセンターのみが存在する環境で、そのデータセンターがアクティブ化されていない場合は、次の例のような出力が表示されます。
Default (d8b74b20-c6e1-11e1-87a3-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.