コード例 #1
0
ファイル: share_manage.py プロジェクト: yuyuyu101/manila
 def _get_share_type_id(context, share_type):
     try:
         stype = share_types.get_share_type_by_name_or_id(context,
                                                          share_type)
         return stype['id']
     except exception.ShareTypeNotFound as e:
         raise exc.HTTPNotFound(explanation=six.text_type(e))
コード例 #2
0
    def _pools(self, req, action='index', enable_share_type=False):
        context = req.environ['manila.context']
        search_opts = {}
        search_opts.update(req.GET)

        if enable_share_type:
            req_share_type = search_opts.pop('share_type', None)
            if req_share_type:
                try:
                    share_type = share_types.get_share_type_by_name_or_id(
                        context, req_share_type)

                    search_opts['capabilities'] = share_type.get('extra_specs',
                                                                 {})
                except exception.ShareTypeNotFound:
                    msg = _("Share type %s not found.") % req_share_type
                    raise exc.HTTPBadRequest(explanation=msg)

        try:
            pools = self.scheduler_api.get_pools(context,
                                                 filters=search_opts,
                                                 cached=True)
        except exception.NotAuthorized:
            raise exc.HTTPForbidden()
        detail = (action == 'detail')
        return self._view_builder.pools(pools, detail=detail)
コード例 #3
0
ファイル: scheduler_stats.py プロジェクト: openstack/manila
    def _pools(self, req, action='index', enable_share_type=False):
        context = req.environ['manila.context']
        search_opts = {}
        search_opts.update(req.GET)

        if enable_share_type:
            req_share_type = search_opts.pop('share_type', None)
            if req_share_type:
                try:
                    share_type = share_types.get_share_type_by_name_or_id(
                        context, req_share_type)

                    search_opts['capabilities'] = share_type.get('extra_specs',
                                                                 {})
                except exception.ShareTypeNotFound:
                    msg = _("Share type %s not found.") % req_share_type
                    raise exc.HTTPBadRequest(explanation=msg)

        pools = self.scheduler_api.get_pools(context, filters=search_opts,
                                             cached=True)
        detail = (action == 'detail')
        return self._view_builder.pools(pools, detail=detail)