コード例 #1
0
ファイル: volumeops.py プロジェクト: hanjinze/nova
    def _detach_vbd(self, vbd_ref, unplug=False):
        if unplug:
            vm_utils.unplug_vbd(self._session, vbd_ref)

        sr_ref = volume_utils.find_sr_from_vbd(self._session, vbd_ref)
        vm_utils.destroy_vbd(self._session, vbd_ref)

        # Forget SR only if not in use
        volume_utils.purge_sr(self._session, sr_ref)
コード例 #2
0
ファイル: volumeops.py プロジェクト: Chillisystems/nova
    def _detach_vbds_and_srs(self, vm_ref, vbd_refs):
        is_vm_shutdown = vm_utils.is_vm_shutdown(self._session, vm_ref)

        for vbd_ref in vbd_refs:
            # find sr before we destroy the vbd
            sr_ref = volume_utils.find_sr_from_vbd(self._session, vbd_ref)

            if not is_vm_shutdown:
                vm_utils.unplug_vbd(self._session, vbd_ref, vm_ref)

            vm_utils.destroy_vbd(self._session, vbd_ref)
            # Forget (i.e. disconnect) SR only if not in use
            volume_utils.purge_sr(self._session, sr_ref)
コード例 #3
0
ファイル: volumeops.py プロジェクト: A7Zulu/nova
        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 = volume_utils.mountpoint_to_number(mountpoint)
        try:
            vbd_ref = vm_utils.find_vbd_by_number(self._session, vm_ref,
                                                  device_number)
        except volume_utils.StorageError, exc:
            LOG.exception(exc)
            raise Exception(_('Unable to locate volume %s') % mountpoint)

        try:
            sr_ref = volume_utils.find_sr_from_vbd(self._session, vbd_ref)
            vm_utils.unplug_vbd(self._session, vbd_ref)
        except volume_utils.StorageError, exc:
            LOG.exception(exc)
            raise Exception(_('Unable to detach volume %s') % mountpoint)
        try:
            vm_utils.destroy_vbd(self._session, vbd_ref)
        except volume_utils.StorageError, exc:
            LOG.exception(exc)
            raise Exception(_('Unable to destroy vbd %s') % mountpoint)

        # Forget SR only if no other volumes on this host are using it
        try:
            volume_utils.purge_sr(self._session, sr_ref)
        except volume_utils.StorageError, exc:
            LOG.exception(exc)
            raise Exception(_('Error purging SR %s') % sr_ref)
コード例 #4
0
ファイル: volumeops.py プロジェクト: OpenStack-Kha/nova
        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 = volume_utils.mountpoint_to_number(mountpoint)
        try:
            vbd_ref = vm_utils.find_vbd_by_number(self._session, vm_ref,
                                                  device_number)
        except volume_utils.StorageError, exc:
            LOG.exception(exc)
            raise Exception(_('Unable to locate volume %s') % mountpoint)

        try:
            sr_ref = volume_utils.find_sr_from_vbd(self._session, vbd_ref)
            vm_utils.unplug_vbd(self._session, vbd_ref)
        except volume_utils.StorageError, exc:
            LOG.exception(exc)
            raise Exception(_('Unable to detach volume %s') % mountpoint)
        try:
            vm_utils.destroy_vbd(self._session, vbd_ref)
        except volume_utils.StorageError, exc:
            LOG.exception(exc)
            raise Exception(_('Unable to destroy vbd %s') % mountpoint)

        # Forget SR only if no other volumes on this host are using it
        try:
            volume_utils.purge_sr(self._session, sr_ref)
        except volume_utils.StorageError, exc:
            LOG.exception(exc)
            raise Exception(_('Error purging SR %s') % sr_ref)