Show Table of Contents
2.4. 示例:使用 Python 列出集群集合
API 类提供了访问集群集合(名为
clusters)的功能。这个集合包括了环境中的所有集群。
例 2.3. 使用 Python 列出集群集合
这个 Python 示例列出了
clusters 集合中的集群。它同时还显示了集合中的每个集群的基本信息。
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")
c_list = api.clusters.list()
for c in c_list:
print "%s (%s)" % (c.get_name(), c.get_id())
api.disconnect()
except Exception as ex:
print "Unexpected error: %s" % ex
如果环境中只包括
Default 集群,这个示例会输出以下信息:
Default (99408929-82cf-4dc7-a532-9d998063fa95)

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.