Show Table of Contents
2.19. Example: Starting a Virtual Machine with Overridden Parameters using Python
Starting a virtual machine with overridden parameters.
Example 2.20. Starting a virtual machine with overridden parameters using Python
This example boots a virtual machine with a Windows ISO and attaches the
virtio-win_x86.vfd floppy disk which contains Windows drivers. This action is equivalent to using the Run Once window in the Administration or User Portal to start a virtual machine.
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
Note
The CD image and floppy disk file must be available in the ISO domain already. If not, use the ISO uploader tool to upload the files. See The ISO Uploader Tool for more information.

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.