Changeset 59581 in vbox for trunk/src/VBox/ValidationKit/tests/api
- Timestamp:
- Feb 4, 2016 2:51:22 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/api/tdAppliance1.py
r59556 r59581 34 34 import os 35 35 import sys 36 import tarfile 36 37 37 38 # Only the main script needs to modify the path. … … 94 95 try: 95 96 fRc = self.testImportOva(os.path.join(g_ksValidationKitDir, 'tests', 'api', sOva)) and fRc; 97 fRc = self.testImportOvaAsOvf(os.path.join(g_ksValidationKitDir, 'tests', 'api', sOva)) and fRc; 96 98 except: 97 99 reporter.errorXcpt(); … … 110 112 oVirtualBox = self.oVBoxMgr.getVirtualBox(); 111 113 114 # 115 # Import it as OVA. 116 # 112 117 try: 113 118 oAppliance = oVirtualBox.createAppliance(); … … 139 144 return False; 140 145 146 # 147 # Export the 148 # 141 149 ## @todo do more with this OVA. Like untaring it and loading it as an OVF. Export it and import it again. 142 150 143 151 return True; 144 152 153 def testImportOvaAsOvf(self, sOva): 154 """ 155 Unpacts the OVA into a subdirectory in the scratch area and imports it as an OVF. 156 """ 157 oVirtualBox = self.oVBoxMgr.getVirtualBox(); 158 159 sTmpDir = os.path.join(self.sScratchPath, os.path.split(sOva)[1] + '-ovf'); 160 sOvf = os.path.join(sTmpDir, os.path.splitext(os.path.split(sOva)[1])[0] + '.ovf'); 161 162 # 163 # Unpack 164 # 165 try: 166 os.mkdir(sTmpDir, 0755); 167 oTarFile = tarfile.open(sOva, 'r:*'); 168 oTarFile.extractall(sTmpDir); 169 oTarFile.close(); 170 except: 171 return reporter.errorXcpt('Unpacking "%s" to "%s" for OVF style importing failed' % (sOvf, sTmpDir,)); 172 173 # 174 # Import. 175 # 176 try: 177 oAppliance2 = oVirtualBox.createAppliance(); 178 except: 179 return reporter.errorXcpt('IVirtualBox::createAppliance failed (#2)'); 180 print "oAppliance2=%s" % (oAppliance2,) 181 182 try: 183 oProgress = vboxwrappers.ProgressWrapper(oAppliance2.read(sOvf), self.oVBoxMgr, self, 'read "%s"' % (sOvf,)); 184 except: 185 return reporter.errorXcpt('IAppliance::read("%s") failed' % (sOvf,)); 186 oProgress.wait(); 187 if oProgress.logResult() is False: 188 return False; 189 190 try: 191 oAppliance2.interpret(); 192 except: 193 return reporter.errorXcpt('IAppliance::interpret() failed on "%s"' % (sOvf,)); 194 195 try: 196 oProgress = vboxwrappers.ProgressWrapper(oAppliance2.importMachines([]), 197 self.oVBoxMgr, self, 'importMachines "%s"' % (sOvf,)); 198 except: 199 return reporter.errorXcpt('IAppliance::importMachines failed on "%s"' % (sOvf,)); 200 oProgress.wait(); 201 if oProgress.logResult() is False: 202 return False; 203 204 return True; 145 205 146 206 if __name__ == '__main__':
Note:
See TracChangeset
for help on using the changeset viewer.