예제 #1
0
파일: volumeops.py 프로젝트: hsluoyz/patron
    def find_bad_volumes(self, vm_ref):
        """Find any volumes with their connection severed.

        Certain VM operations (e.g. `VM.start`, `VM.reboot`, etc.) will not
        work when a VBD is present that points to a non-working volume. To work
        around this, we scan for non-working volumes and detach them before
        retrying a failed operation.
        """
        bad_devices = []
        vbd_refs = self._get_all_volume_vbd_refs(vm_ref)
        for vbd_ref in vbd_refs:
            sr_ref = volume_utils.find_sr_from_vbd(self._session, vbd_ref)

            try:
                # TODO(sirp): bug1152401 This relies on a 120 sec timeout
                # within XenServer, update this to fail-fast when this is fixed
                # upstream
                self._session.SR.scan(sr_ref)
            except self._session.XenAPI.Failure as exc:
                if exc.details[0] == 'SR_BACKEND_FAILURE_40':
                    device = self._session.VBD.get_device(vbd_ref)
                    bad_devices.append('/dev/%s' % device)
                else:
                    raise

        return bad_devices
예제 #2
0
    def find_bad_volumes(self, vm_ref):
        """Find any volumes with their connection severed.

        Certain VM operations (e.g. `VM.start`, `VM.reboot`, etc.) will not
        work when a VBD is present that points to a non-working volume. To work
        around this, we scan for non-working volumes and detach them before
        retrying a failed operation.
        """
        bad_devices = []
        vbd_refs = self._get_all_volume_vbd_refs(vm_ref)
        for vbd_ref in vbd_refs:
            sr_ref = volume_utils.find_sr_from_vbd(self._session, vbd_ref)

            try:
                # TODO(sirp): bug1152401 This relies on a 120 sec timeout
                # within XenServer, update this to fail-fast when this is fixed
                # upstream
                self._session.SR.scan(sr_ref)
            except self._session.XenAPI.Failure as exc:
                if exc.details[0] == 'SR_BACKEND_FAILURE_40':
                    device = self._session.VBD.get_device(vbd_ref)
                    bad_devices.append('/dev/%s' % device)
                else:
                    raise

        return bad_devices
예제 #3
0
파일: volumeops.py 프로젝트: hsluoyz/patron
    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)
예제 #4
0
    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)