当前位置: 首页>>代码示例>>Python>>正文


Python VMHelper.unplug_vbd方法代码示例

本文整理汇总了Python中nova.virt.xenapi.vm_utils.VMHelper.unplug_vbd方法的典型用法代码示例。如果您正苦于以下问题:Python VMHelper.unplug_vbd方法的具体用法?Python VMHelper.unplug_vbd怎么用?Python VMHelper.unplug_vbd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nova.virt.xenapi.vm_utils.VMHelper的用法示例。


在下文中一共展示了VMHelper.unplug_vbd方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _destroy_rescue_vbds

# 需要导入模块: from nova.virt.xenapi.vm_utils import VMHelper [as 别名]
# 或者: from nova.virt.xenapi.vm_utils.VMHelper import unplug_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)
开发者ID:superstack,项目名称:nova,代码行数:10,代码来源:vmops.py

示例2: unrescue

# 需要导入模块: from nova.virt.xenapi.vm_utils import VMHelper [as 别名]
# 或者: from nova.virt.xenapi.vm_utils.VMHelper import unplug_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)
开发者ID:pombredanne,项目名称:nova,代码行数:44,代码来源:vmops.py

示例3: locals

# 需要导入模块: from nova.virt.xenapi.vm_utils import VMHelper [as 别名]
# 或者: from nova.virt.xenapi.vm_utils.VMHelper import unplug_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())
开发者ID:rackerlabs,项目名称:reddwarf,代码行数:32,代码来源:volumeops.py


注:本文中的nova.virt.xenapi.vm_utils.VMHelper.unplug_vbd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。