VirtualBox

Ignore:
Timestamp:
Jun 6, 2016 5:53:01 PM (9 years ago)
Author:
vboxsync
Message:

testmanager: Testboxes can now be members of more than one scheduling group.

Location:
trunk/src/VBox/ValidationKit/testmanager/webui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/webui/wuiadmin.py

    r61432 r61502  
    526526    def _actionTestBoxAdd(self):
    527527        """ Action wrapper. """
    528         from testmanager.core.testbox                  import TestBoxData;
     528        from testmanager.core.testbox                  import TestBoxDataEx;
    529529        from testmanager.webui.wuiadmintestbox         import WuiTestBox;
    530         return self._actionGenericFormAdd(TestBoxData, WuiTestBox);
     530        return self._actionGenericFormAdd(TestBoxDataEx, WuiTestBox);
    531531
    532532    def _actionTestBoxAddPost(self):
    533533        """ Action wrapper. """
    534         from testmanager.core.testbox                  import TestBoxData, TestBoxLogic;
     534        from testmanager.core.testbox                  import TestBoxDataEx, TestBoxLogic;
    535535        from testmanager.webui.wuiadmintestbox         import WuiTestBox;
    536         return self._actionGenericFormAddPost(TestBoxData, TestBoxLogic, WuiTestBox, self.ksActionTestBoxList);
     536        return self._actionGenericFormAddPost(TestBoxDataEx, TestBoxLogic, WuiTestBox, self.ksActionTestBoxList);
    537537
    538538    def _actionTestBoxDetails(self):
    539539        """ Action wrapper. """
    540         from testmanager.core.testbox                  import TestBoxData, TestBoxLogic;
     540        from testmanager.core.testbox                  import TestBoxDataEx, TestBoxLogic;
    541541        from testmanager.webui.wuiadmintestbox         import WuiTestBox;
    542         return self._actionGenericFormDetails(TestBoxData, TestBoxLogic, WuiTestBox, 'idTestBox', 'idGenTestBox');
     542        return self._actionGenericFormDetails(TestBoxDataEx, TestBoxLogic, WuiTestBox, 'idTestBox', 'idGenTestBox');
    543543
    544544    def _actionTestBoxEdit(self):
    545545        """ Action wrapper. """
    546         from testmanager.core.testbox                  import TestBoxData;
     546        from testmanager.core.testbox                  import TestBoxDataEx;
    547547        from testmanager.webui.wuiadmintestbox         import WuiTestBox;
    548         return self._actionGenericFormEdit(TestBoxData, WuiTestBox, TestBoxData.ksParam_idTestBox);
     548        return self._actionGenericFormEdit(TestBoxDataEx, WuiTestBox, TestBoxDataEx.ksParam_idTestBox);
    549549
    550550    def _actionTestBoxEditPost(self):
    551551        """ Action wrapper. """
    552         from testmanager.core.testbox                  import TestBoxData, TestBoxLogic;
     552        from testmanager.core.testbox                  import TestBoxDataEx, TestBoxLogic;
    553553        from testmanager.webui.wuiadmintestbox         import WuiTestBox;
    554         return self._actionGenericFormEditPost(TestBoxData, TestBoxLogic,WuiTestBox, self.ksActionTestBoxList);
     554        return self._actionGenericFormEditPost(TestBoxDataEx, TestBoxLogic,WuiTestBox, self.ksActionTestBoxList);
    555555
    556556    def _actionTestBoxRemovePost(self):
  • trunk/src/VBox/ValidationKit/testmanager/webui/wuiadmintestbox.py

    r61472 r61502  
    3939from testmanager.core.db                import TMDatabaseConnection;
    4040from testmanager.core.schedgroup        import SchedGroupLogic, SchedGroupData;
    41 from testmanager.core.testbox           import TestBoxData;
     41from testmanager.core.testbox           import TestBoxData, TestBoxDataEx;
    4242from testmanager.core.testset           import TestSetData;
    4343from testmanager.core.db                import isDbTimestampInfinity;
     
    102102        oForm.addText(       TestBoxData.ksParam_sName,             oData.sName, 'TestBox Name');
    103103        oForm.addText(       TestBoxData.ksParam_sDescription,      oData.sDescription, 'TestBox Description');
    104         oForm.addComboBox(   TestBoxData.ksParam_idSchedGroup,      oData.idSchedGroup, 'Scheduling Group',
    105                              SchedGroupLogic(TMDatabaseConnection()).getSchedGroupsForCombo());
    106104        oForm.addCheckBox(   TestBoxData.ksParam_fEnabled,          oData.fEnabled, 'Enabled');
    107105        oForm.addComboBox(   TestBoxData.ksParam_enmLomKind,        oData.enmLomKind, 'Lights-out-management',
     
    110108        oForm.addInt(        TestBoxData.ksParam_pctScaleTimeout,   oData.pctScaleTimeout, 'Timeout scale factor (%)');
    111109
    112         ## @todo Pretty format the read-only fields and use hidden fields for
    113         #        passing the actual values. (Yes, we need the values so we can
    114         #        display the form correctly on input error.)
     110        oForm.addListOfSchedGroupsForTestBox(TestBoxDataEx.ksParam_aoInSchedGroups,
     111                                             oData.aoInSchedGroups,
     112                                             SchedGroupLogic(TMDatabaseConnection()).fetchOrderedByName(),
     113                                             'Scheduling Group');
     114        # Command, comment and submit button.
     115        if self._sMode == WuiFormContentBase.ksMode_Edit:
     116            oForm.addComboBox(TestBoxData.ksParam_enmPendingCmd,    oData.enmPendingCmd, 'Pending command',
     117                              TestBoxData.kaoTestBoxCmdDescs);
     118        else:
     119            oForm.addComboBoxRO(TestBoxData.ksParam_enmPendingCmd,  oData.enmPendingCmd, 'Pending command',
     120                                TestBoxData.kaoTestBoxCmdDescs);
     121        oForm.addMultilineText(TestBoxData.ksParam_sComment,        oData.sComment, 'Comment');
     122        if self._sMode != WuiFormContentBase.ksMode_Show:
     123            oForm.addSubmit('Create TestBox' if self._sMode == WuiFormContentBase.ksMode_Add else 'Change TestBox');
     124
     125        return True;
     126
     127
     128    def _generatePostFormContent(self, oData):
     129        from testmanager.webui.wuihlpform import WuiHlpForm;
     130
     131        oForm = WuiHlpForm('testbox-machine-settable', '', fReadOnly = True);
    115132        oForm.addTextRO(     TestBoxData.ksParam_sOs,               oData.sOs, 'TestBox OS');
    116133        oForm.addTextRO(     TestBoxData.ksParam_sOsVersion,        oData.sOsVersion, 'TestBox OS version');
     
    138155        oForm.addIntRO(      TestBoxData.ksParam_iPythonHexVersion, oData.iPythonHexVersion,
    139156                             'Python version (hex)', sPostHtml = webutils.escapeElem(sHexVer));
    140 
    141         if self._sMode == WuiFormContentBase.ksMode_Edit:
    142             oForm.addComboBox(TestBoxData.ksParam_enmPendingCmd,    oData.enmPendingCmd, 'Pending command',
    143                               TestBoxData.kaoTestBoxCmdDescs);
    144         else:
    145             oForm.addComboBoxRO(TestBoxData.ksParam_enmPendingCmd,  oData.enmPendingCmd, 'Pending command',
    146                                 TestBoxData.kaoTestBoxCmdDescs);
    147 
    148         oForm.addMultilineText(TestBoxData.ksParam_sComment,        oData.sComment, 'Comment');
    149 
    150         if self._sMode != WuiFormContentBase.ksMode_Show:
    151             oForm.addSubmit('Create TestBox' if self._sMode == WuiFormContentBase.ksMode_Add else 'Change TestBox');
    152 
    153         return True;
     157        return [('Machine Only Settables', oForm.finalize()),];
     158
    154159
    155160
     
    173178
    174179    def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp):
     180        # type: (list[TestBoxDataForListing], int, int, datetime.datetime, ignore, WuiAdmin) -> None
    175181        WuiListContentWithActionBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
    176182                                              sTitle = 'TestBoxes', sId = 'users', fnDPrint = fnDPrint, oDisp = oDisp);
     
    237243        oComment = self._formatCommentCell(oEntry.sComment);
    238244
    239         # Group link.
    240         oGroup = self._dSchedGroups.get(oEntry.idSchedGroup);
    241         oGroupLink = WuiTmLink(oGroup.sName if oGroup is not None else str(oEntry.idSchedGroup),
    242                                WuiAdmin.ksScriptName,
    243                                { WuiAdmin.ksParamAction: WuiAdmin.ksActionSchedGroupEdit,
    244                                  SchedGroupData.ksParam_idSchedGroup: oEntry.idSchedGroup, },
    245                                sTitle = '#%u' % (oEntry.idSchedGroup,),
    246                                fBracketed = False);
     245        # Group links.
     246        aoGroups = [];
     247        for oInGroup in oEntry.aoInSchedGroups:
     248            oSchedGroup = oInGroup.oSchedGroup;
     249            aoGroups.append(WuiTmLink(oSchedGroup.sName, WuiAdmin.ksScriptName,
     250                                      { WuiAdmin.ksParamAction: WuiAdmin.ksActionSchedGroupEdit,
     251                                        SchedGroupData.ksParam_idSchedGroup: oSchedGroup.idSchedGroup, },
     252                                      sTitle = '#%u' % (oSchedGroup.idSchedGroup,),
     253                                      fBracketed = len(oEntry.aoInSchedGroups) > 1));
    247254
    248255        # Reformat the OS version to take less space.
     
    338345                 WuiSvnLink(oEntry.iTestBoxScriptRev),
    339346                 oEntry.formatPythonVersion(),
    340                  oGroupLink,
     347                 aoGroups,
    341348                 aoOs,
    342349                 oCpu,
  • trunk/src/VBox/ValidationKit/testmanager/webui/wuibase.py

    r61439 r61502  
    316316    #
    317317
    318     def getStringParam(self, sName, asValidValues = None, sDefault = None):
     318    def getStringParam(self, sName, asValidValues = None, sDefault = None, fAllowNull = False):
    319319        """
    320320        Gets a string parameter.
     
    328328                raise WuiException('%s parameter "%s" is given multiple times: "%s"' % (self._sAction, sName, sValue));
    329329            sValue = sValue.strip();
    330         elif sDefault is None:
     330        elif sDefault is None and fAllowNull is not True:
    331331            raise WuiException('%s is missing parameters: "%s"' % (self._sAction, sName,));
    332332        else:
  • trunk/src/VBox/ValidationKit/testmanager/webui/wuihlpform.py

    r61468 r61502  
    763763        For WuiAdminSchedGroup.
    764764        """
    765         if self._fReadOnly:
    766             fReadOnly = True;
     765        if fReadOnly is None or self._fReadOnly:
     766            fReadOnly = self._fReadOnly;
    767767        assert len(aoSchedGroupMembers) <= len(aoAllTestGroups);
    768768        self._addLabel(sName, sLabel);
     
    857857                         u'</table>\n');
    858858
     859    def addListOfSchedGroupsForTestBox(self, sName, aoInSchedGroups, aoAllSchedGroups, sLabel,  # pylint: disable=R0914
     860                                       fReadOnly = None):
     861        # type: (str, TestBoxInSchedGroupDataEx, SchedGroupData, str, bool) -> str
     862        """
     863        For WuiTestGroup.
     864        """
     865        from testmanager.core.testbox import TestBoxInSchedGroupData, TestBoxDataEx;
     866
     867        if fReadOnly is None or self._fReadOnly:
     868            fReadOnly = self._fReadOnly;
     869        assert len(aoInSchedGroups) <= len(aoAllSchedGroups);
     870
     871        # Only show selected groups in read-only mode.
     872        if fReadOnly:
     873            aoAllSchedGroups = [oCur.oSchedGroup for oCur in aoInSchedGroups]
     874
     875        self._addLabel(sName, sLabel);
     876        if len(aoAllSchedGroups) == 0:
     877            return self._add('<li>No scheduling groups available.</li>\n')
     878
     879        # Add special parameter with all the scheduling group IDs in the form.
     880        self._add(u'<input name="%s" type="hidden" value="%s">\n'
     881                  % ( TestBoxDataEx.ksParam_aidSchedGroups,
     882                      ','.join([unicode(oSchedGroup.idSchedGroup) for oSchedGroup in aoAllSchedGroups]), ));
     883
     884        # Table header.
     885        self._add(u'<table class="tmformtbl">\n'
     886                  u' <thead>\n'
     887                  u'  <tr>\n'
     888                  u'    <th rowspan="2"></th>\n'
     889                  u'    <th rowspan="2">Schedulding Grooup</th>\n'
     890                  u'    <th rowspan="2">Priority [0..31]</th>\n'
     891                  u'  </tr>\n'
     892                  u' </thead>\n'
     893                  u' <tbody>\n'
     894                  );
     895
     896        # Table body.
     897        if self._fReadOnly:
     898            fReadOnly = True;
     899        sCheckBoxAttr = ' readonly onclick="return false" onkeydown="return false"' if fReadOnly else '';
     900
     901        oDefMember = TestBoxInSchedGroupData();
     902        aoInSchedGroups = list(aoInSchedGroups); # Copy it so we can pop.
     903        for iSchedGroup, oSchedGroup in enumerate(aoAllSchedGroups):
     904
     905            # Is it a member?
     906            oMember = None;
     907            for i, _ in enumerate(aoInSchedGroups):
     908                if aoInSchedGroups[i].idSchedGroup == oSchedGroup.idSchedGroup:
     909                    oMember = aoInSchedGroups.pop(i);
     910                    break;
     911
     912            # Start on the rows...
     913            sPrefix = u'%s[%d]' % (sName, oSchedGroup.idSchedGroup,);
     914            self._add(u'  <tr class="%s">\n'
     915                      u'    <td>\n'
     916                      u'      <input name="%s[%s]" type="hidden" value="%s">\n' # idSchedGroup
     917                      u'      <input name="%s[%s]" type="hidden" value="%s">\n' # idTestBox
     918                      u'      <input name="%s[%s]" type="hidden" value="%s">\n' # tsExpire
     919                      u'      <input name="%s[%s]" type="hidden" value="%s">\n' # tsEffective
     920                      u'      <input name="%s[%s]" type="hidden" value="%s">\n' # uidAuthor
     921                      u'      <input name="%s" type="checkbox"%s%s value="%d" class="tmform-checkbox" title="#%d - %s">\n' #(list)
     922                      u'    </td>\n'
     923                      % ( 'tmodd' if iSchedGroup & 1 else 'tmeven',
     924                          sPrefix, TestBoxInSchedGroupData.ksParam_idSchedGroup,  oSchedGroup.idSchedGroup,
     925                          sPrefix, TestBoxInSchedGroupData.ksParam_idTestBox,   -1 if oMember is None else oMember.idTestBox,
     926                          sPrefix, TestBoxInSchedGroupData.ksParam_tsExpire,    '' if oMember is None else oMember.tsExpire,
     927                          sPrefix, TestBoxInSchedGroupData.ksParam_tsEffective, '' if oMember is None else oMember.tsEffective,
     928                          sPrefix, TestBoxInSchedGroupData.ksParam_uidAuthor,   '' if oMember is None else oMember.uidAuthor,
     929                          TestBoxDataEx.ksParam_aoInSchedGroups, '' if oMember is None else ' checked', sCheckBoxAttr,
     930                          oSchedGroup.idSchedGroup, oSchedGroup.idSchedGroup, escapeElem(oSchedGroup.sName),
     931                          ));
     932            self._add(u'    <td align="left">%s</td>\n' % ( escapeElem(oSchedGroup.sName), ));
     933
     934            self._add(u'    <td align="center">\n'
     935                      u'      <input name="%s[%s]" type="text" value="%s" style="max-width:3em;" %s>\n'
     936                      u'    </td>\n'
     937                      % ( sPrefix, TestBoxInSchedGroupData.ksParam_iSchedPriority,
     938                          (oMember if oMember is not None else oDefMember).iSchedPriority,
     939                          ' readonly class="tmform-input-readonly"' if fReadOnly else '', ));
     940            self._add(u'  </tr>\n');
     941
     942        return self._add(u' </tbody>\n'
     943                         u'</table>\n');
     944
     945
    859946    #
    860947    # Buttons.
Note: See TracChangeset for help on using the changeset viewer.

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