コード例 #1
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 = 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)
コード例 #2
0
ファイル: volumeops.py プロジェクト: wendy-king/x7_venv
 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 = 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)
コード例 #3
0
        if 'vdi_uuid' in data:
            vdi_uuid = data['vdi_uuid']
        else:
            vdi_uuid = None

        # Introduce VDI  and attach VBD to VM
        try:
            vdi_ref = VolumeHelper.introduce_vdi(self._session, sr_ref,
                                                 vdi_uuid)
        except 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 = VolumeHelper.mountpoint_to_number(mountpoint)
        try:
            vbd_ref = VolumeHelper.create_vbd(self._session,
                                              vm_ref,
                                              vdi_ref,
                                              dev_number,
                                              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:
コード例 #4
0
ファイル: volumeops.py プロジェクト: wendy-king/x7_venv
            vdi_uuid = data['vdi_uuid']
        else:
            vdi_uuid = None

        # Introduce VDI  and attach VBD to VM
        try:
            vdi_ref = VolumeHelper.introduce_vdi(self._session, sr_ref,
                                                 vdi_uuid)
        except 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 = VolumeHelper.mountpoint_to_number(mountpoint)
        try:
            vbd_ref = VolumeHelper.create_vbd(self._session, vm_ref, vdi_ref,
                                              dev_number, 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)