Show Table of Contents
2.4. Example: Listing the Cluster Collection using Python
The API class provides a clusters collection, named
clusters. This collection contains all clusters in the environment.
Example 2.3. Listing the clusters collection using Python
This Python example lists the clusters in the
clusters collection. It also outputs some basic information about each cluster in the collection.
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
In an environment where only the
Default cluster exists, the example outputs:
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.