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.