# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1209433108 -28800
# Node ID 292223637d873644587835e44aa3aadba11c924e
# Parent 22ed2c7c77e8ff3d96b40f1e0db2a931b5a7c37e
[TEST] .2# Add revision branch to RASD.01 & 02
- Added prev & mrev for 'proc' vs. '0', 'KiloBytes' vs.
'MegaBytes' issue.
- Updated style format.
- Added commonly used class name in XenKvmLib.rasd
- Use if statements instead of conditional expressions
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r 22ed2c7c77e8 -r 292223637d87
suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py
--- a/suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py Fri Apr 25 03:20:54 2008
-0700
+++ b/suites/libvirt-cim/cimtest/RASD/01_verify_rasd_fields.py Tue Apr 29 09:38:28 2008
+0800
@@ -47,18 +47,14 @@
import sys
-from XenKvmLib import enumclass
-from VirtLib import utils
from CimTest import Globals
from CimTest.Globals import do_main
from XenKvmLib.test_doms import destroy_and_undefine_all
-import XenKvmLib
from XenKvmLib import assoc
from XenKvmLib import vxml
-from XenKvmLib.vxml import XenXML, KVMXML, get_class
from XenKvmLib.classes import get_typed_class
-from XenKvmLib.rasd import verify_procrasd_values, verify_netrasd_values, \
-verify_diskrasd_values, verify_memrasd_values
+from XenKvmLib import rasd
+from XenKvmLib.const import CIM_REV
from CimTest.Globals import logger
from CimTest.ReturnCodes import PASS, FAIL
@@ -68,42 +64,43 @@ test_vcpus = 1
test_vcpus = 1
test_mem = 128
test_mac = "00:11:22:33:44:aa"
+prev = 531
+mrev = 529
def init_list(xml, disk, virt="Xen"):
"""
Creating the lists that will be used for comparisons.
"""
procrasd = {
- "InstanceID" : '%s/%s' %(test_dom,
"proc"),\
- "ResourceType" : 3,\
- "CreationClassName": get_typed_class(virt,
'ProcResourceAllocationSettingData')
- }
-
+ "InstanceID" : '%s/%s' % (test_dom, "proc"),
+ "ResourceType" : 3,
+ "CreationClassName" : get_typed_class(virt, rasd.pasd_cn)}
netrasd = {
- "InstanceID" : '%s/%s' %(test_dom,test_mac), \
- "ResourceType" : 10 , \
- "ntype1": "bridge", \
- "ntype2": "ethernet", \
- "CreationClassName": get_typed_class(virt,
'NetResourceAllocationSettingData')
- }
-
+ "InstanceID" : '%s/%s' % (test_dom,test_mac),
+ "ResourceType" : 10 ,
+ "ntype1" : "bridge",
+ "ntype2" : "ethernet",
+ "CreationClassName" : get_typed_class(virt, rasd.nasd_cn)}
address = xml.xml_get_disk_source()
diskrasd = {
- "InstanceID" : '%s/%s' %(test_dom, disk), \
- "ResourceType" : 17, \
- "Address" : address, \
- "CreationClassName": get_typed_class(virt,
'DiskResourceAllocationSettingData')
- }
+ "InstanceID" : '%s/%s' % (test_dom, disk),
+ "ResourceType" : 17,
+ "Address" : address,
+ "CreationClassName" : get_typed_class(virt, rasd.dasd_cn)}
memrasd = {
- "InstanceID" : '%s/%s' %(test_dom, "mem"), \
- "ResourceType" : 4, \
- "AllocationUnits" : "KiloBytes",\
- "VirtualQuantity" : (test_mem * 1024), \
- "CreationClassName": get_typed_class(virt,
'MemResourceAllocationSettingData')
- }
+ "InstanceID" : '%s/%s' % (test_dom, "mem"),
+ "ResourceType" : 4,
+ "AllocationUnits" : "KiloBytes",
+ "VirtualQuantity" : (test_mem * 1024),
+ "CreationClassName" : get_typed_class(virt, rasd.masd_cn)}
+ if CIM_REV < prev:
+ procrasd['InstanceID'] = '%s/0' % test_dom
+ if CIM_REV < mrev:
+ memrasd['AllocationUnits'] = 'MegaBytes'
+
return procrasd, netrasd, diskrasd, memrasd
-def assoc_values(ip, assoc_info, xml, disk, virt="Xen"):
+def assoc_values(assoc_info, xml, disk, virt="Xen"):
procrasd, netrasd, diskrasd, memrasd = init_list(xml, disk, virt)
proc_status = 1
net_status = 0
@@ -111,15 +108,15 @@ def assoc_values(ip, assoc_info, xml, di
mem_status = 1
status = 0
try:
- for i in range(len(assoc_info)):
- if assoc_info[i]['InstanceID'] == procrasd['InstanceID']:
- proc_status = verify_procrasd_values(assoc_info[i], procrasd)
- elif assoc_info[i]['InstanceID'] == netrasd['InstanceID']:
- net_status = verify_netrasd_values(assoc_info[i], netrasd)
- elif assoc_info[i]['InstanceID'] == diskrasd['InstanceID']:
- disk_status = verify_diskrasd_values(assoc_info[i], diskrasd)
- elif assoc_info[i]['InstanceID'] == memrasd['InstanceID']:
- mem_status = verify_memrasd_values(assoc_info[i], memrasd)
+ for res in assoc_info:
+ if res['InstanceID'] == procrasd['InstanceID']:
+ proc_status = rasd.verify_procrasd_values(res, procrasd)
+ elif res['InstanceID'] == netrasd['InstanceID']:
+ net_status = rasd.verify_netrasd_values(res, netrasd)
+ elif res['InstanceID'] == diskrasd['InstanceID']:
+ disk_status = rasd.verify_diskrasd_values(res, diskrasd)
+ elif res['InstanceID'] == memrasd['InstanceID']:
+ mem_status = rasd.verify_memrasd_values(res, memrasd)
else:
status = 1
if status != 0 or proc_status != 0 or net_status != 0 or \
@@ -135,8 +132,7 @@ def assoc_values(ip, assoc_info, xml, di
@do_main(sup_types)
def main():
options = main.options
- status = 0
- rc = 1
+ status = PASS
destroy_and_undefine_all(options.ip)
if options.virt == 'Xen':
test_disk = 'xvda'
@@ -144,31 +140,32 @@ def main():
test_disk = 'hda'
virt_xml = vxml.get_class(options.virt)
- cxml = virt_xml(test_dom, mem=test_mem, vcpus = test_vcpus, mac = test_mac, disk =
test_disk)
+ cxml = virt_xml(test_dom, mem=test_mem, vcpus = test_vcpus,
+ mac = test_mac, disk = test_disk)
ret = cxml.create(options.ip)
if not ret:
logger.error('Unable to create domain %s' % test_dom)
return FAIL
if status == 1:
destroy_and_undefine_all(options.ip)
- return 1
+ return FAIL
if options.virt == "XenFV":
instIdval = "Xen:%s" % test_dom
else:
instIdval = "%s:%s" % (options.virt, test_dom)
-
+
+ vssdc_cn = 'VirtualSystemSettingDataComponent'
+ vssd_cn = 'VirtualSystemSettingData'
try:
- assoc_info = assoc.Associators(options.ip, \
- 'VirtualSystemSettingDataComponent', \
- 'VirtualSystemSettingData', \
- options.virt, \
+ assoc_info = assoc.Associators(options.ip, vssdc_cn, vssd_cn,
+ options.virt,
InstanceID = instIdval)
- status = assoc_values(options.ip, assoc_info, cxml, test_disk, options.virt)
+ status = assoc_values(assoc_info, cxml, test_disk, options.virt)
except Exception, details:
- logger.error(Globals.CIM_ERROR_ASSOCIATORS, \
- get_typed_class(options.virt,
'VirtualSystemSettingDataComponent'))
+ logger.error(Globals.CIM_ERROR_ASSOCIATORS,
+ get_typed_class(options.virt, vssdc_cn))
logger.error("Exception : %s" % details)
- status = 1
+ status = FAIL
try:
cxml.destroy(options.ip)
diff -r 22ed2c7c77e8 -r 292223637d87 suites/libvirt-cim/cimtest/RASD/02_enum.py
--- a/suites/libvirt-cim/cimtest/RASD/02_enum.py Fri Apr 25 03:20:54 2008 -0700
+++ b/suites/libvirt-cim/cimtest/RASD/02_enum.py Tue Apr 29 09:38:28 2008 +0800
@@ -28,14 +28,13 @@
import sys
-import XenKvmLib
from XenKvmLib import enumclass
from CimTest.Globals import do_main, CIM_ERROR_ENUMERATE
from XenKvmLib.test_doms import destroy_and_undefine_all
from XenKvmLib.vxml import get_class
from XenKvmLib.classes import get_typed_class
-from XenKvmLib.rasd import verify_procrasd_values, verify_netrasd_values, \
-verify_diskrasd_values, verify_memrasd_values
+from XenKvmLib import rasd
+from XenKvmLib.const import CIM_REV
from CimTest.Globals import logger
from CimTest.ReturnCodes import PASS, FAIL
@@ -45,41 +44,43 @@ test_vcpus = 1
test_vcpus = 1
test_mem = 128
test_mac = "00:11:22:33:44:aa"
-
-def init_list(virt="Xen"):
+prev = 531
+mrev = 529
+
+def init_list(virt):
"""
Creating the lists that will be used for comparisons.
"""
- procrasd = {
- "InstanceID" : '%s/%s' %(test_dom,
"proc"),\
- "ResourceType" : 3,\
- "CreationClassName": get_typed_class(virt,
'ProcResourceAllocationSettingData')
- }
-
- netrasd = {
- "InstanceID" : '%s/%s' %(test_dom,test_mac), \
- "ResourceType" : 10 , \
- "ntype1": "bridge", \
- "ntype2": "ethernet", \
- "CreationClassName": get_typed_class(virt,
'NetResourceAllocationSettingData')
- }
+ proc = {
+ "InstanceID" : '%s/%s' % (test_dom, "proc"),
+ "ResourceType" : 3,
+ "CreationClassName" : get_typed_class(virt, rasd.pasd_cn)}
+ net = {
+ "InstanceID" : '%s/%s' % (test_dom,test_mac),
+ "ResourceType" : 10 ,
+ "ntype1" : "bridge",
+ "ntype2" : "ethernet",
+ "CreationClassName" : get_typed_class(virt, rasd.nasd_cn)}
address = vsxml.xml_get_disk_source()
- diskrasd = {
- "InstanceID" : '%s/%s' %(test_dom, test_disk), \
- "ResourceType" : 17, \
- "Address" : address, \
- "CreationClassName": get_typed_class(virt,
'DiskResourceAllocationSettingData')
- }
- memrasd = {
- "InstanceID" : '%s/%s' %(test_dom, "mem"), \
- "ResourceType" : 4, \
- "AllocationUnits" : "KiloBytes",\
- "VirtualQuantity" : (test_mem * 1024), \
- "CreationClassName": get_typed_class(virt,
'MemResourceAllocationSettingData')
- }
- return procrasd, netrasd, diskrasd, memrasd
-
-def get_inst_from_list(classname, rasd_list, filter_name, exp_val):
+ disk = {
+ "InstanceID" : '%s/%s' % (test_dom, test_disk),
+ "ResourceType" : 17,
+ "Address" : address,
+ "CreationClassName" : get_typed_class(virt, rasd.dasd_cn)}
+ mem = {
+ "InstanceID" : '%s/%s' % (test_dom, "mem"),
+ "ResourceType" : 4,
+ "AllocationUnits" : "KiloBytes",
+ "VirtualQuantity" : (test_mem * 1024),
+ "CreationClassName" : get_typed_class(virt, rasd.masd_cn)}
+ if CIM_REV < prev:
+ proc['InstanceID'] = '%s/0' % test_dom
+ if CIM_REV < mrev:
+ mem['AllocationUnits'] = 'MegaBytes'
+
+ return proc, net, disk, mem
+
+def get_inst_from_list(server, classname, rasd_list, filter_name, exp_val):
status = PASS
ret = FAIL
inst = []
@@ -94,14 +95,14 @@ def get_inst_from_list(classname, rasd_l
status = FAIL
return status, inst
-def get_rasd_values(classname):
+def get_rasd_values(classname, virt, server):
status = PASS
rasd_list = []
try:
- rasd_list = enumclass.enumerate_inst(server, eval('enumclass.' +
classname), virt)
+ rasd_list = enumclass.enumerate_inst(server, classname, virt)
if len(rasd_list) < 1:
- logger.error("%s returned %i instances, excepted atleast 1
instance", classname, \
-
len(rasd_list))
+ logger.error("%s returned %i instances, excepted at least 1.",
+ classname, len(rasd_list))
return FAIL, rasd_list
except Exception, detail:
logger.error(CIM_ERROR_ENUMERATE, classname)
@@ -111,7 +112,8 @@ def get_rasd_values(classname):
# Get the RASD info related to the domain "ONLY".
# We should get atleast one record.
filter_name = {"key" : "InstanceID"}
- status, rasd_values = get_inst_from_list(classname, rasd_list, filter_name,
test_dom)
+ status, rasd_values = get_inst_from_list(server, classname, rasd_list,
+ filter_name, test_dom)
if status != PASS or len(rasd_values) == 0:
return status, rasd_values
@@ -122,14 +124,14 @@ def verify_rasd_values(rasd_values_info)
try:
for rasd_instance in rasd_values_info:
CCName = rasd_instance.classname
- if 'ProcResourceAllocationSettingData' in CCName :
- status = verify_procrasd_values(rasd_instance, procrasd,)
- elif 'NetResourceAllocationSettingData' in CCName :
- status = verify_netrasd_values(rasd_instance, netrasd)
- elif 'DiskResourceAllocationSettingData' in CCName:
- status = verify_diskrasd_values(rasd_instance, diskrasd)
- elif 'MemResourceAllocationSettingData' in CCName :
- status = verify_memrasd_values(rasd_instance, memrasd)
+ if rasd.pasd_cn in CCName :
+ status = rasd.verify_procrasd_values(rasd_instance, procrasd,)
+ elif rasd.nasd_cn in CCName :
+ status = rasd.verify_netrasd_values(rasd_instance, netrasd)
+ elif rasd.dasd_cn in CCName:
+ status = rasd.verify_diskrasd_values(rasd_instance, diskrasd)
+ elif rasd.masd_cn in CCName :
+ status = rasd.verify_memrasd_values(rasd_instance, memrasd)
else:
status = FAIL
if status != PASS:
@@ -142,32 +144,31 @@ def verify_rasd_values(rasd_values_info)
@do_main(sup_types)
def main():
- options = main.options
- destroy_and_undefine_all(options.ip)
+ virt = main.options.virt
+ server = main.options.ip
+ destroy_and_undefine_all(server)
global test_disk, vsxml
- global virt, server
global procrasd, netrasd, diskrasd, memrasd
- server = options.ip
- virt = options.virt
if virt == "Xen":
test_disk = "xvda"
else:
test_disk = "hda"
- vsxml = get_class(virt)(test_dom, mem=test_mem, vcpus = test_vcpus, mac = test_mac,
- disk = test_disk)
+ virtxml = get_class(virt)
+ vsxml = virtxml(test_dom, mem=test_mem, vcpus = test_vcpus,
+ mac = test_mac, disk = test_disk)
try:
- bridge = vsxml.set_vbridge(server)
- ret = vsxml.define(options.ip)
+ vsxml.set_vbridge(server)
+ ret = vsxml.define(server)
if not ret:
logger.error("Failed to Define the domain: %s", test_dom)
return FAIL
except Exception, details:
logger.error("Exception : %s", details)
return FAIL
- class_list = [ get_typed_class(virt, "DiskResourceAllocationSettingData"),
- get_typed_class(virt, "MemResourceAllocationSettingData"),
- get_typed_class(virt, "ProcResourceAllocationSettingData"),
- get_typed_class(virt, "NetResourceAllocationSettingData")
+ class_list = [ get_typed_class(virt, rasd.dasd_cn),
+ get_typed_class(virt, rasd.masd_cn),
+ get_typed_class(virt, rasd.pasd_cn),
+ get_typed_class(virt, rasd.nasd_cn)
]
status = PASS
procrasd, netrasd, diskrasd, memrasd = init_list(virt)
@@ -175,11 +176,12 @@ def main():
# For each loop
# 1) Enumerate one RASD type
# 2) Get the RASD info related to the domain "ONLY".
- # 3) Verifies the RASD values with those supplied during defining the domain.
+ # 3) Verifies the RASD values with those supplied during
+ # defining the domain.
for classname in sorted(class_list):
# Enumerate each RASD types
- status, rasd_values = get_rasd_values(classname)
+ status, rasd_values = get_rasd_values(classname, virt, server)
if status != PASS or len(rasd_values) ==0 :
break
diff -r 22ed2c7c77e8 -r 292223637d87 suites/libvirt-cim/lib/XenKvmLib/rasd.py
--- a/suites/libvirt-cim/lib/XenKvmLib/rasd.py Fri Apr 25 03:20:54 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/rasd.py Tue Apr 29 09:38:28 2008 +0800
@@ -24,6 +24,11 @@ from CimTest import Globals
from CimTest import Globals
from CimTest.Globals import log_param, logger
from CimTest.ReturnCodes import FAIL, PASS
+
+pasd_cn = 'ProcResourceAllocationSettingData'
+nasd_cn = 'NetResourceAllocationSettingData'
+dasd_cn = 'DiskResourceAllocationSettingData'
+masd_cn = 'MemResourceAllocationSettingData'
def CCN_err(assoc_info, list):
Globals.logger.error("%s Mismatch", 'CreationClassName')