Show Table of Contents
2.17. Example: Detaching a Disk using Python
You can use the Python software development kit to detach a virtual disk from a virtual machine.
Example 2.18. Detaching a disk using Python
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")
vm = api.vms.get(name="VM_NAME")
disk = vm.disks.get(name="DISK_NAME")
detach = params.Action(detach=True)
disk.delete(action=detach)
print "Detached disk %s successfully!" % disk
api.disconnect()
except Exception as ex:
print "Unexpected error: %s" % ex

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.