Package ZenModel :: Module EventView
[hide private]
[frames] | no frames]

Source Code for Module ZenModel.EventView

  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.EventView") 
 15   
 16  from _mysql_exceptions import MySQLError 
 17   
 18  from AccessControl import ClassSecurityInfo 
 19  from Globals import InitializeClass 
 20  from Products.ZenUtils.FakeRequest import FakeRequest 
 21   
 22   
23 -class EventView(object):
24 25 security = ClassSecurityInfo() 26
27 - def getEventManager(self, table='status'):
28 """Return the current event manager for this object. 29 """ 30 if table=='history': 31 return self.ZenEventHistory 32 return self.ZenEventManager
33 34
35 - def getEventHistory(self):
36 """Return the current event history for this object. 37 """ 38 return self.ZenEventHistory
39 40
41 - def getJSONEventsInfo(self, offset=0, count=50, fields=[], 42 getTotalCount=True, 43 44 filter='', severity=2, state=1, 45 orderby='', REQUEST=None):
46 """Return the current event list for this managed entity. 47 """ 48 kwargs = locals(); del kwargs['self'] 49 return self.getEventManager().getJSONEventsInfo(self, **kwargs)
50 51
52 - def getJSONHistoryEventsInfo(self, offset=0, count=50, fields=[], 53 getTotalCount=True, 54 startdate=None, enddate=None, 55 filter='', severity=2, state=1, 56 orderby='', REQUEST=None):
57 """Return the current event list for this managed entity. 58 """ 59 kwargs = locals(); del kwargs['self'] 60 return self.getEventHistory().getJSONEventsInfo(self, **kwargs)
61 62
63 - def getJSONFields(self, history=False):
64 """Return the current event list for this managed entity. 65 """ 66 if history: return self.getEventHistory().getJSONFields(self) 67 else: return self.getEventManager().getJSONFields(self)
68 69
70 - def getStatus(self, statusclass=None, **kwargs):
71 """Return the status number for this device of class statClass. 72 """ 73 try: 74 return self.getEventManager().getStatusME(self, statusclass=statusclass, **kwargs) 75 except MySQLError: 76 log.exception("exception getting status") 77 return -1
78 79
80 - def getStatusString(self, statclass, **kwargs):
81 """Return the status number for this device of class statClass. 82 """ 83 return self.convertStatus(self.getStatus(statclass, **kwargs))
84 85
86 - def getEventSummary(self, severity=1, state=1, prodState=None):
87 """Return an event summary list for this managed entity. 88 """ 89 return self.getEventManager().getEventSummaryME(self, severity, state, prodState)
90 91
92 - def getEventOwnerList(self, severity=0, state=1):
93 """Return list of event owners for this mangaed entity. 94 """ 95 return self.getEventManager().getEventOwnerListME(self, severity, state)
96 97
98 - def getStatusImgSrc(self, status):
99 ''' Return the image source for a status number 100 ''' 101 return self.getEventManager().getStatusImgSrc(status)
102 103
104 - def getStatusCssClass(self, status):
105 """Return the css class for a status number. 106 """ 107 return self.getEventManager().getStatusCssClass(status)
108 109 110 security.declareProtected('Manage Events','manage_deleteEvents')
111 - def manage_deleteEvents(self, evids=(), REQUEST=None):
112 """Delete events form this managed entity. 113 """ 114 # If we pass REQUEST in to the getEventManager().manage_deleteEvents() 115 # call we don't get a proper refresh of the event console. It only 116 # works if self.callZenScreen() is called from here rather than down 117 # in the event manager. I'm not sure why. Using FakeResult to fetch 118 # the message seems like best workaround for now. 119 request = FakeRequest() 120 self.getEventManager().manage_deleteEvents(evids, request) 121 if REQUEST: 122 request.setMessage(REQUEST) 123 return self.callZenScreen(REQUEST)
124 125 126 #security.declareProtected('Manage Events','manage_deleteBatchEvents')
127 - def manage_deleteBatchEvents(self, selectstatus='none', goodevids=[], 128 badevids=[], filter='', 129 offset=0, count=50, fields=[], 130 getTotalCount=True, 131 startdate=None, enddate=None, 132 severity=2, state=1, orderby='', 133 REQUEST=None, **kwargs):
134 """Delete events form this managed entity. 135 """ 136 evids = self.getEventManager().getEventBatchME(self, 137 selectstatus=selectstatus, 138 goodevids=goodevids, 139 badevids=badevids, 140 filter=filter, 141 offset=offset, fields=fields, 142 getTotalCount=getTotalCount, 143 startdate=startdate, 144 enddate=enddate, severity=severity, 145 state=state, orderby=orderby, 146 **kwargs) 147 request = FakeRequest() 148 self.manage_deleteEvents(evids, request) 149 return request.get('message', '')
150 151 152 security.declareProtected('Manage Events','manage_undeleteEvents')
153 - def manage_undeleteEvents(self, evids=(), REQUEST=None):
154 """Delete events form this managed entity. 155 """ 156 request = FakeRequest() 157 self.getEventManager().manage_undeleteEvents(evids, request) 158 if REQUEST: 159 request.setMessage(REQUEST) 160 return self.callZenScreen(REQUEST)
161 162 163 #security.declareProtected('Manage Events','manage_undeleteBatchEvents')
164 - def manage_undeleteBatchEvents(self, selectstatus='none', goodevids=[], 165 badevids=[], filter='', 166 offset=0, count=50, fields=[], 167 getTotalCount=True, 168 startdate=None, enddate=None, 169 severity=2, state=1, orderby='', 170 REQUEST=None, **kwargs):
171 """Delete events form this managed entity. 172 Only called from event console, so uses FakeRequest to avoid 173 page rendering. 174 """ 175 evids = self.getEventHistory().getEventBatchME(self, 176 selectstatus=selectstatus, 177 goodevids=goodevids, 178 badevids=badevids, 179 filter=filter, 180 offset=offset, fields=fields, 181 getTotalCount=getTotalCount, 182 startdate=startdate, 183 enddate=enddate, severity=severity, 184 state=state, orderby=orderby, 185 **kwargs) 186 request = FakeRequest() 187 self.manage_undeleteEvents(evids, request) 188 return request.get('message', '')
189 190 191 security.declareProtected('Manage Events','manage_deleteHeartbeat')
192 - def manage_deleteHeartbeat(self, REQUEST=None):
193 """Delete events form this managed entity. 194 """ 195 dev = self.device() 196 if dev: 197 return self.getEventManager().manage_deleteHeartbeat(dev.id, REQUEST) 198 if REQUEST: 199 return self.callZenScreen(REQUEST)
200 201 202 security.declareProtected('Manage Events','manage_ackEvents')
203 - def manage_ackEvents(self, evids=(), REQUEST=None):
204 """Set event state form this managed entity. 205 """ 206 return self.getEventManager().manage_ackEvents(evids, REQUEST)
207 208 209 security.declareProtected('Manage Events','manage_ackBatchEvents')
210 - def manage_ackBatchEvents(self, selectstatus='none', goodevids=[], 211 badevids=[], filter='', 212 offset=0, count=50, fields=[], 213 getTotalCount=True, 214 startdate=None, enddate=None, 215 severity=2, state=1, orderby='', 216 REQUEST=None, **kwargs):
217 """Delete events form this managed entity. 218 Only called from event console, so uses FakeRequest to avoid 219 page rendering. 220 """ 221 evids = self.getEventManager().getEventBatchME(self, 222 selectstatus=selectstatus, 223 goodevids=goodevids, 224 badevids=badevids, 225 filter=filter, 226 offset=offset, fields=fields, 227 getTotalCount=getTotalCount, 228 startdate=startdate, 229 enddate=enddate, severity=severity, 230 state=state, orderby=orderby, 231 **kwargs) 232 request = FakeRequest() 233 self.manage_ackEvents(evids, request) 234 return request.get('message', '')
235 236 237 security.declareProtected('Manage Events','manage_setEventStates')
238 - def manage_setEventStates(self, eventState=None, evids=(), REQUEST=None):
239 """Set event state form this managed entity. 240 """ 241 return self.getEventManager().manage_setEventStates( 242 eventState, evids, REQUEST)
243 244 245 security.declareProtected('Manage Events','manage_createEventMap')
246 - def manage_createEventMap(self, eventClass=None, evids=(), 247 table='status', REQUEST=None):
248 """Create an event map from an event or list of events. 249 """ 250 screen = self.getEventManager(table).manage_createEventMap( 251 eventClass, evids, REQUEST) 252 if REQUEST: 253 if screen: return screen 254 return self.callZenScreen(REQUEST)
255 256 257 InitializeClass(EventView) 258