aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xm-test/tests/block-destroy/06_block-destroy_check_list_pos.py
blob: 7f1c7cd453bccf6b030d80712fbaaad07d51408f (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
#!/usr/bin/python

# Copyright (C) International Business Machines Corp., 2005
# Author: Dan Smith <danms@us.ibm.com>

from XmTestLib import *

import time
import re

def checkBlockList(domain):
    s, o = traceCommand("xm block-list %s" % domain.getName())
    if s != 0:
        FAIL("block-list failed")
    if re.search("769", o):
        return True
    else:
        return False

def checkXmLongList(domain):
    s, o = traceCommand("xm list --long %s" % domain.getName())
    if s != 0:
        FAIL("xm list --long <dom> failed")
    if re.search("hda1", o):
        return True
    else:
        return False

if ENABLE_VMX_SUPPORT:
    SKIP("Block-detach not supported for VMX domains")

domain = XmTestDomain()

try:
    domain.start()
except DomainError,e:
    FAIL(str(e))

s, o = traceCommand("xm block-attach %s phy:/dev/ram0 hda1 w" % domain.getName())
if s != 0:
    FAIL("block-attach failed")

if not checkBlockList(domain):
    FAIL("block-list does not show that hda1 was attached")

if not checkXmLongList(domain):
    FAIL("xm long list does not show that hda1 was attached")

time.sleep(2)

s, o = traceCommand("xm block-detach %s hda1" % domain.getName())
if s != 0:
    FAIL("block-detach failed")

time.sleep(2)

if checkBlockList(domain):
    FAIL("block-list does not show that hda1 was removed")

if checkXmLongList(domain):
    FAIL("xm long list does not show that hda1 was removed")