Changeset 81115 in vbox for trunk/src/VBox/ValidationKit/testmanager/batch/virtual_test_sheriff.py
- Timestamp:
- Oct 5, 2019 1:42:17 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 133742
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/batch/virtual_test_sheriff.py
r80792 r81115 543 543 % ( idTestBox, oTestBox.sName, iFirstOkay, cBad, cOkay)); 544 544 545 # 546 # Reset hanged testboxes 547 # 548 cStatusTimeoutMins = 10; 549 550 self.oDb.execute('SELECT TestBoxStatuses.idTestBox\n' 551 ' FROM TestBoxStatuses, TestBoxes\n' 552 ' WHERE TestBoxStatuses.tsUpdated >= (CURRENT_TIMESTAMP - interval \'%s hours\')\n' 553 ' AND TestBoxStatuses.tsUpdated < (CURRENT_TIMESTAMP - interval \'%s minutes\')\n' 554 ' AND TestBoxStatuses.idTestBox = TestBoxes.idTestBox\n' 555 ' AND Testboxes.tsExpire = \'infinity\'::timestamp', (cHoursBack,cStatusTimeoutMins)); 556 for idTestBox in self.oDb.fetchAll(): 557 idTestBox = idTestBox[0]; 558 try: 559 oTestBox = TestBoxData().initFromDbWithId(self.oDb, idTestBox); 560 except Exception as oXcpt: 561 rcExit = self.eprint('Failed to get data for test box #%u in badTestBoxManagement: %s' % (idTestBox, oXcpt,)); 562 continue; 563 # Skip if the testbox is already disabled, already reset or there's no iLOM 564 if not oTestBox.fEnabled or oTestBox.ipLom is None or oTestBox.sComment is not None and oTestBox.sComment.find('Automatically reset') >= 0: 565 self.dprint(u'badTestBoxManagement: Skipping test box #%u (%s) as it has been disabled already.' 566 % ( idTestBox, oTestBox.sName, )); 567 continue; 568 ## @todo get iLOM credentials from a table? 569 sCmd = 'sshpass -p%s ssh -oStrictHostKeyChecking=no root@%s show /SP && reset /SYS' % (g_ksLomPassword, oTestBox.ipLom,); 570 try: 571 oPs = subprocess.Popen(sCmd, stdout=subprocess.PIPE, shell=True); 572 sStdout = oPs.communicate()[0]; 573 iRC = oPs.wait(); 574 575 oTestBox.sComment = 'Automatically reset (iRC=%u sStdout=%s)' % (iRC, sStdout,); 576 oTestBoxLogic.editEntry(oTestBox, self.uidSelf, fCommit = True); 577 578 sComment = u'Reset testbox #%u (%s) - iRC=%u sStduot=%s' % ( idTestBox, oTestBox.sName, iRC, sStdout); 579 self.vprint(sComment); 580 self.sendEmailAlert(self.uidSelf, sComment); 581 582 except Exception as oXcpt: 583 rcExit = self.eprint(u'Error resetting testbox #%u (%s): %s\n' % (idTestBox, oTestBox.sName, oXcpt,)); 584 545 ## @todo r=bird: review + rewrite; 546 ## - no selecting here, that belongs in the core/*.py files. 547 ## - preserve existing comments. 548 ## - doing way too much in the try/except block. 549 ## - No password quoting in the sshpass command that always fails (127). 550 ## - Timeout is way to low. testboxmem1 need more than 10 min to take a dump, ages to 551 ## get thru POST and another 5 just to time out in grub. Should be an hour or so. 552 ## Besides, it need to be constant elsewhere in the file, not a variable here. 553 ## 554 ## 555 ## Reset hanged testboxes 556 ## 557 #cStatusTimeoutMins = 10; 558 # 559 #self.oDb.execute('SELECT TestBoxStatuses.idTestBox\n' 560 # ' FROM TestBoxStatuses, TestBoxes\n' 561 # ' WHERE TestBoxStatuses.tsUpdated >= (CURRENT_TIMESTAMP - interval \'%s hours\')\n' 562 # ' AND TestBoxStatuses.tsUpdated < (CURRENT_TIMESTAMP - interval \'%s minutes\')\n' 563 # ' AND TestBoxStatuses.idTestBox = TestBoxes.idTestBox\n' 564 # ' AND Testboxes.tsExpire = \'infinity\'::timestamp', (cHoursBack,cStatusTimeoutMins)); 565 #for idTestBox in self.oDb.fetchAll(): 566 # idTestBox = idTestBox[0]; 567 # try: 568 # oTestBox = TestBoxData().initFromDbWithId(self.oDb, idTestBox); 569 # except Exception as oXcpt: 570 # rcExit = self.eprint('Failed to get data for test box #%u in badTestBoxManagement: %s' % (idTestBox, oXcpt,)); 571 # continue; 572 # # Skip if the testbox is already disabled, already reset or there's no iLOM 573 # if not oTestBox.fEnabled or oTestBox.ipLom is None or oTestBox.sComment is not None and oTestBox.sComment.find('Automatically reset') >= 0: 574 # self.dprint(u'badTestBoxManagement: Skipping test box #%u (%s) as it has been disabled already.' 575 # % ( idTestBox, oTestBox.sName, )); 576 # continue; 577 # ## @todo get iLOM credentials from a table? 578 # sCmd = 'sshpass -p%s ssh -oStrictHostKeyChecking=no root@%s show /SP && reset /SYS' % (g_ksLomPassword, oTestBox.ipLom,); 579 # try: 580 # oPs = subprocess.Popen(sCmd, stdout=subprocess.PIPE, shell=True); 581 # sStdout = oPs.communicate()[0]; 582 # iRC = oPs.wait(); 583 # 584 # oTestBox.sComment = 'Automatically reset (iRC=%u sStdout=%s)' % (iRC, sStdout,); 585 # oTestBoxLogic.editEntry(oTestBox, self.uidSelf, fCommit = True); 586 # 587 # sComment = u'Reset testbox #%u (%s) - iRC=%u sStduot=%s' % ( idTestBox, oTestBox.sName, iRC, sStdout); 588 # self.vprint(sComment); 589 # self.sendEmailAlert(self.uidSelf, sComment); 590 # 591 # except Exception as oXcpt: 592 # rcExit = self.eprint(u'Error resetting testbox #%u (%s): %s\n' % (idTestBox, oTestBox.sName, oXcpt,)); 593 # 585 594 return rcExit; 586 595
Note:
See TracChangeset
for help on using the changeset viewer.