1
2
3
4
5
6
7
8
9
10
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
25
26 security = ClassSecurityInfo()
27
28 security.declareProtected(ZEN_MAINTENANCE_WINDOW_VIEW,
29 'getMaintenanceWindows')
31 "Get the Maintenance Windows on this device"
32 return self.maintenanceWindows.objectValuesAll()
33
34 security.declareProtected(ZEN_MAINTENANCE_WINDOW_EDIT,
35 'manage_addMaintenanceWindow')
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
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
64 self.setLastChange()
65 if REQUEST:
66 REQUEST['message'] = "Maintenace Window Deleted"
67 return self.callZenScreen(REQUEST)
68
69
70 InitializeClass(MaintenanceWindowable)
71