Example #1
0
def send(stack, adjustment=None, adjustment_type=None, capacity=None, groupname=None, message="error", suffix=None):
    """Send autoscaling notifications to the configured notification driver."""

    # see: https://wiki.openstack.org/wiki/SystemUsageData

    event_type = "%s.%s" % ("autoscaling", suffix)
    body = engine_api.format_notification_body(stack)
    body["adjustment_type"] = adjustment_type
    body["adjustment"] = adjustment
    body["capacity"] = capacity
    body["groupname"] = groupname
    body["message"] = message

    level = notification.get_default_level()
    if suffix == "error":
        level = notifier_api.ERROR

    notification.notify(stack.context, event_type, level, body)
Example #2
0
File: stack.py Project: rmery/heat
def send(stack):
    """Send usage notifications to the configured notification driver."""

    # The current notifications have a start/end:
    # see: https://wiki.openstack.org/wiki/SystemUsageData
    # so to be consistent we translate our status into a known start/end/error
    # suffix.
    level = notification.get_default_level()
    if stack.status == stack.IN_PROGRESS:
        suffix = "start"
    elif stack.status == stack.COMPLETE:
        suffix = "end"
    else:
        suffix = "error"
        level = notification.ERROR

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

    notification.notify(stack.context, event_type, level, engine_api.format_notification_body(stack))
Example #3
0
def send(stack):
    """Send usage notifications to the configured notification driver."""

    # The current notifications have a start/end:
    # see: https://wiki.openstack.org/wiki/SystemUsageData
    # so to be consistent we translate our status into a known start/end/error
    # suffix.
    level = notification.get_default_level()
    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' % ('stack', stack.action.lower(), suffix)

    notification.notify(stack.context, event_type, level,
                        engine_api.format_notification_body(stack))
Example #4
0
def send(stack,
         adjustment=None,
         adjustment_type=None,
         capacity=None,
         groupname=None,
         message='error',
         suffix=None):
    """Send autoscaling notifications to the configured notification driver."""

    # see: https://wiki.openstack.org/wiki/SystemUsageData

    event_type = '%s.%s' % ('autoscaling', suffix)
    body = engine_api.format_notification_body(stack)
    body['adjustment_type'] = adjustment_type
    body['adjustment'] = adjustment
    body['capacity'] = capacity
    body['groupname'] = groupname
    body['message'] = message

    level = notification.get_default_level()
    if suffix == 'error':
        level = notifier_api.ERROR

    notification.notify(stack.context, event_type, level, body)