# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1222880651 25200
# Node ID 1da63a856b8307cf4479da63ff4ed5ec5b666d2b
# Parent 530d3dab93cd36a2b68e1fb42c71c9a1cfe755fc
[TEST] Fixing and updating 02_reverse.py of ElementCapabilities to work with and without
sblim-base-provider.
1) Fixed the return statement , this was causing the tc to pass with a false positive.
2) Updated the tc to work with/without sblim-base-provider.
3) Updated the tc to use cim_define(). This is req bcs the association of
ElementCapabilities with the
EnabledLogicalElementCapabilities would not be excercised for KVM.
4) Used get_host_info() for getting the host information.
5) Updated the tc to use cim.undefine().
6) Added verification of the VirtualSystemMigrationService service.
7) Updated enumclas to support VirtualSystemMigrationService and
VirtualSystemManagementService.
8) Removed Enumerate instance and used getInstance instead to verify the
VirtualSystemMigrationService and VirtualSystemManagementService
values in the association.
Tested with Xen, XenFV, KVM on current sources and with/without sblim-base-provider
installed.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 530d3dab93cd -r 1da63a856b83
suites/libvirt-cim/cimtest/ElementCapabilities/02_reverse.py
--- a/suites/libvirt-cim/cimtest/ElementCapabilities/02_reverse.py Wed Oct 01 02:29:23
2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementCapabilities/02_reverse.py Wed Oct 01 10:04:11
2008 -0700
@@ -26,26 +26,30 @@ from VirtLib import live
from VirtLib import live
from XenKvmLib import assoc
from XenKvmLib import enumclass
-from XenKvmLib import vsms
-from XenKvmLib.classes import get_typed_class
-from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, CIM_ERROR_ASSOCIATORNAMES
+from XenKvmLib import vxml
+from XenKvmLib.classes import get_typed_class
+from XenKvmLib.classes import get_class_basename
+from XenKvmLib.common_util import get_host_info
+from CimTest.Globals import logger, CIM_ERROR_GETINSTANCE, \
+CIM_ERROR_ASSOCIATORNAMES
from XenKvmLib.const import do_main
from CimTest.ReturnCodes import PASS, FAIL, SKIP
+from XenKvmLib.enumclass import getInstance
sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']
+test_dom = "dom_elecap"
def call_assoc(ip, cn, id, virt="Xen"):
status = PASS
ec_ele = []
+ assoc_cn = get_typed_class(virt, "ElementCapabilities")
try:
ec_ele = assoc.AssociatorNames(ip,
- "ElementCapabilities",
+ assoc_cn,
cn,
- virt,
InstanceID = id)
except Exception:
- logger.error(CIM_ERROR_ASSOCIATORNAMES,
- 'ElementCapabilities')
+ logger.error(CIM_ERROR_ASSOCIATORNAMES, assoc_cn)
status = FAIL
return status, ec_ele
@@ -57,102 +61,126 @@ def filter(list, cn, exp_result):
return FAIL, new_list
return PASS, new_list
-def verify_host(inst_list, ip, virt="Xen"):
- hs = get_typed_class(virt, 'HostSystem')
- status, list = filter(inst_list, hs, 1)
+def verify_host(inst_list, host_name, host_ccn):
+ status, list = filter(inst_list, host_ccn, 1)
if status != PASS:
return status
inst = list[0]
- keys = ['Name', 'CreationClassName']
+ creationclassname = inst.keybindings['CreationClassName']
+ name = inst.keybindings['Name']
+
+ if creationclassname != host_ccn:
+ logger.error("CreationClassName doesn't match")
+ return FAIL
+
+ if name != host_name:
+ logger.error("Name doesn't match")
+ return FAIL
+
+ return PASS
+
+def verify_service(inst_list, ip, virt, host_name, host_ccn,
+ name=" ", ser_cn=""):
+ status, list = filter(inst_list, ser_cn, 1)
+ if status != PASS:
+ return status
+
+ inst = list[0]
+ keys = {
+ 'CreationClassName' : ser_cn,
+ 'Name' : name,
+ 'SystemName' : host_name,
+ 'SystemCreationClassName' : host_ccn
+ }
try:
- host_sys = enumclass.enumerate(ip, 'HostSystem', keys, virt)[0]
- except Exception:
- logger.error(CIM_ERROR_ENUMERATE, 'HostSystem')
+ basename = get_class_basename(ser_cn)
+ service = getInstance(ip, basename, keys, virt)
+ except Exception, detail:
+ logger.error(CIM_ERROR_GETINSTANCE, ser_cn)
+ logger.error("Exeption : %s", detail)
return FAIL
creationclassname = inst.keybindings['CreationClassName']
name = inst.keybindings['Name']
- if creationclassname != host_sys.CreationClassName:
+ if creationclassname != service.CreationClassName:
logger.error("CreationClassName doesn't match")
return FAIL
- elif name != host_sys.Name:
- logger.error("Name doesn't match")
- return FAIL
- return PASS
-
-def verify_service(inst_list, ip, virt):
- service = get_typed_class(virt, "VirtualSystemManagementService")
- status, list = filter(inst_list, service, 1)
- if status != PASS:
- return status
-
- inst = list[0]
- try:
- service = vsms.enumerate_instances(ip, virt)[0]
- except Exception:
- logger.error(CIM_ERROR_ENUMERATE,
- 'VirtualSystemManagementService')
- return FAIL
-
- creationclassname = inst.keybindings['CreationClassName']
- name = inst.keybindings['Name']
-
- if creationclassname != service['CreationClassName']:
- logger.error("CreationClassName doesn't match")
- return FAIL
- elif name != service['Name']:
+ if name != service.Name:
logger.error("InstanceID doesn't match")
return FAIL
-
return PASS
@do_main(sup_types)
def main():
options = main.options
-
+
cap_list = {"VirtualSystemManagementCapabilities" :
"ManagementCapabilities",
- "VirtualSystemMigrationCapabilities" :
"MigrationCapabilities"}
- import pdb
- #pdb.set_trace()
+ "VirtualSystemMigrationCapabilities" :
"MigrationCapabilities"}
+
+ status, host_name, host_ccn = get_host_info(options.ip, options.virt)
+ if status != PASS:
+ logger.error("Failed to get host info")
+ return status
+
for k, v in cap_list.iteritems():
- status, ec_ele = call_assoc(options.ip, k, v, options.virt)
+ cn = get_typed_class(options.virt, k)
+ status, ec_ele = call_assoc(options.ip, cn, v, options.virt)
if status != PASS:
- return
-
- status = verify_host(ec_ele, options.ip, options.virt)
+ return FAIL
+
+ status = verify_host(ec_ele, host_name, host_ccn)
if status != PASS:
return status
-
+
if v == 'ManagementCapabilities':
- status = verify_service(ec_ele, options.ip, options.virt)
- if status != PASS:
- return status
+ cn = get_typed_class(options.virt,
"VirtualSystemManagementService")
+ status = verify_service(ec_ele, options.ip, options.virt,
+ host_name, host_ccn,
+ name="Management Service", ser_cn=cn)
+ else:
+ cn = get_typed_class(options.virt,
"VirtualSystemMigrationService")
+ status = verify_service(ec_ele, options.ip, options.virt,
+ host_name, host_ccn,
+ name="MigrationService", ser_cn=cn)
+ if status != PASS:
+ return status
+
+ virtxml = vxml.get_class(options.virt)
+ cxml = virtxml(test_dom)
+ ret = cxml.cim_define(options.ip)
+ if not ret:
+ logger.error("Failed to define the dom: %s" % test_dom)
+ return FAIL
cs = live.domain_list(options.ip, options.virt)
for system in cs:
- status, elec_cs = call_assoc(options.ip,
- "EnabledLogicalElementCapabilities",
- system,
- options.virt)
+ cn = get_typed_class(options.virt,
"EnabledLogicalElementCapabilities")
+ status, elec_cs = call_assoc(options.ip, cn, system, options.virt)
if status != PASS:
- return
+ return FAIL
if len(elec_cs) < 1:
logger.error("No ELEC instances returned")
+ cxml.undefine(options.ip)
return FAIL
- if elec_cs[0].keybindings['CreationClassName'] !=
get_typed_class(options.virt, "ComputerSystem"):
- logger.error("Excpeted CreationClassName %s, got %s" %
- ("ComputerSystem",
- elec_cs[0].keybindings['CreationClassName']))
- return FAIL
- elif elec_cs[0].keybindings['Name'] != system:
- logger.error("ElementCapabilities association Name error")
+ if elec_cs[0].keybindings['CreationClassName'] != \
+ get_typed_class(options.virt, "ComputerSystem"):
+ logger.error("Excpeted CreationClassName %s, got %s",
+ "ComputerSystem",
+ elec_cs[0].keybindings['CreationClassName'])
+ cxml.undefine(options.ip)
return FAIL
+ if elec_cs[0].keybindings['Name'] != system:
+ logger.error("ElementCapabilities association Name error")
+ cxml.undefine(options.ip)
+ return FAIL
+
+ cxml.undefine(options.ip)
return PASS
if __name__ == "__main__":
diff -r 530d3dab93cd -r 1da63a856b83 suites/libvirt-cim/lib/XenKvmLib/enumclass.py
--- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Wed Oct 01 02:29:23 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Wed Oct 01 10:04:11 2008 -0700
@@ -336,6 +336,25 @@ class KVM_DiskResourceAllocationSettingD
class KVM_DiskResourceAllocationSettingData(CIM_DiskResourceAllocationSettingData):
pass
+class KVM_VirtualSystemMigrationService(CIM_MyClass):
+ pass
+
+class Xen_VirtualSystemMigrationService(CIM_MyClass):
+ pass
+
+class LXC_VirtualSystemMigrationService(CIM_MyClass):
+ pass
+
+class Xen_VirtualSystemManagementService(CIM_MyClass):
+ pass
+
+class KVM_VirtualSystemManagementService(CIM_MyClass):
+ pass
+
+class LXC_VirtualSystemManagementService(CIM_MyClass):
+ pass
+
+
# Generic function which can be used to get the enumerate instances of any
# class when the following fields are specified
# classname = any class for which we want obtain the instances