~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to tools/xm-test/tests/xapi/04_xapi-data_uri_handling.py

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
#============================================================================
 
3
# This library is free software; you can redistribute it and/or
 
4
# modify it under the terms of version 2.1 of the GNU Lesser General Public
 
5
# License as published by the Free Software Foundation.
 
6
#
 
7
# This library is distributed in the hope that it will be useful,
 
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
10
# Lesser General Public License for more details.
 
11
#
 
12
# You should have received a copy of the GNU Lesser General Public
 
13
# License along with this library; if not, write to the Free Software
 
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
#============================================================================
 
16
# Copyright (C) 2009 flonatel GmbH & Co. KG
 
17
#============================================================================
 
18
#
 
19
# This file contains test cases for checking the data URI
 
20
# functionality:
 
21
# kernel and ramdisk are both checked with original uri,
 
22
# file uri and data uri (in every constallation)
 
23
#
 
24
 
 
25
import copy
 
26
 
 
27
from xen.util.fileuri import schemes, scheme_data, scheme_file
 
28
 
 
29
from XmTestLib import *
 
30
from XmTestLib.network_utils import *
 
31
from XmTestLib.XenAPIDomain import XmTestAPIDomain
 
32
 
 
33
kernel_orig_uri = arch.configDefaults['kernel']
 
34
ramdisk_orig_uri = arch.configDefaults['ramdisk']
 
35
kernel_data_uri = scheme_data.create_from_file(kernel_orig_uri)
 
36
ramdisk_data_uri = scheme_data.create_from_file(ramdisk_orig_uri)
 
37
kernel_file_uri = scheme_file.encode(kernel_orig_uri)
 
38
ramdisk_file_uri = scheme_file.encode(ramdisk_orig_uri)
 
39
 
 
40
config = copy.copy(arch.configDefaults)
 
41
 
 
42
for kernel in (kernel_orig_uri, kernel_data_uri, kernel_file_uri):
 
43
    for ramdisk in (ramdisk_orig_uri, ramdisk_data_uri, ramdisk_file_uri):
 
44
        config['kernel'] = kernel
 
45
        config['ramdisk'] = ramdisk
 
46
        print("Using kernel='%s' ramdisk='%s'" % (kernel[:100], ramdisk[:100]))
 
47
        try:
 
48
            guest = XmTestAPIDomain(baseConfig = config)
 
49
            console = guest.start()
 
50
        except DomainError, e:
 
51
            if verbose:
 
52
                print("Failed to create test domain because: %s" % e.extra)
 
53
            FAIL(str(e))
 
54
 
 
55
        try:
 
56
            run = console.runCmd("ls /")
 
57
            if run['return'] > 0:
 
58
                FAIL("Could not start host")
 
59
        except ConsoleError, e:
 
60
            saveLog(console.getHistory())
 
61
            FAIL(str(e))
 
62
            
 
63
        guest.closeConsole()
 
64
        guest.stop()
 
65