- Timestamp:
- Mar 22, 2018 2:17:46 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/api/tdMoveVM1.py
r71411 r71457 34 34 import sys 35 35 import time 36 import shutil 36 37 37 38 # Only the main script needs to modify the path. … … 55 56 def __init__(self, oTstDrv): 56 57 base.SubTestDriverBase.__init__(self, 'move-vm', oTstDrv) 58 self.asRsrcs = self.getResourceSet() 59 60 for oRes in self.asRsrcs: 61 reporter.log('Resource is "%s"' % (oRes,)) 57 62 58 63 def testIt(self): … … 113 118 oVM = None 114 119 115 # del oSession116 117 120 return oVM 118 121 … … 166 169 return False 167 170 171 def getResourceSet(self): 172 # Construct the resource list the first time it's queried. 173 if self.oTstDrv.asRsrcs is None: 174 self.oTstDrv.asRsrcs = [] 175 self.oTstDrv.asRsrcs.append('5.3/isos/tdMoveVM.iso') 176 self.oTstDrv.asRsrcs.append('5.3/floppy/tdMoveVM.img') 177 178 return self.oTstDrv.asRsrcs 179 168 180 # 169 181 #testVMMove … … 236 248 fRc = fRc and oSession.saveSettings() 237 249 if fRc is False: 238 reporter.log('Couldn\'t save machine settings ')250 reporter.log('Couldn\'t save machine settings after 1t scenario') 239 251 240 252 ############# 2 case. ########################################################################################## … … 254 266 fRc = fRc and oSession.saveSettings() 255 267 if fRc is False: 256 reporter.log('Couldn\'t save machine settings ')268 reporter.log('Couldn\'t save machine settings after 2nd scenario') 257 269 258 270 ############# 3 case. ########################################################################################## … … 276 288 fRc = fRc and oSession.saveSettings() 277 289 if fRc is False: 278 reporter.log('Couldn\'t save machine settings ')290 reporter.log('Couldn\'t save machine settings after 3d scenario') 279 291 280 292 ############# 4 case. ########################################################################################## … … 320 332 #There is an ISO image (.iso) attached to the VM. 321 333 #Prerequisites - there is IDE Controller and there are no any images attached to it. 322 # fRc = True 323 # oVirtualBox = self.oTstDrv.oVBoxMgr.getVirtualBox() 324 # oMachine = oVirtualBox.findMachine('test-vm-move') 325 # if oMachine == None: 326 # reporter.log("Machine '%s' is unknown" % (oMachine.name)) 327 # return False 328 # 329 # del oVirtualBox 330 # 331 # sLoc = sMoveLoc + os.sep + oMachine.name + os.sep 332 # sMoveLoc = os.path.join(sOrigLoc, 'moveFolder_5th_scenario') 333 # os.mkdir(sMoveLoc, 0o775) 334 # sISOLoc = os.path.join(g_ksValidationKitDir + os.sep, 'tests' + os.sep + 'api' + os.sep + 'tdMoveVM.iso') 335 # if not os.path.exists(sISOLoc): 336 # reporter.log('ISO file does not exist at "%s"' % (sISOLoc,)) 337 # fRc = False 338 # 339 # #attach ISO image to the IDE controller 340 # if fRc is True: 341 # sController='IDE Controller' 342 # aoMediumAttachments = oMachine.getMediumAttachmentsOfController(sController) 343 # iPort = len(aoMediumAttachments) 344 # reporter.log('sISOLoc "%s", sController "%s", iPort "%s"' % (sISOLoc,sController,iPort)) 345 # fRc = oSession.attachDvd(sISOLoc, sController, iPort, iDevice = 0) 346 # 347 # fRc = fRc and oSession.saveSettings() 348 # if fRc is False: 349 # reporter.log('Couldn\'t save machine settings') 350 # 351 # reporter.log('fRc after oSession.attachDvd "%s"' % (fRc)) 352 # 353 # #move ISO image to the VM settings folder 354 # if fRc is True: 355 # aoMediumAttachments = oMachine.getMediumAttachmentsOfController(sController) 356 # reporter.log('number of attachments on IDE Controller is "%s"' % (len(aoMediumAttachments))) 357 # for oAttachment in aoMediumAttachments: 358 # sActualFilePath = oAttachment.medium.location 359 # reporter.log('medium location is "%s"' % (sActualFilePath)) 360 # 361 # oSubTstDrvMoveMedium1Instance = SubTstDrvMoveMedium1(self.oTstDrv) 362 # oSubTstDrvMoveMedium1Instance.setLocation(sLoc, aoMediumAttachments) 363 # 364 # if fRc is True: 365 # fRc = self.moveVMToLocation(sMoveLoc, oSession.o.machine) and fRc 366 # 367 # fRc = fRc and oSession.saveSettings() 368 # if fRc is False: 369 # reporter.log('Couldn\'t save machine settings') 370 # 371 # #back ISO image to the original destination 372 # aoMediumAttachments = oMachine.getMediumAttachmentsOfController(sController) 373 # oSubTstDrvMoveMedium1Instance.setLocation(sActualFilePath, aoMediumAttachments) 374 # del oSubTstDrvMoveMedium1Instance 375 # 376 # #detach ISO image 377 # fRc = oSession.detachHd(sController, iPort, 0) 378 # 379 # fRc = fRc and oSession.saveSettings() 380 # if fRc is False: 381 # reporter.log('Couldn\'t save machine settings') 334 fRc = True 335 oVirtualBox = self.oTstDrv.oVBoxMgr.getVirtualBox() 336 oMachine = oVirtualBox.findMachine('test-vm-move') 337 if oMachine == None: 338 reporter.log("Machine '%s' is unknown" % (oMachine.name)) 339 return False 340 341 del oVirtualBox 342 343 sLoc = sMoveLoc + os.sep + oMachine.name + os.sep 344 sMoveLoc = os.path.join(sOrigLoc, 'moveFolder_5th_scenario') 345 os.mkdir(sMoveLoc, 0o775) 346 sISOLoc = '5.3/isos/tdMoveVM1.iso' 347 reporter.log("sHost is '%s', sResourcePath is '%s'" % (self.oTstDrv.sHost, self.oTstDrv.sResourcePath)) 348 sISOLoc = self.oTstDrv.getFullResourceName(sISOLoc) 349 350 if not os.path.exists(sISOLoc): 351 reporter.log('ISO file does not exist at "%s"' % (sISOLoc,)) 352 fRc = False 353 354 #Copy ISO image from the common resource folder into machine folder 355 shutil.copy(sISOLoc, sLoc) 356 357 #attach ISO image to the IDE controller 358 if fRc is True: 359 #set actual ISO location 360 sISOLoc = sLoc + os.sep + 'tdMoveVM1.iso' 361 sController='IDE Controller' 362 aoMediumAttachments = oMachine.getMediumAttachmentsOfController(sController) 363 iPort = len(aoMediumAttachments) 364 reporter.log('sISOLoc "%s", sController "%s", iPort "%s"' % (sISOLoc,sController,iPort)) 365 fRc = oSession.attachDvd(sISOLoc, sController, iPort, iDevice = 0) 366 367 if fRc is True: 368 fRc = self.moveVMToLocation(sMoveLoc, oSession.o.machine) and fRc 369 370 #detach ISO image 371 fRc = oSession.detachHd(sController, iPort, 0) 372 373 fRc = fRc and oSession.saveSettings() 374 if fRc is False: 375 reporter.log('Couldn\'t save machine settings after 5th scenario') 382 376 383 377 ############# 6 case. ########################################################################################## 384 378 #There is a floppy image (.img) attached to the VM. 385 379 #Prerequisites - there is Floppy Controller and there are no any images attached to it. 386 # fRc = True 387 # sLoc = sMoveLoc + os.sep + oMachine.name + os.sep 388 # sMoveLoc = os.path.join(sOrigLoc, 'moveFolder_6th_scenario') 389 # os.mkdir(sMoveLoc, 0o775) 390 # sFloppyLoc = os.path.join(g_ksValidationKitDir + os.sep, 'tests' + os.sep + 'api' + os.sep + 'tdMoveVM.img') 391 # if not os.path.exists(sISOLoc): 392 # reporter.log('Floppy disk does not exist at "%s"' % (sISOLoc,)) 393 # fRc = False 394 # 395 # # attach floppy image 396 # if fRc is True: 397 # sController='Floppy Controller' 398 # reporter.log('sFloppyLoc "%s", sController "%s"' % (sFloppyLoc,sController)) 399 # fRc = fRc and oSession.attachFloppy(sFloppyLoc, sController, 0, 0) 400 # 401 # fRc = fRc and oSession.saveSettings() 402 # if fRc is False: 403 # reporter.log('Couldn\'t save machine settings') 404 # 405 # reporter.log('fRc after oSession.attachFloppy "%s"' % (fRc)) 406 # 407 # #move Floppy image to the VM settings folder 408 # if fRc is True: 409 # aoMediumAttachments = oMachine.getMediumAttachmentsOfController(sController) 410 # reporter.log('number of attachments on Floppy Controller is "%s"' % (len(aoMediumAttachments))) 411 # for oAttachment in aoMediumAttachments: 412 # sActualFilePath = oAttachment.medium.location 413 # reporter.log('medium location is "%s"' % (sActualFilePath)) 414 # 415 # oSubTstDrvMoveMedium1Instance = SubTstDrvMoveMedium1(self.oTstDrv) 416 # oSubTstDrvMoveMedium1Instance.setLocation(sLoc, aoMediumAttachments) 417 # 418 # if fRc is True: 419 # fRc = self.moveVMToLocation(sMoveLoc, oSession.o.machine) and fRc 420 # 421 # #back Floppy image to the original destination 422 # aoMediumAttachments = oMachine.getMediumAttachmentsOfController(sController) 423 # oSubTstDrvMoveMedium1Instance.setLocation(sActualFilePath, aoMediumAttachments) 424 # del oSubTstDrvMoveMedium1Instance 425 # 426 # #detach Floppy image 427 # fRc = oSession.detachHd(sController, 0, 0) 428 # 429 # fRc = fRc and oSession.saveSettings() 430 # if fRc is False: 431 # reporter.log('Couldn\'t save machine settings') 432 # 380 fRc = True 381 sLoc = sMoveLoc + os.sep + oMachine.name + os.sep 382 sMoveLoc = os.path.join(sOrigLoc, 'moveFolder_6th_scenario') 383 os.mkdir(sMoveLoc, 0o775) 384 sFloppyLoc = '5.3/floppy/tdMoveVM1.img' 385 sFloppyLoc = self.oTstDrv.getFullResourceName(sFloppyLoc) 386 387 if not os.path.exists(sFloppyLoc): 388 reporter.log('Floppy disk does not exist at "%s"' % (sFloppyLoc,)) 389 fRc = False 390 391 #Copy floppy image from the common resource folder into machine folder 392 shutil.copy(sFloppyLoc, sLoc) 393 394 # attach floppy image 395 if fRc is True: 396 #set actual floppy location 397 sFloppyLoc = sLoc + os.sep + 'tdMoveVM1.img' 398 sController='Floppy Controller' 399 reporter.log('sFloppyLoc "%s", sController "%s"' % (sFloppyLoc,sController)) 400 fRc = fRc and oSession.attachFloppy(sFloppyLoc, sController, 0, 0) 401 402 if fRc is True: 403 fRc = self.moveVMToLocation(sMoveLoc, oSession.o.machine) and fRc 404 405 #detach floppy image 406 fRc = oSession.detachHd(sController, 0, 0) 407 408 fRc = fRc and oSession.saveSettings() 409 if fRc is False: 410 reporter.log('Couldn\'t save machine settings after 6th scenario') 411 433 412 ############# 7 case. ########################################################################################## 434 413 # # There are shareable disk and immutable disk attached to the VM. … … 439 418 # reporter.log('Couldn\'t save machine settings') 440 419 # 441 ############# 8 case. ##########################################################################################442 # # There is "read-only" disk attached to the VM.443 # #444 #445 # fRc = fRc and oSession.saveSettings()446 # if fRc is False:447 # reporter.log('Couldn\'t save machine settings')448 449 420 450 421 fRc = oSession.close() and fRc
Note:
See TracChangeset
for help on using the changeset viewer.