4.5. Example: Listing the Logical Networks Collection using Python
The
API class provides access to a logical networks collection, named networks. This collection contains all logical networks in the environment.
Example 4.4. Listing the logical networks collection using Python
This Python example lists the logical networks in the
networks collection. It also outputs some basic information about each network in the collection.
from ovirtsdk.api import API from ovirtsdk.xml import params try: api = API(url="https://HOST", username="USER", password="PASS", ca_file="ca.crt") n_list = api.logicalnetworks.list() for n in n_list: print "%s (%s)" % (n.get_name(), n.get_id()) api.disconnect() except Exception as ex: print "Unexpected error: %s" % ex
In an environment where only the default management network exists, the example outputs:
rhevm (00000000-0000-0000-0000-000000000009)