ia64/xen-unstable

changeset 14957:aeb1931eab36

[XM-TEST] Move network_utils.py to lib directory

signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
author Tom Wilkie <tom.wilkie@gmail.com>
date Thu Apr 26 15:48:09 2007 +0100 (2007-04-26)
parents a9b9847d97bb
children ac203df11e50
files tools/xm-test/lib/XmTestLib/network_utils.py tools/xm-test/tests/network-attach/01_network_attach_pos.py tools/xm-test/tests/network-attach/02_network_attach_detach_pos.py tools/xm-test/tests/network-attach/03_network_attach_detach_multiple_pos.py tools/xm-test/tests/network-attach/network_utils.py
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/xm-test/lib/XmTestLib/network_utils.py	Thu Apr 26 15:48:09 2007 +0100
     1.3 @@ -0,0 +1,60 @@
     1.4 +#!/usr/bin/python
     1.5 +
     1.6 +# Copyright (C) International Business Machines Corp., 2005
     1.7 +# Author: Murillo F. Bernardes <mfb@br.ibm.com>
     1.8 +
     1.9 +from XmTestLib import *
    1.10 +
    1.11 +def count_eth(console):
    1.12 +    try:
    1.13 +        run = console.runCmd("ifconfig -a | grep eth")
    1.14 +    except ConsoleError, e:
    1.15 +        FAIL(str(e))
    1.16 +    return len(run['output'].splitlines())
    1.17 +
    1.18 +def get_state(domain_name, number):
    1.19 +    s, o = traceCommand("xm network-list %s | awk '/^%d/ {print $5}'" %
    1.20 +                        (domain_name, number))
    1.21 +    print o
    1.22 +    
    1.23 +    if s != 0:
    1.24 +        FAIL("network-list failed")
    1.25 +    if o == "":
    1.26 +        return 0
    1.27 +    else:
    1.28 +        return int(o)
    1.29 +
    1.30 +def network_attach(domain_name, console, bridge=None):
    1.31 +    eths_before = count_eth(console)
    1.32 +    if bridge:
    1.33 +        status, output = traceCommand("xm network-attach %s bridge=%s"
    1.34 +                                      % (domain_name, bridge))
    1.35 +    else:
    1.36 +        status, output = traceCommand("xm network-attach %s" % domain_name)
    1.37 +    if status != 0:
    1.38 +        return -1, "xm network-attach returned invalid %i != 0" % status
    1.39 +
    1.40 +    eths_after = count_eth(console)
    1.41 +    if (eths_after != (eths_before+1)):
    1.42 +        return -2, "Network device is not actually connected to domU"
    1.43 +
    1.44 +    return 0, None 
    1.45 +
    1.46 +def network_detach(domain_name, console, num=0):
    1.47 +    eths_before = count_eth(console)
    1.48 +    status, output = traceCommand("xm network-detach %s %d" % (domain_name, num))
    1.49 +    if status != 0:
    1.50 +        return -1, "xm network-detach returned invalid %i != 0" % status
    1.51 +
    1.52 +    for i in range(10):
    1.53 +        if get_state(domain_name, num) == 0:
    1.54 +            break
    1.55 +        time.sleep(1)
    1.56 +    else:
    1.57 +        FAIL("network-detach failed: device did not disappear")
    1.58 +
    1.59 +    eths_after = count_eth(console)
    1.60 +    if eths_after != (eths_before-1):
    1.61 +        return -2, "Network device was not actually disconnected from domU"
    1.62 +
    1.63 +    return 0, None
     2.1 --- a/tools/xm-test/tests/network-attach/01_network_attach_pos.py	Thu Apr 26 15:40:35 2007 +0100
     2.2 +++ b/tools/xm-test/tests/network-attach/01_network_attach_pos.py	Thu Apr 26 15:48:09 2007 +0100
     2.3 @@ -6,7 +6,7 @@
     2.4  import sys
     2.5  
     2.6  from XmTestLib import *
     2.7 -from network_utils import *
     2.8 +from XmTestLib.network_utils import *
     2.9  
    2.10  if ENABLE_HVM_SUPPORT:
    2.11      SKIP("Network-attach not supported for HVM domains")
     3.1 --- a/tools/xm-test/tests/network-attach/02_network_attach_detach_pos.py	Thu Apr 26 15:40:35 2007 +0100
     3.2 +++ b/tools/xm-test/tests/network-attach/02_network_attach_detach_pos.py	Thu Apr 26 15:48:09 2007 +0100
     3.3 @@ -8,7 +8,7 @@ import re
     3.4  import time
     3.5  
     3.6  from XmTestLib import *
     3.7 -from network_utils import *
     3.8 +from XmTestLib.network_utils import *
     3.9  
    3.10  if ENABLE_HVM_SUPPORT:
    3.11      SKIP("Network-attach not supported for HVM domains")
     4.1 --- a/tools/xm-test/tests/network-attach/03_network_attach_detach_multiple_pos.py	Thu Apr 26 15:40:35 2007 +0100
     4.2 +++ b/tools/xm-test/tests/network-attach/03_network_attach_detach_multiple_pos.py	Thu Apr 26 15:48:09 2007 +0100
     4.3 @@ -8,7 +8,7 @@ import re
     4.4  import time
     4.5  
     4.6  from XmTestLib import *
     4.7 -from network_utils import *
     4.8 +from XmTestLib.network_utils import *
     4.9  
    4.10  if ENABLE_HVM_SUPPORT:
    4.11      SKIP("Network-attach not supported for HVM domains")
     5.1 --- a/tools/xm-test/tests/network-attach/network_utils.py	Thu Apr 26 15:40:35 2007 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,56 +0,0 @@
     5.4 -#!/usr/bin/python
     5.5 -
     5.6 -# Copyright (C) International Business Machines Corp., 2005
     5.7 -# Author: Murillo F. Bernardes <mfb@br.ibm.com>
     5.8 -
     5.9 -from XmTestLib import *
    5.10 -
    5.11 -def count_eth(console):
    5.12 -    try:
    5.13 -        run = console.runCmd("ifconfig -a | grep eth")
    5.14 -    except ConsoleError, e:
    5.15 -        FAIL(str(e))
    5.16 -    return len(run['output'].splitlines())
    5.17 -
    5.18 -def get_state(domain_name, number):
    5.19 -    s, o = traceCommand("xm network-list %s | awk '/^%d/ {print $5}'" %
    5.20 -                        (domain_name, number))
    5.21 -    print o
    5.22 -    
    5.23 -    if s != 0:
    5.24 -        FAIL("network-list failed")
    5.25 -    if o == "":
    5.26 -        return 0
    5.27 -    else:
    5.28 -        return int(o)
    5.29 -
    5.30 -def network_attach(domain_name, console):
    5.31 -    eths_before = count_eth(console)
    5.32 -    status, output = traceCommand("xm network-attach %s" % domain_name)
    5.33 -    if status != 0:
    5.34 -        return -1, "xm network-attach returned invalid %i != 0" % status
    5.35 -
    5.36 -    eths_after = count_eth(console)
    5.37 -    if (eths_after != (eths_before+1)):
    5.38 -        return -2, "Network device is not actually connected to domU"
    5.39 -
    5.40 -    return 0, None 
    5.41 -
    5.42 -def network_detach(domain_name, console, num=0):
    5.43 -    eths_before = count_eth(console)
    5.44 -    status, output = traceCommand("xm network-detach %s %d" % (domain_name, num))
    5.45 -    if status != 0:
    5.46 -        return -1, "xm network-detach returned invalid %i != 0" % status
    5.47 -
    5.48 -    for i in range(10):
    5.49 -        if get_state(domain_name, num) == 0:
    5.50 -            break
    5.51 -        time.sleep(1)
    5.52 -    else:
    5.53 -        FAIL("network-detach failed: device did not disappear")
    5.54 -
    5.55 -    eths_after = count_eth(console)
    5.56 -    if eths_after != (eths_before-1):
    5.57 -        return -2, "Network device was not actually disconnected from domU"
    5.58 -
    5.59 -    return 0, None