Package Products ::
Package Zuul ::
Package routers ::
Module devicemanagement
|
|
1
2
3
4
5
6
7
8
9
10 import logging
11 log = logging.getLogger("zen.MaintenanceWindows")
12
13 from Products.ZenUtils.Ext import DirectResponse
14 from Products import Zuul
15 from Products.Zuul.decorators import require, serviceConnectionError
16 from Products.ZenUtils.Ext import DirectRouter
17 from Products.ZenUtils import Time
20 """
21 Allows setting up of users for administration purposes on devices along
22 with maintenance windows and user commands
23 """
24
26 return Zuul.getFacade('devicemanagement', self.context)
27
28
29
30 - def addMaintWindow(self, params):
31 """
32 adds a new Maintenance Window
33 """
34 facade = self._getFacade()
35 facade.addMaintWindow(params)
36 return DirectResponse.succeed(msg="Maintenance Window %s added successfully." % (params['name']))
37
38 - def deleteMaintWindow(self, uid, id):
39 """
40 delete a maintenance window
41 """
42 facade = self._getFacade()
43 data = facade.deleteMaintWindow(uid, id)
44 return DirectResponse.succeed(data=Zuul.marshal(data))
45
47 """
48 Returns local timezone.
49 """
50 return DirectResponse(data=Time.getLocalTimezone())
51
52 @serviceConnectionError
53 - def getMaintWindows(self, uid, params=None):
54 """
55 Returns the definition and values of all
56 the maintenance windows for this context
57 @type uid: string
58 @param uid: unique identifier of an object
59 @type params: none
60 @param params: none for page reloads and error avoidance
61 """
62 facade = self._getFacade()
63 data = facade.getMaintWindows(uid)
64 return DirectResponse( data=Zuul.marshal(data) )
65
66 - def editMaintWindow(self, params):
67 """
68 Edits the values of of a maintenance window
69 for this context and window id
70 @type params: dict
71 @param params:
72 """
73 facade = self._getFacade()
74 data = facade.editMaintWindow(params)
75 return DirectResponse( data=Zuul.marshal(data) )
76
77
78
79 @serviceConnectionError
81 """
82 Get a list of user commands for a device uid.
83
84 @type uid: string
85 @param uid: Device to use to get user commands
86 @rtype: [dictionary]
87 @return: List of objects representing user commands
88 """
89 facade = self._getFacade()
90 data = facade.getUserCommands(uid)
91 return DirectResponse( data=Zuul.marshal(data) )
92
93 @require('Define Commands Edit')
95 """
96 add a new user command to devices
97 """
98 facade = self._getFacade()
99 facade.addUserCommand(params)
100
101 return DirectResponse.succeed()
102
103 @require('Define Commands Edit')
105 """
106 delete a user command
107 """
108 facade = self._getFacade()
109 data = facade.deleteUserCommand(uid, id)
110 return DirectResponse.succeed(data=Zuul.marshal(data))
111
112 @require('Define Commands Edit')
114 """
115 completes or updates an existing user command
116 """
117 facade = self._getFacade()
118 facade.updateUserCommand(params)
119
120 return DirectResponse.succeed()
121
122
123
124 @serviceConnectionError
126 """
127 Returns the admin roles associated with
128 the device for this context
129 @type uid: string
130 @param uid: unique identifier of an object
131 """
132 facade = self._getFacade()
133 data = facade.getUserList(uid)
134 return DirectResponse( data=Zuul.marshal(data) )
135
136 @serviceConnectionError
138 """
139 Returns the admin roles associated with
140 the device for this context
141 @type uid: string
142 @param uid: unique identifier of an object
143 """
144 facade = self._getFacade()
145 data = facade.getRolesList(uid)
146 return DirectResponse( data=Zuul.marshal(data) )
147
148 @serviceConnectionError
150 """
151 Returns the admin roles associated with
152 the device for this context
153 @type uid: string
154 @param uid: unique identifier of an object
155 """
156 facade = self._getFacade()
157 data = facade.getAdminRoles(uid)
158 return DirectResponse( data=Zuul.marshal(data) )
159
161 """
162 add an admin with a role to a device
163 """
164 facade = self._getFacade()
165 facade.addAdminRole(params)
166 return DirectResponse.succeed(msg="New Administrator added successfully.")
167
169 """
170 adds or updates a role on a existing device administrator
171 """
172 facade = self._getFacade()
173 facade.updateAdminRole(params)
174 return DirectResponse.succeed()
175
177 """
178 removes admin and role on a existing device
179 """
180 facade = self._getFacade()
181 facade.removeAdmin(uid, id)
182 return DirectResponse.succeed()
183