Ce contenu n'est pas disponible dans la langue sélectionnée.
4.2. Example: Accessing the API Entry Point using Python
ovirtsdk
Python library provides the API class, which acts as the entry point for the API.
Example 4.1. Accessing the API entry point using Python
API
class. If connection is established successfully, a message is printed. Lastly, the disconnect()
method of the API
class is called to close the connection.
- The
url
of the Console with which to connect. - The
username
of the user to authenticate. - The
password
of the user to authenticate. - The
ca_file
that is the path to a certificate. The certificate is expected to be a copy of the Console's Certificate Authority. It can be obtained fromhttps://[HOST]/ca.crt
.
API
class supports other parameters. Only mandatory parameters are specified in this example.
Connected to Red Hat Storage Console successfully!
Connected to Red Hat Storage Console successfully!
Example 4.2. Listing the Cluster Collection using Python
API
class provides a cluster collection named default cluster. This collection contains all the clusters in the environment.
Default
cluster exists, the example outputs:
Default (99408929-82cf-4dc7-a532-9d998063fa95)
Default (99408929-82cf-4dc7-a532-9d998063fa95)
Example 4.3. Listing the Networks Collection using Python
API
class provides access to a networks collection named Management Networks
. This collection contains all the networks in the environment.
networks
collection. It also outputs some basic information about each network in the collection.
Management Network 00000000-0000-0000-0000-000000000009 ovirtmgmt
Management Network
00000000-0000-0000-0000-000000000009
ovirtmgmt
Example 4.4. Listing the Host Collection using Python
API
class provides access to a host collection. This collection contains all the hosts in the storage cluster.
host name: 10.70.37.49 (host ID: 5be18d62-e7b0-4407-8ff6-68290a92338f) host name: 10.70.37.50 (host ID: 3b202041-6e14-43df-a844-92a141bed1ed)
host name: 10.70.37.49 (host ID: 5be18d62-e7b0-4407-8ff6-68290a92338f)
host name: 10.70.37.50 (host ID: 3b202041-6e14-43df-a844-92a141bed1ed)
Example 4.5. Listing the Volume Collection using Python
Example 4.6. Listing the Brick Collection from a Volume using Python
getGlusterVolumeBrickDetails()
lists the bricks of the volume that is assigned to the cluster.
Example 4.7. Listing hooks in a Red Hat Storage Console
getHookList(clusterName)
lists the Gluster hooks created in the Console.