Show Table of Contents
2.5. 示例:使用 Python 列出逻辑网络集合
API 类提供了访问逻辑网络集合(名为 networks)的功能。这个集合包括了环境中的所有逻辑网络。
例 2.4. 使用 Python 列出逻辑网络集合
这个 Python 示例列出了
networks 集合中的逻辑网络。它同时还显示了集合中的每个网络的基本信息。
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")
n_list = api.networks.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
如果环境中只包括默认的管理网络,这个示例会输出以下信息:
ovirtmgmt (00000000-0000-0000-0000-000000000009)

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.