cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# -*- coding: utf-8 -*-
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncTest Manager - TestBox.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCopyright (C) 2012-2014 Oracle Corporation
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThis file is part of VirtualBox Open Source Edition (OSE), as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncavailable from http://www.virtualbox.org. This file is free software;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncyou can redistribute it and/or modify it under the terms of the GNU
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncGeneral Public License (GPL) as published by the Free Software
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncFoundation, in version 2 as it comes in the "COPYING" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution. VirtualBox OSE is distributed in the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynchope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThe contents of this file may alternatively be used under the terms
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncof the Common Development and Distribution License Version 1.0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync(CDDL) only, as it comes in the "COPYING.CDDL" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution, in which case the provisions of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCDDL are applicable instead of those of the GPL.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncYou may elect to license modified versions of this file under the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncterms and conditions of either the GPL or the CDDL or both.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Standard python imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Validation Kit imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMExceptionBase, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# pylint: disable=C0103
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass TestBoxData(ModelDataBase): # pylint: disable=R0902
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync TestBox Data.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## LomKind_T
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync kasLomKindValues = [ ksLomKind_None, ksLomKind_ILOM, ksLomKind_ELOM, ksLomKind_AppleXserveLom];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ( ksLomKind_AppleXserveLom, 'Apple Xserve LOM', ''),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## TestBoxCmd_T
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ksTestBoxCmd_UpgradeAndReboot = 'upgrade-and-reboot';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync kasTestBoxCmdValues = [ ksTestBoxCmd_None, ksTestBoxCmd_Abort, ksTestBoxCmd_Reboot, ksTestBoxCmd_Upgrade,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ksTestBoxCmd_UpgradeAndReboot, ksTestBoxCmd_Special];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ( ksTestBoxCmd_Upgrade, 'Upgrade TestBox Script', ''),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ( ksTestBoxCmd_UpgradeAndReboot, 'Upgrade TestBox Script and reboot', ''),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ksParam_pctScaleTimeout = 'TestBox_pctScaleTimeout';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ksParam_fCpuNestedPaging = 'TestBox_fCpuNestedPaging';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ksParam_iTestBoxScriptRev = 'TestBox_iTestBoxScriptRev';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ksParam_iPythonHexVersion = 'TestBox_iPythonHexVersion';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync kasAllowNullAttributes = ['idTestBox', 'tsEffective', 'tsExpire', 'uidAuthor', 'idGenTestBox', 'sDescription',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'ipLom', 'sOs', 'sOsVersion', 'sCpuVendor', 'sCpuArch', 'sCpuName', 'lCpuRevision', 'cCpus',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'fCpuHwVirt', 'fCpuNestedPaging', 'fCpu64BitGuest', 'fChipsetIoMmu', 'cMbMemory',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'cMbScratch', 'sReport', 'iTestBoxScriptRev', 'iPythonHexVersion' ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync kasValidValues_enmPendingCmd = kasTestBoxCmdValues;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Initialize with defaults.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # See the database for explanations of each of these fields.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Internal worker for initFromDbWithId and initFromDbWithGenId as well as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from TestBoxLogic. Expecting a SELECT * FROM TestBoxes result.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def initFromDbWithId(self, oDb, idTestBox, tsNow = None, sPeriodBack = None):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Initialize the object from the database.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oDb.execute(self.formatSimpleNowAndPeriodQuery(oDb,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'SELECT *\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'FROM TestBoxes\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE idTestBox = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise TMExceptionBase('idTestBox=%s not found (tsNow=%s sPeriodBack=%s)' % (idTestBox, tsNow, sPeriodBack,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Initialize the object from the database.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'FROM TestBoxes\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE idGenTestBox = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _validateAndConvertWorker(self, asAllowNullAttributes, oDb):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Override to do extra ipLom checks.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync dErrors = ModelDataBase._validateAndConvertWorker(self, asAllowNullAttributes, oDb);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync dErrors[self.ksParam_ipLom] = 'Light-out-management IP is mandatory and a LOM is selected.'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Unbuttons the version number and formats it as a version string.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return 'N/A';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return 'v%d.%d.%d.%d' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Returns the CPU family for a x86 or amd64 testboxes."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Returns the CPU model for a x86 or amd64 testboxes."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Returns the CPU stepping for a x86 or amd64 testboxes."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync TestBox logic.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Tries to fetch a testbox by its UUID alone.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'FROM TestBoxes\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE uuidSystem = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' AND tsExpire = \'infinity\'::timestamp\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'ORDER BY tsEffective DESC\n',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise TMExceptionBase('Database integrity error: %u hits' % (self._oDb.getRowCount(),));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def fetchForListing(self, iStart, cMaxRows, tsNow):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Fetches testboxes for listing.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns an array (list) of TestBoxData items, empty list if none. The
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync TestBoxData instances have an extra oStatus member that is either None or
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync a TestBoxStatusData instance, and a member tsCurrent holding
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync CURRENT_TIMESTAMP.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Raises exception on error.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from testmanager.core.testboxstatus import TestBoxStatusData;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._oDb.execute('SELECT TestBoxes.*, TestBoxStatuses.*\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'FROM TestBoxes\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'LEFT OUTER JOIN TestBoxStatuses ON (\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' TestBoxStatuses.idTestBox = TestBoxes.idTestBox )\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'ORDER BY sName\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'LIMIT %s OFFSET %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._oDb.execute('SELECT TestBoxes.*, TestBoxStatuses.*\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'FROM TestBoxes\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'LEFT OUTER JOIN TestBoxStatuses ON (\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' TestBoxStatuses.idTestBox = TestBoxes.idTestBox )\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE tsExpire > %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' AND tsEffective <= %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'ORDER BY sName\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'LIMIT %s OFFSET %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTestBox.tsCurrent = self._oDb.getCurrentTimestamp(); # pylint: disable=W0201
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTestBox.oStatus = TestBoxStatusData().initFromDbRow(aoOne[31:]); # pylint: disable=W0201
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def fetchForChangeLog(self, idTestBox, iStart, cMaxRows, tsNow): # pylint: disable=R0914
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Fetches change log entries for a testbox.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns an array of ChangeLogEntry instance and an indicator whether
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync there are more entries.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Raises exception on error.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._oDb.execute('SELECT TestBoxes.*, Users.sUsername\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'FROM TestBoxes\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'LEFT OUTER JOIN Users \n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' ON ( TestBoxes.uidAuthor = Users.uid\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' AND Users.tsEffective <= TestBoxes.tsEffective\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' AND Users.tsExpire > TestBoxes.tsEffective)\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE TestBoxes.tsEffective <= %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' AND TestBoxes.idTestBox = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'ORDER BY TestBoxes.tsExpire DESC\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'LIMIT %s OFFSET %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoRows.append([TestBoxData().initFromDbRow(oRow), oRow[-1],]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Calculate the changes.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sAttr not in [ 'tsEffective', 'tsExpire', 'uidAuthor']:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoChanges.append(AttributeChangeEntry(sAttr, oNewAttr, oOldAttr, str(oNewAttr), str(oOldAttr)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoEntries.append(ChangeLogEntry(oNew.uidAuthor, sAuthor, oNew.tsEffective, oNew.tsExpire, oNew, oOld, aoChanges));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # If we're at the end of the log, add the initial entry.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoEntries.append(ChangeLogEntry(oNew.uidAuthor, aoRows[-1][1], oNew.tsEffective, oNew.tsExpire, oNew, None, []));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def addEntry(self, oData, uidAuthor, fCommit = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Creates a testbox in the database.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns the testbox ID, testbox generation ID and effective timestamp
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync of the created testbox on success. Throws error on failure.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise TMExceptionBase('Invalid data passed to create(): %s' % (dDataErrors,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idTestBox,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' tsEffective,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' tsExpire,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' uidAuthor,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idGenTestBox,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' uuidSystem,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sName,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sDescription,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idSchedGroup,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fEnabled,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' enmLomKind,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' ipLom,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' pctScaleTimeout,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sOsVersion,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuVendor,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuArch,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuName,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' lCpuRevision,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cCpus,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpuHwVirt,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpuNestedPaging,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpu64BitGuest,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fChipsetIoMmu,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cMbMemory,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cMbScratch,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sReport,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' iTestBoxScriptRev,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' iPythonHexVersion,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' enmPendingCmd\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'VALUES (\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' DEFAULT,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' CURRENT_TIMESTAMP,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' DEFAULT,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' DEFAULT,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'RETURNING idTestBox, idGenTestBox, tsEffective'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def editEntry(self, oData, uidAuthor, fCommit = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Data edit update, web UI is the primary user.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns the new generation ID and effective date.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise TMExceptionBase('Invalid data passed to create(): %s' % (dDataErrors,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo check if the data changed.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'SET tsExpire = CURRENT_TIMESTAMP\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE idGenTestBox = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' AND tsExpire = \'infinity\'::timestamp\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'RETURNING tsExpire\n',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Would be easier to do this using an insert or update hook, I think. Much easier.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idGenTestBox,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idTestBox,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' tsEffective,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' uidAuthor,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' uuidSystem,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sName,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sDescription,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idSchedGroup,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fEnabled,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' enmLomKind,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' ipLom,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' pctScaleTimeout,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sOsVersion,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuVendor,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuArch,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuName,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' lCpuRevision,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cCpus,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpuHwVirt,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpuNestedPaging,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpu64BitGuest,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fChipsetIoMmu,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cMbMemory,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cMbScratch,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' iTestBoxScriptRev,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' iPythonHexVersion,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' enmPendingCmd\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'SELECT NEXTVAL(\'TestBoxGenIdSeq\'),\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idTestBox,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sOsVersion,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuVendor,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuArch,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuName,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' lCpuRevision,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cCpus,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpuHwVirt,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpuNestedPaging,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpu64BitGuest,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fChipsetIoMmu,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cMbMemory,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cMbScratch,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' iTestBoxScriptRev,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' iPythonHexVersion,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'FROM TestBoxes\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE idGenTestBox = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'RETURNING idGenTestBox, tsEffective'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if aRow is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def updateOnSignOn(self, idTestBox, idGenTestBox, sTestBoxAddr, sOs, sOsVersion, # pylint: disable=R0913,R0914
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCpuVendor, sCpuArch, sCpuName, lCpuRevision, cCpus, fCpuHwVirt, fCpuNestedPaging, fCpu64BitGuest,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fChipsetIoMmu, cMbMemory, cMbScratch, sReport, iTestBoxScriptRev, iPythonHexVersion):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Update the testbox attributes automatically on behalf of the testbox script.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns the new generation id on success, raises an exception on failure.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Would be easier to do this using an insert or update hook, I think. Much easier.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'SET tsExpire = CURRENT_TIMESTAMP\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE idGenTestBox = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' AND tsExpire = \'infinity\'::timestamp\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'RETURNING tsExpire\n',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idGenTestBox,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idTestBox,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' tsEffective,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' uidAuthor,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' uuidSystem,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sName,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sDescription,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idSchedGroup,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fEnabled,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' enmLomKind,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' ipLom,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' pctScaleTimeout,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sOsVersion,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuVendor,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuArch,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuName,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' lCpuRevision,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cCpus,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpuHwVirt,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpuNestedPaging,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpu64BitGuest,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fChipsetIoMmu,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cMbMemory,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cMbScratch,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sReport,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' iTestBoxScriptRev,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' iPythonHexVersion,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' enmPendingCmd\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'SELECT NEXTVAL(\'TestBoxGenIdSeq\'),\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' uuidSystem,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sName,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sDescription,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idSchedGroup,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fEnabled,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' enmLomKind,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' ipLom,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' pctScaleTimeout,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' enmPendingCmd\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'FROM TestBoxes\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE idGenTestBox = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'RETURNING idGenTestBox'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def setCommand(self, idTestBox, sOldCommand, sNewCommand, uidAuthor = None, fCommit = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Sets or resets the pending command on a testbox.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns (idGenTestBox, tsEffective) of the new row.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Would be easier to do this using an insert or update hook, I think. Much easier.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'SET tsExpire = CURRENT_TIMESTAMP\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE idTestBox = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' AND tsExpire = \'infinity\'::timestamp\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' AND enmPendingCmd = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'RETURNING tsExpire\n',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idGenTestBox,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idTestBox,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' tsEffective,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' uidAuthor,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' uuidSystem,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sName,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sDescription,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idSchedGroup,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fEnabled,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' enmLomKind,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' ipLom,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' pctScaleTimeout,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sOsVersion,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuVendor,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuArch,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuName,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' lCpuRevision,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cCpus,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpuHwVirt,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpuNestedPaging,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpu64BitGuest,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fChipsetIoMmu,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cMbMemory,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cMbScratch,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sReport,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' iTestBoxScriptRev,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' iPythonHexVersion,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' enmPendingCmd\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'SELECT NEXTVAL(\'TestBoxGenIdSeq\'),\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' uuidSystem,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sName,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sDescription,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' idSchedGroup,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fEnabled,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' enmLomKind,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' ipLom,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' pctScaleTimeout,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sOsVersion,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuVendor,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuArch,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sCpuName,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' lCpuRevision,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cCpus,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpuHwVirt,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpuNestedPaging,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fCpu64BitGuest,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' fChipsetIoMmu,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cMbMemory,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' cMbScratch,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' sReport,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' iTestBoxScriptRev,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' iPythonHexVersion,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'FROM TestBoxes\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE idTestBox = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' AND tsExpire = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' AND enmPendingCmd = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'RETURNING idGenTestBox'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Retrieve list of all registered Test Box records from DB.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'FROM TestBoxes\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE tsExpire=\'infinity\'::timestamp;')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _historize(self, idTestBox, uidAuthor, tsExpire = None):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Historizes the current entry. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'SET tsExpire = CURRENT_TIMESTAMP,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' uidAuthor = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE idTestBox = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' AND tsExpire = \'infinity\'::TIMESTAMP\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'SET tsExpire = %s,\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' uidAuthor = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'WHERE idTestBox = %s\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' AND tsExpire = \'infinity\'::TIMESTAMP\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def removeEntry(self, uidAuthor, idTestBox, fCascade = False, fCommit=False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Delete user account
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Unit testing.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# pylint: disable=C0111
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # not reached.