Ce contenu n'est pas disponible dans la langue sélectionnée.
2.2. Example: Accessing the API Entry Point using Python
The ovirtsdk Python library provides the
API
class, which acts as the entry point for the API.
Example 2.1. Accessing the API entry point using Python
This python example connects to an instance of the REST API provided by the Red Hat Virtualization Manager at
rhevm.demo.redhat.com
. To connect the example creates an instance of the API
class If connection was successful a message is printed. Finally the disconnect()
method of the API
class is called to close the connection.
The parameters provided to the constructor for the
The constructor for the
API
class in this example are:
- The
url
of the Manager to which to connect. - The
username
of the user by which to authenticate. - The
password
of the user by which to authenticate. - The
ca_file
, which is the path to a certificate. The certificate is expected to be a copy of the one for the Manager's Certificate Authority. It can be obtained fromhttps://[engine-fqdn]ovirt-engine/services/pki-resource?resource=ca-certificate&format=X509-PEM-CA
.
API
class supports other parameters. Only mandatory parameters are specified in this example.
If the connection attempt was successful, the example outputs the text:
Connected to Red Hat Virtualization Manager successfully!
Connected to Red Hat Virtualization Manager successfully!