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
19 """
20 Allows setting up of users for administration purposes on devices along
21 with maintenance windows and user commands
22 """
23
25 return Zuul.getFacade('devicemanagement', self.context)
26
27
28
29 - def addMaintWindow(self, params):
30 """
31 adds a new Maintenance Window
32 """
33 facade = self._getFacade()
34 facade.addMaintWindow(params)
35 return DirectResponse.succeed(msg="Maintenance Window %s added successfully." % (params['name']))
36
37 - def deleteMaintWindow(self, uid, id):
38 """
39 delete a maintenance window
40 """
41 facade = self._getFacade()
42 data = facade.deleteMaintWindow(uid, id)
43 return DirectResponse.succeed(data=Zuul.marshal(data))
44
45 @serviceConnectionError
46 - def getMaintWindows(self, uid, params=None):
47 """
48 Returns the definition and values of all
49 the maintenance windows for this context
50 @type uid: string
51 @param uid: unique identifier of an object
52 @type params: none
53 @param params: none for page reloads and error avoidance
54 """
55 facade = self._getFacade()
56 data = facade.getMaintWindows(uid)
57 return DirectResponse( data=Zuul.marshal(data) )
58
59 - def editMaintWindow(self, params):
60 """
61 Edits the values of of a maintenance window
62 for this context and window id
63 @type params: dict
64 @param params:
65 """
66 facade = self._getFacade()
67 data = facade.editMaintWindow(params)
68 return DirectResponse( data=Zuul.marshal(data) )
69
70
71
72 @serviceConnectionError
74 """
75 Get a list of user commands for a device uid.
76
77 @type uid: string
78 @param uid: Device to use to get user commands
79 @rtype: [dictionary]
80 @return: List of objects representing user commands
81 """
82 facade = self._getFacade()
83 data = facade.getUserCommands(uid)
84 return DirectResponse( data=Zuul.marshal(data) )
85
86 @require('Manage Device')
88 """
89 add a new user command to devices
90 """
91 facade = self._getFacade()
92 facade.addUserCommand(params)
93
94 return DirectResponse.succeed()
95
96 @require('Manage Device')
98 """
99 delete a user command
100 """
101 facade = self._getFacade()
102 data = facade.deleteUserCommand(uid, id)
103 return DirectResponse.succeed(data=Zuul.marshal(data))
104
105 @require('Manage Device')
107 """
108 completes or updates an existing user command
109 """
110 facade = self._getFacade()
111 facade.updateUserCommand(params)
112
113 return DirectResponse.succeed()
114
115
116
117 @serviceConnectionError
119 """
120 Returns the admin roles associated with
121 the device for this context
122 @type uid: string
123 @param uid: unique identifier of an object
124 """
125 facade = self._getFacade()
126 data = facade.getUserList(uid)
127 return DirectResponse( data=Zuul.marshal(data) )
128
129 @serviceConnectionError
131 """
132 Returns the admin roles associated with
133 the device for this context
134 @type uid: string
135 @param uid: unique identifier of an object
136 """
137 facade = self._getFacade()
138 data = facade.getRolesList(uid)
139 return DirectResponse( data=Zuul.marshal(data) )
140
141 @serviceConnectionError
143 """
144 Returns the admin roles associated with
145 the device for this context
146 @type uid: string
147 @param uid: unique identifier of an object
148 """
149 facade = self._getFacade()
150 data = facade.getAdminRoles(uid)
151 return DirectResponse( data=Zuul.marshal(data) )
152
154 """
155 add an admin with a role to a device
156 """
157 facade = self._getFacade()
158 facade.addAdminRole(params)
159 return DirectResponse.succeed(msg="New Administrator added successfully.")
160
162 """
163 adds or updates a role on a existing device administrator
164 """
165 facade = self._getFacade()
166 facade.updateAdminRole(params)
167 return DirectResponse.succeed()
168
170 """
171 removes admin and role on a existing device
172 """
173 facade = self._getFacade()
174 facade.removeAdmin(uid, id)
175 return DirectResponse.succeed()
176