
- logger.error("The execution should not have reached here!!") - return FAIL + + status = destroy_netpool(options.ip, options.virt, test_pool[i]) + if status != PASS: + logger.error("Unable to destroy networkpool %s", test_pool[i]) + status = FAIL
Should return here. Otherwise, if you're able to clean up the 2nd and 3rd pool, but not the first, the test will return PASS instead of FAIL.
+ + status = undefine_netpool(options.ip, options.virt, test_pool[i]) + if status != PASS: + logger.error("Unable to undefine networkpool %s", test_pool[i]) + status = FAIL
Same issue here.
+ + return status + if __name__ == "__main__": sys.exit(main()) - diff -r 92caf252c2fa -r af273b2ad41c suites/libvirt-cim/lib/XenKvmLib/pool.py --- a/suites/libvirt-cim/lib/XenKvmLib/pool.py Mon May 04 03:49:32 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/pool.py Wed May 06 21:48:09 2009 -0700 @@ -21,15 +21,21 @@ #
import sys -from CimTest.Globals import logger +from CimTest.Globals import logger, CIM_NS from CimTest.ReturnCodes import PASS, FAIL from XenKvmLib.classes import get_typed_class from XenKvmLib.const import get_provider_version, default_pool_name from XenKvmLib.enumclass import EnumInstances from VirtLib.utils import run_remote -from XenKvmLib.xm_virt_util import virt2uri +from XenKvmLib.xm_virt_util import virt2uri, net_list +from XenKvmLib import rpcs_service +from pywbem.cim_obj import CIMInstance, CIMInstanceName +import pywbem
+cim_errno = pywbem.CIM_ERR_NOT_SUPPORTED +cim_mname = "CreateChildResourcePool" input_graphics_pool_rev = 757 +libvirt_cim_child_pool_rev = 837
def pool_cn_to_rasd_cn(pool_cn, virt): if pool_cn.find('ProcessorPool') >= 0: @@ -97,3 +103,94 @@
return volume
+def net_undefine(network, server, virt="Xen"): + """Function undefine a given virtual network""" + + cmd = "virsh -c %s net-undefine %s" % (virt2uri(virt), network) + ret, out = run_remote(server, cmd) + + return ret + +def undefine_netpool(server, virt, net_name): + if net_name == None: + return FAIL + + ret = net_undefine(net_name, server, virt) + if ret != 0: + logger.error("Failed to undefine Virtual Network '%s'", net_name) + return FAIL + + return PASS + +def create_verify_netpool(server, virt, test_pool):
This is a long function. I would break this up so there is a function for creating the network pool and different function for verifying.
+ elif curr_cim_rev >= libvirt_cim_child_pool_rev: + nprasd = get_typed_class(virt, + 'NetPoolResourceAllocationSettingData') + addr = "192.168.0.9" + n_list = net_list(server, virt) + for _net_name in n_list: + cmd = "virsh net-dumpxml %s | awk '/ip address/ {print}' | \ + cut -d ' ' -f 4 | sed 's/address=//'" % _net_name + s, in_use_addr = run_remote(server, cmd) + in_use_addr = in_use_addr.strip("'") + if in_use_addr == addr: + logger.error("IP address is in use by a different network") + return FAIL + np_prop = { + "Address" : addr, + "Netmask" : "255.255.255.0", + "IPRangeStart" : "192.168.0.31", + "IPRangeEnd" : "192.168.0.57", + } + np_id = 'NetworkPool/%s' % test_pool + iname = CIMInstanceName(nprasd, + namespace = CIM_NS, + keybindings = {'InstanceID':np_id}) + if test_pool == "routedpool": + np_prop["ForwardMode"] = "route eth1" + elif test_pool == "natpool": + np_prop["ForwardMode"] = "nat"
The template NetPoolRASDs are now available in the providers. It's probably better to use those than to hand build the instances.
+ + nrasd = CIMInstance(nprasd, path = iname, properties = np_prop) + try: + rpcs_conn.CreateChildResourcePool(ElementName=test_pool, + Settings=[nrasd.tomof()]) + except Exception, details: + logger.error("Error in childpool creation") + logger.error(details) + return FAIL + + networkpool = get_typed_class(virt, 'NetworkPool') + pool_list = EnumInstances(server, networkpool) + if len(pool_list) < 1: + logger.error("Return %i instances, expected at least one instance", + len(pool_list)) + return FAIL + + for i in range(0, len(pool_list)): + ret_pool = pool_list[i].InstanceID + if ret_pool == np_id: + status = PASS + break + elif ret_pool != poolname and i == len(pool_list)-1: + logger.error("Can not find expected pool") + return FAIL
You only verify the InstanceID - you don't verify that the pool was created as expected. Ideally, this would also verify the NetPoolRASD that represents the current configuration of the NetworkPool. But I haven't implemented that piece yet.
+ + return status
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com