本文整理汇总了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
示例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
示例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