[PATCH 0 of 4] Adding tc to verify creation/deletion of DiskPool.

The patchset includes new tc to cover the creation and deletion of DiskPool. It also includes the changes to RPCS/04_CreateChildResourcePool.py and RPCS/07_DeleteChildResourcePool.py to align with the create_pool() and verify_pool() changes. This test case should be applied on top of "(#2) Return SKIP if the provider version doesn't support template pool RASDs" Tested with KVM on F10 with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com>

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1243504352 25200 # Node ID 9b503078f05e7ff90f203f1b8075cec655118b0d # Parent 8eda9601bbace5fe53e4df54d6528d4fd3edf809 [TEST] Add new tc to verify dir type diskpool creations using CreateChildResourcePool(). This test case should be applied on top of "(#2) Return SKIP if the provider version doesn't support template pool RASDs" Tested with KVM on F10 with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 8eda9601bbac -r 9b503078f05e suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/08_CreateDiskResourcePool.py Thu May 28 02:52:32 2009 -0700 @@ -0,0 +1,102 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Deepti B. Kalakeri<dkalaker@in.ibm.com> +# +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# 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 +# General Public License for more details. +# +# You should have received a copy of the GNU 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 +# +# This test case should test the CreateChildResourcePool service +# supplied by the RPCS provider. +# Input +# ----- +# IN -- ElementName -- String -- The desired name of the resource pool +# IN -- Settings -- String -- A string representation of a +# CIM_ResourceAllocationSettingData +# instance that represents the allocation +# assigned to this child pool +# IN -- ParentPool -- CIM_ResourcePool REF -- The parent pool from which +# to create this pool +# +# Output +# ------ +# OUT -- Pool -- CIM_ResourcePool REF -- The resulting resource pool +# OUT -- Job -- CIM_ConcreteJob REF -- Returned job if started +# OUT -- Error -- String -- Encoded error instance if the operation +# failed and did not return a job +# +# Exception details before Revision 846 +# ----- +# Error code: CIM_ERR_NOT_SUPPORTED +# +# After revision 846, the service is implemented +# +# -Date: 26.05.2009 + +import sys +from CimTest.Globals import logger +from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib.const import do_main, platform_sup +from XenKvmLib.classes import get_typed_class +from XenKvmLib.common_util import destroy_diskpool +from XenKvmLib.pool import create_pool, verify_pool, undefine_diskpool + +test_pool = "diskpool" +dp_types = { "DISK_POOL_DIR" : 1 } + + +@do_main(platform_sup) +def main(): + options = main.options + server = options.ip + virt = options.virt + pool_attr = { "Path" : "/tmp" } + + # For now the test case support only the creation of + # dir type disk pool, later change to fs and netfs etc + for key, value in dp_types.iteritems(): + status = create_pool(server, virt, test_pool, pool_attr, + mode_type=value, pool_type= "DiskPool") + if status != PASS: + logger.error("Failed to create '%s' type diskpool '%s'", + key, test_pool) + return FAIL + + status = verify_pool(server, virt, test_pool, pool_attr, + mode_type=value, pool_type="DiskPool") + if status != PASS: + logger.error("Error in diskpool verification") + destroy_diskpool(server, virt, test_pool) + undefine_diskpool(server, virt, test_pool) + return FAIL + + status = destroy_diskpool(server, virt, test_pool) + if status != PASS: + logger.error("Unable to destroy diskpool '%s'", test_pool) + return FAIL + + status = undefine_diskpool(server, virt, test_pool) + if status != PASS: + logger.error("Unable to undefine diskpool '%s'", test_pool) + return FAIL + + status = PASS + + return status + +if __name__ == "__main__": + sys.exit(main())

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1243504212 25200 # Node ID 8eda9601bbace5fe53e4df54d6528d4fd3edf809 # Parent ff0fb8fca1512987cb6a8210e7a3e95396dfa0a9 [TEST] Modifying RPCS/04_CreateChildResourcePool.py and RPCS/07_DeleteChildResourcePool.py Modifying RPCS/04_CreateChildResourcePool.py and RPCS/07_DeleteChildResourcePool.py to align with the changes to create_pool() and verify_pool() changes of pool.py. diff -r ff0fb8fca151 -r 8eda9601bbac suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py Thu May 28 02:38:21 2009 -0700 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py Thu May 28 02:50:12 2009 -0700 @@ -54,7 +54,7 @@ from XenKvmLib.const import do_main, platform_sup from XenKvmLib.classes import get_typed_class from XenKvmLib.common_util import destroy_netpool -from XenKvmLib.pool import create_netpool, verify_pool, undefine_netpool +from XenKvmLib.pool import create_pool, verify_pool, undefine_netpool test_pool = "testpool" @@ -76,15 +76,17 @@ "IPRangeStart" : range_addr_start, "IPRangeEnd" : range_addr_end } - for item in range(0, 3): - status = create_netpool(options.ip, options.virt, - test_pool, pool_attr, mode_type=item) + net_type = ["isolated", "nat", "route"] + for item in range(0, len(net_type)): + logger.info("Creating '%s' type network", net_type[item]) + status = create_pool(options.ip, options.virt, + test_pool, pool_attr, mode_type=item) if status != PASS: logger.error("Error in networkpool creation") return status - status = verify_pool(options.ip, options.virt, np, - test_pool, pool_attr, mode_type=item) + status = verify_pool(options.ip, options.virt, + test_pool, pool_attr, mode_type=item) if status != PASS: logger.error("Error in networkpool verification") destroy_netpool(options.ip, options.virt, test_pool) diff -r ff0fb8fca151 -r 8eda9601bbac suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/07_DeleteResourcePool.py --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/07_DeleteResourcePool.py Thu May 28 02:38:21 2009 -0700 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/07_DeleteResourcePool.py Thu May 28 02:50:12 2009 -0700 @@ -52,7 +52,7 @@ from XenKvmLib.enumclass import EnumInstances, EnumNames from XenKvmLib.classes import get_typed_class from XenKvmLib.common_util import destroy_netpool -from XenKvmLib.pool import create_netpool, verify_pool +from XenKvmLib.pool import create_pool, verify_pool cim_errno = pywbem.CIM_ERR_NOT_SUPPORTED cim_mname = "DeleteResourcePool" @@ -71,7 +71,8 @@ rpcs_conn.DeleteResourcePool() except pywbem.CIMError, (err_no, desc): if err_no == cim_errno : - logger.info("Got expected exception for '%s' service", cim_mname) + logger.info("Got expected exception for '%s' service", + cim_mname) logger.info("Errno is '%s' ", err_no) logger.info("Error string is '%s'", desc) return PASS @@ -87,21 +88,22 @@ "IPRangeEnd" : "192.168.0.15", "ForwardMode" : "nat" } - np = get_typed_class(options.virt, 'NetworkPool') - np_id = "NetworkPool/%s" % test_pool - status = create_netpool(options.ip, options.virt, test_pool, pool_attr) + status = create_pool(options.ip, options.virt, test_pool, pool_attr) if status != PASS: logger.error("Error in networkpool creation") return status - status = verify_pool(options.ip, options.virt, np, - test_pool, pool_attr) + status = verify_pool(options.ip, options.virt, + test_pool, pool_attr) + if status != PASS: logger.error("Error in networkpool verification") destroy_netpool(options.ip, options.virt, test_pool) return status + np = get_typed_class(options.virt, 'NetworkPool') + np_id = "NetworkPool/%s" % test_pool netpool = EnumNames(options.ip, np) for i in range(0, len(netpool)): ret_pool = netpool[i].keybindings['InstanceID']

Deepti B. Kalakeri wrote:
# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1243504212 25200 # Node ID 8eda9601bbace5fe53e4df54d6528d4fd3edf809 # Parent ff0fb8fca1512987cb6a8210e7a3e95396dfa0a9 [TEST] Modifying RPCS/04_CreateChildResourcePool.py and RPCS/07_DeleteChildResourcePool.py
Modifying RPCS/04_CreateChildResourcePool.py and RPCS/07_DeleteChildResourcePool.py to align with the changes to create_pool() and verify_pool() changes of pool.py.
diff -r ff0fb8fca151 -r 8eda9601bbac suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py
This patch is missing a DCO. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1243503501 25200 # Node ID ff0fb8fca1512987cb6a8210e7a3e95396dfa0a9 # Parent 13e68baa2f6de1737a7ad17e9d4909782d3fe192 [TEST] Adding new tc to verify DiskPool Deletion using DeleteResourcePool. Tested with KVM on F10 with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 13e68baa2f6d -r ff0fb8fca151 suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py Thu May 28 02:38:21 2009 -0700 @@ -0,0 +1,133 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Guolian Yun <yunguol@cn.ibm.com> +# +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# 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 +# General Public License for more details. +# +# You should have received a copy of the GNU 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 +# +# This test case should test the DeleteResourcePool service +# supplied by the RPCS provider. +# The DeleteResourcePool is used to delete a resource pool. +# DeleteResourcePool() details: +# Input +# ----- +# IN -- Pool -- CIM_ResourcePool REF -- The resource pool to delete +# +# Output +# ------ +# OUT -- Job -- CIM_ConcreteJob REF -- Returned job if started +# OUT -- Error-- String -- Encoded error instance if the operation +# failed and did not return a job. +# +# Exception details before Revision 841 +# ----- +# Error code: CIM_ERR_NOT_SUPPORTED +# +# After revision 841, the service is implemented +# The test case verifies DeleteResourcePool is able to delete the +# dir type diskpool. +# -Date: 26.05.2009 + +import sys +import pywbem +from XenKvmLib import rpcs_service +from CimTest.Globals import logger +from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib.const import do_main, platform_sup, get_provider_version +from XenKvmLib.enumclass import EnumInstances, EnumNames +from XenKvmLib.classes import get_typed_class +from XenKvmLib.pool import create_pool, verify_pool, undefine_diskpool +from XenKvmLib.common_util import destroy_diskpool + +cim_errno = pywbem.CIM_ERR_NOT_SUPPORTED +cim_mname = "DeleteResourcePool" +libvirt_cim_child_pool_rev = 841 +test_pool = "dp_pool" +TYPE = 1 # Dir type diskpool + +@do_main(platform_sup) +def main(): + status = FAIL + options = main.options + server = options.ip + virt = options.virt + cn = get_typed_class(virt, "ResourcePoolConfigurationService") + rpcs_conn = eval("rpcs_service." + cn)(server) + curr_cim_rev, changeset = get_provider_version(virt, server) + if curr_cim_rev < libvirt_cim_child_pool_rev: + + try: + rpcs_conn.DeleteResourcePool() + except pywbem.CIMError, (err_no, desc): + if err_no == cim_errno : + logger.info("Got expected exception for '%s' service", cim_mname) + logger.info("Errno is '%s' ", err_no) + logger.info("Error string is '%s'", desc) + return PASS + else: + logger.error("Unexpected rc code %s and description %s\n", + err_no, desc) + return status + + elif curr_cim_rev >= libvirt_cim_child_pool_rev: + + try: + pool_attr = { "Path" : "/tmp" } + status = create_pool(server, virt, test_pool, pool_attr, + pool_type="DiskPool", mode_type=TYPE) + if status != PASS: + logger.error("Failed to create diskpool '%s'", test_pool) + return FAIL + + status = verify_pool(server, virt, test_pool, + pool_attr, pool_type="DiskPool") + if status != PASS: + raise Exception("Failed to verify diskpool '%s'" % test_pool) + + dp = get_typed_class(virt, 'DiskPool') + dp_id = "DiskPool/%s" % test_pool + pool_settings = None + pool = EnumNames(server, dp) + for i in range(0, len(pool)): + ret_pool = pool[i].keybindings['InstanceID'] + if ret_pool == dp_id: + pool_settings = pool[i] + break + + if pool_settings == None: + logger.error("Failed to get poolsettings for '%s'", test_pool) + return FAIL + + rpcs_conn.DeleteResourcePool(Pool = pool_settings) + pool = EnumInstances(server, dp) + for i in range(0, len(pool)): + ret_pool = pool[i].InstanceID + if ret_pool == dp_id: + raise Exception("Failed to delete diskpool '%s'" %test_pool) + + status = PASS + except Exception, details: + logger.error("Exception details: %s", details) + destroy_diskpool(server, virt, test_pool) + undefine_diskpool(server, virt, test_pool) + return FAIL + + return status + +if __name__ == "__main__": + sys.exit(main())

Deepti B. Kalakeri wrote:
# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1243503501 25200 # Node ID ff0fb8fca1512987cb6a8210e7a3e95396dfa0a9 # Parent 13e68baa2f6de1737a7ad17e9d4909782d3fe192 [TEST] Adding new tc to verify DiskPool Deletion using DeleteResourcePool.
Tested with KVM on F10 with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com>
diff -r 13e68baa2f6d -r ff0fb8fca151 suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py Thu May 28 02:38:21 2009 -0700
No complaints on this patch.. just a question. =) Do you plan on updating this test case to support deletion of other disk pool types? All the pool types should be identical. So if you plan on using different test cases, it would be a good idea to put parts of this test case into a function (or functions) at some point later on. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
Deepti B. Kalakeri wrote:
# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1243503501 25200 # Node ID ff0fb8fca1512987cb6a8210e7a3e95396dfa0a9 # Parent 13e68baa2f6de1737a7ad17e9d4909782d3fe192 [TEST] Adding new tc to verify DiskPool Deletion using DeleteResourcePool.
Tested with KVM on F10 with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com>
diff -r 13e68baa2f6d -r ff0fb8fca151 suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteDiskPool.py Thu May 28 02:38:21 2009 -0700
No complaints on this patch.. just a question. =) Do you plan on updating this test case to support deletion of other disk pool types? All the pool types should be identical. So if you plan on using different test cases, it would be a good idea to put parts of this test case into a function (or functions) at some point later on.
Yes we should be supporting the deletion of the other disk / net types. When that happens we can see if we need to write different functions. For now the DeleteResourcePool() has atleast one test for verification. Do you think we should immediately implement the deletion of the other types as well ? -- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com

No complaints on this patch.. just a question. =) Do you plan on updating this test case to support deletion of other disk pool types? All the pool types should be identical. So if you plan on using different test cases, it would be a good idea to put parts of this test case into a function (or functions) at some point later on.
Yes we should be supporting the deletion of the other disk / net types. When that happens we can see if we need to write different functions. For now the DeleteResourcePool() has atleast one test for verification. Do you think we should immediately implement the deletion of the other types as well ?
No, this is fine for now. I was just curious how you were planning to approach it. But this sounds fine to me. Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1243503287 25200 # Node ID 13e68baa2f6de1737a7ad17e9d4909782d3fe192 # Parent 3c17b4d15e84469ed3d2307a7123c75d99415dee [TEST][Rebased] Modifying pool.py and vxml.py to accomodate changes for diskpool. Tested with KVM on F10 and with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 3c17b4d15e84 -r 13e68baa2f6d suites/libvirt-cim/lib/XenKvmLib/pool.py --- a/suites/libvirt-cim/lib/XenKvmLib/pool.py Fri May 22 01:41:08 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/pool.py Thu May 28 02:34:47 2009 -0700 @@ -32,7 +32,7 @@ from XenKvmLib import rpcs_service import pywbem from CimTest.CimExt import CIMClassMOF -from XenKvmLib.vxml import NetXML +from XenKvmLib.vxml import NetXML, PoolXML from XenKvmLib.xm_virt_util import virsh_version cim_errno = pywbem.CIM_ERR_NOT_SUPPORTED @@ -106,8 +106,7 @@ return volume -def get_pool_rasds(server, virt, - pool_type="NetworkPool", filter_default=True): +def get_pool_rasds(server, virt, pool_type="NetworkPool", filter_default=True): net_pool_rasd_rev = 867 disk_pool_rasd_rev = 863 @@ -124,7 +123,7 @@ logger.error("%s template RASDs not supported. %s.", pool_type, detail) return SKIP, None - net_pool_rasds = [] + n_d_pool_rasds = [] ac_cn = get_typed_class(virt, "AllocationCapabilities") an_cn = get_typed_class(virt, "SettingsDefineCapabilities") @@ -140,11 +139,11 @@ if filter_default == True: for item in rasd: if item['InstanceID'] == "Default": - net_pool_rasds.append(item) + n_d_pool_rasds.append(item) else: return PASS, rasd - return PASS, net_pool_rasds + return PASS, n_d_pool_rasds def net_undefine(network, server, virt="Xen"): """Function undefine a given virtual network""" @@ -165,16 +164,32 @@ return PASS -def create_netpool(server, virt, test_pool, pool_attr_list, mode_type=0): - status = PASS +def undefine_diskpool(server, virt, dp_name): + libvirt_version = virsh_version(server, virt) + if libvirt_version >= '0.4.1': + if dp_name == None: + return FAIL + + cmd = "virsh -c %s pool-undefine %s" % (virt2uri(virt), dp_name) + ret, out = run_remote(server, cmd) + if ret != 0: + logger.error("Failed to undefine pool '%s'", dp_name) + return FAIL + + return PASS + +def create_pool(server, virt, test_pool, pool_attr_list, + mode_type=0, pool_type="NetworkPool"): + rpcs = get_typed_class(virt, "ResourcePoolConfigurationService") rpcs_conn = eval("rpcs_service." + rpcs)(server) curr_cim_rev, changeset = get_provider_version(virt, server) if curr_cim_rev < libvirt_cim_child_pool_rev: + try: rpcs_conn.CreateChildResourcePool() except pywbem.CIMError, (err_no, desc): - if err_no == cim_errno : + if err_no == cim_errno: logger.info("Got expected exception for '%s'service", cim_mname) logger.info("Errno is '%s' ", err_no) logger.info("Error string is '%s'", desc) @@ -183,78 +198,92 @@ logger.error("Unexpected rc code %s and description %s\n", err_no, desc) return FAIL + elif curr_cim_rev >= libvirt_cim_child_pool_rev: - n_list = net_list(server, virt) - for _net_name in n_list: - net_xml = NetXML(server=server, networkname=_net_name, - virt=virt, is_new_net=False) - pool_use_attr = net_xml.xml_get_netpool_attr_list() - if pool_attr_list['Address'] in pool_use_attr: - logger.error("IP address is in use by a different network") - return FAIL + + if pool_type == "NetworkPool" : + n_list = net_list(server, virt) + for _net_name in n_list: + net_xml = NetXML(server=server, networkname=_net_name, + virt=virt, is_new_net=False) + pool_use_attr = net_xml.xml_get_netpool_attr_list() + if pool_attr_list['Address'] in pool_use_attr: + logger.error("IP address is in use by a different network") + return FAIL - status, net_pool_rasds = get_pool_rasds(server, virt) + status, n_d_pool_rasds = get_pool_rasds(server, virt, pool_type) if status != PASS: return status - if len(net_pool_rasds) == 0: - logger.error("We can not get NetPoolRASDs") + if len(n_d_pool_rasds) == 0: + logger.error("Failed to get '%sRASD'", pool_type) return FAIL else: - for i in range(0, len(net_pool_rasds)): - if net_pool_rasds[i]['ForwardMode'] == mode_type: - net_pool_rasds[i]['PoolID'] = "NetworkPool/%s" % test_pool - for attr, val in pool_attr_list.iteritems(): - net_pool_rasds[i][attr] = val - break - - pool_settings = inst_to_mof(net_pool_rasds[i]) + for i in range(0, len(n_d_pool_rasds)): + pool_id = "%s/%s" %(pool_type, test_pool) + n_d_pool_rasds[i]['PoolID'] = pool_id + if pool_type == "NetworkPool": + key = 'ForwardMode' + elif pool_type == "DiskPool": + key = 'Type' + + if n_d_pool_rasds[i][key] == mode_type: + for attr, val in pool_attr_list.iteritems(): + n_d_pool_rasds[i][attr] = val + break + + pool_settings = inst_to_mof(n_d_pool_rasds[i]) try: rpcs_conn.CreateChildResourcePool(ElementName=test_pool, Settings=[pool_settings]) except Exception, details: - logger.error("Error in childpool creation") - logger.error(details) + logger.error("Exception in create_pool()") + logger.error("Exception details: %s", details) return FAIL - return status + return PASS - -def verify_pool(server, virt, pooltype, poolname, pool_attr_list, mode_type=0): +def verify_pool(server, virt, poolname, pool_attr_list, mode_type=0, + pool_type="NetworkPool"): status = FAIL - pool_list = EnumInstances(server, pooltype) + pool_cn = get_typed_class(virt, pool_type) + pool_list = EnumInstances(server, pool_cn) if len(pool_list) < 1: - logger.error("Return %i instances, expected at least one instance", - len(pool_list)) + logger.error("Got %i instances, expected at least one instance", + len(pool_list)) return FAIL - poolid = "NetworkPool/%s" % poolname + poolid = "%s/%s" % (pool_type, poolname) for i in range(0, len(pool_list)): ret_pool = pool_list[i].InstanceID if ret_pool != poolid: continue - net_xml = NetXML(server, virt=virt, networkname=poolname, - is_new_net=False) + if pool_type == "NetworkPool": + net_xml = NetXML(server, virt=virt, networkname=poolname, + is_new_net=False) - ret_mode = net_xml.xml_get_netpool_mode() - libvirt_version = virsh_version(server, virt) + ret_mode = net_xml.xml_get_netpool_mode() + libvirt_version = virsh_version(server, virt) + #Forward mode support was added in 0.4.2 + if libvirt_version >= '0.4.2': + if mode_type == 1 and ret_mode != "nat": + logger.error("Error when verifying 'nat' type network") + return FAIL + elif mode_type == 2 and ret_mode != "route": + logger.error("Error when verifying 'route' type network") + return FAIL + ret_pool_attr_list = net_xml.xml_get_netpool_attr_list() - #Forward mode support was added in 0.4.2 - if libvirt_version >= '0.4.2': - if mode_type == 1 and ret_mode != "nat": - logger.error("Got error when verify nat type") - return FAIL - elif mode_type == 2 and ret_mode != "route": - logger.error("Got error when verify route type") - return FAIL - - ret_pool_attr_list = net_xml.xml_get_netpool_attr_list() + elif pool_type == "DiskPool": + disk_xml = PoolXML(server ,virt=virt, poolname=poolname, + is_new_pool=False) + ret_pool_attr_list = disk_xml.xml_get_pool_attr_list() for i in range(0, len(ret_pool_attr_list)): if ret_pool_attr_list[i] not in pool_attr_list.itervalues(): - logger.error("Got error when parsing %s", ret_pool_attr_list[i]) + logger.error("Failed to verify '%s'", ret_pool_attr_list[i]) return FAIL status = PASS diff -r 3c17b4d15e84 -r 13e68baa2f6d suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Fri May 22 01:41:08 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Thu May 28 02:34:47 2009 -0700 @@ -293,7 +293,7 @@ class PoolXML(Virsh, XMLClass): def __init__(self, server, poolname=const.default_pool_name, - virt='xen'): + virt='xen', is_new_pool=True): XMLClass.__init__(self) if virt == 'XenFV': @@ -302,6 +302,17 @@ self.pool_name = poolname self.server = server + if is_new_pool is False: + cmd = "virsh pool-dumpxml %s" % self.pool_name + s, disk_xml = utils.run_remote(server, cmd) + if s != 0: + logger.error("Encounter error dump netxml") + return None + else: + self.xml_string = disk_xml + self.xdoc = minidom.parseString(self.xml_string) + return + pool = self.add_sub_node(self.xdoc, 'pool', type='dir') self.add_sub_node(pool, 'name', self.pool_name) target = self.add_sub_node(pool, 'target') @@ -313,10 +324,19 @@ def destroy_vpool(self): return self.run(self.server, 'pool-destroy', self.pool_name) + def undefine_vpool(self): + return self.run(self.server, 'pool-undefine', self.pool_name) + def xml_get_diskpool_name(self): dpoolname = self.get_value_xpath('/pool/name') return dpoolname + def xml_get_pool_attr_list(self): + pool_attr_list = [] + poolpath = self.get_value_xpath('/pool/target/path') + pool_attr_list.append(poolpath) + + return pool_attr_list class VirtXML(Virsh, XMLClass): """Base class for all XML generation & operation"""
participants (3)
-
Deepti B Kalakeri
-
Deepti B. Kalakeri
-
Kaitlin Rupert