User Tools

Site Tools


soft:server-apps-notifications

Notifications Application

This pluggable app enables notifying users (via email) when predefined situations happens (e.g. an slice is going to expire, a node has become unavailable…).

Usage of notifications plugins

To enable the existent notifications (defined as plugins) you need to synchronize your database after enabling this application. You can follow two procedures:

  1. (A) Execute management command: python manage.py syncnotifications
  2. (B) Syncronize via web interface, visit http://localhost/admin/notifications/notification/sync-plugins/

Slice expiration

Warn slices admin that a slice is near to expire (by default 4 days before).

Node unavailable

Warn nodes admin that a node has become OFFLINE (by default after 1 day offline).

Node on safe state

Warn nodes admin that a node stays in SAFEafter a while (by default for 4 days).

Auto-discover

Automatically find resources registred on app/notifications.py modules. Examples:

# state/notifications.py
...
from notifications import Notification
 
class NodeNotAvailable(Notification):
    model = Node
    description = 'Notificate %s days after the node goes offline' % STATE_NODE_OFFLINE_WARNING.days
    verbose_name = 'Node not available notification'
    default_subject = 'Node {{ node.name }} appear OFFLINE for more than {{ exp_warn.days }} days'
    default_message = 'Your node {% url \'admin:nodes_node_change\' node.pk %} appear as offline.'
 
    def check_condition(self, obj):
        # define the condition that raises the notification
        return obj.state == 'offline'
 
    def get_recipients(self, obj):
        # return a list of user's emails to notify
        return ['admin@node']
 
    def get_context(self, obj):
        # pass extra context to render subject and message
        context = super(NodeNotAvailable, self).get_context(obj)
        context.update({...})
        return context
soft/server-apps-notifications.txt · Last modified: 2014/05/14 13:22 by santiago