Changeset 72737 in vbox for trunk/src/VBox/ValidationKit/tests/api
- Timestamp:
- Jun 29, 2018 7:06:45 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 123273
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/api/tdAppliance1.py
r70849 r72737 43 43 44 44 # Validation Kit imports. 45 from testdriver import base 46 from testdriver import reporter 47 from testdriver import vboxwrappers 45 from testdriver import base; 46 from testdriver import reporter; 47 from testdriver import vboxwrappers; 48 48 49 49 … … 54 54 55 55 def __init__(self, oTstDrv): 56 base.SubTestDriverBase.__init__(self, 'appliance', oTstDrv) 56 base.SubTestDriverBase.__init__(self, 'appliance', oTstDrv); 57 57 58 58 def testIt(self): … … 60 60 Execute the sub-testcase. 61 61 """ 62 fRc = True 62 fRc = True; 63 63 64 64 # Import a set of simple OVAs. … … 88 88 'tdAppliance1-t7-bad-instance.ova', 89 89 ): 90 reporter.testStart(sOva) 90 reporter.testStart(sOva); 91 91 try: 92 fRc = self.testImportOva(os.path.join(g_ksValidationKitDir, 'tests', 'api', sOva)) and fRc 93 fRc = self.testImportOvaAsOvf(os.path.join(g_ksValidationKitDir, 'tests', 'api', sOva)) and fRc 92 fRc = self.testImportOva(os.path.join(g_ksValidationKitDir, 'tests', 'api', sOva)) and fRc; 93 fRc = self.testImportOvaAsOvf(os.path.join(g_ksValidationKitDir, 'tests', 'api', sOva)) and fRc; 94 94 except: 95 reporter.errorXcpt() 96 fRc = False 97 fRc = reporter.testDone() and fRc 95 reporter.errorXcpt(); 96 fRc = False; 97 fRc = reporter.testDone() and fRc; 98 98 99 99 ## @todo more stuff 100 return fRc 100 return fRc; 101 101 102 102 # … … 106 106 def testImportOva(self, sOva): 107 107 """ xxx """ 108 oVirtualBox = self.oTstDrv.oVBoxMgr.getVirtualBox() 108 oVirtualBox = self.oTstDrv.oVBoxMgr.getVirtualBox(); 109 109 110 110 # … … 112 112 # 113 113 try: 114 oAppliance = oVirtualBox.createAppliance() 115 except: 116 return reporter.errorXcpt('IVirtualBox::createAppliance failed') 114 oAppliance = oVirtualBox.createAppliance(); 115 except: 116 return reporter.errorXcpt('IVirtualBox::createAppliance failed'); 117 117 118 118 try: 119 119 oProgress = vboxwrappers.ProgressWrapper(oAppliance.read(sOva), self.oTstDrv.oVBoxMgr, self.oTstDrv, 120 'read "%s"' % (sOva,)) 121 except: 122 return reporter.errorXcpt('IAppliance::read("%s") failed' % (sOva,)) 123 oProgress.wait() 124 if oProgress.logResult() is False: 125 return False 126 127 try: 128 oAppliance.interpret() 129 except: 130 return reporter.errorXcpt('IAppliance::interpret() failed on "%s"' % (sOva,)) 120 'read "%s"' % (sOva,)); 121 except: 122 return reporter.errorXcpt('IAppliance::read("%s") failed' % (sOva,)); 123 oProgress.wait(); 124 if oProgress.logResult() is False: 125 return False; 126 127 try: 128 oAppliance.interpret(); 129 except: 130 return reporter.errorXcpt('IAppliance::interpret() failed on "%s"' % (sOva,)); 131 131 132 132 # 133 133 try: 134 134 oProgress = vboxwrappers.ProgressWrapper(oAppliance.importMachines([]), 135 self.oTstDrv.oVBoxMgr, self.oTstDrv, 'importMachines "%s"' % (sOva,)) 136 except: 137 return reporter.errorXcpt('IAppliance::importMachines failed on "%s"' % (sOva,)) 138 oProgress.wait() 139 if oProgress.logResult() is False: 140 return False 135 self.oTstDrv.oVBoxMgr, self.oTstDrv, 'importMachines "%s"' % (sOva,)); 136 except: 137 return reporter.errorXcpt('IAppliance::importMachines failed on "%s"' % (sOva,)); 138 oProgress.wait(); 139 if oProgress.logResult() is False: 140 return False; 141 141 142 142 # … … 145 145 ## @todo do more with this OVA. Like untaring it and loading it as an OVF. Export it and import it again. 146 146 147 return True 147 return True; 148 148 149 149 def testImportOvaAsOvf(self, sOva): … … 151 151 Unpacks the OVA into a subdirectory in the scratch area and imports it as an OVF. 152 152 """ 153 oVirtualBox = self.oTstDrv.oVBoxMgr.getVirtualBox() 154 155 sTmpDir = os.path.join(self.oTstDrv.sScratchPath, os.path.split(sOva)[1] + '-ovf') 156 sOvf = os.path.join(sTmpDir, os.path.splitext(os.path.split(sOva)[1])[0] + '.ovf') 153 oVirtualBox = self.oTstDrv.oVBoxMgr.getVirtualBox(); 154 155 sTmpDir = os.path.join(self.oTstDrv.sScratchPath, os.path.split(sOva)[1] + '-ovf'); 156 sOvf = os.path.join(sTmpDir, os.path.splitext(os.path.split(sOva)[1])[0] + '.ovf'); 157 157 158 158 # … … 160 160 # 161 161 try: 162 os.mkdir(sTmpDir, 0o755) 163 oTarFile = tarfile.open(sOva, 'r:*') 164 oTarFile.extractall(sTmpDir) 165 oTarFile.close() 166 except: 167 return reporter.errorXcpt('Unpacking "%s" to "%s" for OVF style importing failed' % (sOvf, sTmpDir,)) 162 os.mkdir(sTmpDir, 0o755); 163 oTarFile = tarfile.open(sOva, 'r:*'); 164 oTarFile.extractall(sTmpDir); 165 oTarFile.close(); 166 except: 167 return reporter.errorXcpt('Unpacking "%s" to "%s" for OVF style importing failed' % (sOvf, sTmpDir,)); 168 168 169 169 # … … 171 171 # 172 172 try: 173 oAppliance2 = oVirtualBox.createAppliance() 174 except: 175 return reporter.errorXcpt('IVirtualBox::createAppliance failed (#2)') 173 oAppliance2 = oVirtualBox.createAppliance(); 174 except: 175 return reporter.errorXcpt('IVirtualBox::createAppliance failed (#2)'); 176 176 177 177 try: 178 178 oProgress = vboxwrappers.ProgressWrapper(oAppliance2.read(sOvf), self.oTstDrv.oVBoxMgr, self.oTstDrv, 179 'read "%s"' % (sOvf,)) 180 except: 181 return reporter.errorXcpt('IAppliance::read("%s") failed' % (sOvf,)) 182 oProgress.wait() 183 if oProgress.logResult() is False: 184 return False 185 186 try: 187 oAppliance2.interpret() 188 except: 189 return reporter.errorXcpt('IAppliance::interpret() failed on "%s"' % (sOvf,)) 179 'read "%s"' % (sOvf,)); 180 except: 181 return reporter.errorXcpt('IAppliance::read("%s") failed' % (sOvf,)); 182 oProgress.wait(); 183 if oProgress.logResult() is False: 184 return False; 185 186 try: 187 oAppliance2.interpret(); 188 except: 189 return reporter.errorXcpt('IAppliance::interpret() failed on "%s"' % (sOvf,)); 190 190 191 191 try: 192 192 oProgress = vboxwrappers.ProgressWrapper(oAppliance2.importMachines([]), 193 self.oTstDrv.oVBoxMgr, self.oTstDrv, 'importMachines "%s"' % (sOvf,)) 194 except: 195 return reporter.errorXcpt('IAppliance::importMachines failed on "%s"' % (sOvf,)) 196 oProgress.wait() 197 if oProgress.logResult() is False: 198 return False 199 200 return True 193 self.oTstDrv.oVBoxMgr, self.oTstDrv, 'importMachines "%s"' % (sOvf,)); 194 except: 195 return reporter.errorXcpt('IAppliance::importMachines failed on "%s"' % (sOvf,)); 196 oProgress.wait(); 197 if oProgress.logResult() is False: 198 return False; 199 200 return True; 201 201 202 202
Note:
See TracChangeset
for help on using the changeset viewer.