[PATCH 0 of 2] Adding new tc to verify the template RASDs for parent NetPoolRASD.

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1242733506 25200 # Node ID 093bda6ad92c0d6b030cfc1e9d98743335555dff # Parent 6dc2d815e480237c91115cd0d86f6325503e33f7 [TEST] Modifying get_pool_rasds() of pool.py. Modifying get_pool_rasds() of pool.py to return all Parent DiskPool and NetworkPool records when required. Tested with KVM on F10 with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 6dc2d815e480 -r 093bda6ad92c suites/libvirt-cim/lib/XenKvmLib/pool.py --- a/suites/libvirt-cim/lib/XenKvmLib/pool.py Sun May 17 23:34:58 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/pool.py Tue May 19 04:45:06 2009 -0700 @@ -105,23 +105,26 @@ return volume -def get_pool_rasds(server, virt): +def get_pool_rasds(server, virt, pool_type="NetworkPool", + filter_default=True): net_pool_rasds = [] ac_cn = get_typed_class(virt, "AllocationCapabilities") an_cn = get_typed_class(virt, "SettingsDefineCapabilities") - key_list = {"InstanceID" : "NetworkPool/0" } - + key_list = {"InstanceID" : "%s/0" %pool_type } + try: inst = GetInstance(server, ac_cn, key_list) rasd = Associators(server, an_cn, ac_cn, InstanceID=inst.InstanceID) except Exception, detail: logger.error("Exception: %s", detail) return None - - for item in rasd: - if item['InstanceID'] == "Default": - net_pool_rasds.append(item) + if filter_default == True: + for item in rasd: + if item['InstanceID'] == "Default": + net_pool_rasds.append(item) + else: + return rasd return net_pool_rasds @@ -211,7 +214,7 @@ net_xml = NetXML(server, virt=virt, networkname=poolname, is_new_net=False) ret_pool_attr_list = net_xml.xml_get_netpool_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])

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1242733975 25200 # Node ID 4129e1f0e95aad2d1f61a0d96735e55e4dd8104f # Parent 093bda6ad92c0d6b030cfc1e9d98743335555dff [TEST] Adding new tc to verify the template RASDs for parent NetPoolRASD. Tested with KVM on F10 with current sources. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 093bda6ad92c -r 4129e1f0e95a suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/RASD/06_parent_net_pool.py Tue May 19 04:52:55 2009 -0700 @@ -0,0 +1,122 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Deepti B. Kalakeri <deeptik@linux.vnet.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 is used to verify the Parent NetPoolRASD and +# DiskPoolRASD properties in detail using the SettingsDefineCapabilities +# association. +# +# Ex: +# Command: +# wbemcli ai -ac SettingsDefineCapabilities \ +# 'http://localhost:5988/root/virt:KVM_AllocationCapabilties.InstanceID=\ +# "NetworkPool/0"' +# +# Output: +# localhost/root/virt:KVM_NetPoolResourceAllocationSettingData.InstanceID="Default" +# -InstanceID="Default" [ verified for Maximum, Increment, Default as well ] +# -ResourceType=10 +# -PoolID="NetworkPool/0" +# -Address="192.168.122.1" +# -Netmask="255.255.255.0" +# -IPRangeStart="192.168.122.2" +# -IPRangeEnd="192.168.122.254" +# -ForwardDevice= [ verified for 'None' and "eth0" ] +# -ForwardMode=0 [ verified for 1,2 as well ] +# +# +# +# Date : 18-05-2009 + +import sys +from sets import Set +from CimTest.Globals import logger +from XenKvmLib.const import do_main +from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib.pool import get_pool_rasds + +sup_types = ['KVM', 'Xen', 'XenFV'] + +def get_rec(netpool_rasd, inst_id='Default'): + recs = [] + for np_rasd in netpool_rasd: + if np_rasd['InstanceID'] == inst_id and \ + 'NetworkPool/0' == np_rasd['PoolID']: + recs.append(np_rasd) + return recs + +def verify_rec(netpool_rasd, inst_type='Default'): + logger.info("Verifying '%s' records", inst_type) + try: + n_rec_val = { 'ResourceType' : 10, + 'PoolID' : "NetworkPool/0", + 'Address' : "192.168.122.1", + 'Netmask' : "255.255.255.0", + 'IPRangeStart' : "192.168.122.2", + 'IPRangeEnd' : "192.168.122.254" + } + + n_rec = get_rec(netpool_rasd, inst_id=inst_type) + if len(n_rec) != 5: + raise Exception("Got %s recs instead of 5" %(len(n_rec))) + return FAIL + + exp_mode_device = [('None', 0L), ('None', 1L), ('eth0', 1L), + ('None', 2L), ('eth0', 2L)] + + res_mode_device = [] + for rec in n_rec: + l = (str(rec['ForwardDevice']), rec['ForwardMode']) + res_mode_device.append(l) + + if len(Set(exp_mode_device) & Set(res_mode_device)) != 5 : + raise Exception("Mismatching Mode and device values, " \ + "Got %s, Expected %s" %(exp_mode_device, \ + res_mode_device)) + + for key in n_rec_val.keys(): + for rec in n_rec: + if n_rec_val[key] != rec[key]: + raise Exception("'%s' Mismatch, Got %s, Expected %s" \ + % (key, rec[key], n_rec_val[key])) + + except Exception, details: + logger.error("Exception details: %s", details) + return FAIL + + return PASS + + +@do_main(sup_types) +def main(): + options = main.options + virt = options.virt + server = options.ip + status = FAIL + netpool_rasd = get_pool_rasds(server, virt, filter_default=False) + inst_list = [ 'Default', 'Minimum', 'Maximum', 'Increment' ] + for inst_type in inst_list: + status = verify_rec(netpool_rasd, inst_type) + if status != PASS: + return FAIL + return status +if __name__ == "__main__": + sys.exit(main())

+ +def get_rec(netpool_rasd, inst_id='Default'): + recs = [] + for np_rasd in netpool_rasd: + if np_rasd['InstanceID'] == inst_id and \ + 'NetworkPool/0' == np_rasd['PoolID']:
libvirt-cim will only generate NetPoolRASDs for the parent pool (which is NetworkPool/0"). So there's no need to verify the PoolID here. You have PoolID in the n_rec_val list anyway, so it'll get verified in verify_rec()
+ recs.append(np_rasd) + return recs + +def verify_rec(netpool_rasd, inst_type='Default'): + logger.info("Verifying '%s' records", inst_type) + try: + n_rec_val = { 'ResourceType' : 10, + 'PoolID' : "NetworkPool/0", + 'Address' : "192.168.122.1", + 'Netmask' : "255.255.255.0", + 'IPRangeStart' : "192.168.122.2", + 'IPRangeEnd' : "192.168.122.254" + } + + n_rec = get_rec(netpool_rasd, inst_id=inst_type) + if len(n_rec) != 5: + raise Exception("Got %s recs instead of 5" %(len(n_rec))) + return FAIL + + exp_mode_device = [('None', 0L), ('None', 1L), ('eth0', 1L), + ('None', 2L), ('eth0', 2L)] + + res_mode_device = [] + for rec in n_rec: + l = (str(rec['ForwardDevice']), rec['ForwardMode']) + res_mode_device.append(l) + + if len(Set(exp_mode_device) & Set(res_mode_device)) != 5 : + raise Exception("Mismatching Mode and device values, " \ + "Got %s, Expected %s" %(exp_mode_device, \ + res_mode_device)) + + for key in n_rec_val.keys(): + for rec in n_rec: + if n_rec_val[key] != rec[key]: + raise Exception("'%s' Mismatch, Got %s, Expected %s" \ + % (key, rec[key], n_rec_val[key])) + + except Exception, details: + logger.error("Exception details: %s", details) + return FAIL + + return PASS + + +@do_main(sup_types) +def main(): + options = main.options + virt = options.virt + server = options.ip + status = FAIL + netpool_rasd = get_pool_rasds(server, virt, filter_default=False) + inst_list = [ 'Default', 'Minimum', 'Maximum', 'Increment' ] + for inst_type in inst_list: + status = verify_rec(netpool_rasd, inst_type) + if status != PASS: + return FAIL
The bulk of the test is happening in a different function.. since there's not much going on in the test, you can just put the body of verify_rec() in main. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Deepti B. Kalakeri
-
Kaitlin Rupert