Show Table of Contents
2.17. 示例:使用 Python 分离一个磁盘
您可以使用 Python 软件开发套件从虚拟机上分离虚拟磁盘。
例 2.18. 使用 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.