VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/api/tdAppliance1.py@ 59556

Last change on this file since 59556 was 59556, checked in by vboxsync, 9 years ago

tdAppliance1.py: Quick import test of the tiny checked in OVAs.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdAppliance1.py 59556 2016-02-02 02:06:22Z vboxsync $
4
5"""
6VirtualBox Validation Kit - IAppliance Test #1
7"""
8
9__copyright__ = \
10"""
11Copyright (C) 2010-2015 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: 59556 $"
31
32
33# Standard Python imports.
34import os
35import sys
36
37# Only the main script needs to modify the path.
38try: __file__
39except: __file__ = sys.argv[0];
40g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
41sys.path.append(g_ksValidationKitDir);
42
43# Validation Kit imports.
44from testdriver import reporter;
45from testdriver import base;
46from testdriver import vbox;
47from testdriver import vboxwrappers;
48
49
50class tdAppliance1(vbox.TestDriver):
51 """
52 IAppliance Test #1.
53 """
54
55 def __init__(self):
56 vbox.TestDriver.__init__(self);
57 self.asRsrcs = None;
58
59
60 #
61 # Overridden methods.
62 #
63
64 def actionConfig(self):
65 """
66 Import the API.
67 """
68 if not self.importVBoxApi():
69 return False;
70 return True;
71
72 def actionExecute(self):
73 """
74 Execute the testcase.
75 """
76 fRc = True;
77
78 # Import a set of simple OVAs.
79 # Note! Manifests generated by ovftool 4.0.0 does not include the ovf, while the ones b 4.1.0 does.
80 for sOva in (
81 # t1 is a plain VM without any disks, ovftool 4.0 export from fusion
82 'tdAppliance1-t1.ova',
83 # t2 is a plain VM with one disk. Both 4.0 and 4.1.0 exports.
84 'tdAppliance1-t2.ova',
85 'tdAppliance1-t2-ovftool-4.1.0.ova',
86 # t3 is a VM with one gzipped disk and selecting SHA256 on the ovftool cmdline (--compress=9 --shaAlgorithm=sha256).
87 'tdAppliance1-t3.ova',
88 'tdAppliance1-t3-ovftool-4.1.0.ova',
89 # t4 is a VM with with two gzipped disk, SHA256 and a signed manifest (--privateKey=./tdAppliance1-t4.pem).
90 'tdAppliance1-t4.ova',
91 'tdAppliance1-t4-ovftool-4.1.0.ova',
92 ):
93 reporter.testStart(sOva);
94 try:
95 fRc = self.testImportOva(os.path.join(g_ksValidationKitDir, 'tests', 'api', sOva)) and fRc;
96 except:
97 reporter.errorXcpt();
98 fRc = False;
99 fRc = reporter.testDone() and fRc;
100
101 ## @todo more stuff
102 return fRc;
103
104 #
105 # Test execution helpers.
106 #
107
108 def testImportOva(self, sOva):
109 """ xxx """
110 oVirtualBox = self.oVBoxMgr.getVirtualBox();
111
112 try:
113 oAppliance = oVirtualBox.createAppliance();
114 except:
115 return reporter.errorXcpt('IVirtualBox::createAppliance failed');
116 print "oAppliance=%s" % (oAppliance,)
117
118 try:
119 oProgress = vboxwrappers.ProgressWrapper(oAppliance.read(sOva), self.oVBoxMgr, self, 'read "%s"' % (sOva,));
120 except:
121 return reporter.errorXcpt('IAppliance::read("%s") failed' % (sOva,));
122 oProgress.wait();
123 if oProgress.logResult() is False:
124 return False;
125
126 try:
127 oAppliance.interpret();
128 except:
129 return reporter.errorXcpt('IAppliance::interpret() failed on "%s"' % (sOva,));
130
131 #
132 try:
133 oProgress = vboxwrappers.ProgressWrapper(oAppliance.importMachines([]),
134 self.oVBoxMgr, self, 'importMachines "%s"' % (sOva,));
135 except:
136 return reporter.errorXcpt('IAppliance::importMachines failed on "%s"' % (sOva,));
137 oProgress.wait();
138 if oProgress.logResult() is False:
139 return False;
140
141 ## @todo do more with this OVA. Like untaring it and loading it as an OVF. Export it and import it again.
142
143 return True;
144
145
146if __name__ == '__main__':
147 sys.exit(tdAppliance1().main(sys.argv));
148
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