当前位置: 首页>>代码示例>>Python>>正文


Python DesignateContext.sudo方法代码示例

本文整理汇总了Python中designate.context.DesignateContext.sudo方法的典型用法代码示例。如果您正苦于以下问题:Python DesignateContext.sudo方法的具体用法?Python DesignateContext.sudo怎么用?Python DesignateContext.sudo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在designate.context.DesignateContext的用法示例。


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

示例1: process_request

# 需要导入模块: from designate.context import DesignateContext [as 别名]
# 或者: from designate.context.DesignateContext import sudo [as 别名]
    def process_request(self, request):
        headers = request.headers

        try:
            if headers['X-Identity-Status'] is 'Invalid':
                #TODO(graham) fix the return to use non-flask resources
                return flask.Response(status=401)
        except KeyError:
            #If the key is valid, Keystone does not include this header at all
            pass

        roles = headers.get('X-Roles').split(',')

        context = DesignateContext(auth_token=headers.get('X-Auth-Token'),
                                   user=headers.get('X-User-ID'),
                                   tenant=headers.get('X-Tenant-ID'),
                                   roles=roles)

        # Store the context where oslo-log exepcts to find it.
        local.store.context = context

        # Attempt to sudo, if requested.
        sudo_tenant_id = headers.get('X-Designate-Sudo-Tenant-ID', None)

        if sudo_tenant_id and (uuidutils.is_uuid_like(sudo_tenant_id)
                               or sudo_tenant_id.isdigit()):
            context.sudo(sudo_tenant_id)

        # Attach the context to the request environment
        request.environ['context'] = context
开发者ID:vinod-m,项目名称:designate,代码行数:32,代码来源:middleware.py

示例2: process_request

# 需要导入模块: from designate.context import DesignateContext [as 别名]
# 或者: from designate.context.DesignateContext import sudo [as 别名]
    def process_request(self, request):
        headers = request.headers

        roles = headers.get('X-Roles').split(',')

        context = DesignateContext(auth_token=headers.get('X-Auth-Token'),
                                   user=headers.get('X-User-ID'),
                                   tenant=headers.get('X-Tenant-ID'),
                                   roles=roles)

        # Store the context where oslo-log exepcts to find it.
        local.store.context = context

        # Attempt to sudo, if requested.
        sudo_tenant_id = headers.get('X-Designate-Sudo-Tenant-ID', None)

        if sudo_tenant_id and (uuidutils.is_uuid_like(sudo_tenant_id)
                               or sudo_tenant_id.isdigit()):
            context.sudo(sudo_tenant_id)

        # Attach the context to the request environment
        request.environ['context'] = context
开发者ID:butangero,项目名称:designate,代码行数:24,代码来源:middleware.py

示例3: process_request

# 需要导入模块: from designate.context import DesignateContext [as 别名]
# 或者: from designate.context.DesignateContext import sudo [as 别名]
    def process_request(self, request):
        headers = request.headers

        try:
            if headers["X-Identity-Status"] is "Invalid":
                # TODO(graham) fix the return to use non-flask resources
                return flask.Response(status=401)
        except KeyError:
            # If the key is valid, Keystone does not include this header at all
            pass

        if headers.get("X-Service-Catalog"):
            catalog = json.loads(headers.get("X-Service-Catalog"))
        else:
            catalog = None

        roles = headers.get("X-Roles").split(",")

        context = DesignateContext(
            auth_token=headers.get("X-Auth-Token"),
            user=headers.get("X-User-ID"),
            tenant=headers.get("X-Tenant-ID"),
            roles=roles,
            service_catalog=catalog,
        )

        # Store the context where oslo-log exepcts to find it.
        local.store.context = context

        # Attempt to sudo, if requested.
        sudo_tenant_id = headers.get("X-Designate-Sudo-Tenant-ID", None)

        if sudo_tenant_id and (uuidutils.is_uuid_like(sudo_tenant_id) or sudo_tenant_id.isdigit()):
            context.sudo(sudo_tenant_id)

        # Attach the context to the request environment
        request.environ["context"] = context
开发者ID:redhat-cip,项目名称:debian-designate,代码行数:39,代码来源:middleware.py


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