aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xm-test/tests/xapi/04_xapi-data_uri_handling.py
blob: 7d1a39b503bc9acf2695fb04f91b011b8a3cca1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/python
#============================================================================
# This library is free software; you can redistribute it and/or
# modify it under the terms of version 2.1 of the GNU Lesser General Public
# License as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#============================================================================
# Copyright (C) 2009 flonatel GmbH & Co. KG
#============================================================================
#
# This file contains test cases for checking the data URI
# functionality:
# kernel and ramdisk are both checked with original uri,
# file uri and data uri (in every constallation)
#

import copy

from xen.util.fileuri import schemes, scheme_data, scheme_file

from XmTestLib import *
from XmTestLib.network_utils import *
from XmTestLib.XenAPIDomain import XmTestAPIDomain

kernel_orig_uri = arch.configDefaults['kernel']
ramdisk_orig_uri = arch.configDefaults['ramdisk']
kernel_data_uri = scheme_data.create_from_file(kernel_orig_uri)
ramdisk_data_uri = scheme_data.create_from_file(ramdisk_orig_uri)
kernel_file_uri = scheme_file.encode(kernel_orig_uri)
ramdisk_file_uri = scheme_file.encode(ramdisk_orig_uri)

config = copy.copy(arch.configDefaults)

for kernel in (kernel_orig_uri, kernel_data_uri, kernel_file_uri):
    for ramdisk in (ramdisk_orig_uri, ramdisk_data_uri, ramdisk_file_uri):
        config['kernel'] = kernel
        config['ramdisk'] = ramdisk
        print("Using kernel='%s' ramdisk='%s'" % (kernel[:100], ramdisk[:100]))
        try:
            guest = XmTestAPIDomain(baseConfig = config)
            console = guest.start()
        except DomainError, e:
            if verbose:
                print("Failed to create test domain because: %s" % e.extra)
            FAIL(str(e))

        try:
            run = console.runCmd("ls /")
            if run['return'] > 0:
                FAIL("Could not start host")
        except ConsoleError, e:
            saveLog(console.getHistory())
            FAIL(str(e))
            
        guest.closeConsole()
        guest.stop()