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 Permissions 
 20  from Products.ZenModel.ZenModelRM import ZenModelRM 
 21  from Products.ZenModel.MaintenanceWindow import MaintenanceWindow 
 22  from Products.ZenRelations.RelSchema import * 
 23   
24 -def manage_addActionRuleWindow(context, id, REQUEST=None):
25 """Create an aciton rule""" 26 ed = ActionRuleWindow(id) 27 context._setObject(id, ed) 28 if REQUEST is not None: 29 REQUEST['RESPONSE'].redirect(context.absolute_url() + '/manage_main')
30 31 addActionRuleWindow = DTMLFile('dtml/addActionRuleWindow',globals()) 32
33 -class ActionRuleWindow(MaintenanceWindow):
34 35 backCrumb = 'editActionRuleSchedule' # FIXME 36 37 actionRule = None 38 39 factory_type_information = ( 40 { 41 'immediate_view' : 'actionRuleWindowDetail', 42 'actions' : 43 ( 44 { 'id' : 'status' 45 , 'name' : 'Status' 46 , 'action' : 'actionRuleWindowDetail' 47 , 'permissions' : ( Permissions.view, ) 48 }, 49 { 'id' : 'viewHistory' 50 , 'name' : 'Modifications' 51 , 'action' : 'viewHistory' 52 , 'permissions' : ( Permissions.view, ) 53 }, 54 ) 55 }, 56 ) 57 58 _relations = ( 59 ("actionRule", ToOne(ToManyCont,"Products.ZenEvents.ActionRule","windows")), 60 ) 61
62 - def target(self):
63 return self.actionRule()
64
65 - def begin(self, now = None):
66 self.target().enabled = True 67 if not now: 68 now = time.time() 69 self.started = now
70
71 - def end(self):
72 self.started = None 73 self.target().enabled = False
74
75 - def manage_editActionRuleWindow(self, 76 startDate='', 77 startHours='', 78 startMinutes='00', 79 durationDays='0', 80 durationHours='00', 81 durationMinutes='00', 82 repeat='Never', 83 enabled=True, 84 REQUEST=None, 85 **kw):
86 "Update the ActionRuleWindow from GUI elements" 87 args = locals().copy() 88 for name in 'self kw'.split(): del args[name] 89 result = self.manage_editMaintenanceWindow(**args) 90 try: 91 del self.startProductionState 92 except AttributeError: 93 pass 94 try: 95 del self.stopProductionState 96 except AttributeError: 97 pass 98 99 return result
100