Show Table of Contents
2.19. 例: Python を使用した上書きパラメーターでの仮想マシンの起動
上書きパラメーターで仮想マシンを起動します。
例2.20 Python を使用した上書きパラメーターでの仮想マシンの起動
以下の例では、Windows ISO を使用して仮想マシンをブートして、Windows ドライバーを含む
virtio-win_x86.vfd フロッピーディスクをアタッチします。このアクションは、管理ポータルまたはユーザーポータルで 1 回実行ウィンドウを使用して仮想マシンを起動するのと同じです。
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")
except Exception as ex:
print "Failed to connect to API: %s" % ex
try:
vm = api.vms.get(name="Win_machine")
except Exception as ex:
print "Failed to retrieve VM: %s" % ex
cdrom = params.CdRom(file=params.File(id="windows_example.iso"))
floppy = params.Floppy(file=params.File(id="virtio-win_x86.vfd"))
try:
vm.start(
action=params.Action(
vm=params.VM(
os=params.OperatingSystem(
boot=[params.Boot(dev="cdrom")]
),
cdroms=params.CdRoms(cdrom=[cdrom]),
floppies=params.Floppies(floppy=[floppy])
)
)
)
except Exception as ex:
print "Failed to start VM: %s" % ex
注記
CD イメージとフロッピーディスクファイルはすでに ISO ドメインで利用できる状態でなければなりません。まだ用意されていない場合は、ISO アップローダーを使用してこれらのファイルをアップロードしてください。詳しい情報は 「ISO アプローダーツール」を参照してください。

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.