Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
            target_lun = data['target_lun']
        else:
            vdi_uuid = None

        # Introduce VDI  and attach VBD to VM
        try:
            vdi_ref = volume_utils.introduce_vdi(self._session, sr_ref,
                                                 vdi_uuid, target_lun)
        except volume_utils.StorageError, exc:
            LOG.exception(exc)
            self.forget_sr(uuid)
            raise Exception(
                _('Unable to create VDI on SR %(sr_ref)s for'
                  ' instance %(instance_name)s') % locals())

        dev_number = volume_utils.mountpoint_to_number(mountpoint)
        try:
            vbd_ref = vm_utils.create_vbd(self._session,
                                          vm_ref,
                                          vdi_ref,
                                          dev_number,
                                          bootable=False)
        except self._session.XenAPI.Failure, exc:
            LOG.exception(exc)
            self.forget_sr(uuid)
            raise Exception(
                _('Unable to use SR %(sr_ref)s for'
                  ' instance %(instance_name)s') % locals())

        try:
            self._session.call_xenapi("VBD.plug", vbd_ref)
Exemplo n.º 6
0
        elif 'target_lun' in data:
            target_lun = data['target_lun']
        else:
            vdi_uuid = None

        # Introduce VDI  and attach VBD to VM
        try:
            vdi_ref = volume_utils.introduce_vdi(self._session, sr_ref,
                                                 vdi_uuid, target_lun)
        except volume_utils.StorageError, exc:
            LOG.exception(exc)
            self.forget_sr(uuid)
            raise Exception(_('Unable to create VDI on SR %(sr_ref)s for'
                    ' instance %(instance_name)s') % locals())

        dev_number = volume_utils.mountpoint_to_number(mountpoint)
        try:
            vbd_ref = vm_utils.create_vbd(self._session, vm_ref, vdi_ref,
                                          dev_number, bootable=False)
        except self.XenAPI.Failure, exc:
            LOG.exception(exc)
            self.forget_sr(uuid)
            raise Exception(_('Unable to use SR %(sr_ref)s for'
                              ' instance %(instance_name)s') % locals())

        try:
            self._session.call_xenapi("VBD.plug", vbd_ref)
        except self.XenAPI.Failure, exc:
            LOG.exception(exc)
            self.forget_sr(uuid)
            raise Exception(_('Unable to attach volume to instance %s')