本文整理汇总了Python中nova.virt.xenapi.vm_utils.VMHelper.destroy_vbd方法的典型用法代码示例。如果您正苦于以下问题:Python VMHelper.destroy_vbd方法的具体用法?Python VMHelper.destroy_vbd怎么用?Python VMHelper.destroy_vbd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nova.virt.xenapi.vm_utils.VMHelper
的用法示例。
在下文中一共展示了VMHelper.destroy_vbd方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _destroy_rescue_vbds
# 需要导入模块: from nova.virt.xenapi.vm_utils import VMHelper [as 别名]
# 或者: from nova.virt.xenapi.vm_utils.VMHelper import destroy_vbd [as 别名]
def _destroy_rescue_vbds(self, rescue_vm_ref):
"""Destroys all VBDs tied to a rescue VM."""
vbd_refs = self._session.get_xenapi().VM.get_VBDs(rescue_vm_ref)
for vbd_ref in vbd_refs:
vbd_rec = self._session.get_xenapi().VBD.get_record(vbd_ref)
if vbd_rec.get("userdevice", None) == "1": # VBD is always 1
VMHelper.unplug_vbd(self._session, vbd_ref)
VMHelper.destroy_vbd(self._session, vbd_ref)
示例2: unrescue
# 需要导入模块: from nova.virt.xenapi.vm_utils import VMHelper [as 别名]
# 或者: from nova.virt.xenapi.vm_utils.VMHelper import destroy_vbd [as 别名]
def unrescue(self, instance, callback):
"""Unrescue the specified instance
- unplug the instance VM's disk from the rescue VM
- teardown the rescue VM
- release the bootlock to allow the instance VM to start
"""
rescue_vm_ref = VMHelper.lookup(self._session,
instance.name + "-rescue")
if not rescue_vm_ref:
raise exception.NotFound(_(
"Instance is not in Rescue Mode: %s" % instance.name))
original_vm_ref = self._get_vm_opaque_ref(instance)
vbd_refs = self._session.get_xenapi().VM.get_VBDs(rescue_vm_ref)
instance._rescue = False
for vbd_ref in vbd_refs:
_vbd_ref = self._session.get_xenapi().VBD.get_record(vbd_ref)
if _vbd_ref["userdevice"] == "1":
VMHelper.unplug_vbd(self._session, vbd_ref)
VMHelper.destroy_vbd(self._session, vbd_ref)
task1 = self._session.call_xenapi("Async.VM.hard_shutdown",
rescue_vm_ref)
self._session.wait_for_task(task1, instance.id)
vdi_refs = VMHelper.lookup_vm_vdis(self._session, rescue_vm_ref)
for vdi_ref in vdi_refs:
try:
task = self._session.call_xenapi('Async.VDI.destroy', vdi_ref)
self._session.wait_for_task(task, instance.id)
except self.XenAPI.Failure:
continue
task2 = self._session.call_xenapi('Async.VM.destroy', rescue_vm_ref)
self._session.wait_for_task(task2, instance.id)
self._release_bootlock(original_vm_ref)
self._start(instance, original_vm_ref)
示例3: locals
# 需要导入模块: from nova.virt.xenapi.vm_utils import VMHelper [as 别名]
# 或者: from nova.virt.xenapi.vm_utils.VMHelper import destroy_vbd [as 别名]
LOG.info(_("Mountpoint %(mountpoint)s attached to" " instance %(instance_name)s") % locals())
def detach_volume(self, instance_name, mountpoint):
"""Detach volume storage to VM instance"""
# Before we start, check that the VM exists
vm_ref = VMHelper.lookup(self._session, instance_name)
if vm_ref is None:
raise exception.InstanceNotFound(instance_id=instance_name)
# Detach VBD from VM
LOG.debug(_("Detach_volume: %(instance_name)s, %(mountpoint)s") % locals())
device_number = VolumeHelper.mountpoint_to_number(mountpoint)
try:
vbd_ref = VMHelper.find_vbd_by_number(self._session, vm_ref, device_number)
except StorageError, exc:
LOG.exception(exc)
raise Exception(_("Unable to locate volume %s") % mountpoint)
else:
try:
sr_ref = VolumeHelper.find_sr_from_vbd(self._session, vbd_ref)
VMHelper.unplug_vbd(self._session, vbd_ref)
except StorageError, exc:
LOG.exception(exc)
raise Exception(_("Unable to detach volume %s") % mountpoint)
try:
VMHelper.destroy_vbd(self._session, vbd_ref)
except StorageError, exc:
LOG.exception(exc)
# Forget SR
VolumeHelper.destroy_iscsi_storage(self._session, sr_ref)
LOG.info(_("Mountpoint %(mountpoint)s detached from" " instance %(instance_name)s") % locals())