VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/webui/wuiadmin.py@ 61240

Last change on this file since 61240 was 61240, checked in by vboxsync, 9 years ago

wuifailurecategory.py -> wuiadminfailurecategory.py

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 42.3 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: wuiadmin.py 61240 2016-05-27 12:05:23Z vboxsync $
3
4"""
5Test Manager Core - WUI - Admin Main page.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2012-2015 Oracle Corporation
11
12This file is part of VirtualBox Open Source Edition (OSE), as
13available from http://www.virtualbox.org. This file is free software;
14you can redistribute it and/or modify it under the terms of the GNU
15General Public License (GPL) as published by the Free Software
16Foundation, in version 2 as it comes in the "COPYING" file of the
17VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
20The contents of this file may alternatively be used under the terms
21of the Common Development and Distribution License Version 1.0
22(CDDL) only, as it comes in the "COPYING.CDDL" file of the
23VirtualBox OSE distribution, in which case the provisions of the
24CDDL are applicable instead of those of the GPL.
25
26You may elect to license modified versions of this file under the
27terms and conditions of either the GPL or the CDDL or both.
28"""
29__version__ = "$Revision: 61240 $"
30
31
32# Standard python imports.
33import cgitb;
34import sys;
35
36# Validation Kit imports.
37from common import webutils
38from testmanager import config;
39from testmanager.core.buildsource import BuildSourceLogic, BuildSourceData
40from testmanager.core.build import BuildCategoryLogic, BuildCategoryData, BuildLogic, BuildData;
41from testmanager.core.globalresource import GlobalResourceLogic, GlobalResourceData
42from testmanager.core.schedulerbase import SchedulerBase
43from testmanager.core.schedgroup import SchedGroupLogic, SchedGroupData, SchedGroupDataEx
44from testmanager.core.systemlog import SystemLogLogic
45from testmanager.core.testbox import TestBoxData, TestBoxLogic
46from testmanager.core.testcase import TestCaseLogic, TestCaseData, TestCaseDataEx
47from testmanager.core.useraccount import UserAccountLogic, UserAccountData
48from testmanager.core.testgroup import TestGroupLogic, TestGroupDataEx;
49from testmanager.core.failurecategory import FailureCategoryLogic, FailureCategoryData
50from testmanager.core.failurereason import FailureReasonLogic, FailureReasonData
51from testmanager.core.buildblacklist import BuildBlacklistLogic, BuildBlacklistData
52from testmanager.webui.wuibase import WuiDispatcherBase, WuiException
53from testmanager.webui.wuiadminbuild import WuiAdminBuild, WuiAdminBuildList
54from testmanager.webui.wuiadminsystemlog import WuiAdminSystemLogList
55from testmanager.webui.wuiadminbuildsource import WuiAdminBuildSrc, WuiAdminBuildSrcList;
56from testmanager.webui.wuiadminbuildcategory import WuiAdminBuildCat, WuiAdminBuildCatList;
57from testmanager.webui.wuiadminglobalrsrc import WuiGlobalResource, WuiGlobalResourceList
58from testmanager.webui.wuiadmintestbox import WuiTestBoxList, WuiTestBox
59from testmanager.webui.wuiadmintestcase import WuiTestCase, WuiTestCaseList
60from testmanager.webui.wuiadminuseraccount import WuiUserAccountList, WuiUserAccount
61from testmanager.webui.wuiadmintestgroup import WuiTestGroup, WuiTestGroupList;
62from testmanager.webui.wuiadminschedgroup import WuiSchedGroup, WuiAdminSchedGroupList;
63from testmanager.webui.wuiadminbuildblacklist import WuiAdminBuildBlacklist, WuiAdminListOfBlacklistItems
64from testmanager.webui.wuiadminfailurecategory import WuiFailureCategory, WuiFailureCategoryList
65from testmanager.webui.wuiadminfailurereason import WuiAdminFailureReason, WuiAdminFailureReasonList
66
67
68class WuiAdmin(WuiDispatcherBase):
69 """
70 WUI Admin main page.
71 """
72
73 ## The name of the script.
74 ksScriptName = 'admin.py'
75
76
77 ## @name Actions
78 ## @{
79 ksActionSystemLogList = 'SystemLogList'
80
81 ksActionUserList = 'UserList'
82 ksActionUserAdd = 'UserAdd'
83 ksActionUserEdit = 'UserEdit'
84 ksActionUserAddPost = 'UserAddPost'
85 ksActionUserEditPost = 'UserEditPost'
86 ksActionUserDelPost = 'UserDelPost'
87
88 ksActionTestBoxList = 'TestBoxList'
89 ksActionTestBoxListPost = 'TestBoxListPost'
90 ksActionTestBoxAdd = 'TestBoxAdd'
91 ksActionTestBoxAddPost = 'TestBoxAddPost'
92 ksActionTestBoxEdit = 'TestBoxEdit'
93 ksActionTestBoxEditPost = 'TestBoxEditPost'
94 ksActionTestBoxDetails = 'TestBoxDetails'
95 ksActionTestBoxRemovePost = 'TestBoxRemove'
96 ksActionTestBoxesRegenQueues = 'TestBoxesRegenQueues';
97
98 ksActionTestCaseList = 'TestCaseList'
99 ksActionTestCaseAdd = 'TestCaseAdd'
100 ksActionTestCaseAddPost = 'TestCaseAddPost'
101 ksActionTestCaseClone = 'TestCaseClone'
102 ksActionTestCaseDetails = 'TestCaseDetails'
103 ksActionTestCaseEdit = 'TestCaseEdit'
104 ksActionTestCaseEditPost = 'TestCaseEditPost'
105 ksActionTestCaseDoRemove = 'TestCaseDoRemove'
106
107 ksActionGlobalRsrcShowAll = 'GlobalRsrcShowAll'
108 ksActionGlobalRsrcShowAdd = 'GlobalRsrcShowAdd'
109 ksActionGlobalRsrcShowEdit = 'GlobalRsrcShowEdit'
110 ksActionGlobalRsrcAdd = 'GlobalRsrcAddPost'
111 ksActionGlobalRsrcEdit = 'GlobalRsrcEditPost'
112 ksActionGlobalRsrcDel = 'GlobalRsrcDelPost'
113
114 ksActionBuildList = 'BuildList'
115 ksActionBuildAdd = 'BuildAdd'
116 ksActionBuildAddPost = 'BuildAddPost'
117 ksActionBuildClone = 'BuildClone'
118 ksActionBuildDetails = 'BuildDetails'
119 ksActionBuildDoRemove = 'BuildDoRemove'
120 ksActionBuildEdit = 'BuildEdit'
121 ksActionBuildEditPost = 'BuildEditPost'
122
123 ksActionBuildBlacklist = 'BuildBlacklist';
124 ksActionBuildBlacklistAdd = 'BuildBlacklistAdd';
125 ksActionBuildBlacklistAddPost = 'BuildBlacklistAddPost';
126 ksActionBuildBlacklistClone = 'BuildBlacklistClone';
127 ksActionBuildBlacklistDetails = 'BuildBlacklistDetails';
128 ksActionBuildBlacklistDoRemove = 'BuildBlacklistDoRemove';
129 ksActionBuildBlacklistEdit = 'BuildBlacklistEdit';
130 ksActionBuildBlacklistEditPost = 'BuildBlacklistEditPost';
131
132 ksActionFailureCategoryList = 'FailureCategoryList';
133 ksActionFailureCategoryAdd = 'FailureCategoryAdd';
134 ksActionFailureCategoryAddPost = 'FailureCategoryAddPost';
135 ksActionFailureCategoryDetails = 'FailureCategoryDetails';
136 ksActionFailureCategoryDoRemove = 'FailureCategoryDoRemove';
137 ksActionFailureCategoryEdit = 'FailureCategoryEdit';
138 ksActionFailureCategoryEditPost = 'FailureCategoryEditPost';
139
140 ksActionFailureReasonList = 'FailureReasonList'
141 ksActionFailureReasonAdd = 'FailureReasonAdd'
142 ksActionFailureReasonAddPost = 'FailureReasonAddPost'
143 ksActionFailureReasonDetails = 'FailureReasonDetails'
144 ksActionFailureReasonDoRemove = 'FailureReasonDoRemove'
145 ksActionFailureReasonEdit = 'FailureReasonEdit'
146 ksActionFailureReasonEditPost = 'FailureReasonEditPost'
147
148 ksActionBuildSrcList = 'BuildSrcList'
149 ksActionBuildSrcAdd = 'BuildSrcAdd'
150 ksActionBuildSrcAddPost = 'BuildSrcAddPost'
151 ksActionBuildSrcClone = 'BuildSrcClone'
152 ksActionBuildSrcDetails = 'BuildSrcDetails'
153 ksActionBuildSrcEdit = 'BuildSrcEdit'
154 ksActionBuildSrcEditPost = 'BuildSrcEditPost'
155 ksActionBuildSrcDoRemove = 'BuildSrcDoRemove'
156
157 ksActionBuildCategoryList = 'BuildCategoryList'
158 ksActionBuildCategoryAdd = 'BuildCategoryAdd'
159 ksActionBuildCategoryAddPost = 'BuildCategoryAddPost'
160 ksActionBuildCategoryClone = 'BuildCategoryClone';
161 ksActionBuildCategoryDetails = 'BuildCategoryDetails';
162 ksActionBuildCategoryDoRemove = 'BuildCategoryDoRemove';
163
164 ksActionTestGroupList = 'TestGroupList'
165 ksActionTestGroupAdd = 'TestGroupAdd'
166 ksActionTestGroupAddPost = 'TestGroupAddPost'
167 ksActionTestGroupClone = 'TestGroupClone'
168 ksActionTestGroupDetails = 'TestGroupDetails'
169 ksActionTestGroupDoRemove = 'TestGroupDoRemove'
170 ksActionTestGroupEdit = 'TestGroupEdit'
171 ksActionTestGroupEditPost = 'TestGroupEditPost'
172 ksActionTestCfgRegenQueues = 'TestCfgRegenQueues'
173
174 ksActionSchedGroupList = 'SchedGroupList'
175 ksActionSchedGroupAdd = 'SchedGroupAdd';
176 ksActionSchedGroupAddPost = 'SchedGroupAddPost';
177 ksActionSchedGroupClone = 'SchedGroupClone';
178 ksActionSchedGroupDetails = 'SchedGroupDetails';
179 ksActionSchedGroupDoRemove = 'SchedGroupDel';
180 ksActionSchedGroupEdit = 'SchedGroupEdit';
181 ksActionSchedGroupEditPost = 'SchedGroupEditPost';
182 ## @}
183
184 def __init__(self, oSrvGlue):
185 WuiDispatcherBase.__init__(self, oSrvGlue, self.ksScriptName);
186
187 self._sTemplate = 'template.html';
188
189 # Use short form to avoid hitting the right margin (130) when using lambda.
190 d = self._dDispatch; # pylint: disable=C0103
191
192 #
193 # System Log actions.
194 #
195 d[self.ksActionSystemLogList] = lambda: self._actionGenericListing(SystemLogLogic, WuiAdminSystemLogList)
196
197 #
198 # User Account actions.
199 #
200 d[self.ksActionUserList] = lambda: self._actionGenericListing(UserAccountLogic, WuiUserAccountList)
201 d[self.ksActionUserAdd] = lambda: self._actionGenericFormAdd(UserAccountData, WuiUserAccount)
202 d[self.ksActionUserEdit] = lambda: self._actionGenericFormEdit(UserAccountData, WuiUserAccount,
203 UserAccountData.ksParam_uid);
204 d[self.ksActionUserAddPost] = lambda: self._actionGenericFormAddPost(UserAccountData, UserAccountLogic,
205 WuiUserAccount, self.ksActionUserList)
206 d[self.ksActionUserEditPost] = lambda: self._actionGenericFormEditPost(UserAccountData, UserAccountLogic,
207 WuiUserAccount, self.ksActionUserList)
208 d[self.ksActionUserDelPost] = lambda: self._actionGenericDoRemove(UserAccountLogic,
209 UserAccountData.ksParam_uid,
210 self.ksActionUserList)
211
212 #
213 # TestBox actions.
214 #
215 d[self.ksActionTestBoxList] = lambda: self._actionGenericListing(TestBoxLogic, WuiTestBoxList);
216 d[self.ksActionTestBoxListPost] = self._actionTestBoxListPost;
217 d[self.ksActionTestBoxAdd] = lambda: self._actionGenericFormAdd(TestBoxData, WuiTestBox);
218 d[self.ksActionTestBoxAddPost] = lambda: self._actionGenericFormAddPost(TestBoxData, TestBoxLogic,
219 WuiTestBox, self.ksActionTestBoxList);
220 d[self.ksActionTestBoxDetails] = lambda: self._actionGenericFormDetails(TestBoxData, TestBoxLogic, WuiTestBox,
221 'idTestBox', 'idGenTestBox');
222 d[self.ksActionTestBoxEdit] = lambda: self._actionGenericFormEdit(TestBoxData, WuiTestBox,
223 TestBoxData.ksParam_idTestBox);
224 d[self.ksActionTestBoxEditPost] = lambda: self._actionGenericFormEditPost(TestBoxData, TestBoxLogic,
225 WuiTestBox, self.ksActionTestBoxList);
226 d[self.ksActionTestBoxRemovePost] = lambda: self._actionGenericDoRemove(TestBoxLogic,
227 TestBoxData.ksParam_idTestBox,
228 self.ksActionTestBoxList)
229 d[self.ksActionTestBoxesRegenQueues] = self._actionRegenQueuesCommon;
230
231 #
232 # Test Case actions.
233 #
234 d[self.ksActionTestCaseList] = lambda: self._actionGenericListing(TestCaseLogic, WuiTestCaseList);
235 d[self.ksActionTestCaseAdd] = lambda: self._actionGenericFormAdd(TestCaseDataEx, WuiTestCase);
236 d[self.ksActionTestCaseAddPost] = lambda: self._actionGenericFormAddPost(TestCaseDataEx, TestCaseLogic,
237 WuiTestCase, self.ksActionTestCaseList);
238 d[self.ksActionTestCaseClone] = lambda: self._actionGenericFormClone( TestCaseDataEx, WuiTestCase,
239 'idTestCase', 'idGenTestCase');
240 d[self.ksActionTestCaseDetails] = lambda: self._actionGenericFormDetails(TestCaseDataEx, TestCaseLogic,
241 WuiTestCase, 'idTestCase',
242 'idGenTestCase');
243 d[self.ksActionTestCaseEdit] = lambda: self._actionGenericFormEdit(TestCaseDataEx, WuiTestCase,
244 TestCaseDataEx.ksParam_idTestCase);
245 d[self.ksActionTestCaseEditPost] = lambda: self._actionGenericFormEditPost(TestCaseDataEx, TestCaseLogic,
246 WuiTestCase, self.ksActionTestCaseList);
247 d[self.ksActionTestCaseDoRemove] = lambda: self._actionGenericDoRemove(TestCaseLogic,
248 TestCaseData.ksParam_idTestCase,
249 self.ksActionTestCaseList);
250
251 #
252 # Global Resource actions
253 #
254 d[self.ksActionGlobalRsrcShowAll] = lambda: self._actionGenericListing(GlobalResourceLogic, WuiGlobalResourceList)
255 d[self.ksActionGlobalRsrcShowAdd] = lambda: self._actionGlobalRsrcShowAddEdit(WuiAdmin.ksActionGlobalRsrcAdd)
256 d[self.ksActionGlobalRsrcShowEdit] = lambda: self._actionGlobalRsrcShowAddEdit(WuiAdmin.ksActionGlobalRsrcEdit)
257 d[self.ksActionGlobalRsrcAdd] = lambda: self._actionGlobalRsrcAddEdit(WuiAdmin.ksActionGlobalRsrcAdd)
258 d[self.ksActionGlobalRsrcEdit] = lambda: self._actionGlobalRsrcAddEdit(WuiAdmin.ksActionGlobalRsrcEdit)
259 d[self.ksActionGlobalRsrcDel] = lambda: self._actionGenericDoDelOld(GlobalResourceLogic,
260 GlobalResourceData.ksParam_idGlobalRsrc,
261 self.ksActionGlobalRsrcShowAll)
262
263 #
264 # Build Source actions
265 #
266 d[self.ksActionBuildSrcList] = lambda: self._actionGenericListing(BuildSourceLogic, WuiAdminBuildSrcList)
267 d[self.ksActionBuildSrcAdd] = lambda: self._actionGenericFormAdd(BuildSourceData, WuiAdminBuildSrc);
268 d[self.ksActionBuildSrcAddPost] = lambda: self._actionGenericFormAddPost(BuildSourceData, BuildSourceLogic,
269 WuiAdminBuildSrc, self.ksActionBuildSrcList);
270 d[self.ksActionBuildSrcClone] = lambda: self._actionGenericFormClone( BuildSourceData, WuiAdminBuildSrc,
271 'idBuildSrc');
272 d[self.ksActionBuildSrcDetails] = lambda: self._actionGenericFormDetails(BuildSourceData, BuildSourceLogic,
273 WuiAdminBuildSrc, 'idBuildSrc');
274 d[self.ksActionBuildSrcDoRemove] = lambda: self._actionGenericDoRemove(BuildSourceLogic,
275 BuildSourceData.ksParam_idBuildSrc,
276 self.ksActionBuildSrcList);
277 d[self.ksActionBuildSrcEdit] = lambda: self._actionGenericFormEdit(BuildSourceData, WuiAdminBuildSrc,
278 BuildSourceData.ksParam_idBuildSrc);
279 d[self.ksActionBuildSrcEditPost] = lambda: self._actionGenericFormEditPost(BuildSourceData, BuildSourceLogic,
280 WuiAdminBuildSrc,
281 self.ksActionBuildSrcList);
282
283
284 #
285 # Build actions
286 #
287 d[self.ksActionBuildList] = lambda: self._actionGenericListing(BuildLogic, WuiAdminBuildList)
288 d[self.ksActionBuildAdd] = lambda: self._actionGenericFormAdd(BuildData, WuiAdminBuild)
289 d[self.ksActionBuildAddPost] = lambda: self._actionGenericFormAddPost(BuildData, BuildLogic, WuiAdminBuild,
290 self.ksActionBuildList)
291 d[self.ksActionBuildClone] = lambda: self._actionGenericFormClone( BuildData, WuiAdminBuild, 'idBuild');
292 d[self.ksActionBuildDetails] = lambda: self._actionGenericFormDetails(BuildData, BuildLogic,
293 WuiAdminBuild, 'idBuild');
294 d[self.ksActionBuildDoRemove] = lambda: self._actionGenericDoRemove(BuildLogic, BuildData.ksParam_idBuild,
295 self.ksActionBuildList);
296 d[self.ksActionBuildEdit] = lambda: self._actionGenericFormEdit(BuildData, WuiAdminBuild,
297 BuildData.ksParam_idBuild);
298 d[self.ksActionBuildEditPost] = lambda: self._actionGenericFormEditPost(BuildData, BuildLogic, WuiAdminBuild,
299 self.ksActionBuildList)
300
301 #
302 # Build Black List actions
303 #
304 d[self.ksActionBuildBlacklist] = lambda: self._actionGenericListing(BuildBlacklistLogic,
305 WuiAdminListOfBlacklistItems);
306 d[self.ksActionBuildBlacklistAdd] = lambda: self._actionGenericFormAdd(BuildBlacklistData, WuiAdminBuildBlacklist);
307 d[self.ksActionBuildBlacklistAddPost] = lambda: self._actionGenericFormAddPost(BuildBlacklistData, BuildBlacklistLogic,
308 WuiAdminBuildBlacklist,
309 self.ksActionBuildBlacklist);
310 d[self.ksActionBuildBlacklistClone] = lambda: self._actionGenericFormClone(BuildBlacklistData,
311 WuiAdminBuildBlacklist,
312 'idBlacklisting');
313 d[self.ksActionBuildBlacklistDetails] = lambda: self._actionGenericFormDetails(BuildBlacklistData,
314 BuildBlacklistLogic,
315 WuiAdminBuildBlacklist,
316 'idBlacklisting');
317 d[self.ksActionBuildBlacklistDoRemove] = lambda: self._actionGenericDoRemove(BuildBlacklistLogic,
318 BuildBlacklistData.ksParam_idBlacklisting,
319 self.ksActionBuildBlacklist)
320 d[self.ksActionBuildBlacklistEdit] = lambda: self._actionGenericFormEdit(BuildBlacklistData,
321 WuiAdminBuildBlacklist,
322 BuildBlacklistData.ksParam_idBlacklisting);
323 d[self.ksActionBuildBlacklistEditPost] = lambda: self._actionGenericFormEditPost(BuildBlacklistData,
324 BuildBlacklistLogic,
325 WuiAdminBuildBlacklist,
326 self.ksActionBuildBlacklist)
327
328
329 #
330 # Failure Category actions
331 #
332 d[self.ksActionFailureCategoryList] = \
333 lambda: self._actionGenericListing(FailureCategoryLogic, WuiFailureCategoryList);
334 d[self.ksActionFailureCategoryAdd] = \
335 lambda: self._actionGenericFormAdd(FailureCategoryData, WuiFailureCategory);
336 d[self.ksActionFailureCategoryAddPost] = \
337 lambda: self._actionGenericFormAddPost(FailureCategoryData, FailureCategoryLogic, WuiFailureCategory,
338 self.ksActionFailureCategoryList)
339 d[self.ksActionFailureCategoryDetails] = \
340 lambda: self._actionGenericFormDetails(FailureCategoryData, FailureCategoryLogic, WuiFailureCategory);
341
342 d[self.ksActionFailureCategoryDoRemove] = \
343 lambda: self._actionGenericDoRemove(FailureCategoryLogic, FailureCategoryData.ksParam_idFailureCategory,
344 self.ksActionFailureCategoryList);
345 d[self.ksActionFailureCategoryEdit] = \
346 lambda: self._actionGenericFormEdit(FailureCategoryData, WuiFailureCategory,
347 FailureCategoryData.ksParam_idFailureCategory);
348 d[self.ksActionFailureCategoryEditPost] = \
349 lambda: self._actionGenericFormEditPost(FailureCategoryData, FailureCategoryLogic, WuiFailureCategory,
350 self.ksActionFailureCategoryList);
351
352 #
353 # Failure Reason actions
354 #
355 d[self.ksActionFailureReasonList] = \
356 lambda: self._actionGenericListing(FailureReasonLogic, WuiAdminFailureReasonList)
357
358 d[self.ksActionFailureReasonAdd] = \
359 lambda: self._actionGenericFormAdd(FailureReasonData, WuiAdminFailureReason);
360 d[self.ksActionFailureReasonAddPost] = \
361 lambda: self._actionGenericFormAddPost(FailureReasonData, FailureReasonLogic, WuiAdminFailureReason,
362 self.ksActionFailureReasonList);
363 d[self.ksActionFailureReasonDetails] = \
364 lambda: self._actionGenericFormDetails(FailureReasonData, FailureReasonLogic, WuiAdminFailureReason);
365 d[self.ksActionFailureReasonDoRemove] = \
366 lambda: self._actionGenericDoRemove(FailureReasonLogic, FailureReasonData.ksParam_idFailureReason,
367 self.ksActionFailureReasonList);
368 d[self.ksActionFailureReasonEdit] = \
369 lambda: self._actionGenericFormEdit(FailureReasonData, WuiAdminFailureReason);
370
371 d[self.ksActionFailureReasonEditPost] = \
372 lambda: self._actionGenericFormEditPost(FailureReasonData, FailureReasonLogic, WuiAdminFailureReason,\
373 self.ksActionFailureReasonList)
374
375 #
376 # Build Category actions
377 #
378 d[self.ksActionBuildCategoryList] = lambda: self._actionGenericListing(BuildCategoryLogic, WuiAdminBuildCatList);
379 d[self.ksActionBuildCategoryAdd] = lambda: self._actionGenericFormAdd(BuildCategoryData, WuiAdminBuildCat);
380 d[self.ksActionBuildCategoryAddPost] = lambda: self._actionGenericFormAddPost(BuildCategoryData, BuildCategoryLogic,
381 WuiAdminBuildCat,
382 self.ksActionBuildCategoryList);
383 d[self.ksActionBuildCategoryClone] = lambda: self._actionGenericFormClone( BuildCategoryData, WuiAdminBuildCat,
384 'idBuildCategory');
385 d[self.ksActionBuildCategoryDetails] = lambda: self._actionGenericFormDetails(BuildCategoryData, BuildCategoryLogic,
386 WuiAdminBuildCat, 'idBuildCategory');
387 d[self.ksActionBuildCategoryDoRemove] = lambda: self._actionGenericDoRemove(BuildCategoryLogic,
388 BuildCategoryData.ksParam_idBuildCategory,
389 self.ksActionBuildCategoryList)
390
391 #
392 # Test Group actions
393 #
394 d[self.ksActionTestGroupList] = lambda: self._actionGenericListing(TestGroupLogic, WuiTestGroupList);
395 d[self.ksActionTestGroupAdd] = lambda: self._actionGenericFormAdd(TestGroupDataEx, WuiTestGroup);
396 d[self.ksActionTestGroupAddPost] = lambda: self._actionGenericFormAddPost(TestGroupDataEx, TestGroupLogic,
397 WuiTestGroup, self.ksActionTestGroupList);
398 d[self.ksActionTestGroupClone] = lambda: self._actionGenericFormClone( TestGroupDataEx, WuiTestGroup,
399 'idTestGroup');
400 d[self.ksActionTestGroupDetails] = lambda: self._actionGenericFormDetails(TestGroupDataEx, TestGroupLogic,
401 WuiTestGroup, 'idTestGroup');
402 d[self.ksActionTestGroupEdit] = lambda: self._actionGenericFormEdit(TestGroupDataEx, WuiTestGroup,
403 TestGroupDataEx.ksParam_idTestGroup);
404 d[self.ksActionTestGroupEditPost] = lambda: self._actionGenericFormEditPost(TestGroupDataEx, TestGroupLogic,
405 WuiTestGroup, self.ksActionTestGroupList);
406 d[self.ksActionTestGroupDoRemove] = lambda: self._actionGenericDoRemove(TestGroupLogic,
407 TestGroupDataEx.ksParam_idTestGroup,
408 self.ksActionTestGroupList)
409 d[self.ksActionTestCfgRegenQueues] = self._actionRegenQueuesCommon;
410
411 #
412 # Scheduling Group actions
413 #
414 d[self.ksActionSchedGroupList] = lambda: self._actionGenericListing(SchedGroupLogic, WuiAdminSchedGroupList)
415 d[self.ksActionSchedGroupAdd] = lambda: self._actionGenericFormAdd(SchedGroupDataEx, WuiSchedGroup);
416 d[self.ksActionSchedGroupClone] = lambda: self._actionGenericFormClone( SchedGroupDataEx, WuiSchedGroup,
417 'idSchedGroup');
418 d[self.ksActionSchedGroupDetails] = lambda: self._actionGenericFormDetails(SchedGroupDataEx, SchedGroupLogic,
419 WuiSchedGroup, 'idSchedGroup');
420 d[self.ksActionSchedGroupEdit] = lambda: self._actionGenericFormEdit(SchedGroupDataEx, WuiSchedGroup,
421 SchedGroupData.ksParam_idSchedGroup);
422 d[self.ksActionSchedGroupAddPost] = lambda: self._actionGenericFormAddPost(SchedGroupDataEx, SchedGroupLogic,
423 WuiSchedGroup, self.ksActionSchedGroupList);
424 d[self.ksActionSchedGroupEditPost] = lambda: self._actionGenericFormEditPost(SchedGroupDataEx, SchedGroupLogic,
425 WuiSchedGroup, self.ksActionSchedGroupList);
426 d[self.ksActionSchedGroupDoRemove] = lambda: self._actionGenericDoRemove(SchedGroupLogic,
427 SchedGroupData.ksParam_idSchedGroup,
428 self.ksActionSchedGroupList)
429
430 self._aaoMenus = \
431 [
432 [
433 'Builds', self._sActionUrlBase + self.ksActionBuildList,
434 [
435 [ 'Builds', self._sActionUrlBase + self.ksActionBuildList ],
436 [ 'Blacklist', self._sActionUrlBase + self.ksActionBuildBlacklist ],
437 [ 'Build Sources', self._sActionUrlBase + self.ksActionBuildSrcList ],
438 [ 'Build Categories', self._sActionUrlBase + self.ksActionBuildCategoryList ],
439 [ 'New Build', self._sActionUrlBase + self.ksActionBuildAdd ],
440 [ 'New Blacklisting', self._sActionUrlBase + self.ksActionBuildBlacklistAdd ],
441 [ 'New Build Source', self._sActionUrlBase + self.ksActionBuildSrcAdd],
442 [ 'New Build Category', self._sActionUrlBase + self.ksActionBuildCategoryAdd ],
443 ]
444 ],
445 [
446 'Failure Reasons', self._sActionUrlBase + self.ksActionFailureReasonList,
447 [
448 [ 'Failure Categories', self._sActionUrlBase + self.ksActionFailureCategoryList ],
449 [ 'Failure Reasons', self._sActionUrlBase + self.ksActionFailureReasonList ],
450 [ 'New Failure Category', self._sActionUrlBase + self.ksActionFailureCategoryAdd ],
451 [ 'New Failure Reason', self._sActionUrlBase + self.ksActionFailureReasonAdd ],
452 ]
453 ],
454 [
455 'System', self._sActionUrlBase + self.ksActionSystemLogList,
456 [
457 [ 'System Log', self._sActionUrlBase + self.ksActionSystemLogList ],
458 [ 'User Accounts', self._sActionUrlBase + self.ksActionUserList ],
459 [ 'New User', self._sActionUrlBase + self.ksActionUserAdd ],
460 ]
461 ],
462 [
463 'TestBoxes', self._sActionUrlBase + self.ksActionTestBoxList,
464 [
465 [ 'TestBoxes', self._sActionUrlBase + self.ksActionTestBoxList ],
466 [ 'Scheduling Groups', self._sActionUrlBase + self.ksActionSchedGroupList ],
467 [ 'New TestBox', self._sActionUrlBase + self.ksActionTestBoxAdd ],
468 [ 'New Scheduling Group', self._sActionUrlBase + self.ksActionSchedGroupAdd ],
469 [ 'Regenerate All Scheduling Queues', self._sActionUrlBase + self.ksActionTestBoxesRegenQueues ],
470 ]
471 ],
472 [
473 'Test Config', self._sActionUrlBase + self.ksActionTestGroupList,
474 [
475 [ 'Test Cases', self._sActionUrlBase + self.ksActionTestCaseList ],
476 [ 'Test Groups', self._sActionUrlBase + self.ksActionTestGroupList ],
477 [ 'Global Resources', self._sActionUrlBase + self.ksActionGlobalRsrcShowAll ],
478 [ 'New Test Case', self._sActionUrlBase + self.ksActionTestCaseAdd ],
479 [ 'New Test Group', self._sActionUrlBase + self.ksActionTestGroupAdd ],
480 [ 'New Global Resource', self._sActionUrlBase + self.ksActionGlobalRsrcShowAdd ],
481 [ 'Regenerate All Scheduling Queues', self._sActionUrlBase + self.ksActionTestCfgRegenQueues ],
482 ]
483 ],
484 [
485 '> Test Results', 'index.py?' + webutils.encodeUrlParams(self._dDbgParams), []
486 ],
487 ];
488
489
490 def _actionDefault(self):
491 """Show the default admin page."""
492 self._sAction = self.ksActionTestBoxList;
493 return self._actionGenericListing(TestBoxLogic, WuiTestBoxList);
494
495 def _actionGenericDoDelOld(self, oCoreObjectLogic, sCoreObjectIdFieldName, sRedirectAction):
496 """
497 Delete entry (using oLogicType.remove).
498
499 @param oCoreObjectLogic A *Logic class
500
501 @param sCoreObjectIdFieldName Name of HTTP POST variable that
502 contains object ID information
503
504 @param sRedirectAction An action for redirect user to
505 in case of operation success
506 """
507 iCoreDataObjectId = self.getStringParam(sCoreObjectIdFieldName) # STRING?!?!
508 self._checkForUnknownParameters()
509
510 try:
511 self._sPageTitle = None
512 self._sPageBody = None
513 self._sRedirectTo = self._sActionUrlBase + sRedirectAction
514 return oCoreObjectLogic(self._oDb).remove(self._oCurUser.uid, iCoreDataObjectId)
515 except Exception as oXcpt:
516 self._oDb.rollback();
517 self._sPageTitle = 'Unable to delete record'
518 self._sPageBody = str(oXcpt);
519 if config.g_kfDebugDbXcpt:
520 self._sPageBody += cgitb.html(sys.exc_info());
521 self._sRedirectTo = None
522
523 return False
524
525 def _actionGenericDoRemove(self, oLogicType, sParamId, sRedirAction):
526 """
527 Delete entry (using oLogicType.removeEntry).
528
529 oLogicType is a class that implements addEntry.
530
531 sParamId is the name (ksParam_...) of the HTTP variable hold the ID of
532 the database entry to delete.
533
534 sRedirAction is what action to redirect to on success.
535 """
536 idEntry = self.getIntParam(sParamId, iMin = 1, iMax = 0x7fffffe)
537 fCascade = self.getBoolParam('fCascadeDelete', False);
538 self._checkForUnknownParameters()
539
540 try:
541 self._sPageTitle = None
542 self._sPageBody = None
543 self._sRedirectTo = self._sActionUrlBase + sRedirAction;
544 return oLogicType(self._oDb).removeEntry(self._oCurUser.uid, idEntry, fCascade = fCascade, fCommit = True);
545 except Exception as oXcpt:
546 self._oDb.rollback();
547 self._sPageTitle = 'Unable to delete entry';
548 self._sPageBody = str(oXcpt);
549 if config.g_kfDebugDbXcpt:
550 self._sPageBody += cgitb.html(sys.exc_info());
551 self._sRedirectTo = None;
552 return False;
553
554
555 #
556 # System Category.
557 #
558
559 # (all generic)
560
561 #
562 # TestBox & Scheduling Category.
563 #
564
565 def _actionTestBoxListPost(self):
566 """Actions on a list of testboxes."""
567
568 # Parameters.
569 aidTestBoxes = self.getListOfIntParams(TestBoxData.ksParam_idTestBox, iMin = 1, aiDefaults = []);
570 sListAction = self.getStringParam(self.ksParamListAction);
571 if sListAction in [asDesc[0] for asDesc in WuiTestBoxList.kasTestBoxActionDescs]:
572 idAction = None;
573 else:
574 asActionPrefixes = [ 'setgroup-', ];
575 i = 0;
576 while i < len(asActionPrefixes) and not sListAction.startswith(asActionPrefixes[i]):
577 i += 1;
578 if i >= len(asActionPrefixes):
579 raise WuiException('Parameter "%s" has an invalid value: "%s"' % (self.ksParamListAction, sListAction,));
580 idAction = sListAction[len(asActionPrefixes[i]):];
581 if not idAction.isdigit():
582 raise WuiException('Parameter "%s" has an invalid value: "%s"' % (self.ksParamListAction, sListAction,));
583 idAction = int(idAction);
584 sListAction = sListAction[:len(asActionPrefixes[i]) - 1];
585 self._checkForUnknownParameters();
586
587
588 # Take action.
589 if sListAction is 'none':
590 pass;
591 else:
592 oLogic = TestBoxLogic(self._oDb);
593 aoTestBoxes = []
594 for idTestBox in aidTestBoxes:
595 aoTestBoxes.append(TestBoxData().initFromDbWithId(self._oDb, idTestBox));
596
597 if sListAction in [ 'enable', 'disable' ]:
598 fEnable = sListAction == 'enable';
599 for oTestBox in aoTestBoxes:
600 if oTestBox.fEnabled != fEnable:
601 oTestBox.fEnabled = fEnable;
602 oLogic.editEntry(oTestBox, self._oCurUser.uid, fCommit = False);
603 elif sListAction == 'setgroup':
604 for oTestBox in aoTestBoxes:
605 if oTestBox.idSchedGroup != idAction:
606 oTestBox.idSchedGroup = idAction;
607 oLogic.editEntry(oTestBox, self._oCurUser.uid, fCommit = False);
608 else:
609 for oTestBox in aoTestBoxes:
610 if oTestBox.enmPendingCmd != sListAction:
611 oTestBox.enmPendingCmd = sListAction;
612 oLogic.editEntry(oTestBox, self._oCurUser.uid, fCommit = False);
613 self._oDb.commit();
614
615 # Re-display the list.
616 self._sPageTitle = None;
617 self._sPageBody = None;
618 self._sRedirectTo = self._sActionUrlBase + self.ksActionTestBoxList;
619 return True;
620
621 ## @todo scheduling groups code goes here...
622
623 def _actionRegenQueuesCommon(self):
624 """
625 Common code for ksActionTestBoxesRegenQueues and ksActionTestCfgRegenQueues.
626
627 Too lazy to put this in some separate place right now.
628 """
629 self._checkForUnknownParameters();
630 ## @todo should also be changed to a POST with a confirmation dialog preceeding it.
631
632 self._sPageTitle = 'Regenerate All Scheduling Queues';
633 self._sPageBody = '';
634 aoGroups = SchedGroupLogic(self._oDb).getAll();
635 for oGroup in aoGroups:
636 self._sPageBody += '<h3>%s (ID %#d)</h3>' % (webutils.escapeElem(oGroup.sName), oGroup.idSchedGroup);
637 try:
638 (aoErrors, asMessages) = SchedulerBase.recreateQueue(self._oDb, self._oCurUser.uid, oGroup.idSchedGroup, 2);
639 except Exception as oXcpt:
640 self._oDb.rollback();
641 self._sPageBody += '<p>SchedulerBase.recreateQueue threw an exception: %s</p>' \
642 % (webutils.escapeElem(str(oXcpt)),);
643 self._sPageBody += cgitb.html(sys.exc_info());
644 else:
645 if len(aoErrors) == 0:
646 self._sPageBody += '<p>Successfully regenerated.</p>';
647 else:
648 for oError in aoErrors:
649 if oError[1] is None:
650 self._sPageBody += '<p>%s.</p>' % (webutils.escapeElem(oError[0]),);
651 ## @todo links.
652 #elif isinstance(oError[1], TestGroupData):
653 # self._sPageBody += '<p>%s.</p>' % (webutils.escapeElem(oError[0]),);
654 #elif isinstance(oError[1], TestGroupCase):
655 # self._sPageBody += '<p>%s.</p>' % (webutils.escapeElem(oError[0]),);
656 else:
657 self._sPageBody += '<p>%s. [Cannot link to %s]</p>' \
658 % (webutils.escapeElem(oError[0]), webutils.escapeElem(str(oError[1])));
659 for sMsg in asMessages:
660 self._sPageBody += '<p>%s<p>\n' % (webutils.escapeElem(sMsg),);
661 return True;
662
663
664
665 #
666 # Test Config Category.
667 #
668
669 def _actionGlobalRsrcShowAddEdit(self, sAction): # pylint: disable=C0103
670 """Show Global Resource creation or edit dialog"""
671
672 oGlobalResourceLogic = GlobalResourceLogic(self._oDb)
673 if sAction == WuiAdmin.ksActionGlobalRsrcEdit:
674 idGlobalRsrc = self.getIntParam(GlobalResourceData.ksParam_idGlobalRsrc, iDefault = -1)
675 oData = oGlobalResourceLogic.getById(idGlobalRsrc)
676 else:
677 oData = GlobalResourceData()
678 oData.convertToParamNull()
679
680 self._checkForUnknownParameters()
681
682 oContent = WuiGlobalResource(oData)
683 (self._sPageTitle, self._sPageBody) = oContent.showAddModifyPage(sAction)
684
685 return True
686
687 def _actionGlobalRsrcAddEdit(self, sAction):
688 """Add or modify Global Resource record"""
689
690 oData = GlobalResourceData()
691 oData.initFromParams(self, fStrict=True)
692
693 self._checkForUnknownParameters()
694
695 if self._oSrvGlue.getMethod() != 'POST':
696 raise WuiException('Expected "POST" request, got "%s"' % (self._oSrvGlue.getMethod(),))
697
698 oGlobalResourceLogic = GlobalResourceLogic(self._oDb)
699 dErrors = oData.validateAndConvert(self._oDb);
700 if len(dErrors) == 0:
701 if sAction == WuiAdmin.ksActionGlobalRsrcAdd:
702 oGlobalResourceLogic.addGlobalResource(self._oCurUser.uid, oData)
703 elif sAction == WuiAdmin.ksActionGlobalRsrcEdit:
704 idGlobalRsrc = self.getStringParam(GlobalResourceData.ksParam_idGlobalRsrc)
705 oGlobalResourceLogic.editGlobalResource(self._oCurUser.uid, idGlobalRsrc, oData)
706 else:
707 raise WuiException('Invalid parameter.')
708 self._sPageTitle = None;
709 self._sPageBody = None;
710 self._sRedirectTo = self._sActionUrlBase + self.ksActionGlobalRsrcShowAll;
711 else:
712 oContent = WuiGlobalResource(oData)
713 (self._sPageTitle, self._sPageBody) = oContent.showAddModifyPage(sAction, dErrors=dErrors)
714
715 return True
716
717 def _generatePage(self):
718 """Override parent handler in order to change page titte"""
719 if self._sPageTitle is not None:
720 self._sPageTitle = 'Test Manager Admin - ' + self._sPageTitle
721
722 return WuiDispatcherBase._generatePage(self)
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette