VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/api/tdMoveVM1.py@ 71550

Last change on this file since 71550 was 71550, checked in by vboxsync, 7 years ago

bugref:8345. Removed the unused variables.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 27.0 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# "$Id: tdMoveVM1.py 71550 2018-03-28 16:19:50Z vboxsync $"
4
5"""
6VirtualBox Validation Kit - VM Move Test #1
7"""
8
9__copyright__ = \
10"""
11Copyright (C) 2010-2018 Oracle Corporation
12
13This file is part of VirtualBox Open Source Edition (OSE), as
14available from http://www.virtualbox.org. This file is free software;
15you can redistribute it and/or modify it under the terms of the GNU
16General Public License (GPL) as published by the Free Software
17Foundation, in version 2 as it comes in the "COPYING" file of the
18VirtualBox OSE distribution. VirtualBox OSE is distributed in the
19hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20
21The contents of this file may alternatively be used under the terms
22of the Common Development and Distribution License Version 1.0
23(CDDL) only, as it comes in the "COPYING.CDDL" file of the
24VirtualBox OSE distribution, in which case the provisions of the
25CDDL are applicable instead of those of the GPL.
26
27You may elect to license modified versions of this file under the
28terms and conditions of either the GPL or the CDDL or both.
29"""
30__version__ = "$Revision: 71550 $"
31
32# Standard Python imports.
33import os
34import sys
35import time
36import shutil
37from collections import defaultdict
38
39# Only the main script needs to modify the path.
40try: __file__
41except: __file__ = sys.argv[0]
42g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
43sys.path.append(g_ksValidationKitDir)
44
45# Validation Kit imports.
46from testdriver import base
47from testdriver import reporter
48from testdriver import vboxcon
49from testdriver import vboxwrappers
50from tdMoveMedium1 import SubTstDrvMoveMedium1
51
52class SubTstDrvMoveVM1(base.SubTestDriverBase):
53 """
54 Sub-test driver for VM Move Test #1.
55 """
56
57 def __init__(self, oTstDrv):
58 base.SubTestDriverBase.__init__(self, 'move-vm', oTstDrv)
59 self.asRsrcs = self.__getResourceSet()
60 self.asImagesNames = []
61 self.dsKeys = dict (StandardImage = 'SATA Controller',
62 ISOImage = 'IDE Controller',
63 FloppyImage = 'Floppy Controller',
64 SettingsFile = 'Settings File',
65 LogFile = 'Log File',
66 SavedStateFile = 'Saved State File',
67 SnapshotFile = 'Snapshot File')
68
69 def testIt(self):
70 """
71 Execute the sub-testcase.
72 """
73 reporter.log('ValidationKit folder is "%s"' % (g_ksValidationKitDir,))
74 return self.testVMMove()
75
76 #
77 # Test execution helpers.
78 #
79
80 #
81 #createTestMachine
82 #
83 def createTestMachine(self):
84 oVM = self.oTstDrv.createTestVM('test-vm-move', 1, None, 4)
85 if oVM is None:
86 return None
87
88 # create hard disk images, one for each file-based backend, using the first applicable extension
89 fRc = True
90 oSession = self.oTstDrv.openSession(oVM)
91 aoDskFmts = self.oTstDrv.oVBoxMgr.getArray(self.oTstDrv.oVBox.systemProperties, 'mediumFormats')
92
93 for oDskFmt in aoDskFmts:
94 aoDskFmtCaps = self.oTstDrv.oVBoxMgr.getArray(oDskFmt, 'capabilities')
95 if vboxcon.MediumFormatCapabilities_File not in aoDskFmtCaps \
96 or vboxcon.MediumFormatCapabilities_CreateDynamic not in aoDskFmtCaps:
97 continue
98 (asExts, aTypes) = oDskFmt.describeFileExtensions()
99 for i in range(0, len(asExts)):
100 if aTypes[i] is vboxcon.DeviceType_HardDisk:
101 sExt = '.' + asExts[i]
102 break
103 if sExt is None:
104 fRc = False
105 break
106 sFile = 'test-vm-move' + str(len(self.asImagesNames)) + sExt
107 sHddPath = os.path.join(self.oTstDrv.sScratchPath, sFile)
108 oHd = oSession.createBaseHd(sHddPath, sFmt=oDskFmt.id, cb=1024*1024)
109 if oHd is None:
110 fRc = False
111 break
112
113 # attach HDD, IDE controller exists by default, but we use SATA just in case
114 sController=self.dsKeys['StandardImage']
115 fRc = fRc and oSession.attachHd(sHddPath, sController, iPort = len(self.asImagesNames),
116 fImmutable=False, fForceResource=False)
117 if fRc:
118 self.asImagesNames.append(sFile)
119
120 fRc = fRc and oSession.saveSettings()
121 fRc = oSession.close() and fRc
122
123 if fRc is False:
124 oVM = None
125
126 return oVM
127
128 #
129 #moveVMToLocation
130 #
131 def moveVMToLocation(self, sLocation, oVM):
132 fRc = True
133 try:
134 #move machine
135 reporter.log('Moving machine "%s" to the "%s"' % (oVM.name, sLocation))
136 oType = 'basic'
137 oProgress = vboxwrappers.ProgressWrapper(oVM.moveTo(sLocation, oType), self.oTstDrv.oVBoxMgr, self.oTstDrv,
138 'moving machine "%s"' % (oVM.name,))
139
140 except:
141 return reporter.errorXcpt('Machine::moveTo("%s") for machine "%s" failed' % (sLocation, oVM.name,))
142
143 oProgress.wait()
144 if oProgress.logResult() is False:
145 fRc = False
146 reporter.log('Progress object returned False')
147 else:
148 fRc = True
149
150 return fRc
151
152 #
153 #checkLocation
154 #
155 #Prerequisites:
156 #1. All standard images are attached to SATA controller
157 #2. All ISO images are attached to IDE controller
158 #3. All floppy images are attached to Floppy controller
159 #4. The type defaultdict from collection is used here (some sort of multimap data structure)
160 #5. The dsReferenceFiles parameter here is the structure defaultdict(set):
161 # [
162 # ('StandardImage': ['somedisk.vdi', 'somedisk.vmdk',...]),
163 # ('ISOImage': ['somedisk_1.iso','somedisk_2.iso',...]),
164 # ('FloppyImage': ['somedisk_1.img','somedisk_2.img',...]),
165 # ('SnapshotFile': ['snapshot file 1','snapshot file 2', ...]),
166 # ('SettingsFile', ['setting file',...]),
167 # ('SavedStateFile': ['state file 1','state file 2',...]),
168 # ('LogFile': ['log file 1','log file 2',...]),
169 # ]
170 #
171 def checkLocation(self, oMachine, dsReferenceFiles):
172
173 fRc = True
174
175 for key, value in self.dsKeys.iteritems():
176 aActuals = set()
177 aReferences = set()
178
179 #Check standard images locations, ISO files locations, floppy images locations, snapshots files locations
180 if key == 'StandardImage' or key == 'ISOImage' or key == 'FloppyImage':
181 aReferences = dsReferenceFiles[key]
182 if len (aReferences) > 0:
183 aoMediumAttachments = oMachine.getMediumAttachmentsOfController(value)
184 for oAttachment in aoMediumAttachments:
185 aActuals.add(oAttachment.medium.location)
186
187 elif key == 'SnapshotFile':
188 aReferences = dsReferenceFiles[key]
189 if len (aReferences) > 0:
190 aActuals = self.__getSnapshotsFiles(oMachine)
191
192 #Check setting file location
193 elif key == 'SettingsFile':
194 aReferences = dsReferenceFiles[key]
195 if len (aReferences) > 0:
196 aActuals.add(oMachine.settingsFilePath)
197
198 #Check saved state files location
199 elif key == 'SavedStateFile':
200 aReferences = dsReferenceFiles[key]
201 if len (aReferences) > 0:
202 aActuals = self.__getStatesFiles(oMachine)
203
204 #Check log files location
205 elif key == 'LogFile':
206 aReferences = dsReferenceFiles[key]
207 if len (aReferences) > 0:
208 aActuals = self.__getLogFiles(oMachine)
209
210 if len(aActuals) > 0:
211 reporter.log('Check %s' % (key))
212 intersection = aReferences.intersection(aActuals)
213 for eachItem in intersection:
214 reporter.log('Item location "%s" is correct' % (eachItem))
215
216 difference = aReferences.difference(aActuals)
217 for eachItem in difference:
218 reporter.log('Item location "%s" isn\'t correct' % (eachItem))
219
220 if len (intersection) != len (aActuals):
221 reporter.log('Not all items in the right location. Check it.')
222 fRc = False
223
224 return fRc
225
226 #
227 #checkAPIVersion
228 #
229 def checkAPIVersion(self):
230 if self.oTstDrv.fpApiVer >= 5.3:
231 return True
232
233 return False
234
235 def __getStatesFiles(self, oMachine, fPrint = False):
236 asStateFilesList = set()
237 sFolder = oMachine.snapshotFolder
238 for sFile in os.listdir(sFolder):
239 if sFile.endswith(".sav"):
240 sFullPath = os.path.join(sFolder, sFile)
241 asStateFilesList.add(sFullPath)
242 if fPrint is True:
243 reporter.log("State file is %s" % (sFullPath))
244 return asStateFilesList
245
246 def __getSnapshotsFiles(self, oMachine, fPrint = False):
247 asSnapshotsFilesList = set()
248 sFolder = oMachine.snapshotFolder
249 for sFile in os.listdir(sFolder):
250 if sFile.endswith(".sav") is False:
251 sFullPath = os.path.join(sFolder, sFile)
252 asSnapshotsFilesList.add(sFullPath)
253 if fPrint is True:
254 reporter.log("Snapshot file is %s" % (sFullPath))
255 return asSnapshotsFilesList
256
257 def __getLogFiles(self, oMachine, fPrint = False):
258 asLogFilesList = set()
259 sFolder = oMachine.logFolder
260 for sFile in os.listdir(sFolder):
261 if sFile.endswith(".log"):
262 sFullPath = os.path.join(sFolder, sFile)
263 asLogFilesList.add(sFullPath)
264 if fPrint is True:
265 reporter.log("Log file is %s" % (sFullPath))
266 return asLogFilesList
267
268 def __getResourceSet(self):
269 # Construct the resource list the first time it's queried.
270 if self.oTstDrv.asRsrcs is None:
271 self.oTstDrv.asRsrcs = []
272 self.oTstDrv.asRsrcs.append('5.3/isos/tdMoveVM.iso')
273 self.oTstDrv.asRsrcs.append('5.3/floppy/tdMoveVM.img')
274
275 return self.oTstDrv.asRsrcs
276
277 def __testScenario_2(self, oSession, oMachine, sNewLoc, sOldLoc):
278
279 sController = self.dsKeys['StandardImage']
280 aoMediumAttachments = oMachine.getMediumAttachmentsOfController(sController)
281 oSubTstDrvMoveMedium1Instance = SubTstDrvMoveMedium1(self.oTstDrv)
282 oSubTstDrvMoveMedium1Instance.setLocation(sOldLoc, aoMediumAttachments)
283
284 del oSubTstDrvMoveMedium1Instance
285
286 dsReferenceFiles = defaultdict(set)
287
288 for s in self.asImagesNames:
289 reporter.log('"%s"' % (s,))
290 dsReferenceFiles['StandardImage'].add(sNewLoc + os.sep + oMachine.name + os.sep + s)
291
292 sSettingFile = os.path.join(sNewLoc, os.path.join(oMachine.name, oMachine.name + '.vbox'))
293 dsReferenceFiles['SettingsFile'].add(sSettingFile)
294
295 fRc = self.moveVMToLocation(sNewLoc, oSession.o.machine)
296
297 if fRc is True:
298 fRc = self.checkLocation(oSession.o.machine, dsReferenceFiles)
299 if fRc is False:
300 reporter.testFailure('!!!!!!!!!!!!!!!!!! 2nd scenario: Check locations failed... !!!!!!!!!!!!!!!!!!')
301 else:
302 reporter.testFailure('!!!!!!!!!!!!!!!!!! 2nd scenario: Move VM failed... !!!!!!!!!!!!!!!!!!')
303
304 fRes = oSession.saveSettings()
305 if fRes is False:
306 reporter.log('2nd scenario: Couldn\'t save machine settings')
307
308 return fRc
309
310 def __testScenario_3(self, oSession, oMachine, sNewLoc):
311
312 #At moment, it's used only one snapshot due to the difficulty to get
313 #all attachments of the machine (i.e. not only attached at moment)
314 cSnap = 1
315
316 for counter in range(1,cSnap+1):
317 strSnapshot = 'Snapshot' + str(counter)
318 fRc = oSession.takeSnapshot(strSnapshot)
319 if fRc is False:
320 reporter.testFailure('3rd scenario: Can\'t take snapshot "%s"' % (strSnapshot,))
321
322 dsReferenceFiles = defaultdict(set)
323
324 sController = self.dsKeys['StandardImage']
325 aoMediumAttachments = oMachine.getMediumAttachmentsOfController(sController)
326 if fRc is True:
327 for oAttachment in aoMediumAttachments:
328 sRes = oAttachment.medium.location.rpartition(os.sep)
329 dsReferenceFiles['SnapshotFile'].add(sNewLoc + os.sep + oMachine.name + os.sep +
330 'Snapshots' + os.sep + sRes[2])
331
332 sSettingFile = os.path.join(sNewLoc, os.path.join(oMachine.name, oMachine.name + '.vbox'))
333 dsReferenceFiles['SettingsFile'].add(sSettingFile)
334
335 fRc = self.moveVMToLocation(sNewLoc, oSession.o.machine)
336
337 if fRc is True:
338 fRc = self.checkLocation(oSession.o.machine, dsReferenceFiles)
339 if fRc is False:
340 reporter.testFailure('!!!!!!!!!!!!!!!!!! 3rd scenario: Check locations failed... !!!!!!!!!!!!!!!!!!')
341 else:
342 reporter.testFailure('!!!!!!!!!!!!!!!!!! 3rd scenario: Move VM failed... !!!!!!!!!!!!!!!!!!')
343
344 fRes = oSession.saveSettings()
345 if fRes is False:
346 reporter.log('3d scenario: Couldn\'t save machine settings')
347
348 return fRc
349
350 def __testScenario_4(self, oMachine, sNewLoc):
351
352 #Run VM and get new Session object
353 oSession = self.oTstDrv.startVm(oMachine)
354
355 #some time interval should be here for not closing VM just after start
356 time.sleep(1)
357
358 if oMachine.state != self.oTstDrv.oVBoxMgr.constants.MachineState_Running:
359 reporter.log("Machine '%s' is not Running" % (oMachine.name))
360 fRc = False
361
362 #call Session::saveState(), already closes session unless it failed
363 fRc = oSession.saveState()
364 self.oTstDrv.terminateVmBySession(oSession)
365
366 if fRc:
367 #create a new Session object for moving VM
368 oSession = self.oTstDrv.openSession(oMachine)
369
370 #always clear before each scenario
371 dsReferenceFiles = defaultdict(set)
372
373 asLogs = self.__getLogFiles(oMachine)
374 for sFile in asLogs:
375 sRes = sFile.rpartition(os.sep)
376 dsReferenceFiles['LogFile'].add(sNewLoc + os.sep + oMachine.name + os.sep + 'Logs' + os.sep + sRes[2])
377
378 asStates = self.__getStatesFiles(oMachine)
379 for sFile in asStates:
380 sRes = sFile.rpartition(os.sep)
381 dsReferenceFiles['SavedStateFile'].add(sNewLoc + os.sep + oMachine.name + os.sep + 'Snapshots' + os.sep + sRes[2])
382
383 fRc = self.moveVMToLocation(sNewLoc, oSession.o.machine)
384
385 if fRc is True:
386 fRc = self.checkLocation(oSession.o.machine, dsReferenceFiles)
387 if fRc is False:
388 reporter.testFailure('!!!!!!!!!!!!!!!!!! 4th scenario: Check locations failed... !!!!!!!!!!!!!!!!!!')
389 else:
390 reporter.testFailure('!!!!!!!!!!!!!!!!!! 4th scenario: Move VM failed... !!!!!!!!!!!!!!!!!!')
391
392 # cleaning up: get rid of saved state
393 fRes = oSession.discardSavedState(True)
394 if fRes is False:
395 reporter.log('4th scenario: Failed to discard the saved state of machine')
396
397 fRes = oSession.close()
398 if fRes is False:
399 reporter.log('4th scenario: Couldn\'t close machine session')
400 else:
401 reporter.testFailure('!!!!!!!!!!!!!!!!!! 4th scenario: Terminate machine by session failed... !!!!!!!!!!!!!!!!!!')
402
403 return fRc
404
405 def __testScenario_5(self, oMachine, sNewLoc, sOldLoc):
406
407 fRc = True
408 sISOImageName = 'tdMoveVM1.iso'
409
410 #always clear before each scenario
411 dsReferenceFiles = defaultdict(set)
412
413 #create a new Session object
414 oSession = self.oTstDrv.openSession(oMachine)
415
416 sISOLoc = '5.3/isos/tdMoveVM1.iso'
417 reporter.log("sHost is '%s', sResourcePath is '%s'" % (self.oTstDrv.sHost, self.oTstDrv.sResourcePath))
418 sISOLoc = self.oTstDrv.getFullResourceName(sISOLoc)
419
420 if not os.path.exists(sISOLoc):
421 reporter.log('ISO file does not exist at "%s"' % (sISOLoc,))
422 fRc = False
423
424 #Copy ISO image from the common resource folder into machine folder
425 shutil.copy(sISOLoc, sOldLoc)
426
427 #attach ISO image to the IDE controller
428 if fRc is True:
429 #set actual ISO location
430 sISOLoc = sOldLoc + os.sep + sISOImageName
431 sController=self.dsKeys['ISOImage']
432 aoMediumAttachments = oMachine.getMediumAttachmentsOfController(sController)
433 iPort = len(aoMediumAttachments)
434 fRc = oSession.attachDvd(sISOLoc, sController, iPort, iDevice = 0)
435 dsReferenceFiles['ISOImage'].add(os.path.join(os.path.join(sNewLoc, oMachine.name), sISOImageName))
436
437 if fRc is True:
438 fRc = self.moveVMToLocation(sNewLoc, oSession.o.machine)
439 if fRc is True:
440 fRc = self.checkLocation(oSession.o.machine, dsReferenceFiles)
441 if fRc is False:
442 reporter.testFailure('!!!!!!!!!!!!!!!!!! 5th scenario: Check locations failed... !!!!!!!!!!!!!!!!!!')
443 else:
444 reporter.testFailure('!!!!!!!!!!!!!!!!!! 5th scenario: Move VM failed... !!!!!!!!!!!!!!!!!!')
445 else:
446 reporter.testFailure('!!!!!!!!!!!!!!!!!! 5th scenario: Attach ISO image failed... !!!!!!!!!!!!!!!!!!')
447
448 #detach ISO image
449 fRes = oSession.detachHd(sController, iPort, 0)
450 if fRes is False:
451 reporter.log('5th scenario: Couldn\'t detach image from the controller %s '
452 'port %s device %s' % (sController, iPort, 0))
453
454 fRes = oSession.saveSettings()
455 if fRes is False:
456 reporter.log('5th scenario: Couldn\'t save machine settings')
457
458 fRes = oSession.close()
459 if fRes is False:
460 reporter.log('5th scenario: Couldn\'t close machine session')
461
462 return fRc
463
464 def __testScenario_6(self, oMachine, sNewLoc, sOldLoc):
465
466 fRc = True
467
468 #always clear before each scenario
469 dsReferenceFiles = defaultdict(set)
470
471 #create a new Session object
472 oSession = self.oTstDrv.openSession(oMachine)
473
474 sFloppyLoc = '5.3/floppy/tdMoveVM1.img'
475 sFloppyLoc = self.oTstDrv.getFullResourceName(sFloppyLoc)
476
477 if not os.path.exists(sFloppyLoc):
478 reporter.log('Floppy disk does not exist at "%s"' % (sFloppyLoc,))
479 fRc = False
480
481 #Copy floppy image from the common resource folder into machine folder
482 shutil.copy(sFloppyLoc, sOldLoc)
483
484 # attach floppy image
485 if fRc is True:
486 #set actual floppy location
487 sFloppyImageName = 'tdMoveVM1.img'
488 sFloppyLoc = sOldLoc + os.sep + sFloppyImageName
489 sController=self.dsKeys['FloppyImage']
490 fRc = fRc and oSession.attachFloppy(sFloppyLoc, sController, 0, 0)
491 dsReferenceFiles['FloppyImage'].add(os.path.join(os.path.join(sNewLoc, oMachine.name), sFloppyImageName))
492
493 if fRc is True:
494 fRc = self.moveVMToLocation(sNewLoc, oSession.o.machine)
495 if fRc is True:
496 fRc = self.checkLocation(oSession.o.machine, dsReferenceFiles)
497 if fRc is False:
498 reporter.testFailure('!!!!!!!!!!!!!!!!!! 5th scenario: Check locations failed... !!!!!!!!!!!!!!!!!!')
499 else:
500 reporter.testFailure('!!!!!!!!!!!!!!!!!! 5th scenario: Move VM failed... !!!!!!!!!!!!!!!!!!')
501 else:
502 reporter.testFailure('!!!!!!!!!!!!!!!!!! 5th scenario: Attach floppy image failed... !!!!!!!!!!!!!!!!!!')
503
504 #detach floppy image
505 fRes = oSession.detachHd(sController, 0, 0)
506 if fRes is False:
507 reporter.log('6th scenario: Couldn\'t detach image from the controller %s port %s device %s' % (sController, 0, 0))
508
509 fRes = oSession.saveSettings()
510 if fRes is False:
511 reporter.testFailure('6th scenario: Couldn\'t save machine settings')
512
513 fRes = oSession.close()
514 if fRes is False:
515 reporter.log('6th scenario: Couldn\'t close machine session')
516 return fRc
517
518 #
519 #testVMMove
520 #
521 def testVMMove(self):
522 """
523 Test machine moving.
524 """
525 reporter.testStart('machine moving')
526
527 if not self.oTstDrv.importVBoxApi():
528 return False
529
530 fSupported = self.checkAPIVersion()
531
532 if fSupported is False:
533 reporter.log('API version is below "%s". Just skip this test.' % (self.oTstDrv.fpApiVer))
534 return reporter.testDone()[1] == 0
535 else:
536 reporter.log('API version is "%s". Continuing the test.' % (self.oTstDrv.fpApiVer))
537
538 #Scenarios
539 #1. All disks attached to VM are located outside the VM's folder.
540 # There are no any snapshots and logs.
541 # In this case only VM setting file should be moved (.vbox file)
542 #
543 #2. All disks attached to VM are located inside the VM's folder.
544 # There are no any snapshots and logs.
545 #
546 #3. There are snapshots.
547 #
548 #4. There are one or more save state files in the snapshots folder
549 # and some files in the logs folder.
550 #
551 #5. There is an ISO image (.iso) attached to the VM.
552 #
553 #6. There is a floppy image (.img) attached to the VM.
554 #
555 #7. There are shareable disk and immutable disk attached to the VM.
556
557 try:
558 #create test machine
559 oMachine = self.createTestMachine()
560
561 if oMachine is None:
562 reporter.error('Failed to create test machine')
563
564 #create temporary subdirectory in the current working directory
565 sOrigLoc = self.oTstDrv.sScratchPath
566 sBaseLoc = os.path.join(sOrigLoc, 'moveFolder')
567 os.mkdir(sBaseLoc, 0o775)
568
569 #lock machine
570 #get session machine
571 oSession = self.oTstDrv.openSession(oMachine)
572 fRc = True
573
574 sNewLoc = sBaseLoc + os.sep
575
576 dsReferenceFiles = defaultdict(set)
577
578############# 1 case. ##########################################################################################
579 # All disks attached to VM are located outside the VM's folder.
580 # There are no any snapshots and logs.
581 # In this case only VM setting file should be moved (.vbox file)
582 for s in self.asImagesNames:
583 reporter.log('"%s"' % (s,))
584 dsReferenceFiles['StandardImage'].add(os.path.join(sOrigLoc, s))
585
586 sSettingFile = os.path.join(sNewLoc, os.path.join(oMachine.name, oMachine.name + '.vbox'))
587 dsReferenceFiles['SettingsFile'].add(sSettingFile)
588
589 fRc = self.moveVMToLocation(sNewLoc, oSession.o.machine)
590
591 if fRc is True:
592 fRc = self.checkLocation(oSession.o.machine, dsReferenceFiles)
593 if fRc is False:
594 reporter.testFailure('!!!!!!!!!!!!!!!!!! 1st scenario: Check locations failed... !!!!!!!!!!!!!!!!!!')
595 return reporter.testDone()[1] == 0
596 else:
597 reporter.testFailure('!!!!!!!!!!!!!!!!!! 1st scenario: Move VM failed... !!!!!!!!!!!!!!!!!!')
598 return reporter.testDone()[1] == 0
599
600 fRc = oSession.saveSettings()
601 if fRc is False:
602 reporter.testFailure('1st scenario: Couldn\'t save machine settings')
603
604############# 2 case. ##########################################################################################
605 # All disks attached to VM are located inside the VM's folder.
606 # There are no any snapshots and logs.
607 sOldLoc = sNewLoc + oMachine.name + os.sep
608 sNewLoc = os.path.join(sOrigLoc, 'moveFolder_2d_scenario')
609 os.mkdir(sNewLoc, 0o775)
610
611 fRc = self.__testScenario_2(oSession, oMachine, sNewLoc, sOldLoc)
612 if fRc is False:
613 return reporter.testDone()[1] == 0
614
615############# 3 case. ##########################################################################################
616 # There are snapshots.
617 sOldLoc = sNewLoc + oMachine.name + os.sep
618 sNewLoc = os.path.join(sOrigLoc, 'moveFolder_3d_scenario')
619 os.mkdir(sNewLoc, 0o775)
620
621 fRc = self.__testScenario_3(oSession, oMachine, sNewLoc)
622 if fRc is False:
623 return reporter.testDone()[1] == 0
624
625############# 4 case. ##########################################################################################
626 # There are one or more save state files in the snapshots folder
627 # and some files in the logs folder.
628 # Here we run VM, next stop it in the "save" state.
629 # And next move VM
630
631 sOldLoc = sNewLoc + oMachine.name + os.sep
632 sNewLoc = os.path.join(sOrigLoc, 'moveFolder_4th_scenario')
633 os.mkdir(sNewLoc, 0o775)
634
635 #Close Session object because after starting VM we get new instance of session
636 fRc = oSession.close() and fRc
637 if fRc is False:
638 reporter.log('Couldn\'t close machine session')
639
640 del oSession
641
642 fRc = self.__testScenario_4(oMachine, sNewLoc)
643 if fRc is False:
644 return reporter.testDone()[1] == 0
645
646############## 5 case. ##########################################################################################
647 #There is an ISO image (.iso) attached to the VM.
648 #Prerequisites - there is IDE Controller and there are no any images attached to it.
649
650 sOldLoc = sNewLoc + os.sep + oMachine.name + os.sep
651 sNewLoc = os.path.join(sOrigLoc, 'moveFolder_5th_scenario')
652 os.mkdir(sNewLoc, 0o775)
653 fRc = self.__testScenario_5(oMachine, sNewLoc, sOldLoc)
654 if fRc is False:
655 return reporter.testDone()[1] == 0
656
657############# 6 case. ##########################################################################################
658 #There is a floppy image (.img) attached to the VM.
659 #Prerequisites - there is Floppy Controller and there are no any images attached to it.
660
661 sOldLoc = sNewLoc + os.sep + oMachine.name + os.sep
662 sNewLoc = os.path.join(sOrigLoc, 'moveFolder_6th_scenario')
663 os.mkdir(sNewLoc, 0o775)
664 fRc = self.__testScenario_6(oMachine, sNewLoc, sOldLoc)
665 if fRc is False:
666 return reporter.testDone()[1] == 0
667
668############# 7 case. ##########################################################################################
669# # There are shareable disk and immutable disk attached to the VM.
670# #
671#
672# fRc = fRc and oSession.saveSettings()
673# if fRc is False:
674# reporter.log('Couldn\'t save machine settings')
675#
676
677 assert fRc is True
678 except:
679 reporter.errorXcpt()
680
681 return reporter.testDone()[1] == 0
682
683
684if __name__ == '__main__':
685 sys.path.append(os.path.dirname(os.path.abspath(__file__)))
686 from tdApi1 import tdApi1
687 sys.exit(tdApi1([SubTstDrvMoveVM1]).main(sys.argv))
688
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette