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

Source Code for Module ZenModel.MaintenanceWindowable

 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  """ 
14  MaintenanceWindowable.py 
15   
16  Created by Marc Irlandez on 2007-04-05. 
17  """ 
18  from AccessControl import ClassSecurityInfo 
19  from Globals import InitializeClass 
20  from ZenossSecurity import * 
21  from MaintenanceWindow import MaintenanceWindow 
22  from Products.ZenUtils.Utils import prepId 
23   
24 -class MaintenanceWindowable:
25 26 security = ClassSecurityInfo() 27 28 security.declareProtected(ZEN_MAINTENANCE_WINDOW_VIEW, 29 'getMaintenanceWindows')
30 - def getMaintenanceWindows(self):
31 "Get the Maintenance Windows on this device" 32 return self.maintenanceWindows.objectValuesAll()
33 34 security.declareProtected(ZEN_MAINTENANCE_WINDOW_EDIT, 35 'manage_addMaintenanceWindow')
36 - def manage_addMaintenanceWindow(self, newId=None, REQUEST=None):
37 "Add a Maintenance Window to this device" 38 mw = None 39 if newId: 40 preppedId = prepId(newId) 41 mw = MaintenanceWindow(preppedId) 42 mw.name = newId 43 self.maintenanceWindows._setObject(preppedId, mw) 44 if hasattr(self, 'setLastChange'): 45 # Only Device and DeviceClass have setLastChange for now. 46 self.setLastChange() 47 if REQUEST: 48 if mw: 49 REQUEST['message'] = "Maintenace Window Added" 50 return self.callZenScreen(REQUEST)
51 52 53 security.declareProtected(ZEN_MAINTENANCE_WINDOW_EDIT, 54 'manage_deleteMaintenanceWindow')
55 - def manage_deleteMaintenanceWindow(self, maintenanceIds=(), REQUEST=None):
56 "Delete a Maintenance Window to this device" 57 import types 58 if type(maintenanceIds) in types.StringTypes: 59 maintenanceIds = [maintenanceIds] 60 for id in maintenanceIds: 61 self.maintenanceWindows._delObject(id) 62 if hasattr(self, 'setLastChange'): 63 # Only Device and DeviceClass have setLastChange for now. 64 self.setLastChange() 65 if REQUEST: 66 REQUEST['message'] = "Maintenace Window Deleted" 67 return self.callZenScreen(REQUEST)
68 69 70 InitializeClass(MaintenanceWindowable) 71