Package ZenEvents :: Module ActionRuleWindow
[hide private]
[frames] | no frames]

Source Code for Module ZenEvents.ActionRuleWindow

  1  ########################################################################### 
  2  # 
  3  # This program is part of Zenoss Core, an open source monitoring platform. 
  4  # Copyright (C) 2007, Zenoss Inc. 
  5  # 
  6  # This program is free software; you can redistribute it and/or modify it 
  7  # under the terms of the GNU General Public License version 2 as published by 
  8  # the Free Software Foundation. 
  9  # 
 10  # For complete information please visit: http://www.zenoss.com/oss/ 
 11  # 
 12  ########################################################################### 
 13  import logging 
 14  log = logging.getLogger("zen.ActionRuleWindow") 
 15   
 16  import time 
 17   
 18  from Globals import DTMLFile 
 19  from AccessControl import ClassSecurityInfo 
 20  from Products.ZenModel.ZenossSecurity import * 
 21  from Products.ZenModel.MaintenanceWindow import MaintenanceWindow 
 22  from Products.ZenRelations.RelSchema import * 
 23  from Products.ZenUtils.Utils import unused 
 24   
25 -def manage_addActionRuleWindow(context, id, REQUEST=None):
26 """Create an aciton rule""" 27 ed = ActionRuleWindow(id) 28 context._setObject(id, ed) 29 if REQUEST is not None: 30 REQUEST['RESPONSE'].redirect(context.absolute_url() + '/manage_main')
31 32 addActionRuleWindow = DTMLFile('dtml/addActionRuleWindow',globals()) 33
34 -class ActionRuleWindow(MaintenanceWindow):
35 36 backCrumb = 'editActionRuleSchedule' # FIXME 37 38 actionRule = None 39 40 factory_type_information = ( 41 { 42 'immediate_view' : 'actionRuleWindowDetail', 43 'actions' : 44 ( 45 { 'id' : 'status' 46 , 'name' : 'Status' 47 , 'action' : 'actionRuleWindowDetail' 48 , 'permissions' : ( ZEN_VIEW, ) 49 }, 50 { 'id' : 'viewHistory' 51 , 'name' : 'Modifications' 52 , 'action' : 'viewHistory' 53 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,) 54 }, 55 ) 56 }, 57 ) 58 59 _relations = ( 60 ("actionRule", ToOne(ToManyCont,"Products.ZenEvents.ActionRule","windows")), 61 ) 62 63 security = ClassSecurityInfo() 64
65 - def target(self):
66 return self.actionRule()
67
68 - def begin(self, now = None):
69 self.target().enabled = True 70 if not now: 71 now = time.time() 72 self.started = now
73
74 - def end(self):
75 self.started = None 76 self.target().enabled = False
77 78 security.declareProtected(ZEN_CHANGE_ALERTING_RULES, 'manage_editActionRuleWindow')
79 - def manage_editActionRuleWindow(self, 80 startDate='', 81 startHours='', 82 startMinutes='00', 83 durationDays='0', 84 durationHours='00', 85 durationMinutes='00', 86 repeat='Never', 87 enabled=True, 88 REQUEST=None, 89 **kw):
90 "Update the ActionRuleWindow from GUI elements" 91 unused(startDate, startHours, startMinutes, 92 durationDays, durationHours, durationMinutes, 93 repeat, kw, enabled) 94 args = locals().copy() 95 for name in 'self kw'.split(): del args[name] 96 result = self.manage_editMaintenanceWindow(**args) 97 try: 98 del self.startProductionState 99 except AttributeError: 100 pass 101 try: 102 del self.stopProductionState 103 except AttributeError: 104 pass 105 106 return result
107