[Libvirt-cim] [PATCH 2 of 6] [TEST] Create a network pool before tests are run

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Mon Aug 25 14:22:35 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1219444184 25200
# Node ID 254abd366384a00a88b3042201c65bbb99d85a1f
# Parent  b445b3731ab95f0a00b0e9076f3be6adbb426562
[TEST] Create a network pool before tests are run.

This ensures a network pool is available for the tests to use.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r b445b3731ab9 -r 254abd366384 suites/libvirt-cim/main.py
--- a/suites/libvirt-cim/main.py	Fri Aug 22 15:29:43 2008 -0700
+++ b/suites/libvirt-cim/main.py	Fri Aug 22 15:29:44 2008 -0700
@@ -34,6 +34,9 @@
 sys.path.append('./lib')
 from XenKvmLib.reporting import gen_report, send_report 
 from VirtLib import utils
+from CimTest.ReturnCodes import PASS, FAIL
+from XenKvmLib import const 
+from XenKvmLib.common_util import create_netpool_conf, destroy_netpool
 
 parser = OptionParser()
 parser.add_option("-i", "--ip", dest="ip", default="localhost",
@@ -122,6 +125,22 @@
 
     return addr, relay
 
+def setup_env(ip, virt):
+    status, netpool = create_netpool_conf(ip, virt, 
+                                          net_name=const.default_network_name)
+    if status != PASS:
+        print "\nUnable to create network pool %s" % const.default_network_name
+        return status
+
+    return PASS
+
+def cleanup_env(ip, virt):
+    status = destroy_netpool(ip, virt, const.default_network_name) 
+    if status != PASS:
+        print "Unable to destroy network pool %s." % const.default_network_name
+        return status
+
+    return PASS
 
 def main():
     (options, args) = parser.parse_args()
@@ -173,6 +192,11 @@
     else:
         dbg = ""
 
+    status = setup_env(options.ip, options.virt)
+    if status != PASS:
+        print "Please check your environment.\n"
+        return 1
+
     print "\nTesting " + options.virt + " hypervisor"
 
     for test in test_list: 
@@ -192,6 +216,10 @@
     testsuite.debug("%s\n" % div) 
     testsuite.finish()
 
+    status = cleanup_env(options.ip, options.virt)
+    if status != PASS:
+        print "Unable to clean up.  Please check your environment.\n"
+
     msg_body, heading = gen_report(options.virt, options.ip, testsuite.log_file)
 
     if options.report:




More information about the Libvirt-cim mailing list