3.5. ホストの一覧表示
hosts コレクションには、環境内のすべてのホストが含まれます。
例3.3 ホストのリスト表示
この例では、hosts コレクション内のホストとその ID をリスト表示します。
V4
import ovirtsdk4 as sdk
import ovirtsdk4.types as types
connection = sdk.Connection(
url='https://engine.example.com/ovirt-engine/api',
username='admin@internal',
password='password',
ca_file='ca.pem',
)
host_service = connection.system_service().hosts_service()
hosts = host_service.list()
for host in hosts:
print("%s (%s)" % (host.name, host.id))
connection.close()
MyHost という 1 つのホストのみが接続されている環境では、例は次のテキストを出力します。
MyHost (00000000-0000-0000-0000-000000000000)