Este contenido no está disponible en el idioma seleccionado.
2.17. Example: Attaching an ISO Image to a Virtual Machine using Python
To begin installing a guest operating system on a newly created virtual machine you must attach an ISO file containing the operating system installation media.
Example 2.16. Identifying ISO images
ISO images are found in the
files
collection attached to the ISO storage domain. This example lists the contents of the files
collection on an ISO storage domain.
If successful the script will output an entry like this for each file found in the
files
collection:
RHEL6.3-Server-x86_64-DVD1.iso
RHEL6.3-Server-x86_64-DVD1.iso
Note that because files on the ISO domain must be uniquely named the
id
and name
attributes of the file are shared.
Example 2.17. Attaching an ISO image to a virtual machine using Python
This Python example attaches the
RHEL6.3-Server-x86_64-DVD1.iso
ISO image file to the vm1
virtual machine. Once identified the image file is attached using the add
method of the virtual machine's cdroms
collection.
If the
add
request is successful then the script will output:
Attached CD to 'vm1'.
Attached CD to 'vm1'.
Note
This procedure is for attaching an ISO image to virtual machines with a status of
Down
. To attach an ISO to a virtual machine with an Up
status, amend the second try
statement to the following:
Example 2.18. Ejecting a cdrom from a Virtual Machine using Python
Eject an ISO from a virtual machine's
cdrom
collection.