Пример #1
0
    def test_update_access_not_found_exception(self):
        access1 = {
            'access_type': 'ip',
            'access_to': '188.100.20.10',
            'access_level': 'ro'
        }
        access2 = {
            'access_type': 'something',
            'access_to': '172.24.10.10',
            'access_level': 'rw'
        }
        access_list = [access1, access2]

        self.mock_object(
            self._driver, '_ensure_share',
            mock.Mock(side_effect=exception.HNASItemNotFoundException(
                msg='fake')))

        self.assertRaises(exception.ShareResourceNotFound,
                          self._driver.update_access,
                          'context',
                          share,
                          access_list,
                          add_rules=[],
                          delete_rules=[])
Пример #2
0
    def check_quota(self, vvol_name):
        command = ['quota', 'list', '--verbose', self.fs_name, vvol_name]
        output, err = self._execute(command)

        if 'No quotas matching specified filter criteria' in output:
            msg = (_("Virtual volume %s does not have any quota.") % vvol_name)
            raise exception.HNASItemNotFoundException(msg=msg)
Пример #3
0
    def _get_export(self, name, is_snapshot=False):
        if is_snapshot:
            name = '/snapshots/' + name
        else:
            name = '/shares/' + name

        command = ['nfs-export', 'list ', name]
        export_list = []
        try:
            output, err = self._execute(command)
        except processutils.ProcessExecutionError as e:
            if 'does not exist' in e.stderr:
                msg = _("Export %(name)s was not found in EVS "
                        "%(evs_id)s.") % {
                            'name': name,
                            'evs_id': self.evs_id,
                        }
                LOG.exception(msg)
                raise exception.HNASItemNotFoundException(msg=msg)
            else:
                msg = _("Could not list NFS exports by name %s.") % name
                LOG.exception(msg)
                raise exception.HNASBackendException(msg=msg)
        items = output.split('Export name')

        if items[0][0] == '\n':
            items.pop(0)

        for i in range(0, len(items)):
            export_list.append(Export(items[i]))
        return export_list
Пример #4
0
 def check_export(self, vvol_name):
     export = self._get_share_export(vvol_name)
     if (vvol_name in export[0].export_name
             and self.fs_name in export[0].file_system_label):
         return
     else:
         msg = _("Export %s does not exist.") % export[0].export_name
         raise exception.HNASItemNotFoundException(msg=msg)
Пример #5
0
 def check_export(self, vvol_name, is_snapshot=False):
     export = self._get_export(vvol_name, is_snapshot=is_snapshot)
     if (vvol_name in export[0].export_name
             and self.fs_name in export[0].file_system_label):
         return
     else:
         msg = _("Export %s does not exist.") % export[0].export_name
         LOG.error(msg)
         raise exception.HNASItemNotFoundException(msg=msg)
Пример #6
0
 def check_vvol(self, vvol_name):
     command = ['virtual-volume', 'list', '--verbose', self.fs_name,
                vvol_name]
     try:
         self._execute(command)
     except processutils.ProcessExecutionError:
         msg = _("Virtual volume %s does not exist.") % vvol_name
         LOG.exception(msg)
         raise exception.HNASItemNotFoundException(msg=msg)
Пример #7
0
 def check_fs_mounted(self):
     command = ['df', '-a', '-f', self.fs_name]
     output, err = self._execute(command)
     if "not found" in output:
         msg = (_("Filesystem %s does not exist or it is not available "
                  "in the current EVS context.") % self.fs_name)
         raise exception.HNASItemNotFoundException(msg=msg)
     else:
         line = output.split('\n')
         fs = Filesystem(line[3])
         return fs.mounted
Пример #8
0
 def check_fs_mounted(self):
     fs_list = self._get_filesystem_list()
     for i in range(0, len(fs_list)):
         if fs_list[i].name == self.fs_name:
             if fs_list[i].state == 'Mount':
                 return True
             else:
                 return False
     msg = (_("Filesystem %s does not exist or it is not available "
              "in the current EVS context.") % self.fs_name)
     raise exception.HNASItemNotFoundException(msg=msg)
Пример #9
0
    def check_cifs(self, vvol_name):
        output = self._cifs_list(vvol_name)

        cifs_share = CIFSShare(output)

        if self.fs_name != cifs_share.fs:
            msg = _("CIFS share %(share)s is not located in "
                    "configured filesystem "
                    "%(fs)s.") % {'share': vvol_name,
                                  'fs': self.fs_name}
            LOG.error(msg)
            raise exception.HNASItemNotFoundException(msg=msg)
Пример #10
0
    def get_share_usage(self, share_id):
        command = ['quota', 'list', self.fs_name, share_id]
        output, err = self._execute(command)

        quota = Quota(output)

        if quota.usage is None:
            msg = (_("Virtual volume %s does not have any quota.") % share_id)
            raise exception.HNASItemNotFoundException(msg=msg)
        else:
            bytes_usage = strutils.string_to_bytes(
                six.text_type(quota.usage) + quota.usage_unit)
            return bytes_usage / units.Gi
Пример #11
0
    def check_quota(self, vvol_name):
        command = ['quota', 'list', '--verbose', self.fs_name, vvol_name]
        try:
            output, err = self._execute(command)

        except processutils.ProcessExecutionError:
            msg = _("Could not check quota of vvol %s.") % vvol_name
            LOG.exception(msg)
            raise exception.HNASBackendException(msg=msg)

        if 'No quotas matching specified filter criteria' in output:
            msg = _("Virtual volume %s does not have any"
                    " quota.") % vvol_name
            LOG.error(msg)
            raise exception.HNASItemNotFoundException(msg=msg)
Пример #12
0
Файл: ssh.py Проект: vkmc/manila
    def _cifs_list(self, vvol_name):
        command = ['cifs-share', 'list', vvol_name]
        try:
            output, err = self._execute(command)
        except processutils.ProcessExecutionError as e:
            if 'does not exist' in e.stderr:
                msg = _("CIFS share %(share)s was not found in EVS "
                        "%(evs_id)s") % {
                            'share': vvol_name,
                            'evs_id': self.evs_id
                        }
                raise exception.HNASItemNotFoundException(msg=msg)
            else:
                raise

        return output
Пример #13
0
    def _get_share_export(self, share_id):
        share_id = '/shares/' + share_id
        command = ['nfs-export', 'list ', share_id]
        export_list = []
        try:
            output, err = self._execute(command)
        except processutils.ProcessExecutionError as e:
            if 'does not exist' in e.stderr:
                msg = _("Export %(share)s was not found in EVS "
                        "%(evs_id)s") % {'share': share_id,
                                         'evs_id': self.evs_id}
                raise exception.HNASItemNotFoundException(msg=msg)
            else:
                raise
        items = output.split('Export name')

        if items[0][0] == '\n':
            items.pop(0)

        for i in range(0, len(items)):
            export_list.append(Export(items[i]))
        return export_list
Пример #14
0
    def _get_share_export(self, share_id):
        share_id = '/shares/' + share_id
        command = ['nfs-export', 'list ', share_id]
        output, err = self._execute(command)
        export_list = []

        if 'No exports are currently configured' in output:
            msg = _("Export %(share)s was not found in EVS "
                    "%(evs_id)s") % {
                        'share': share_id,
                        'evs_id': self.evs_id
                    }
            raise exception.HNASItemNotFoundException(msg=msg)
        else:
            items = output.split('Export name')

            if items[0][0] == '\n':
                items.pop(0)

            for i in range(0, len(items)):
                export_list.append(Export(items[i]))
            return export_list