Пример #1
0
    def _locked_selectfs(self, op, path):
        if op == 'create':
            command = [
                'selectfs', self.fs_name, '\n', 'ssc', '127.0.0.1',
                'console-context', '--evs', self.evs_id, 'mkdir', '-p', path
            ]
            try:
                self._execute(command)
            except processutils.ProcessExecutionError as e:
                if "Current file system invalid: VolumeNotFound" in e.stderr:
                    msg = _("Command to create directory %s failed due to "
                            "context change.") % path
                    LOG.debug(msg)
                    raise exception.HNASSSCContextChange(msg=msg)
                else:
                    msg = _("Failed to create directory %s.") % path
                    LOG.exception(msg)
                    raise exception.HNASBackendException(msg=msg)

        if op == 'delete':
            command = [
                'selectfs', self.fs_name, '\n', 'ssc', '127.0.0.1',
                'console-context', '--evs', self.evs_id, 'rmdir', path
            ]
            try:
                self._execute(command)
            except processutils.ProcessExecutionError as e:
                if 'DirectoryNotEmpty' in e.stderr:
                    msg = _("Share %s has more snapshots.") % path
                    LOG.debug(msg)
                    raise exception.HNASDirectoryNotEmpty(msg=msg)
                elif 'cannot remove' in e.stderr and 'NotFound' in e.stderr:
                    LOG.warning(
                        "Attempted to delete path %s but it does "
                        "not exist.", path)
                elif 'Current file system invalid: VolumeNotFound' in e.stderr:
                    msg = _("Command to delete empty directory %s failed due "
                            "to context change.") % path
                    LOG.debug(msg)
                    raise exception.HNASSSCContextChange(msg=msg)
                else:
                    msg = _("Failed to delete directory %s.") % path
                    LOG.exception(msg)
                    raise exception.HNASBackendException(msg=msg)
Пример #2
0
 def create_directory(self, dest_path):
     self._locked_selectfs('create', dest_path)
     if not self.check_directory(dest_path):
         msg = _("Command to create directory %(path)s was run in another "
                 "filesystem instead of %(fs)s.") % {
                     'path': dest_path,
                     'fs': self.fs_name,
                 }
         LOG.warning(msg)
         raise exception.HNASSSCContextChange(msg=msg)
Пример #3
0
 def delete_directory(self, path):
     try:
         self._locked_selectfs('delete', path)
     except exception.HNASDirectoryNotEmpty:
         pass
     else:
         if self.check_directory(path):
             msg = _("Command to delete empty directory %(path)s was run in"
                     " another filesystem instead of %(fs)s.") % {
                         'path': path,
                         'fs': self.fs_name,
                     }
             LOG.debug(msg)
             raise exception.HNASSSCContextChange(msg=msg)