ironic.common.context module

class ironic.common.context.RequestContext(is_public_api=False, auth_token_info=None, **kwargs)[source]

Bases: RequestContext

Extends security contexts from the oslo.context library.

FROM_DICT_EXTRA_KEYS: ty.List[str] = ['auth_token_info']
ensure_thread_contain_context()[source]

Ensure threading contains context

For async/periodic tasks, the context of local thread is missing. Set it with request context and this is useful to log the request_id in log messages.

classmethod from_environ(environ, **kwargs)[source]

Load a context object from a request environment.

If keyword arguments are provided then they override the values in the request environment, injecting the kwarg arguments used by ironic, as unknown values are filtered out from the final context object in the base oslo.context library.

Parameters:

environ (dict) – The environment dictionary associated with a request.

to_dict()[source]

Return a dictionary of context attributes.

to_policy_values()[source]

A dictionary of context attributes to enforce policy with.

oslo.policy enforcement requires a dictionary of attributes representing the current logged in user on which it applies policy enforcement. This dictionary defines a standard list of attributes that should be available for enforcement across services.

It is expected that services will often have to override this method with either deprecated values or additional attributes used by that service specific policy.

ironic.common.context.get_admin_context()[source]

Create an administrator context.