Changeset 83415 in vbox
- Timestamp:
- Mar 25, 2020 4:27:11 PM (5 years ago)
- Location:
- trunk/src/VBox/ValidationKit/testmanager
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/config.py
r83381 r83415 90 90 ## File on the build binary share that can be used to check that it's mounted. 91 91 g_ksBuildBinRootFile = 'builds.txt' 92 ## Template for paratial database dump files. One argument: UID 93 g_ksTmDbDumpFileTemplate = '/var/tmp/tm-partial-db-dump-for-%u.zip' 92 94 ## @} 93 95 … … 142 144 g_kcMaxUploads = 256; 143 145 ## @} 146 147 148 ## @name Partial Database Dump 149 ## @{ 150 151 ## Minimum number of day. Set higher than g_kcTmDbDumpMaxDays to disable. 152 g_kcTmDbDumpMinDays = 1; 153 ## Maximum number of day. Keep low - consider space and runtime. 154 g_kcTmDbDumpMaxDays = 31; 155 ## The default number of days. 156 g_kcTmDbDumpDefaultDays = 14; 157 ## @} 158 144 159 145 160 ## @name Debug Features -
trunk/src/VBox/ValidationKit/testmanager/webui/wuiadmin.py
r83360 r83415 35 35 36 36 # Validation Kit imports. 37 from common import webutils37 from common import utils, webutils; 38 38 from testmanager import config; 39 39 from testmanager.webui.wuibase import WuiDispatcherBase, WuiException … … 55 55 ksActionSystemLogList = 'SystemLogList' 56 56 ksActionSystemChangelogList = 'SystemChangelogList' 57 ksActionSystemDbDump = 'SystemDbDump' 58 ksActionSystemDbDumpDownload = 'SystemDbDumpDownload' 57 59 58 60 ksActionUserList = 'UserList' … … 167 169 168 170 # 169 # System Logactions.171 # System actions. 170 172 # 171 173 self._dDispatch[self.ksActionSystemChangelogList] = self._actionSystemChangelogList; 172 174 self._dDispatch[self.ksActionSystemLogList] = self._actionSystemLogList; 175 self._dDispatch[self.ksActionSystemDbDump] = self._actionSystemDbDump; 176 self._dDispatch[self.ksActionSystemDbDumpDownload] = self._actionSystemDbDumpDownload; 173 177 174 178 # … … 345 349 [ 'Changelog', self._sActionUrlBase + self.ksActionSystemChangelogList, False ], 346 350 [ 'System log', self._sActionUrlBase + self.ksActionSystemLogList, False ], 351 [ 'Partial DB Dump', self._sActionUrlBase + self.ksActionSystemDbDump, False ], 347 352 [ 'User accounts', self._sActionUrlBase + self.ksActionUserList, False ], 348 353 [ 'New user', self._sActionUrlBase + self.ksActionUserAdd, True ], … … 423 428 424 429 def _actionSystemChangelogList(self): 425 """ Action wrapper. """430 """ Action handler. """ 426 431 from testmanager.core.systemchangelog import SystemChangelogLogic; 427 432 from testmanager.webui.wuiadminsystemchangelog import WuiAdminSystemChangelogList; … … 447 452 from testmanager.webui.wuiadminsystemlog import WuiAdminSystemLogList; 448 453 return self._actionGenericListing(SystemLogLogic, WuiAdminSystemLogList) 454 455 def _actionSystemDbDump(self): 456 """ Action handler. """ 457 from testmanager.webui.wuiadminsystemdbdump import WuiAdminSystemDbDumpForm; 458 459 cDaysBack = self.getIntParam(self.ksParamDaysBack, iMin = config.g_kcTmDbDumpMinDays, 460 iMax = config.g_kcTmDbDumpMaxDays, iDefault = config.g_kcTmDbDumpDefaultDays); 461 self._checkForUnknownParameters(); 462 463 oContent = WuiAdminSystemDbDumpForm(cDaysBack, oDisp = self); 464 (self._sPageTitle, self._sPageBody) = oContent.showForm(); 465 return True; 466 467 def _actionSystemDbDumpDownload(self): 468 """ Action handler. """ 469 import datetime; 470 import os; 471 472 cDaysBack = self.getIntParam(self.ksParamDaysBack, iMin = config.g_kcTmDbDumpMinDays, 473 iMax = config.g_kcTmDbDumpMaxDays, iDefault = config.g_kcTmDbDumpDefaultDays); 474 self._checkForUnknownParameters(); 475 476 # 477 # Generate the dump. 478 # 479 # We generate a file name that's unique to a user is smart enough to only 480 # issue one of these requests at the time. This also makes sure we won't 481 # waste too much space should this code get interrupted and rerun. 482 # 483 oFile = None; 484 oNow = datetime.datetime.utcnow(); 485 sTmpFile = config.g_ksTmDbDumpFileTemplate % (self._oCurUser.uid,); 486 sScript = os.path.join(config.g_ksTestManagerDir, 'db', 'partial-db-dump.py'); 487 try: 488 (iExitCode, sStdOut, sStdErr) = utils.processOutputUnchecked([sScript, '--days-to-dump', str(cDaysBack), 489 '-f', sTmpFile,]); 490 if iExitCode != 0: 491 raise Exception('iExitCode=%s\n--- stderr ---\n%s\n--- stdout ---\n%s' % (iExitCode, sStdOut, sStdErr,)); 492 493 # 494 # Open and send the dump. 495 # 496 oFile = open(sTmpFile, 'rb'); 497 cbFile = os.fstat(oFile.fileno()).st_size; 498 499 self._oSrvGlue.setHeaderField('Content-Type', 'application/zip'); 500 self._oSrvGlue.setHeaderField('Content-Disposition', 501 oNow.strftime('attachment; filename="partial-db-dump-%Y-%m-%dT%H-%M-%S.zip"')); 502 self._oSrvGlue.setHeaderField('Content-Length', str(cbFile)); 503 504 while True: 505 abChunk = oFile.read(262144); 506 if not abChunk: 507 break; 508 self._oSrvGlue.writeRaw(abChunk); 509 510 finally: 511 # Delete the file to save space. 512 if oFile: 513 try: oFile.close(); 514 except: pass; 515 utils.noxcptDeleteFile(sTmpFile); 516 return self.ksDispatchRcAllDone; 517 449 518 450 519 # User Account actions.
Note:
See TracChangeset
for help on using the changeset viewer.