示例#1
0
 def _delete_share(self, share, is_snapshot):
     if is_snapshot:
         dataset_name = self._make_snapshot_name(share)
     else:
         dataset_name = self._make_share_name(share)
     try:
         infinidat_filesystem = (
             self._get_infinidat_filesystem_by_name(dataset_name))
     except exception.ShareResourceNotFound:
         message = ("share %(share)s not found on Infinibox, skipping "
                    "delete")
         LOG.warning(message, {"share": share})
         return  # filesystem not found
     if infinidat_filesystem.has_children():
         # can't delete a filesystem that has a live snapshot
         if is_snapshot:
             raise exception.ShareSnapshotIsBusy(snapshot_name=dataset_name)
         else:
             reason = _("share has snapshots and cannot be deleted")
             raise exception.ShareBusyException(reason=reason)
     try:
         infinidat_export = self._get_export(infinidat_filesystem)
     except exception.ShareBackendException:
         # it's possible that the export has been deleted
         pass
     else:
         infinidat_export.safe_delete()
     infinidat_filesystem.safe_delete()
示例#2
0
文件: api.py 项目: wzhmei/manila
 def _check_is_share_busy(self, share):
     """Raises an exception if share is busy with an active task."""
     if share.is_busy:
         msg = _("Share %(share_id)s is busy as part of an active "
                 "task: %(task)s.") % {
                     'share_id': share['id'],
                     'task': share['task_state']
                 }
         raise exception.ShareBusyException(reason=msg)
示例#3
0
 def _unmount_device_with_retry():
     try:
         self._execute('umount', '-f', mount_path, run_as_root=True)
     except exception.ProcessExecutionError as exc:
         if 'is busy' in exc.stderr.lower():
             raise exception.ShareBusyException(
                 reason=share_or_snapshot['name'])
         elif 'not mounted' in exc.stderr.lower():
             if raise_if_missing:
                 LOG.error('Unable to find device: %s', exc)
                 raise
         else:
             LOG.error('Unable to umount: %s', exc)
             raise
示例#4
0
 def _unmount_device(self, share_or_snapshot):
     """Unmount the filesystem of a share or snapshot LV."""
     mount_path = self._get_mount_path(share_or_snapshot)
     if os.path.exists(mount_path):
         # umount, may be busy
         try:
             self._execute('umount', '-f', mount_path, run_as_root=True)
         except exception.ProcessExecutionError as exc:
             if 'device is busy' in six.text_type(exc):
                 raise exception.ShareBusyException(
                     reason=share_or_snapshot['name'])
             else:
                 LOG.error('Unable to umount: %s', exc)
                 raise
         # remove dir
         self._execute('rmdir', mount_path, run_as_root=True)
示例#5
0
 def _remove_export(self, ctx, share):
     """Removes an access rules for a share."""
     mount_path = self._get_mount_path(share)
     if os.path.exists(mount_path):
         # umount, may be busy
         try:
             self._execute('umount', '-f', mount_path, run_as_root=True)
         except exception.ProcessExecutionError as exc:
             if 'device is busy' in six.text_type(exc):
                 raise exception.ShareBusyException(reason=share['name'])
             else:
                 LOG.info(_LI('Unable to umount: %s'), exc)
         # remove dir
         try:
             os.rmdir(mount_path)
         except OSError:
             LOG.warning(_LW('Unable to delete %s'), mount_path)
示例#6
0
 def try_mount_volume():
     try:
         vserver_client.mount_volume(share_name)
     except netapp_api.NaApiError as e:
         undergoing_snap_init = 'snapmirror initialize'
         msg_args = {'name': share_name}
         if (e.code == netapp_api.EAPIERROR
                 and undergoing_snap_init in e.message):
             msg = _('The share %(name)s is undergoing a snapmirror '
                     'initialize. Will retry the operation.') % msg_args
             LOG.warning(msg)
             raise exception.ShareBusyException(reason=msg)
         else:
             msg = _("Unable to perform mount operation for the share "
                     "%(name)s. Caught an unexpected error. Not "
                     "retrying.") % msg_args
             raise exception.NetAppException(message=msg)
示例#7
0
 def _unmount_device(self, share_or_snapshot, raise_if_missing=True):
     """Unmount the filesystem of a share or snapshot LV."""
     mount_path = self._get_mount_path(share_or_snapshot)
     if os.path.exists(mount_path):
         # umount, may be busy
         try:
             self._execute('umount', '-f', mount_path, run_as_root=True)
         except exception.ProcessExecutionError as exc:
             if 'device is busy' in exc.stderr.lower():
                 raise exception.ShareBusyException(
                     reason=share_or_snapshot['name'])
             elif 'not mounted' in exc.stderr.lower():
                 if raise_if_missing:
                     LOG.error('Unable to find device: %s', exc)
                     raise
             else:
                 LOG.error('Unable to umount: %s', exc)
                 raise
         # remove dir
         self._execute('rmdir', mount_path, run_as_root=True)