Example #1
0
 def _find_vbd(self, vm_ref, mountpoint):
     device_number = volume_utils.get_device_number(mountpoint)
     try:
         return vm_utils.find_vbd_by_number(self._session, vm_ref,
                                            device_number)
     except exception.StorageError:
         return
Example #2
0
    def detach_volume(self, connection_info, instance_name, mountpoint):
        """Detach volume storage to VM instance."""
        LOG.debug(
            _("Detach_volume: %(instance_name)s, %(mountpoint)s") % locals())

        device_number = volume_utils.get_device_number(mountpoint)
        vm_ref = vm_utils.vm_ref_or_raise(self._session, instance_name)

        try:
            vbd_ref = vm_utils.find_vbd_by_number(self._session, vm_ref,
                                                  device_number)
        except volume_utils.StorageError:
            # NOTE(sirp): If we don't find the VBD then it must have been
            # detached previously.
            LOG.warn(
                _('Skipping detach because VBD for %(instance_name)s was'
                  ' not found') % locals())
            return

        # Unplug VBD if we're NOT shutdown
        unplug = not vm_utils._is_vm_shutdown(self._session, vm_ref)
        self._detach_vbd(vbd_ref, unplug=unplug)

        LOG.info(
            _('Mountpoint %(mountpoint)s detached from instance'
              ' %(instance_name)s') % locals())
Example #3
0
 def _find_vbd(self, vm_ref, mountpoint):
     device_number = volume_utils.get_device_number(mountpoint)
     try:
         return vm_utils.find_vbd_by_number(
                 self._session, vm_ref, device_number)
     except exception.StorageError:
         return
Example #4
0
    def detach_volume(self, connection_info, instance_name, mountpoint):
        """Detach volume storage to VM instance"""

        vm_ref = vm_utils.vm_ref_or_raise(self._session, 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)
Example #5
0
    def detach_volume(self, connection_info, instance_name, mountpoint):
        """Detach volume storage to VM instance"""

        vm_ref = vm_utils.vm_ref_or_raise(self._session, 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)
Example #6
0
 def detach_volume(self, connection_info, instance_name, mountpoint):
     """Detach volume storage to VM instance"""
     # Before we start, check that the VM exists
     vm_ref = vm_utils.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 = 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)
Example #7
0
 def detach_volume(self, connection_info, instance_name, mountpoint):
     """Detach volume storage to VM instance"""
     # Before we start, check that the VM exists
     vm_ref = vm_utils.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 = 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)
Example #8
0
    def detach_volume(self, connection_info, instance_name, mountpoint):
        """Detach volume storage to VM instance."""
        LOG.debug(_("Detach_volume: %(instance_name)s, %(mountpoint)s")
                % locals())

        device_number = volume_utils.get_device_number(mountpoint)
        vm_ref = vm_utils.vm_ref_or_raise(self._session, instance_name)

        vbd_ref = vm_utils.find_vbd_by_number(
                self._session, vm_ref, device_number)

        # Unplug VBD if we're NOT shutdown
        unplug = not vm_utils._is_vm_shutdown(self._session, vm_ref)
        self._detach_vbd(vbd_ref, unplug=unplug)

        LOG.info(_('Mountpoint %(mountpoint)s detached from instance'
                   ' %(instance_name)s') % locals())
Example #9
0
    def detach_volume(self, connection_info, instance_name, mountpoint):
        """Detach volume storage to VM instance."""
        LOG.debug(_("Detach_volume: %(instance_name)s, %(mountpoint)s") % locals())

        device_number = volume_utils.get_device_number(mountpoint)
        vm_ref = vm_utils.vm_ref_or_raise(self._session, instance_name)

        try:
            vbd_ref = vm_utils.find_vbd_by_number(self._session, vm_ref, device_number)
        except volume_utils.StorageError:
            # NOTE(sirp): If we don't find the VBD then it must have been
            # detached previously.
            LOG.warn(_("Skipping detach because VBD for %(instance_name)s was" " not found") % locals())
            return

        # Unplug VBD if we're NOT shutdown
        unplug = not vm_utils._is_vm_shutdown(self._session, vm_ref)
        self._detach_vbd(vbd_ref, unplug=unplug)

        LOG.info(_("Mountpoint %(mountpoint)s detached from instance" " %(instance_name)s") % locals())