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

Python policy.check_is_admin函数代码示例

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

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



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

示例1: get_bgp_peers

 def get_bgp_peers(self, context, fields=None, filters=None, sorts=None,
                   limit=None, marker=None, page_reverse=False):
     policy.check_is_admin(context)
     return super(BgpPlugin, self).get_bgp_peers(
                                              context, fields=fields,
                                              filters=filters, sorts=sorts,
                                              limit=limit, marker=marker,
                                              page_reverse=page_reverse)
开发者ID:paperandsoap,项目名称:neutron-dynamic-routing,代码行数:8,代码来源:bgp_plugin.py


示例2: delete_bgp_speaker

 def delete_bgp_speaker(self, context, bgp_speaker_id):
     policy.check_is_admin(context)
     hosted_bgp_dragents = self.get_dragents_hosting_bgp_speakers(
                                                          context,
                                                          [bgp_speaker_id])
     super(BgpPlugin, self).delete_bgp_speaker(context, bgp_speaker_id)
     for agent in hosted_bgp_dragents:
         self._bgp_rpc.bgp_speaker_removed(context,
                                           bgp_speaker_id,
                                           agent.host)
开发者ID:paperandsoap,项目名称:neutron-dynamic-routing,代码行数:10,代码来源:bgp_plugin.py


示例3: add_bgp_peer

 def add_bgp_peer(self, context, bgp_speaker_id, bgp_peer_info):
     policy.check_is_admin(context)
     ret_value = super(BgpPlugin, self).add_bgp_peer(context,
                                                     bgp_speaker_id,
                                                     bgp_peer_info)
     hosted_bgp_dragents = self.get_dragents_hosting_bgp_speakers(
                                                          context,
                                                          [bgp_speaker_id])
     for agent in hosted_bgp_dragents:
         self._bgp_rpc.bgp_peer_associated(context, bgp_speaker_id,
                                           ret_value['bgp_peer_id'],
                                           agent.host)
     return ret_value
开发者ID:paperandsoap,项目名称:neutron-dynamic-routing,代码行数:13,代码来源:bgp_plugin.py


示例4: __init__

    def __init__(self, user_id, tenant_id, is_admin=None, read_deleted="no",
                 roles=None, timestamp=None, **kwargs):
        """Object initialization.

        :param read_deleted: 'no' indicates deleted records are hidden, 'yes'
            indicates deleted records are visible, 'only' indicates that
            *only* deleted records are visible.
        """
        if kwargs:
            LOG.warn(_('Arguments dropped when creating '
                       'context: %s'), kwargs)
        super(ContextBase, self).__init__(user=user_id, tenant=tenant_id,
                                          is_admin=is_admin)
        self.read_deleted = read_deleted
        if not timestamp:
            timestamp = datetime.utcnow()
        self.timestamp = timestamp
        self._session = None
        self.roles = roles or []
        if self.is_admin is None:
            self.is_admin = policy.check_is_admin(self)
        elif self.is_admin:
            # Ensure context is populated with admin roles
            # TODO(salvatore-orlando): It should not be necessary
            # to populate roles in artificially-generated contexts
            # address in bp/make-authz-orthogonal
            admin_roles = policy.get_admin_roles()
            if admin_roles:
                self.roles = list(set(self.roles) | set(admin_roles))
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Neutron,代码行数:29,代码来源:context.py


示例5: __init__

    def __init__(self, user_id, tenant_id, is_admin=None, read_deleted="no",
                 roles=None, timestamp=None, load_admin_roles=True, **kwargs):
        """Object initialization.

        :param read_deleted: 'no' indicates deleted records are hidden, 'yes'
            indicates deleted records are visible, 'only' indicates that
            *only* deleted records are visible.
        """
        if kwargs:
            LOG.warn(_('Arguments dropped when creating '
                       'context: %s'), kwargs)
        super(ContextBase, self).__init__(user=user_id, tenant=tenant_id,
                                          is_admin=is_admin)
        self.read_deleted = read_deleted
        if not timestamp:
            timestamp = datetime.utcnow()
        self.timestamp = timestamp
        self._session = None
        self.roles = roles or []
        if self.is_admin is None:
            self.is_admin = policy.check_is_admin(self)
        elif self.is_admin and load_admin_roles:
            # Ensure context is populated with admin roles
            admin_roles = policy.get_admin_roles()
            if admin_roles:
                self.roles = list(set(self.roles) | set(admin_roles))
开发者ID:CampHarmony,项目名称:neutron,代码行数:26,代码来源:context.py


示例6: load_context

    def load_context(self, req):
        super(NeutronContextFilter, self).load_context(req)
        tenant_id = req.headers.get('X_TENANT_ID')
        user_id = req.headers.get('X_USER_ID')
        if tenant_id is None or user_id is None:
            if self.require_auth_info:
                return False
            # get_admin_context() does not provide a parameter to set
            # overwrite=True
            # set overwrite=True to avoid duplicate request-id's
            ctx = self.neutron_ctx.Context(user_id=None,
                                           tenant_id=None,
                                           is_admin=True,
                                           overwrite=True)
        else:
            # set overwrite=True to avoid duplicate request-id's
            ctx = self.neutron_ctx.Context(user_id=user_id,
                                           tenant_id=tenant_id,
                                           overwrite=True)
        self.context = ctx
        self._process_roles(req.headers.get('X_ROLES', ''))

        # By default, the normal neutron context will set is_advcsvc to True if
        # it is an admin context.  This resets it to what the actual policy
        # says it should be.  This must be done after _process_roles is called
        # because the policy check relies on the roles.
        # TODO(blogan): remove this if upstream changes the behavior
        # of is_advsvc to only depend on the policy.
        self.context.is_advsvc = policy.check_is_advsvc(self.context)
        # If not admin, check if current roles provide admin status.
        if not self.context.is_admin:
            self.context.is_admin = policy.check_is_admin(self.context)
        req.environ['neutron.context'] = self.context
        return True
开发者ID:roaet,项目名称:wafflehaus.neutron,代码行数:34,代码来源:neutron_context.py


示例7: __init__

    def __init__(self, user_id=None, tenant_id=None, is_admin=None,
                 timestamp=None, tenant_name=None, user_name=None,
                 is_advsvc=None, **kwargs):
        """Object initialization.

        :param overwrite: Set to False to ensure that the greenthread local
            copy of the index is not overwritten.
        """
        # NOTE(jamielennox): We maintain these arguments in order for tests
        # that pass arguments positionally.
        kwargs.setdefault('user', user_id)
        kwargs.setdefault('tenant', tenant_id)
        super(ContextBase, self).__init__(is_admin=is_admin, **kwargs)

        self.user_name = user_name
        self.tenant_name = tenant_name

        if not timestamp:
            timestamp = datetime.datetime.utcnow()
        self.timestamp = timestamp
        self.is_advsvc = is_advsvc
        if self.is_advsvc is None:
            self.is_advsvc = self.is_admin or policy.check_is_advsvc(self)
        if self.is_admin is None:
            self.is_admin = policy.check_is_admin(self)
开发者ID:cloudbase,项目名称:neutron,代码行数:25,代码来源:context.py


示例8: __init__

    def __init__(self, user_id, tenant_id, is_admin=None, roles=None,
                 timestamp=None, request_id=None, tenant_name=None,
                 user_name=None, overwrite=True, auth_token=None,
                 is_advsvc=None, **kwargs):
        """Object initialization.

        :param overwrite: Set to False to ensure that the greenthread local
            copy of the index is not overwritten.

        :param kwargs: Extra arguments that might be present, but we ignore
            because they possibly came in from older rpc messages.
        """
        super(ContextBase, self).__init__(auth_token=auth_token,
                                          user=user_id, tenant=tenant_id,
                                          is_admin=is_admin,
                                          request_id=request_id,
                                          overwrite=overwrite)
        self.user_name = user_name
        self.tenant_name = tenant_name

        if not timestamp:
            timestamp = datetime.datetime.utcnow()
        self.timestamp = timestamp
        self.roles = roles or []
        self.is_advsvc = is_advsvc
        if self.is_advsvc is None:
            self.is_advsvc = self.is_admin or policy.check_is_advsvc(self)
        if self.is_admin is None:
            self.is_admin = policy.check_is_admin(self)
开发者ID:cisco-openstack,项目名称:neutron,代码行数:29,代码来源:context.py


示例9: __init__

    def __init__(
        self,
        user_id,
        tenant_id,
        is_admin=None,
        read_deleted="no",
        roles=None,
        timestamp=None,
        load_admin_roles=True,
        request_id=None,
        tenant_name=None,
        user_name=None,
        overwrite=True,
        auth_token=None,
        **kwargs
    ):
        """Object initialization.

        :param read_deleted: 'no' indicates deleted records are hidden, 'yes'
            indicates deleted records are visible, 'only' indicates that
            *only* deleted records are visible.

        :param overwrite: Set to False to ensure that the greenthread local
            copy of the index is not overwritten.

        :param kwargs: Extra arguments that might be present, but we ignore
            because they possibly came in from older rpc messages.
        """
        super(ContextBase, self).__init__(
            auth_token=auth_token, user=user_id, tenant=tenant_id, is_admin=is_admin, request_id=request_id
        )
        self.user_name = user_name
        self.tenant_name = tenant_name

        self.read_deleted = read_deleted
        if not timestamp:
            timestamp = datetime.datetime.utcnow()
        self.timestamp = timestamp
        self._session = None
        self.roles = roles or []
        self.is_advsvc = policy.check_is_advsvc(self)
        if self.is_admin is None:
            self.is_admin = policy.check_is_admin(self)
        elif self.is_admin and load_admin_roles:
            # Ensure context is populated with admin roles
            admin_roles = policy.get_admin_roles()
            if admin_roles:
                self.roles = list(set(self.roles) | set(admin_roles))
        # Allow openstack.common.log to access the context
        if overwrite or not hasattr(local.store, "context"):
            local.store.context = self

        # Log only once the context has been configured to prevent
        # format errors.
        if kwargs:
            LOG.debug(_("Arguments dropped when creating " "context: %s"), kwargs)
开发者ID:asadoughi,项目名称:neutron,代码行数:56,代码来源:context.py


示例10: __init__

    def __init__(self, user_id, tenant_id, is_admin=None, read_deleted="no",
                 roles=None, timestamp=None, load_admin_roles=True,
                 request_id=None, tenant_name=None, user_name=None,
                 overwrite=True, auth_token=None, **kwargs):
        """Object initialization.

        :param read_deleted: 'no' indicates deleted records are hidden, 'yes'
            indicates deleted records are visible, 'only' indicates that
            *only* deleted records are visible.

        :param overwrite: Set to False to ensure that the greenthread local
            copy of the index is not overwritten.

        :param kwargs: Extra arguments that might be present, but we ignore
            because they possibly came in from older rpc messages.
        """
        super(ContextBase, self).__init__(auth_token=auth_token,
                                          user=user_id, tenant=tenant_id,
                                          is_admin=is_admin,
                                          request_id=request_id,
                                          overwrite=overwrite)
        self.user_name = user_name
        self.tenant_name = tenant_name

        self.read_deleted = read_deleted
        if not timestamp:
            timestamp = datetime.datetime.utcnow()
        self.timestamp = timestamp
        self._session = None
        self.roles = roles or []
        self.is_advsvc = policy.check_is_advsvc(self)
        if self.is_admin is None:
            self.is_admin = policy.check_is_admin(self)
        elif self.is_admin and load_admin_roles:
            # Ensure context is populated with admin roles
            admin_roles = policy.get_admin_roles()
            if admin_roles:
                self.roles = list(set(self.roles) | set(admin_roles))
开发者ID:CloudA,项目名称:neutron,代码行数:38,代码来源:context.py


示例11: list_bgp_speaker_on_dragent

 def list_bgp_speaker_on_dragent(self, context, agent_id):
     policy.check_is_admin(context)
     return super(BgpPlugin, self).list_bgp_speaker_on_dragent(context,
                                                               agent_id)
开发者ID:paperandsoap,项目名称:neutron-dynamic-routing,代码行数:4,代码来源:bgp_plugin.py


示例12: get_bgp_peer

 def get_bgp_peer(self, context, bgp_peer_id, fields=None):
     policy.check_is_admin(context)
     return super(BgpPlugin, self).get_bgp_peer(context,
                                                bgp_peer_id,
                                                fields=fields)
开发者ID:paperandsoap,项目名称:neutron-dynamic-routing,代码行数:5,代码来源:bgp_plugin.py


示例13: test_check_is_admin_with_admin_context_succeeds

 def test_check_is_admin_with_admin_context_succeeds(self):
     admin_context = context.get_admin_context()
     self.assertTrue(policy.check_is_admin(admin_context))
开发者ID:Intellifora,项目名称:neutron,代码行数:3,代码来源:test_policy.py


示例14: update_bgp_peer

 def update_bgp_peer(self, context, bgp_peer_id, bgp_peer):
     policy.check_is_admin(context)
     return super(BgpPlugin, self).update_bgp_peer(context,
                                                   bgp_peer_id,
                                                   bgp_peer)
开发者ID:paperandsoap,项目名称:neutron-dynamic-routing,代码行数:5,代码来源:bgp_plugin.py


示例15: delete_bgp_peer

 def delete_bgp_peer(self, context, bgp_peer_id):
     policy.check_is_admin(context)
     super(BgpPlugin, self).delete_bgp_peer(context, bgp_peer_id)
开发者ID:paperandsoap,项目名称:neutron-dynamic-routing,代码行数:3,代码来源:bgp_plugin.py


示例16: add_bgp_speaker_to_dragent

 def add_bgp_speaker_to_dragent(self, context, agent_id, speaker_id):
     policy.check_is_admin(context)
     super(BgpPlugin, self).add_bgp_speaker_to_dragent(context,
                                                       agent_id,
                                                       speaker_id)
开发者ID:paperandsoap,项目名称:neutron-dynamic-routing,代码行数:5,代码来源:bgp_plugin.py


示例17: remove_bgp_speaker_from_dragent

 def remove_bgp_speaker_from_dragent(self, context, agent_id, speaker_id):
     policy.check_is_admin(context)
     super(BgpPlugin, self).remove_bgp_speaker_from_dragent(context,
                                                            agent_id,
                                                            speaker_id)
开发者ID:paperandsoap,项目名称:neutron-dynamic-routing,代码行数:5,代码来源:bgp_plugin.py


示例18: test_check_is_admin_with_user_context_fails

 def test_check_is_admin_with_user_context_fails(self):
     self.assertFalse(policy.check_is_admin(self.context))
开发者ID:21atlas,项目名称:neutron,代码行数:2,代码来源:test_policy.py


示例19: test_check_is_admin_with_admin_context_succeeds

 def test_check_is_admin_with_admin_context_succeeds(self):
     admin_context = context.get_admin_context()
     # explicitly set roles as this test verifies user credentials
     # with the policy engine
     admin_context.roles = ['admin']
     self.assertTrue(policy.check_is_admin(admin_context))
开发者ID:21atlas,项目名称:neutron,代码行数:6,代码来源:test_policy.py


示例20: list_dragent_hosting_bgp_speaker

 def list_dragent_hosting_bgp_speaker(self, context, speaker_id):
     policy.check_is_admin(context)
     return super(BgpPlugin, self).list_dragent_hosting_bgp_speaker(
                                                                context,
                                                                speaker_id)
开发者ID:paperandsoap,项目名称:neutron-dynamic-routing,代码行数:5,代码来源:bgp_plugin.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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