Esempio n. 1
0
 def __init__(self,
              aoEntries,
              iPage,
              cItemsPerPage,
              tsEffective,
              fnDPrint,
              oDisp,
              cDaysBack,
              aiSelectedSortColumns=None):
     WuiListContentBase.__init__(
         self,
         aoEntries,
         iPage,
         cItemsPerPage,
         tsEffective,
         'System Changelog',
         fnDPrint=fnDPrint,
         oDisp=oDisp,
         aiSelectedSortColumns=aiSelectedSortColumns)
     self._asColumnHeaders = ['When', 'User', 'Event', 'Details']
     self._asColumnAttribs = ['align="center"', 'align="center"', '', '']
     self._oBuildBlacklistLogic = BuildBlacklistLogic(oDisp.getDb())
     self._oBuildLogic = BuildLogic(oDisp.getDb())
     self._oBuildSourceLogic = BuildSourceLogic(oDisp.getDb())
     self._oFailureCategoryLogic = FailureCategoryLogic(oDisp.getDb())
     self._oFailureReasonLogic = FailureReasonLogic(oDisp.getDb())
     self._oGlobalResourceLogic = GlobalResourceLogic(oDisp.getDb())
     self._oSchedGroupLogic = SchedGroupLogic(oDisp.getDb())
     self._oTestBoxLogic = TestBoxLogic(oDisp.getDb())
     self._oTestCaseLogic = TestCaseLogic(oDisp.getDb())
     self._oTestGroupLogic = TestGroupLogic(oDisp.getDb())
     self._oUserAccountLogic = UserAccountLogic(oDisp.getDb())
     self._sPrevDate = ''
     _ = cDaysBack
Esempio n. 2
0
    def _populateForm(self, oForm, oData):
        oForm.addIntRO(      TestBoxData.ksParam_idTestBox,         oData.idTestBox, 'TestBox ID');
        oForm.addIntRO(      TestBoxData.ksParam_idGenTestBox,      oData.idGenTestBox, 'TestBox generation ID');
        oForm.addTimestampRO(TestBoxData.ksParam_tsEffective,       oData.tsEffective, 'Last changed');
        oForm.addTimestampRO(TestBoxData.ksParam_tsExpire,          oData.tsExpire, 'Expires (excl)');
        oForm.addIntRO(      TestBoxData.ksParam_uidAuthor,         oData.uidAuthor, 'Changed by UID');

        oForm.addText(       TestBoxData.ksParam_ip,                oData.ip, 'TestBox IP Address'); ## make read only??
        oForm.addUuid(       TestBoxData.ksParam_uuidSystem,        oData.uuidSystem, 'TestBox System/Firmware UUID');
        oForm.addText(       TestBoxData.ksParam_sName,             oData.sName, 'TestBox Name');
        oForm.addText(       TestBoxData.ksParam_sDescription,      oData.sDescription, 'TestBox Description');
        oForm.addCheckBox(   TestBoxData.ksParam_fEnabled,          oData.fEnabled, 'Enabled');
        oForm.addComboBox(   TestBoxData.ksParam_enmLomKind,        oData.enmLomKind, 'Lights-out-management',
                             TestBoxData.kaoLomKindDescs);
        oForm.addText(       TestBoxData.ksParam_ipLom,             oData.ipLom, 'Lights-out-management IP Address');
        oForm.addInt(        TestBoxData.ksParam_pctScaleTimeout,   oData.pctScaleTimeout, 'Timeout scale factor (%)');

        oForm.addListOfSchedGroupsForTestBox(TestBoxDataEx.ksParam_aoInSchedGroups,
                                             oData.aoInSchedGroups,
                                             SchedGroupLogic(TMDatabaseConnection()).fetchOrderedByName(),
                                             'Scheduling Group');
        # Command, comment and submit button.
        if self._sMode == WuiFormContentBase.ksMode_Edit:
            oForm.addComboBox(TestBoxData.ksParam_enmPendingCmd,    oData.enmPendingCmd, 'Pending command',
                              TestBoxData.kaoTestBoxCmdDescs);
        else:
            oForm.addComboBoxRO(TestBoxData.ksParam_enmPendingCmd,  oData.enmPendingCmd, 'Pending command',
                                TestBoxData.kaoTestBoxCmdDescs);
        oForm.addMultilineText(TestBoxData.ksParam_sComment,        oData.sComment, 'Comment');
        if self._sMode != WuiFormContentBase.ksMode_Show:
            oForm.addSubmit('Create TestBox' if self._sMode == WuiFormContentBase.ksMode_Add else 'Change TestBox');

        return True;
Esempio n. 3
0
    def doIt(self):
        """
        Does the job.
        """
        oDb = TMDatabaseConnection();

        aoGroups = SchedGroupLogic(oDb).getAll();
        iRc = 0;
        for oGroup in aoGroups:
            if not self.oConfig.fQuiet:
                print '%s (ID %#d):' % (oGroup.sName, oGroup.idSchedGroup,);
            try:
                (aoErrors, asMessages) = SchedulerBase.recreateQueue(oDb, self.oConfig.uid, oGroup.idSchedGroup, 2);
            except Exception as oXcpt:
                oDb.rollback();
                print '  !!Hit exception processing "%s": %s' % (oGroup.sName, oXcpt,);
            else:
                if len(aoErrors) == 0:
                    if not self.oConfig.fQuiet:
                        print '  Successfully regenerated.';
                else:
                    iRc = 1;
                    print '  %d errors:' % (len(aoErrors,));
                    for oError in aoErrors:
                        if oError[1]  is None:
                            print '  !!%s' % (oError[0],);
                        else:
                            print '  !!%s (%s)' % (oError[0], oError[1]);
                if len(asMessages) > 0 and not self.oConfig.fQuiet:
                    print '  %d messages:' % (len(asMessages),);
                    for sMsg in asMessages:
                        print '  ##%s' % (sMsg,);
        return iRc;
Esempio n. 4
0
    def _actionRegenQueuesCommon(self):
        """
        Common code for ksActionTestBoxesRegenQueues and ksActionTestCfgRegenQueues.

        Too lazy to put this in some separate place right now.
        """
        self._checkForUnknownParameters()
        ## @todo should also be changed to a POST with a confirmation dialog preceeding it.

        self._sPageTitle = 'Regenerate All Scheduling Queues'
        self._sPageBody = ''
        aoGroups = SchedGroupLogic(self._oDb).getAll()
        for oGroup in aoGroups:
            self._sPageBody += '<h3>%s (ID %#d)</h3>' % (webutils.escapeElem(
                oGroup.sName), oGroup.idSchedGroup)
            try:
                (aoErrors, asMessages) = SchedulerBase.recreateQueue(
                    self._oDb, self._oCurUser.uid, oGroup.idSchedGroup, 2)
            except Exception as oXcpt:
                self._oDb.rollback()
                self._sPageBody += '<p>SchedulerBase.recreateQueue threw an exception: %s</p>' \
                                % (webutils.escapeElem(str(oXcpt)),)
                self._sPageBody += cgitb.html(sys.exc_info())
            else:
                if len(aoErrors) == 0:
                    self._sPageBody += '<p>Successfully regenerated.</p>'
                else:
                    for oError in aoErrors:
                        if oError[1] is None:
                            self._sPageBody += '<p>%s.</p>' % (
                                webutils.escapeElem(oError[0]), )
                        ## @todo links.
                        #elif isinstance(oError[1], TestGroupData):
                        #    self._sPageBody += '<p>%s.</p>' % (webutils.escapeElem(oError[0]),);
                        #elif isinstance(oError[1], TestGroupCase):
                        #    self._sPageBody += '<p>%s.</p>' % (webutils.escapeElem(oError[0]),);
                        else:
                            self._sPageBody += '<p>%s. [Cannot link to %s]</p>' \
                                             % (webutils.escapeElem(oError[0]), webutils.escapeElem(str(oError[1])))
                for sMsg in asMessages:
                    self._sPageBody += '<p>%s<p>\n' % (
                        webutils.escapeElem(sMsg), )
        return True
Esempio n. 5
0
 def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp):
     WuiListContentWithActionBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
                                           sTitle = 'TestBoxes', sId = 'users', fnDPrint = fnDPrint, oDisp = oDisp);
     self._asColumnHeaders.extend([ 'Name', 'LOM', 'Status',
                                    'Cmd', 'Script', 'Python', 'Group',
                                    'OS', 'CPU', 'Features', 'CPUs', 'RAM', 'Scratch',
                                    'Actions' ]);
     self._asColumnAttribs.extend([ 'align="center"', 'align="center"', 'align="center"',
                                    'align="center"', 'align="center"', 'align="center"', 'align="center"',
                                    '', '', '', 'align="right"', 'align="right"', 'align="right"',
                                    'align="center"' ]);
     self._aoActions     = list(self.kasTestBoxActionDescs);
     self._aoSchedGroups = SchedGroupLogic(self._oDisp.getDb()).fetchOrderedByName();
     self._dSchedGroups  = dict();
     for oSchedGroup in self._aoSchedGroups:
         self._aoActions.append([ 'setgroup-%u' % (oSchedGroup.idSchedGroup,),
                                  'Migrate to group %s (#%u)' % (oSchedGroup.sName, oSchedGroup.idSchedGroup,),
                                  oSchedGroup.sDescription ]);
         self._dSchedGroups[oSchedGroup.idSchedGroup] = oSchedGroup;
     self._sAction       = oDisp.ksActionTestBoxListPost;
     self._sCheckboxName = TestBoxData.ksParam_idTestBox;
    def _populateForm(self, oForm, oData):
        oForm.addIntRO(TestBoxData.ksParam_idTestBox, oData.idTestBox,
                       'TestBox ID')
        oForm.addIntRO(TestBoxData.ksParam_idGenTestBox, oData.idGenTestBox,
                       'TestBox generation ID')
        oForm.addTimestampRO(TestBoxData.ksParam_tsEffective,
                             oData.tsEffective, 'Last changed')
        oForm.addTimestampRO(TestBoxData.ksParam_tsExpire, oData.tsExpire,
                             'Expires (excl)')
        oForm.addIntRO(TestBoxData.ksParam_uidAuthor, oData.uidAuthor,
                       'Changed by UID')

        oForm.addText(TestBoxData.ksParam_ip, oData.ip, 'TestBox IP Address')
        oForm.addUuid(TestBoxData.ksParam_uuidSystem, oData.uuidSystem,
                      'TestBox System/Firmware UUID')
        oForm.addText(TestBoxData.ksParam_sName, oData.sName, 'TestBox Name')
        oForm.addText(TestBoxData.ksParam_sDescription, oData.sDescription,
                      'TestBox Description')
        oForm.addComboBox(
            TestBoxData.ksParam_idSchedGroup, oData.idSchedGroup,
            'Scheduling Group',
            SchedGroupLogic(TMDatabaseConnection()).getSchedGroupsForCombo())
        oForm.addCheckBox(TestBoxData.ksParam_fEnabled, oData.fEnabled,
                          'Enabled')
        oForm.addComboBox(TestBoxData.ksParam_enmLomKind, oData.enmLomKind,
                          'Lights-out-management', TestBoxData.kaoLomKindDescs)
        oForm.addText(TestBoxData.ksParam_ipLom, oData.ipLom,
                      'Lights-out-management IP Address')
        oForm.addInt(TestBoxData.ksParam_pctScaleTimeout,
                     oData.pctScaleTimeout, 'Timeout scale factor (%)')

        ## @todo Pretty format the read-only fields and use hidden fields for
        #        passing the actual values. (Yes, we need the values so we can
        #        display the form correctly on input error.)
        oForm.addTextRO(TestBoxData.ksParam_sOs, oData.sOs, 'TestBox OS')
        oForm.addTextRO(TestBoxData.ksParam_sOsVersion, oData.sOsVersion,
                        'TestBox OS version')
        oForm.addTextRO(TestBoxData.ksParam_sCpuArch, oData.sCpuArch,
                        'TestBox OS kernel architecture')
        oForm.addTextRO(TestBoxData.ksParam_sCpuVendor, oData.sCpuVendor,
                        'TestBox CPU vendor')
        oForm.addTextRO(TestBoxData.ksParam_sCpuName, oData.sCpuName,
                        'TestBox CPU name')
        if oData.lCpuRevision:
            oForm.addTextRO(TestBoxData.ksParam_lCpuRevision,
                            '%#x' % (oData.lCpuRevision, ),
                            'TestBox CPU revision',
                            sPostHtml=' (family=%#x model=%#x stepping=%#x)' %
                            (
                                oData.getCpuFamily(),
                                oData.getCpuModel(),
                                oData.getCpuStepping(),
                            ),
                            sSubClass='long')
        else:
            oForm.addLongRO(TestBoxData.ksParam_lCpuRevision,
                            oData.lCpuRevision, 'TestBox CPU revision')
        oForm.addIntRO(TestBoxData.ksParam_cCpus, oData.cCpus,
                       'Number of CPUs, cores and threads')
        oForm.addCheckBoxRO(TestBoxData.ksParam_fCpuHwVirt, oData.fCpuHwVirt,
                            'VT-x or AMD-V supported')
        oForm.addCheckBoxRO(TestBoxData.ksParam_fCpuNestedPaging,
                            oData.fCpuNestedPaging, 'Nested paging supported')
        oForm.addCheckBoxRO(TestBoxData.ksParam_fCpu64BitGuest,
                            oData.fCpu64BitGuest, '64-bit guest supported')
        oForm.addCheckBoxRO(TestBoxData.ksParam_fChipsetIoMmu,
                            oData.fChipsetIoMmu, 'I/O MMU supported')
        oForm.addMultilineTextRO(TestBoxData.ksParam_sReport, oData.sReport,
                                 'Hardware/software report')
        oForm.addLongRO(TestBoxData.ksParam_cMbMemory, oData.cMbMemory,
                        'Installed RAM size (MB)')
        oForm.addLongRO(TestBoxData.ksParam_cMbScratch, oData.cMbScratch,
                        'Available scratch space (MB)')
        oForm.addIntRO(TestBoxData.ksParam_iTestBoxScriptRev,
                       oData.iTestBoxScriptRev, 'TestBox Script SVN revision')
        # Later:
        #if not self.isAttributeNull(''):
        #    sHexVer = '%s.%s.%.%s' % (oData.iPythonHexVersion >> 24, (oData.iPythonHexVersion >> 16) & 0xff,
        #                             (oData.iPythonHexVersion >> 8) & 0xff, oData.iPythonHexVersion & 0xff);
        #else:
        #    sHexVer = str(oData.iPythonHexVersion);

        oForm.addIntRO(TestBoxData.ksParam_iPythonHexVersion,
                       oData.iPythonHexVersion, 'Python version (hex)')
        if self._sMode == WuiFormContentBase.ksMode_Edit:
            oForm.addComboBox(TestBoxData.ksParam_enmPendingCmd,
                              oData.enmPendingCmd, 'Pending command',
                              TestBoxData.kaoTestBoxCmdDescs)
        else:
            oForm.addComboBoxRO(TestBoxData.ksParam_enmPendingCmd,
                                oData.enmPendingCmd, 'Pending command',
                                TestBoxData.kaoTestBoxCmdDescs)

        if self._sMode != WuiFormContentBase.ksMode_Show:
            oForm.addSubmit(
                'Create TestBox' if self._sMode ==
                WuiFormContentBase.ksMode_Add else 'Change TestBox')

        return True