def _anchorAndAppendBinaries(self, sBinaries, aoRows): """ Formats each binary (if any) into a row with a download link. """ if sBinaries is not None: for sBinary in sBinaries.split(','): if not webutils.hasSchema(sBinary): sBinary = config.g_ksBuildBinUrlPrefix + sBinary; aoRows.append([WuiLinkBase(webutils.getFilename(sBinary), sBinary, fBracketed = False),]); return aoRows;
def _formatListEntry(self, iEntry): # pylint: disable=R0914 from testmanager.webui.wuiadmin import WuiAdmin oEntry = self._aoEntries[iEntry] # Lights outs managment. if oEntry.enmLomKind == TestBoxData.ksLomKind_ILOM: aoLom = [ WuiLinkBase('ILOM', 'https://%s/' % (oEntry.ipLom, ), fBracketed=False), ] elif oEntry.enmLomKind == TestBoxData.ksLomKind_ELOM: aoLom = [ WuiLinkBase('ELOM', 'http://%s/' % (oEntry.ipLom, ), fBracketed=False), ] elif oEntry.enmLomKind == TestBoxData.ksLomKind_AppleXserveLom: aoLom = ['Apple LOM'] elif oEntry.enmLomKind == TestBoxData.ksLomKind_None: aoLom = ['none'] else: aoLom = [ 'Unexpected enmLomKind value "%s"' % (oEntry.enmLomKind, ) ] if oEntry.ipLom is not None: if oEntry.enmLomKind in [ TestBoxData.ksLomKind_ILOM, TestBoxData.ksLomKind_ELOM ]: aoLom += [ WuiLinkBase('(ssh)', 'ssh://%s' % (oEntry.ipLom, ), fBracketed=False) ] aoLom += [WuiRawHtml('<br>'), '%s' % (oEntry.ipLom, )] # State and Last seen. if oEntry.oStatus is None: oSeen = WuiSpanText('tmspan-offline', 'Never') oState = '' else: oDelta = oEntry.tsCurrent - oEntry.oStatus.tsUpdated if oDelta.days <= 0 and oDelta.seconds <= self.kcSecMaxStatusDeltaAlive: oSeen = WuiSpanText( 'tmspan-online', u'%s\u00a0s\u00a0ago' % (oDelta.days * 24 * 3600 + oDelta.seconds, )) else: oSeen = WuiSpanText( 'tmspan-offline', u'%s' % (self.formatTsShort(oEntry.oStatus.tsUpdated), )) if oEntry.oStatus.idTestSet is None: oState = str(oEntry.oStatus.enmState) else: from testmanager.webui.wuimain import WuiMain oState = WuiTmLink( oEntry.oStatus.enmState, WuiMain.ksScriptName, # pylint: disable=R0204 { WuiMain.ksParamAction: WuiMain.ksActionTestResultDetails, TestSetData.ksParam_idTestSet: oEntry.oStatus.idTestSet, }, sTitle='#%u' % (oEntry.oStatus.idTestSet, ), fBracketed=False) # Comment oComment = self._formatCommentCell(oEntry.sComment) # Group links. aoGroups = [] for oInGroup in oEntry.aoInSchedGroups: oSchedGroup = oInGroup.oSchedGroup aoGroups.append( WuiTmLink(oSchedGroup.sName, WuiAdmin.ksScriptName, { WuiAdmin.ksParamAction: WuiAdmin.ksActionSchedGroupEdit, SchedGroupData.ksParam_idSchedGroup: oSchedGroup.idSchedGroup, }, sTitle='#%u' % (oSchedGroup.idSchedGroup, ), fBracketed=len(oEntry.aoInSchedGroups) > 1)) # Reformat the OS version to take less space. aoOs = ['N/A'] if oEntry.sOs is not None and oEntry.sOsVersion is not None and oEntry.sCpuArch: sOsVersion = oEntry.sOsVersion if sOsVersion[0] not in [ 'v', 'V', 'r', 'R'] \ and sOsVersion[0].isdigit() \ and sOsVersion.find('.') in range(4) \ and oEntry.sOs in [ 'linux', 'solaris', 'darwin', ]: sOsVersion = 'v' + sOsVersion sVer1 = sOsVersion sVer2 = None if oEntry.sOs == 'linux' or oEntry.sOs == 'darwin': iSep = sOsVersion.find(' / ') if iSep > 0: sVer1 = sOsVersion[:iSep].strip() sVer2 = sOsVersion[iSep + 3:].strip() sVer2 = sVer2.replace('Red Hat Enterprise Linux Server', 'RHEL') sVer2 = sVer2.replace('Oracle Linux Server', 'OL') elif oEntry.sOs == 'solaris': iSep = sOsVersion.find(' (') if iSep > 0 and sOsVersion[-1] == ')': sVer1 = sOsVersion[:iSep].strip() sVer2 = sOsVersion[iSep + 2:-1].strip() elif oEntry.sOs == 'win': iSep = sOsVersion.find('build') if iSep > 0: sVer1 = sOsVersion[:iSep].strip() sVer2 = 'B' + sOsVersion[iSep + 1:].strip() aoOs = [ WuiSpanText('tmspan-osarch', u'%s.%s' % ( oEntry.sOs, oEntry.sCpuArch, )), WuiSpanText( 'tmspan-osver1', sVer1.replace('-', u'\u2011'), ), ] if sVer2 is not None: aoOs += [ WuiRawHtml('<br>'), WuiSpanText('tmspan-osver2', sVer2.replace('-', u'\u2011')), ] # Format the CPU revision. oCpu = None if oEntry.lCpuRevision is not None and oEntry.sCpuVendor is not None and oEntry.sCpuName is not None: oCpu = [ u'%s (fam:%xh\u00a0m:%xh\u00a0s:%xh)' % ( oEntry.sCpuVendor, oEntry.getCpuFamily(), oEntry.getCpuModel(), oEntry.getCpuStepping(), ), WuiRawHtml('<br>'), oEntry.sCpuName, ] else: oCpu = [] if oEntry.sCpuVendor is not None: oCpu.append(oEntry.sCpuVendor) if oEntry.lCpuRevision is not None: oCpu.append('%#x' % (oEntry.lCpuRevision, )) if oEntry.sCpuName is not None: oCpu.append(oEntry.sCpuName) # Stuff cpu vendor and cpu/box features into one field. asFeatures = [] if oEntry.fCpuHwVirt is True: asFeatures.append(u'HW\u2011Virt') if oEntry.fCpuNestedPaging is True: asFeatures.append(u'Nested\u2011Paging') if oEntry.fCpu64BitGuest is True: asFeatures.append(u'64\u2011bit\u2011Guest') if oEntry.fChipsetIoMmu is True: asFeatures.append(u'I/O\u2011MMU') sFeatures = u' '.join(asFeatures) if asFeatures else u'' # Collection applicable actions. aoActions = [ WuiTmLink( 'Details', WuiAdmin.ksScriptName, { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestBoxDetails, TestBoxData.ksParam_idTestBox: oEntry.idTestBox, WuiAdmin.ksParamEffectiveDate: self._tsEffectiveDate, }), ] if self._oDisp is None or not self._oDisp.isReadOnlyUser(): if isDbTimestampInfinity(oEntry.tsExpire): aoActions += [ WuiTmLink( 'Edit', WuiAdmin.ksScriptName, { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestBoxEdit, TestBoxData.ksParam_idTestBox: oEntry.idTestBox, }), WuiTmLink( 'Remove', WuiAdmin.ksScriptName, { WuiAdmin.ksParamAction: WuiAdmin.ksActionTestBoxRemovePost, TestBoxData.ksParam_idTestBox: oEntry.idTestBox }, sConfirm='Are you sure that you want to remove %s (%s)?' % (oEntry.sName, oEntry.ip)), ] if oEntry.sOs not in [ 'win', 'os2', ] and oEntry.ip is not None: aoActions.append( WuiLinkBase( 'ssh', 'ssh://vbox@%s' % (oEntry.ip, ), )) return [ self._getCheckBoxColumn(iEntry, oEntry.idTestBox), [ WuiSpanText('tmspan-name', oEntry.sName), WuiRawHtml('<br>'), '%s' % (oEntry.ip, ), ], aoLom, [ '' if oEntry.fEnabled else 'disabled / ', oState, WuiRawHtml('<br>'), oSeen, ], oEntry.enmPendingCmd, oComment, WuiSvnLink(oEntry.iTestBoxScriptRev), oEntry.formatPythonVersion(), aoGroups, aoOs, oCpu, sFeatures, oEntry.cCpus if oEntry.cCpus is not None else 'N/A', utils.formatNumberNbsp(oEntry.cMbMemory) + u'\u00a0MB' if oEntry.cMbMemory is not None else 'N/A', utils.formatNumberNbsp(oEntry.cMbScratch) + u'\u00a0MB' if oEntry.cMbScratch is not None else 'N/A', aoActions, ]