keystone.notifications module

OpenStack Identity Service 资源通知模块。

keystone.notifications.ACTIONS = ('created', 'deleted', 'disabled', 'updated', 'internal')

资源上的操作。

class keystone.notifications.Audit[source]

基类: object

审计通知函数命名空间。

这是一个命名空间对象,包含所有直接通知函数,用于 Manager 方法。

classmethod added_to(target_type, target_id, actor_type, actor_id, initiator=None, public=True, reason=None)[source]
classmethod created(resource_type, resource_id, initiator=None, public=True, reason=None)[source]
classmethod deleted(resource_type, resource_id, initiator=None, public=True, reason=None)[source]
classmethod disabled(resource_type, resource_id, initiator=None, public=True, reason=None)[source]
classmethod internal(resource_type, resource_id, reason=None)[source]
classmethod removed_from(target_type, target_id, actor_type, actor_id, initiator=None, public=True, reason=None)[source]
classmethod updated(resource_type, resource_id, initiator=None, public=True, reason=None)[source]
class keystone.notifications.CadfNotificationWrapper(operation)[source]

基类: object

发送 CADF 事件通知,用于各种方法。

此函数仅用于身份验证事件。 其 actionevent_type 在下面规定。

  • action: authenticate

  • event_type: identity.authenticate

发送 CADF 通知,用于诸如身份验证是否成功之类的事件。

参数:

operation – 正在执行的身份验证相关操作

class keystone.notifications.CadfRoleAssignmentNotificationWrapper(operation)[source]

基类: object

发送 role_assignment 方法的 CADF 通知。

此函数仅用于角色分配事件。 其 actionevent_type 在下面规定。

  • action: created.role_assignmentdeleted.role_assignment

  • event_type: identity.role_assignment.created

    identity.role_assignment.deleted

如果包装的方法未引发 Exception(例如 keystone.exception.NotFound),则发送 CADF 通知。

参数:

operation – 来自 ACTIONS 的值之一 (created 或 deleted)

ROLE_ASSIGNMENT = 'role_assignment'
keystone.notifications.build_audit_initiator()[source]

描述当前已身份验证上下文的 pyCADF 发起者。

keystone.notifications.clear_subscribers()[source]

清空订阅者字典。

这有效地停止了通知,因为将没有订阅者可以发布到。

keystone.notifications.emit_event

CadfNotificationWrapper 的别名

keystone.notifications.invalidate_token_cache_notification(reason)[source]

用于使 token 缓存失效的特定通知。

参数:

reason (string) – 使 token 缓存失效的具体原因。

keystone.notifications.listener(cls)[source]

一个类装饰器,用于声明一个类作为通知监听器。

一个通知监听器必须通过定义 event_callbacks 属性或属性来指定它感兴趣的事件。 event_callbacks 是一个字典,其中键是事件类型,值是包含资源类型到回调的映射的字典。

ACTIONS 包含当前支持的事件的常量。 目前没有单个位置可以找到资源类型的常量。

示例

@listener
class Something(object):
    def __init__(self):
        self.event_callbacks = {
            notifications.ACTIONS.created: {
                'user': self._user_created_callback
            },
            notifications.ACTIONS.deleted: {
                'project': [
                    self._project_deleted_callback,
                    self._do_cleanup,
                ]
            },
        }
keystone.notifications.notify_event_callbacks(service, resource_type, operation, payload)[source]

向已注册的扩展发送通知。

keystone.notifications.register_event_callback(event, resource_type, callbacks)[source]

将每个回调与事件注册。

参数:
  • event (keystone.notifications.ACTIONS) – 正在注册的操作

  • resource_type (str) – 正在操作的资源类型

  • callbacks (list) – 要与事件注册的回调项

引发:
  • ValueError – 如果事件不是有效的 ACTION

  • TypeError – 如果回调不可调用

keystone.notifications.reset_notifier()[source]

重置通知内部状态。

这仅用于测试目的。

keystone.notifications.role_assignment

CadfRoleAssignmentNotificationWrapper 的别名

keystone.notifications.send_saml_audit_notification(action, user_id, group_ids, identity_provider, protocol, token_id, outcome)[source]

发送通知,以告知观察者 SAML 事件。

参数:
  • action (str) – 正在审计的操作

  • user_id (str) – 来自 Keystone token 的用户 ID

  • group_ids (list) – 来自 Keystone token 的 Group ID 列表

  • identity_provider (str or None) – 来自 Keystone token 的 IdP 的 ID

  • protocol (str) – 来自 Keystone token 的 IdP 的协议 ID

  • token_id (str or None) – 来自 Keystone token 的 audit_id

  • outcome (str) – pycadf.cadftaxonomy 的其中之一