예제 #1
0
def send(stack):
    """Send usage notifications to the configured notification driver."""

    publisher_id = CONF.default_publisher_id
    if publisher_id is None:
        publisher_id = notifier_api.publisher_id(SERVICE)

    # The current notifications have a start/end:
    # see: https://wiki.openstack.org/wiki/SystemUsageData
    # so to be consistant we translate our status into a known start/end/error
    # suffix.
    level = CONF.default_notification_level.upper()
    if stack.status == stack.IN_PROGRESS:
        suffix = 'start'
    elif stack.status == stack.COMPLETE:
        suffix = 'end'
    else:
        suffix = 'error'
        level = notifier_api.ERROR

    event_type = '%s.%s.%s' % (SERVICE, stack.action.lower(), suffix)

    notifier_api.notify(stack.context, publisher_id,
                        event_type, level,
                        engine_api.format_notification_body(stack))
예제 #2
0
def send(stack):
    """Send usage notifications to the configured notification driver."""

    publisher_id = CONF.default_publisher_id
    if publisher_id is None:
        publisher_id = notifier_api.publisher_id(SERVICE)

    # The current notifications have a start/end:
    # see: https://wiki.openstack.org/wiki/SystemUsageData
    # so to be consistant we translate our status into a known start/end/error
    # suffix.
    level = CONF.default_notification_level.upper()
    if stack.status == stack.IN_PROGRESS:
        suffix = 'start'
    elif stack.status == stack.COMPLETE:
        suffix = 'end'
    else:
        suffix = 'error'
        level = notifier_api.ERROR

    event_type = '%s.%s.%s' % (SERVICE, stack.action.lower(), suffix)

    notifier_api.notify(stack.context, publisher_id, event_type, level,
                        engine_api.format_notification_body(stack))
예제 #3
0
def _get_default_publisher():
    publisher_id = CONF.default_publisher_id
    if publisher_id is None:
        publisher_id = notifier_api.publisher_id(SERVICE)
    return publisher_id