• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python policy.check函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中quantum.policy.check函数的典型用法代码示例。如果您正苦于以下问题:Python check函数的具体用法?Python check怎么用?Python check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了check函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _items

 def _items(self, request, do_authz=False, parent_id=None):
     """Retrieves and formats a list of elements of the requested entity"""
     # NOTE(salvatore-orlando): The following ensures that fields which
     # are needed for authZ policy validation are not stripped away by the
     # plugin before returning.
     original_fields, fields_to_add = self._do_field_list(_fields(request))
     kwargs = {'filters': _filters(request, self._attr_info),
               'fields': original_fields}
     if parent_id:
         kwargs[self._parent_id_name] = parent_id
     obj_getter = getattr(self._plugin, self._plugin_handlers[self.LIST])
     obj_list = obj_getter(request.context, **kwargs)
     # Check authz
     if do_authz:
         # FIXME(salvatore-orlando): obj_getter might return references to
         # other resources. Must check authZ on them too.
         # Omit items from list that should not be visible
         obj_list = [obj for obj in obj_list
                     if policy.check(request.context,
                                     self._plugin_handlers[self.SHOW],
                                     obj,
                                     plugin=self._plugin)]
     return {self._collection: [self._view(obj,
                                           fields_to_strip=fields_to_add)
                                for obj in obj_list]}
开发者ID:alexpilotti,项目名称:quantum,代码行数:25,代码来源:base.py


示例2: _check_service_type_view_auth

 def _check_service_type_view_auth(self, context, service_type):
     # FIXME(salvatore-orlando): This should be achieved via policy
     # engine without need for explicit checks in manager code.
     # Also, the policy in this way does not make a lot of sense
     return policy.check(context,
                         "extension:service_type:view_extended",
                         service_type)
开发者ID:JunPark,项目名称:quantum,代码行数:7,代码来源:servicetype_db.py


示例3: _check_portbindings_view_auth

 def _check_portbindings_view_auth(self, context, port):
     #TODO(salv-orlando): Remove this as part of bp/make-authz-orthogonal
     keys_to_delete = []
     for key in port:
         if key.startswith('binding'):
             policy_rule = "get_port:%s" % key
             if not policy.check(context, policy_rule, port):
                 keys_to_delete.append(key)
     for key in keys_to_delete:
         del port[key]
     return port
开发者ID:alanmeadows,项目名称:quantum,代码行数:11,代码来源:portbindings_db.py


示例4: _items

    def _items(self, request, do_authz=False):
        """Retrieves and formats a list of elements of the requested entity"""
        kwargs = {"filters": filters(request), "verbose": verbose(request), "fields": fields(request)}

        obj_getter = getattr(self._plugin, "get_%s" % self._collection)
        obj_list = obj_getter(request.context, **kwargs)

        # Check authz
        if do_authz:
            # Omit items from list that should not be visible
            obj_list = [obj for obj in obj_list if policy.check(request.context, "get_%s" % self._resource, obj)]

        return {self._collection: [self._view(obj) for obj in obj_list]}
开发者ID:harspras,项目名称:openstack-catalyst,代码行数:13,代码来源:base.py


示例5: _items

    def _items(self, request, do_authz=False, parent_id=None):
        """Retrieves and formats a list of elements of the requested entity"""
        # NOTE(salvatore-orlando): The following ensures that fields which
        # are needed for authZ policy validation are not stripped away by the
        # plugin before returning.
        original_fields, fields_to_add = self._do_field_list(
            api_common.list_args(request, 'fields'))
        filters = api_common.get_filters(request, self._attr_info,
                                         ['fields', 'sort_key', 'sort_dir',
                                          'limit', 'marker', 'page_reverse'])
        kwargs = {'filters': filters,
                  'fields': original_fields}
        sorting_helper = self._get_sorting_helper(request)
        pagination_helper = self._get_pagination_helper(request)
        sorting_helper.update_args(kwargs)
        sorting_helper.update_fields(original_fields, fields_to_add)
        pagination_helper.update_args(kwargs)
        pagination_helper.update_fields(original_fields, fields_to_add)
        if parent_id:
            kwargs[self._parent_id_name] = parent_id
        obj_getter = getattr(self._plugin, self._plugin_handlers[self.LIST])
        obj_list = obj_getter(request.context, **kwargs)
        obj_list = sorting_helper.sort(obj_list)
        obj_list = pagination_helper.paginate(obj_list)

        # Check authz
        if do_authz:
            # FIXME(salvatore-orlando): obj_getter might return references to
            # other resources. Must check authZ on them too.
            # Omit items from list that should not be visible
            obj_list = [obj for obj in obj_list
                        if policy.check(request.context,
                                        self._plugin_handlers[self.SHOW],
                                        obj,
                                        plugin=self._plugin)]
        collection = {self._collection:
                      [self._view(obj,
                                  fields_to_strip=fields_to_add)
                       for obj in obj_list]}
        pagination_links = pagination_helper.get_links(obj_list)
        if pagination_links:
            collection[self._collection + "_links"] = pagination_links

        return collection
开发者ID:AmirolAhmad,项目名称:quantum,代码行数:44,代码来源:base.py


示例6: _items

    def _items(self, request, do_authz=False):
        """Retrieves and formats a list of elements of the requested entity"""
        # NOTE(salvatore-orlando): The following ensures that fields which
        # are needed for authZ policy validation are not stripped away by the
        # plugin before returning.
        original_fields, fields_to_add = self._do_field_list(fields(request))
        kwargs = {'filters': filters(request),
                  'verbose': verbose(request),
                  'fields': original_fields}
        obj_getter = getattr(self._plugin, "get_%s" % self._collection)
        obj_list = obj_getter(request.context, **kwargs)
        # Check authz
        if do_authz:
            # Omit items from list that should not be visible
            obj_list = [obj for obj in obj_list
                        if policy.check(request.context,
                                        "get_%s" % self._resource,
                                        obj)]

        return {self._collection: [self._view(obj,
                                              fields_to_strip=fields_to_add)
                                   for obj in obj_list]}
开发者ID:xchenum,项目名称:quantum-bug,代码行数:22,代码来源:base.py


示例7: _check_view_auth

 def _check_view_auth(self, context, resource, action):
     return policy.check(context, action, resource)
开发者ID:alexpilotti,项目名称:quantum,代码行数:2,代码来源:lb_quantum_plugin.py


示例8: _check_l3_view_auth

 def _check_l3_view_auth(self, context, network):
     return policy.check(context,
                         "extension:router:view",
                         network)
开发者ID:CiscoAS,项目名称:quantum,代码行数:4,代码来源:l3_db.py


示例9: _check_provider_view_auth

 def _check_provider_view_auth(self, context, network):
     return policy.check(context,
                         "extension:provider_network:view",
                         network)
开发者ID:riverbedstingray,项目名称:quantum,代码行数:4,代码来源:ovs_quantum_plugin.py


示例10: test_check_bad_action_noraise

 def test_check_bad_action_noraise(self):
     action = "example:denied"
     result = policy.check(self.context, action, self.target)
     self.assertEqual(result, False)
开发者ID:ykaneko,项目名称:quantum,代码行数:4,代码来源:test_policy.py



注:本文中的quantum.policy.check函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python policy.enforce函数代码示例发布时间:2022-05-26
下一篇:
Python ovs_db_v2.set_port_status函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap