Package Products :: Package ZenEvents :: Module ActionRule |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenEvents.ActionRule

     1  ##############################################################################
     2  #
     3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved.
     4  #
     5  # This content is made available according to terms specified in
     6  # License.zenoss under the directory where your Zenoss product is installed.
     7  #
     8  ##############################################################################
     9
    10
    11  import logging
    12  log = logging.getLogger("zen.ActionRule")
    13
    14  from Globals import InitializeClass
    15  from AccessControl import ClassSecurityInfo
    16
    17  from Products.ZenModel.ZenModelRM import ZenModelRM
    18  from Products.ZenRelations.RelSchema import *
    19  from Products.ZenEvents.EventFilter import EventFilter
    20
    21 -class ActionRule(ZenModelRM, EventFilter):
    22      """
    23      Rule applied to events that then executes an action on matching events.
    24      """
    25
    26      meta_type = "ActionRule"
    27
    28      where = "severity >= 4 and eventState = 0 and prodState = 1000"
    29      delay = 0
    30      repeatTime = 0
    31      action = "email"
    32      format = "[zenoss] %(device)s %(summary)s"
    33      body =  "Device: %(device)s\n" \
    34              "Component: %(component)s\n" \
    35              "Severity: %(severityString)s\n" \
    36              "Time: %(firstTime)s\n" \
    37              "Message:\n%(message)s\n" \
    38              "<a href=\"%(eventUrl)s\">Event Detail</a>\n" \
    39              "<a href=\"%(ackUrl)s\">Acknowledge</a>\n" \
    40              "<a href=\"%(deleteUrl)s\">Delete</a>\n" \
    41              "<a href=\"%(eventsUrl)s\">Device Events</a>\n"
    42      sendClear = True
    43      clearFormat = "[zenoss] CLEAR: %(device)s %(clearOrEventSummary)s"
    44      clearBody =  \
    45              "Event: '%(summary)s'\n" \
    46              "Cleared by: '%(clearSummary)s'\n" \
    47              "At: %(clearFirstTime)s\n" \
    48              "Device: %(device)s\n" \
    49              "Component: %(component)s\n" \
    50              "Severity: %(severityString)s\n" \
    51              "Message:\n%(message)s\n" \
    52              "<a href=\"%(undeleteUrl)s\">Undelete</a>\n"
    53      enabled = False
    54      actionTypes = ("page", "email")
    55      targetAddr = ""
    56      plainText = False
    57
    58      _properties = ZenModelRM._properties + (
    59          {'id':'where', 'type':'text', 'mode':'w'},
    60          {'id':'format', 'type':'text', 'mode':'w'},
    61          {'id':'body', 'type':'text', 'mode':'w'},
    62          {'id':'sendClear', 'type':'boolean', 'mode':'w'},
    63          {'id':'clearFormat', 'type':'text', 'mode':'w'},
    64          {'id':'clearBody', 'type':'text', 'mode':'w'},
    65          {'id':'delay', 'type':'int', 'mode':'w'},
    66          {'id':'action', 'type':'selection', 'mode':'w',
    67              'select_variable': 'actionTypes',},
    68          {'id':'enabled', 'type':'boolean', 'mode':'w'},
    69          {'id':'targetAddr', 'type':'string', 'mode':'w'},
    70          {'id':'repeatTime', 'type':'int', 'mode':'w'},
    71          {'id':'plainText', 'type':'boolean', 'mode':'w'},
    72      )
    73
    74      _relations = (
    75          ("windows", ToManyCont(ToOne,"Products.ZenEvents.ActionRuleWindow","actionRule")),
    76          )
    77
    78      security = ClassSecurityInfo()
    79
    80 -    def getUser(self):
    81          """Return the user this action is for.
    82          """
    83          return self.getPrimaryParent()
    84
    85 -    def getUserid(self):
    86          """Return the userid this action is for.
    87          """
    88          return self.getUser().getId()
    89
    90  InitializeClass(ActionRule)
    91