[PATCH] [TEST][Resubmitting: Addition] Add cross-provider test case 04_vssd_to_rasd.py
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1207115950 -19800
# Node ID e2cd9e869996152255adcf54e4c4e38331fcf760
# Parent 2a4a86706ee4bdb3cf3d0c20d38718e9fb6bc74f
[TEST][Resubmitting: Addition] Add cross-provider test case 04_vssd_to_rasd.py.
1) Removed the check_len() function and included the logic in the same file.
2) It traverses the following path:
{VSSD} --> [VirtualSystemSettingDataComponent](RASD)
Verify the Device RASD returned with the values expected - those given in the xml description.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 2a4a86706ee4 -r e2cd9e869996 suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py Wed Apr 02 11:29:10 2008 +0530
@@ -0,0 +1,242 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+# Deepti B. Kalakeri <deeptik(a)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 is a cross-provider testcase to
+# Get the setting data properties for the given guest.
+#
+#
+# It traverses the following path:
+# {VSSD} --> [VirtualSystemSettingDataComponent](RASD)
+# (Verify the Device RASD returned with the values expected - those given in test_xml)
+#
+# Steps:
+# ------
+# 1) Define a guest domain.
+# 1) Get the VSSD info using enumeration.
+# 2) From the VSSD output get the info related to the domain. We expect only one
+# VSSD info related to the domain to be returned.
+# 4) Get the various devices allocated to the domain by using the VirtualSystemSettingDataComponent
+# association and giving the VSSD output from the previous VSSD enumeration as inputs.
+# 5) Verify the Disk, Memory, Network, Processor RASD values.
+# 7) Undefine the guest domain.
+#
+# Date : 26-03-2008
+
+
+import sys
+import XenKvmLib
+from XenKvmLib import enumclass
+from CimTest.Globals import do_main, CIM_ERROR_ASSOCIATORS, CIM_ERROR_ENUMERATE
+from CimTest.Globals import log_param, logger
+from CimTest.ReturnCodes import PASS, FAIL
+from XenKvmLib.test_doms import destroy_and_undefine_all
+from XenKvmLib import assoc
+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
+
+sup_types = ['Xen', 'KVM', 'XenFV']
+
+test_dom = "VSSDC_dom"
+test_vcpus = 1
+test_mem = 128
+test_mac = "00:11:22:33:44:aa"
+
+def setup_env():
+ vsxml_info = None
+ vsxml_info = get_class(virt)(test_dom, mem=test_mem, vcpus = test_vcpus,
+ mac = test_mac, disk = test_disk)
+ try:
+ bridge = vsxml_info.set_vbridge(server)
+ ret = vsxml_info.define(server)
+ if not ret:
+ logger.error("Failed to Define the domain: %s", test_dom)
+ return FAIL, vsxml_info
+ except Exception, details:
+ logger.error("Exception : %s", details)
+ return FAIL, vsxml_info
+ return PASS, vsxml_info
+
+def init_list(virt):
+ """
+ Creating the lists that will be used for comparisons.
+ """
+ procrasd = {
+ "InstanceID" : '%s/%s' %(test_dom,0),\
+ "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')
+ }
+
+ address = eval("%s.%s" % (get_class(virt), 'disk_path'))
+ 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" : "MegaBytes",\
+ "VirtualQuantity" : (test_mem * 1024), \
+ "CreationClassName": get_typed_class(virt, 'MemResourceAllocationSettingData')
+ }
+ return procrasd, netrasd, diskrasd, memrasd
+
+def get_inst_from_list(classname, vssd_list, filter_name, exp_val):
+ status = PASS
+ ret = -1
+ inst = []
+ for rec in vssd_list:
+ record = rec[filter_name['key']]
+ if record.find(exp_val) >=0 :
+ inst.append(rec)
+ ret = PASS
+
+ # When no records are found.
+ if ret != PASS:
+ logger.error("%s with %s was not returned" % (classname, exp_val))
+ status = FAIL
+
+ # We expect only one record to be returned.
+ if len(inst) != 1:
+ logger.error("%s returned %i %s objects, expected only 1" % (classname, len(inst), 'VSSD'))
+ status = FAIL
+
+ if status != PASS:
+ vsxml.undefine(server)
+
+ return status, inst
+
+def get_vssd_info():
+ vssd = []
+ status = PASS
+ try:
+ classname = get_typed_class(virt, 'VirtualSystemSettingData')
+ vssd = enumclass.enumerate_inst(server, eval('enumclass.' + classname), virt)
+ if len(vssd) < 1 :
+ logger.error("%s returned %i %s objects, expected atleast 1" % (classname, len(vssd), 'VSSD'))
+ status = FAIL
+
+ except Exception, detail:
+ logger.error(CIM_ERROR_ENUMERATE, classname)
+ logger.error("Exception: %s", detail)
+ status = FAIL
+
+ if status != PASS:
+ return status, vssd
+
+ filter_name = {"key" : "InstanceID"}
+ # Get the info ONLY related to the domain.
+ status, vssd_values = get_inst_from_list(classname, vssd, filter_name, test_dom)
+
+ return status, vssd_values
+
+def get_rasd_values_from_vssdc_assoc(vssd_values):
+ status = PASS
+ vssdc_assoc_info = []
+ # We should have only one VSSD record, the check for this is already done in
+ # get_inst_from_list() function, hence can safely use index 0.
+ instIdval = vssd_values[0]['InstanceID']
+ qcn = vssd_values[0].classname
+ assoc_cname = get_typed_class(virt, 'VirtualSystemSettingDataComponent')
+ try:
+ vssdc_assoc_info = assoc.Associators(server, assoc_cname, qcn, virt, InstanceID = instIdval)
+ if len(vssdc_assoc_info) < 4:
+ logger.error("%s returned %i %s objects, expected 4" % (assoc_cname, len(vssdc_assoc_info), qcn))
+ status = FAIL
+
+ except Exception, details:
+ logger.error(CIM_ERROR_ASSOCIATORS, assoc_cname)
+ logger.error("Exception : %s" % details)
+ status = FAIL
+ return status, vssdc_assoc_info
+
+def verify_rasd_values(rasd_values_info):
+ procrasd, netrasd, diskrasd, memrasd = init_list(virt)
+ 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)
+ else:
+ status = FAIL
+ if status != PASS:
+ logger.error("Mistmatching %s values", CCName )
+ break
+ except Exception, detail :
+ logger.error("Exception in verify_rasd_values function: %s" % detail)
+ status = FAIL
+ return status
+
+@do_main(sup_types)
+def main():
+ options = main.options
+ log_param()
+ destroy_and_undefine_all(options.ip)
+ global test_disk, vsxml
+ global virt, server
+ server = options.ip
+ virt = options.virt
+ if virt == "Xen":
+ test_disk = "xvda"
+ else:
+ test_disk = "hda"
+
+ status, vsxml = setup_env()
+ if status != PASS:
+ return status
+
+ status, vssd_values = get_vssd_info()
+ if status != PASS or len(vssd_values) == 0:
+ return status
+
+ status, rasd_values = get_rasd_values_from_vssdc_assoc(vssd_values)
+ if status != PASS or len(rasd_values) == 0:
+ vsxml.undefine(server)
+ return status
+
+ status = verify_rasd_values(rasd_values)
+ try:
+ vsxml.undefine(server)
+ except Exception, detail:
+ logger.error("Failed to undefine domain %s", test_dom)
+ logger.error("Exception: %s", detail)
+ status = FAIL
+ return status
+
+if __name__ == "__main__":
+ sys.exit(main())
16 years, 8 months
[PATCH] [TEST] Run basicConfig() on logger to make python-2.4 happy
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1206986099 25200
# Node ID bde349d23ce5320d7c593e57df45335dcae62df8
# Parent ace377826c9c8f3b034f5c696ffb71dfb163d77b
[TEST] Run basicConfig() on logger to make python-2.4 happy
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r ace377826c9c -r bde349d23ce5 lib/CimTest/Globals.py
--- a/lib/CimTest/Globals.py Mon Mar 31 10:54:26 2008 -0700
+++ b/lib/CimTest/Globals.py Mon Mar 31 10:54:59 2008 -0700
@@ -50,6 +50,7 @@ CIM_PORT = "5988"
CIM_PORT = "5988"
NM = "TEST LOG"
platform_sup = ["Xen", "KVM", "XenFV"]
+logging.basicConfig()
logger = logging.getLogger(NM)
logging.PRINT = logging.DEBUG + 50
logging.addLevelName(logging.PRINT, "PRINT")
16 years, 8 months
[PATCH] [TEST] ElementCapabilities.05 for XenFV and KVM support
by Guo Lian Yun
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1207122743 25200
# Node ID 701b8b384b1c48f38758ab5d68e6b3f5d3e4317a
# Parent 2a4a86706ee4bdb3cf3d0c20d38718e9fb6bc74f
[TEST] ElementCapabilities.05 for XenFV and KVM support
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 2a4a86706ee4 -r 701b8b384b1c suites/libvirt-cim/cimtest/ElementCapabilities/05_hostsystem_cap.py
--- a/suites/libvirt-cim/cimtest/ElementCapabilities/05_hostsystem_cap.py Tue Apr 01 19:06:53 2008 +0530
+++ b/suites/libvirt-cim/cimtest/ElementCapabilities/05_hostsystem_cap.py Wed Apr 02 00:52:23 2008 -0700
@@ -4,7 +4,8 @@
#
# Authors:
# Deepti B. Kalakeri <dkalaker(a)in.ibm.com>
-#
+# Guolian Yun <yunguol(a)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
@@ -50,11 +51,12 @@ from VirtLib import utils
from VirtLib import utils
from XenKvmLib.assoc import AssociatorNames
from XenKvmLib.common_util import get_host_info
+from XenKvmLib.classes import get_typed_class
from CimTest.Globals import log_param, logger, CIM_ERROR_ASSOCIATORNAMES
from CimTest.Globals import do_main
from CimTest.ReturnCodes import PASS, FAIL
-sup_types = ['Xen']
+sup_types = ['Xen', 'XenFV', 'KVM']
def print_err(err, detail, cn):
logger.error(err % cn)
@@ -79,15 +81,16 @@ def get_inst_from_list(cn, cs_list, filt
return status, inst
-def get_assoc_info(server, cn, an, qcn, name):
+def get_assoc_info(server, cn, an, qcn, name, virt="Xen"):
status = PASS
assoc_info = []
try:
assoc_info = AssociatorNames(server,
an,
cn,
+ virt,
CreationClassName = cn,
- Name = name)
+ Name = name,)
if len(assoc_info) < 1:
logger.error("%s returned %i %s objects" % (an, len(assoc_info), qcn))
status = FAIL
@@ -96,10 +99,10 @@ def get_assoc_info(server, cn, an, qcn,
status = FAIL
return status, assoc_info
-def get_association_info(server, service_fieldname, cn, an, qcn):
+def get_association_info(server, service_fieldname, cn, an, qcn, virt="Xen"):
status = PASS
cn = service_list[service_fieldname]['CreationClassName']
- an = 'Xen_ElementCapabilities'
+ an = get_typed_class(virt, 'ElementCapabilities')
qcn = 'Capabilities'
name = service_list[service_fieldname]['Name']
sccname = service_list[service_fieldname]['SystemCreationClassName']
@@ -109,6 +112,7 @@ def get_association_info(server, service
assoc_info = AssociatorNames(server,
an,
cn,
+ virt,
CreationClassName = cn,
Name = name,
SystemCreationClassName=sccname,
@@ -137,12 +141,12 @@ def get_values(cn, service_assoc_info, f
service_list[fieldname] = service_info
return status
-def verify_cap_fields(server, service_fieldname, cap_key):
+def verify_cap_fields(server, service_fieldname, cap_key, virt="Xen"):
cn = service_list[service_fieldname]['CreationClassName']
- an = 'Xen_ElementCapabilities'
+ an = get_typed_class(virt, 'ElementCapabilities')
qcn = 'Capabilities'
status, cap_assoc_info = get_association_info(server, service_fieldname, \
- cn, an, qcn)
+ cn, an, qcn, virt)
if status != PASS or len(cap_assoc_info) == 0:
return status
cn = cap_assoc_info[0].classname
@@ -167,27 +171,27 @@ def main():
# initialising the list
service_list = { 'ManagementService' : 'Management Service', \
- 'MigrationService' : 'MigrationService'
+ 'MigrationService' : 'MigrationService'
}
# This will be used for the comparison at the end.
- mgtcap = { 'ClassName' : 'Xen_VirtualSystemManagementCapabilities', \
+ mgtcap = { 'ClassName' : get_typed_class(options.virt, 'VirtualSystemManagementCapabilities'), \
'InstanceID' : 'ManagementCapabilities'
}
- migcap = { 'ClassName' : 'Xen_VirtualSystemMigrationCapabilities', \
+ migcap = { 'ClassName' : get_typed_class(options.virt, 'VirtualSystemMigrationCapabilities'), \
'InstanceID' : 'MigrationCapabilities'
}
cap_list = {
'ManagementCapabilities' : mgtcap, \
'MigrationCapabilities' : migcap
}
-
+
# Get the host info
- status, host_name, classname = get_host_info(server)
- if status != PASS:
- return status
-
- an = 'Xen_HostedService'
+ status, host_name, classname = get_host_info(server, options.virt)
+ if status != PASS:
+ return status
+
+ an = get_typed_class(options.virt, 'HostedService')
cn = classname
qcn = 'Service'
name = host_name
@@ -211,7 +215,7 @@ def main():
# Query ElementCapabilities and verify the ManagementCapabilities information.
service_fieldname = 'ManagementService'
cap_key = 'ManagementCapabilities'
- status = verify_cap_fields(server, service_fieldname, cap_key)
+ status = verify_cap_fields(server, service_fieldname, cap_key, options.virt)
if status != PASS:
logger.error("ManagementCapabilities Verification failed")
return status
16 years, 8 months
[PATCH] [TEST] .2# ElementConforms.02 for XenFV and KVM support
by Guo Lian Yun
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1207103576 25200
# Node ID 1d7f014df23ecd5fa9cb44ebb936152608d6e744
# Parent 2a4a86706ee4bdb3cf3d0c20d38718e9fb6bc74f
[TEST] .2# ElementConforms.02 for XenFV and KVM support
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 2a4a86706ee4 -r 1d7f014df23e suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py
--- a/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Tue Apr 01 19:06:53 2008 +0530
+++ b/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Tue Apr 01 19:32:56 2008 -0700
@@ -3,6 +3,7 @@
# Copyright 2008 IBM Corp.
#
# Authors:
+# Guolian Yun <yunguol(a)cn.ibm.com>
# Kaitlin Rupert <karupert(a)us.ibm.com>
# Veerendra Chandrappa <vechandr(a)in.ibm.com>
#
@@ -45,11 +46,13 @@ from XenKvmLib import hostsystem
from XenKvmLib import hostsystem
from XenKvmLib import computersystem
from XenKvmLib import assoc
-from XenKvmLib.test_doms import test_domain_function, destroy_and_undefine_all
+from XenKvmLib.test_doms import destroy_and_undefine_all
+from XenKvmLib.test_doms import destroy_and_undefine_all
from XenKvmLib import enumclass
+from XenKvmLib.vxml import XenXML, KVMXML, get_class
from CimTest.ReturnCodes import PASS, FAIL
-sup_types = ['Xen']
+sup_types = ['Xen', 'XenFV', 'KVM']
test_dom = "domgst"
@@ -83,9 +86,10 @@ def main():
status = FAIL
log_param()
destroy_and_undefine_all(options.ip)
- test_xml = testxml(test_dom)
+ virt_xml = get_class(options.virt)
+ cxml = virt_xml(test_dom)
- ret = test_domain_function(test_xml, options.ip, cmd = "create")
+ ret = cxml.create(options.ip)
if not ret:
logger.error("ERROR: Failed to Create the dom: %s" % test_dom)
return status
@@ -93,7 +97,7 @@ def main():
inst_list = []
try:
- cs_list = computersystem.enumerate(options.ip)
+ cs_list = computersystem.enumerate(options.ip, options.virt)
# The len should be atleast two, as the CS returns info
# one regarding VS and the other one for Domain-0.
if len(cs_list) < 1:
@@ -109,7 +113,7 @@ def main():
return status
#Getting the hostname, to verify with the value returned by the assoc.
- host_sys = hostsystem.enumerate(options.ip)
+ host_sys = hostsystem.enumerate(options.ip, options.virt)
if len(host_sys) < 1:
logger.error("ERROR: Enumerate returned 0 host instances")
@@ -130,11 +134,12 @@ def main():
try:
key_list = ["InstanceID"]
proflist = enumclass.enumerate(options.ip, \
- enumclass.Xen_RegisteredProfile, \
- key_list)
+ "RegisteredProfile", \
+ key_list,
+ options.virt)
except Exception, detail:
logger.error(CIM_ERROR_ENUMERATE, \
- 'Xen_RegisteredProfile')
+ 'RegisteredProfile')
logger.error("Exception: %s", detail)
return status
@@ -148,8 +153,9 @@ def main():
cn = item.CreationClassName
name = item.Name
profs = assoc.Associators(options.ip,
- "Xen_ElementConformsToProfile",
- cn,
+ "ElementConformsToProfile",
+ cn,
+ options.virt,
CreationClassName=cn,
Name=name)
if len(profs) != 1:
@@ -161,11 +167,12 @@ def main():
logger.error("Verification of profile instance failed")
except Exception, detail:
- logger.error(CIM_ERROR_ASSOCIATORS, 'Xen_RegisteredProfile')
+ logger.error(CIM_ERROR_ASSOCIATORS, 'RegisteredProfile')
logger.error("Exception: %s", detail)
status = FAIL
- ret = test_domain_function(test_dom, options.ip, cmd = "destroy")
+ cxml.destroy(options.ip)
+ cxml.undefine(options.ip)
return status
if __name__ == "__main__":
16 years, 8 months
[PATCH] [TEST][Addition] : Adding check_len() function to verify the lenght of the association, list etc
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1207032270 -19800
# Node ID 37958b18d9a91b23b833248f29e5edc6ab74144b
# Parent 5d47437104551b638aa75e2e525e49ec4b41e3ec
[TEST][Addition] : Adding check_len() function to verify the lenght of the association, list etc.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 5d4743710455 -r 37958b18d9a9 suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Mar 31 07:54:19 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue Apr 01 12:14:30 2008 +0530
@@ -187,3 +187,21 @@ def try_getinstance(conn, classname, key
'%s' passed.", classname, field_name)
return XFAIL_RC(bug_no)
+def check_len(an, assoc_list_info, qcn, crit='eq', exp_len=0):
+ if crit == 'ne':
+ expr = 'len(assoc_list_info) != exp_len'
+ elif crit == 'eq':
+ expr = 'len(assoc_list_info) == exp_len'
+ elif crit == 'lt':
+ expr = 'len(assoc_list_info) < exp_len'
+ elif crit == 'gt':
+ expr = 'len(assoc_list_info) > exp_len'
+ elif crit == 'le':
+ expr = 'len(assoc_list_info) <= exp_len'
+ else:
+ expr = 'len(assoc_list_info) <= exp_len'
+ if eval(expr) :
+ logger.error("%s returned %i %s objects, as compared with %i" % (an, len(assoc_list_info), qcn, exp_len))
+ return FAIL
+ return PASS
+
16 years, 8 months
[PATCH] [TEST] [Addition] Add cross-provider test case 04_vssd_to_rasd.py
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1207057156 -19800
# Node ID f04ed96435d9efdf0c3c95fe9b8c45f01906bc76
# Parent 8f853c0a97356add879048a403dcad9b02d9e72f
[TEST] [Addition] Add cross-provider test case 04_vssd_to_rasd.py.
It traverses the following path:
{VSSD} --> [VirtualSystemSettingDataComponent](RASD)
Verify the Device RASD returned with the values expected - those given in the xml description.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 8f853c0a9735 -r f04ed96435d9 suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/VSSD/04_vssd_to_rasd.py Tue Apr 01 19:09:16 2008 +0530
@@ -0,0 +1,234 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+# Deepti B. Kalakeri <dkalaker(a)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 is a cross-provider testcase to
+# Get the setting data properties for the given guest.
+#
+#
+# It traverses the following path:
+# {VSSD} --> [VirtualSystemSettingDataComponent](RASD)
+# (Verify the Device RASD returned with the values expected - those given in test_xml)
+#
+# Steps:
+# ------
+# 1) Define a guest domain.
+# 1) Get the VSSD info using enumeration.
+# 2) From the VSSD output get the info related to the domain. We expect only one
+# VSSD info related to the domain to be returned.
+# 4) Get the various devices allocated to the domain by using the VirtualSystemSettingDataComponent
+# association and giving the VSSD output from the previous VSSD enumeration as inputs.
+# 5) Verify the Disk, Memory, Network, Processor RASD values.
+# 7) Undefine the guest domain.
+#
+# Date : 26-03-2008
+
+
+import sys
+import XenKvmLib
+from XenKvmLib import enumclass
+from XenKvmLib.common_util import check_len
+from CimTest.Globals import do_main, CIM_ERROR_ASSOCIATORS, CIM_ERROR_ENUMERATE
+from CimTest.Globals import log_param, logger
+from CimTest.ReturnCodes import PASS, FAIL
+from XenKvmLib.test_doms import destroy_and_undefine_all
+from XenKvmLib import assoc
+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
+
+sup_types = ['Xen', 'KVM', 'XenFV']
+
+test_dom = "VSSDC_dom"
+test_vcpus = 1
+test_mem = 128
+test_mac = "00:11:22:33:44:aa"
+
+def setup_env():
+ vsxml_info = None
+ vsxml_info = get_class(virt)(test_dom, mem=test_mem, vcpus = test_vcpus,
+ mac = test_mac, disk = test_disk)
+ try:
+ bridge = vsxml_info.set_vbridge(server)
+ ret = vsxml_info.define(server)
+ if not ret:
+ logger.error("Failed to Define the domain: %s", test_dom)
+ return FAIL, vsxml_info
+ except Exception, details:
+ logger.error("Exception : %s", details)
+ return FAIL, vsxml_info
+ return PASS, vsxml_info
+
+def init_list(virt):
+ """
+ Creating the lists that will be used for comparisons.
+ """
+ procrasd = {
+ "InstanceID" : '%s/%s' %(test_dom,0),\
+ "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')
+ }
+
+ address = eval("%s.%s" % (get_class(virt), 'disk_path'))
+ 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" : "MegaBytes",\
+ "VirtualQuantity" : (test_mem * 1024), \
+ "CreationClassName": get_typed_class(virt, 'MemResourceAllocationSettingData')
+ }
+ return procrasd, netrasd, diskrasd, memrasd
+
+def get_inst_from_list(classname, vssd_list, filter_name, exp_val):
+ status = PASS
+ ret = -1
+ inst = []
+ for rec in vssd_list:
+ record = rec[filter_name['key']]
+ if record.find(exp_val) >=0 :
+ inst.append(rec)
+ ret = PASS
+
+ # When no records are found.
+ if ret != PASS:
+ logger.error("%s with %s was not returned" % (classname, exp_val))
+ status = FAIL
+
+ # We expect only one record to be returned.
+ status = check_len(classname, inst, 'VSSD' , crit='ne', exp_len=1)
+
+ if status != PASS:
+ vsxml.undefine(server)
+
+ return status, inst
+
+def get_vssd_info():
+ vssd = []
+ try:
+ classname = get_typed_class(virt, 'VirtualSystemSettingData')
+ vssd = enumclass.enumerate_inst(server, eval('enumclass.' + classname), virt)
+ status = check_len(classname, vssd, 'VSSD' , crit='lt', exp_len=1)
+ except Exception, detail:
+ logger.error(CIM_ERROR_ENUMERATE, classname)
+ logger.error("Exception: %s", detail)
+ status = FAIL
+
+ if status != PASS:
+ return FAIL, vssd
+
+ filter_name = {"key" : "InstanceID"}
+ # Get the info ONLY related to the domain.
+ status, vssd_values = get_inst_from_list(classname, vssd, filter_name, test_dom)
+
+ return status, vssd_values
+
+def get_rasd_values_from_vssdc_assoc(vssd_values):
+ status = PASS
+ vssdc_assoc_info = []
+ # We should have only one VSSD record, the check for this is already done in
+ # get_inst_from_list() function, hence can safely use index 0.
+ instIdval = vssd_values[0]['InstanceID']
+ qcn = vssd_values[0].classname
+ assoc_cname = get_typed_class(virt, 'VirtualSystemSettingDataComponent')
+ try:
+ vssdc_assoc_info = assoc.Associators(server, assoc_cname, qcn, virt, InstanceID = instIdval)
+ status = check_len(assoc_cname, vssdc_assoc_info, qcn, crit='lt', exp_len=1)
+ except Exception, details:
+ logger.error(CIM_ERROR_ASSOCIATORS, assoc_cname)
+ logger.error("Exception : %s" % details)
+ status = FAIL
+ return status, vssdc_assoc_info
+
+def verify_rasd_values(rasd_values_info):
+ procrasd, netrasd, diskrasd, memrasd = init_list(virt)
+ 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)
+ else:
+ status = FAIL
+ if status != PASS:
+ logger.error("Mistmatching %s values", CCName )
+ break
+ except Exception, detail :
+ logger.error("Exception in verify_rasd_values function: %s" % detail)
+ status = FAIL
+ return status
+
+@do_main(sup_types)
+def main():
+ options = main.options
+ log_param()
+ destroy_and_undefine_all(options.ip)
+ global test_disk, vsxml
+ global virt, server
+ server = options.ip
+ virt = options.virt
+ if virt == "Xen":
+ test_disk = "xvda"
+ else:
+ test_disk = "hda"
+
+ status, vsxml = setup_env()
+ if status != PASS:
+ return status
+
+ status, vssd_values = get_vssd_info()
+ if status != PASS or len(vssd_values) == 0:
+ return status
+
+ status, rasd_values = get_rasd_values_from_vssdc_assoc(vssd_values)
+ if status != PASS or len(rasd_values) == 0:
+ vsxml.undefine(server)
+ return status
+
+ status = verify_rasd_values(rasd_values)
+ try:
+ vsxml.undefine(server)
+ except Exception, detail:
+ logger.error("Failed to undefine domain %s", test_dom)
+ logger.error("Exception: %s", detail)
+ status = FAIL
+ return status
+
+if __name__ == "__main__":
+ sys.exit(main())
16 years, 8 months
[PATCH] [TEST][Addition] : Adding 02_enum.py tc to verify RASD properties
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1207057013 -19800
# Node ID 8f853c0a97356add879048a403dcad9b02d9e72f
# Parent 74a458de2c6ed158c83f0bf7e3687fc36f46b284
[TEST][Addition] : Adding 02_enum.py tc to verify RASD properties.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 74a458de2c6e -r 8f853c0a9735 suites/libvirt-cim/cimtest/RASD/02_enum.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/RASD/02_enum.py Tue Apr 01 19:06:53 2008 +0530
@@ -0,0 +1,201 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+# Deepti B. Kalakeri <dkalaker(a)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 is used to verify the ResourceAllocationSettingData
+# properties in detail.
+#
+# Date : 26-03-2008
+#
+
+
+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 CimTest.Globals import log_param, logger
+from CimTest.ReturnCodes import PASS, FAIL
+
+sup_types = ['Xen', 'KVM', 'XenFV']
+
+test_dom = "VSSDC_dom"
+test_vcpus = 1
+test_mem = 128
+test_mac = "00:11:22:33:44:aa"
+
+def init_list(virt="Xen"):
+ """
+ Creating the lists that will be used for comparisons.
+ """
+ procrasd = {
+ "InstanceID" : '%s/%s' %(test_dom,0),\
+ "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')
+ }
+ address = eval("%s.%s" % (get_class(virt), 'disk_path'))
+ 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" : "MegaBytes",\
+ "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):
+ status = PASS
+ ret = FAIL
+ inst = []
+ for rec in rasd_list:
+ record = rec[filter_name['key']]
+ if exp_val in record :
+ inst.append(rec)
+ ret = PASS
+ if ret != PASS:
+ logger.error("%s with %s was not returned" % (classname, exp_val))
+ vsxml.undefine(server)
+ status = FAIL
+ return status, inst
+
+def get_rasd_values(classname):
+ status = PASS
+ rasd_list = []
+ try:
+ rasd_list = enumclass.enumerate_inst(server, eval('enumclass.' + classname), virt)
+ if len(rasd_list) < 1:
+ logger.error("%s returned %i instances, excepted atleast 1 instance", classname, \
+ len(rasd_list))
+ return FAIL, rasd_list
+ except Exception, detail:
+ logger.error(CIM_ERROR_ENUMERATE, classname)
+ logger.error("Exception: %s", detail)
+ return FAIL, rasd_list
+
+ # 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)
+ if status != PASS or len(rasd_values) == 0:
+ return status, rasd_values
+
+ return status, rasd_values
+
+
+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)
+ else:
+ status = FAIL
+ if status != PASS:
+ logger.error("Mistmatching %s values", CCName )
+ break
+ except Exception, detail :
+ logger.error("Exception in verify_rasd_values function: %s" % detail)
+ status = FAIL
+ return status
+
+@do_main(sup_types)
+def main():
+ options = main.options
+ log_param()
+ destroy_and_undefine_all(options.ip)
+ 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)
+ try:
+ bridge = vsxml.set_vbridge(server)
+ ret = vsxml.define(options.ip)
+ 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")
+ ]
+ status = PASS
+ procrasd, netrasd, diskrasd, memrasd = init_list(virt)
+
+ # 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.
+
+ for classname in sorted(class_list):
+ # Enumerate each RASD types
+ status, rasd_values = get_rasd_values(classname)
+ if status != PASS or len(rasd_values) ==0 :
+ break
+
+ # Verify RASD values.
+ status = verify_rasd_values(rasd_values)
+ if status != PASS:
+ break
+
+ try:
+ vsxml.undefine(server)
+ except Exception, detail:
+ logger.error("Failed to undefine domain %s", test_dom)
+ logger.error("Exception: %s", detail)
+ status = FAIL
+ return status
+
+if __name__ == "__main__":
+ sys.exit(main())
16 years, 8 months