1 | # -*- coding: utf-8 -*-
|
---|
2 | # $Id: wuiadminschedgroup.py 56295 2015-06-09 14:29:55Z vboxsync $
|
---|
3 |
|
---|
4 | """
|
---|
5 | Test Manager WUI - Scheduling groups.
|
---|
6 | """
|
---|
7 |
|
---|
8 | __copyright__ = \
|
---|
9 | """
|
---|
10 | Copyright (C) 2012-2015 Oracle Corporation
|
---|
11 |
|
---|
12 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
13 | available from http://www.virtualbox.org. This file is free software;
|
---|
14 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
15 | General Public License (GPL) as published by the Free Software
|
---|
16 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
17 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
18 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
19 |
|
---|
20 | The contents of this file may alternatively be used under the terms
|
---|
21 | of the Common Development and Distribution License Version 1.0
|
---|
22 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
23 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
24 | CDDL are applicable instead of those of the GPL.
|
---|
25 |
|
---|
26 | You may elect to license modified versions of this file under the
|
---|
27 | terms and conditions of either the GPL or the CDDL or both.
|
---|
28 | """
|
---|
29 | __version__ = "$Revision: 56295 $"
|
---|
30 |
|
---|
31 |
|
---|
32 | # Validation Kit imports.
|
---|
33 | from testmanager.core.buildsource import BuildSourceData, BuildSourceLogic;
|
---|
34 | from testmanager.core.db import isDbTimestampInfinity;
|
---|
35 | from testmanager.core.schedgroup import SchedGroupData, SchedGroupDataEx;
|
---|
36 | from testmanager.core.testgroup import TestGroupData, TestGroupLogic;
|
---|
37 | from testmanager.core.testbox import TestBoxData;
|
---|
38 | from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink
|
---|
39 |
|
---|
40 |
|
---|
41 | class WuiSchedGroup(WuiFormContentBase):
|
---|
42 | """
|
---|
43 | WUI Scheduling Groups HTML content generator.
|
---|
44 | """
|
---|
45 |
|
---|
46 | def __init__(self, oData, sMode, oDisp):
|
---|
47 | assert isinstance(oData, SchedGroupData);
|
---|
48 | if sMode == WuiFormContentBase.ksMode_Add:
|
---|
49 | sTitle = 'New Scheduling Group';
|
---|
50 | elif sMode == WuiFormContentBase.ksMode_Edit:
|
---|
51 | sTitle = 'Edit Scheduling Group'
|
---|
52 | else:
|
---|
53 | assert sMode == WuiFormContentBase.ksMode_Show;
|
---|
54 | sTitle = 'Scheduling Group';
|
---|
55 | WuiFormContentBase.__init__(self, oData, sMode, 'SchedGroup', oDisp, sTitle);
|
---|
56 |
|
---|
57 | # Read additional bits form the DB.
|
---|
58 | self._aoAllTestGroups = TestGroupLogic(oDisp.getDb()).getAll();
|
---|
59 |
|
---|
60 |
|
---|
61 | def _populateForm(self, oForm, oData):
|
---|
62 | """
|
---|
63 | Construct an HTML form
|
---|
64 | """
|
---|
65 |
|
---|
66 | oForm.addIntRO (SchedGroupData.ksParam_idSchedGroup, oData.idSchedGroup, 'ID')
|
---|
67 | oForm.addTimestampRO(SchedGroupData.ksParam_tsEffective, oData.tsEffective, 'Last changed')
|
---|
68 | oForm.addTimestampRO(SchedGroupData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)')
|
---|
69 | oForm.addIntRO (SchedGroupData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID')
|
---|
70 | oForm.addText (SchedGroupData.ksParam_sName, oData.sName, 'Name')
|
---|
71 | oForm.addText (SchedGroupData.ksParam_sDescription, oData.sDescription, 'Description')
|
---|
72 | oForm.addCheckBox (SchedGroupData.ksParam_fEnabled, oData.fEnabled, 'Enabled')
|
---|
73 |
|
---|
74 | oForm.addComboBox (SchedGroupData.ksParam_enmScheduler, oData.enmScheduler, 'Scheduler type',
|
---|
75 | SchedGroupData.kasSchedulerDesc)
|
---|
76 |
|
---|
77 | aoBuildSrcIds = BuildSourceLogic(self._oDisp.getDb()).fetchForCombo();
|
---|
78 | oForm.addComboBox (SchedGroupData.ksParam_idBuildSrc, oData.idBuildSrc, 'Build source', aoBuildSrcIds);
|
---|
79 | oForm.addComboBox (SchedGroupData.ksParam_idBuildSrcTestSuite,
|
---|
80 | oData.idBuildSrcTestSuite, 'Test suite', aoBuildSrcIds);
|
---|
81 |
|
---|
82 | oForm.addListOfSchedGroupMembers(SchedGroupDataEx.ksParam_aoMembers,
|
---|
83 | oData.aoMembers, self._aoAllTestGroups, 'Test groups',
|
---|
84 | fReadOnly = self._sMode == WuiFormContentBase.ksMode_Show);
|
---|
85 |
|
---|
86 | oForm.addSubmit()
|
---|
87 |
|
---|
88 | return True;
|
---|
89 |
|
---|
90 | class WuiAdminSchedGroupList(WuiListContentBase):
|
---|
91 | """
|
---|
92 | Content generator for the schedule group listing.
|
---|
93 | """
|
---|
94 |
|
---|
95 | def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp):
|
---|
96 | WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
|
---|
97 | sTitle = 'Registered Scheduling Groups', sId = 'schedgroups',
|
---|
98 | fnDPrint = fnDPrint, oDisp = oDisp);
|
---|
99 |
|
---|
100 | self._asColumnHeaders = [
|
---|
101 | 'ID', 'Name', 'Enabled', 'Scheduler Type',
|
---|
102 | 'Build Source', 'Validation Kit Source', 'Test Groups', 'TestBoxes', 'Actions',
|
---|
103 | ];
|
---|
104 |
|
---|
105 | self._asColumnAttribs = [
|
---|
106 | 'align="right"', 'align="center"', 'align="center"', 'align="center"',
|
---|
107 | 'align="center"', 'align="center"', '', '', 'align="center"',
|
---|
108 | ];
|
---|
109 |
|
---|
110 | def _formatListEntry(self, iEntry):
|
---|
111 | """
|
---|
112 | Format *show all* table entry
|
---|
113 | """
|
---|
114 | from testmanager.webui.wuiadmin import WuiAdmin
|
---|
115 | oEntry = self._aoEntries[iEntry]
|
---|
116 |
|
---|
117 | oBuildSrc = None;
|
---|
118 | if oEntry.idBuildSrc is not None:
|
---|
119 | oBuildSrc = WuiTmLink(oEntry.oBuildSrc.sName if oEntry.oBuildSrc else str(oEntry.idBuildSrc),
|
---|
120 | WuiAdmin.ksScriptName,
|
---|
121 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildSrcDetails,
|
---|
122 | BuildSourceData.ksParam_idBuildSrc: oEntry.idBuildSrc, });
|
---|
123 |
|
---|
124 | oValidationKitSrc = None;
|
---|
125 | if oEntry.idBuildSrcTestSuite is not None:
|
---|
126 | oValidationKitSrc = WuiTmLink(oEntry.oBuildSrcValidationKit.sName if oEntry.oBuildSrcValidationKit
|
---|
127 | else str(oEntry.idBuildSrcTestSuite),
|
---|
128 | WuiAdmin.ksScriptName,
|
---|
129 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildSrcDetails,
|
---|
130 | BuildSourceData.ksParam_idBuildSrc: oEntry.idBuildSrcTestSuite, });
|
---|
131 |
|
---|
132 | # Test groups
|
---|
133 | aoMembers = [];
|
---|
134 | for oMember in oEntry.aoMembers:
|
---|
135 | aoMembers.append(WuiTmLink(oMember.oTestGroup.sName, WuiAdmin.ksScriptName,
|
---|
136 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestGroupDetails,
|
---|
137 | TestGroupData.ksParam_idTestGroup: oMember.idTestGroup,
|
---|
138 | WuiAdmin.ksParamEffectiveDate: self._tsEffectiveDate, },
|
---|
139 | sTitle = '#%s' % (oMember.idTestGroup,) if oMember.oTestGroup.sDescription is None
|
---|
140 | else '#%s - %s' % (oMember.idTestGroup, oMember.oTestGroup.sDescription,) ));
|
---|
141 |
|
---|
142 | # Test boxes.
|
---|
143 | aoTestBoxes = [];
|
---|
144 | for oTestBox in oEntry.aoTestBoxes:
|
---|
145 | aoTestBoxes.append(WuiTmLink(oTestBox.sName, WuiAdmin.ksScriptName,
|
---|
146 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestBoxDetails,
|
---|
147 | TestBoxData.ksParam_idTestBox: oTestBox.idTestBox,
|
---|
148 | WuiAdmin.ksParamEffectiveDate: self._tsEffectiveDate, },
|
---|
149 | sTitle = '#%s - %s / %s - %s.%s (%s)'
|
---|
150 | % (oTestBox.idTestBox, oTestBox.ip, oTestBox.uuidSystem, oTestBox.sOs,
|
---|
151 | oTestBox.sCpuArch, oTestBox.sOsVersion,)));
|
---|
152 |
|
---|
153 |
|
---|
154 | # Actions
|
---|
155 | aoActions = [ WuiTmLink('Details', WuiAdmin.ksScriptName,
|
---|
156 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionSchedGroupDetails,
|
---|
157 | SchedGroupData.ksParam_idSchedGroup: oEntry.idSchedGroup,
|
---|
158 | WuiAdmin.ksParamEffectiveDate: self._tsEffectiveDate, } ),];
|
---|
159 | if isDbTimestampInfinity(oEntry.tsExpire):
|
---|
160 | aoActions.append(WuiTmLink('Modify', WuiAdmin.ksScriptName,
|
---|
161 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionSchedGroupEdit,
|
---|
162 | SchedGroupData.ksParam_idSchedGroup: oEntry.idSchedGroup } ));
|
---|
163 | aoActions.append(WuiTmLink('Clone', WuiAdmin.ksScriptName,
|
---|
164 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionSchedGroupClone,
|
---|
165 | SchedGroupData.ksParam_idSchedGroup: oEntry.idSchedGroup,
|
---|
166 | WuiAdmin.ksParamEffectiveDate: self._tsEffectiveDate, } ));
|
---|
167 | if isDbTimestampInfinity(oEntry.tsExpire):
|
---|
168 | aoActions.append(WuiTmLink('Remove', WuiAdmin.ksScriptName,
|
---|
169 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionSchedGroupDoRemove,
|
---|
170 | SchedGroupData.ksParam_idSchedGroup: oEntry.idSchedGroup },
|
---|
171 | sConfirm = 'Are you sure you want to remove scheduling group #%d?'
|
---|
172 | % (oEntry.idSchedGroup,)));
|
---|
173 |
|
---|
174 | return [
|
---|
175 | oEntry.idSchedGroup,
|
---|
176 | oEntry.sName,
|
---|
177 | oEntry.fEnabled,
|
---|
178 | oEntry.enmScheduler,
|
---|
179 | oBuildSrc,
|
---|
180 | oValidationKitSrc,
|
---|
181 | aoMembers,
|
---|
182 | aoTestBoxes,
|
---|
183 | aoActions,
|
---|
184 | ];
|
---|