# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1223289748 25200
# Node ID 13af302129be5d68230f6eabf2a268eb5f17f1e3
# Parent b710ecb26adf500caa6b801fdf10e4efbed3877e
[TEST] Updating enumclass.py library and Rebasing, Fixing and updating ElementCapabilities
tc to work with and without sblim-base-provider.
changes to 01_forward.py:
-------------------------
1) Rebased and Updated the tc to work with/without sblim-base-provider.
2) Updated the tc to use cim_define(). This is req bcs the association of
ElementCapabilities with the CS would not be excercised for KVM.
3) Included the bug no 00007. Included XFAIL .
4) Updated the tc to use cim.undefine().
changes to 02_reverse.py:
-------------------------
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) Updated the tc to use cim.undefine().
5) Added verification of the VirtualSystemMigrationService service.
6) Updated enumclas to support VirtualSystemMigrationService and
VirtualSystemManagementService.
7) 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 b710ecb26adf -r 13af302129be
suites/libvirt-cim/cimtest/ElementCapabilities/01_forward.py
--- a/suites/libvirt-cim/cimtest/ElementCapabilities/01_forward.py Fri Oct 03 06:34:29
2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementCapabilities/01_forward.py Mon Oct 06 03:42:28
2008 -0700
@@ -23,17 +23,19 @@
import sys
from VirtLib import utils
from VirtLib import live
+from XenKvmLib import vxml
from XenKvmLib import assoc
from XenKvmLib import enumclass
from XenKvmLib.classes import get_typed_class
-from CimTest.Globals import logger, CIM_ERROR_ASSOCIATORNAMES, \
- CIM_ERROR_ENUMERATE
+from CimTest.Globals import logger, CIM_ERROR_ASSOCIATORNAMES
from XenKvmLib.const import do_main
-from CimTest.ReturnCodes import PASS, FAIL, SKIP
+from CimTest.ReturnCodes import PASS, FAIL, SKIP, XFAIL_RC
from XenKvmLib.enumclass import enumerate
from XenKvmLib.common_util import get_host_info
sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']
+test_dom = "dom_elecap"
+bug_sblim = "00007"
def append_to_list(server, virt, poolname, valid_elc_id):
keys_list = ['InstanceID']
@@ -67,7 +69,6 @@
logger.error("Failed to get host info")
return status
-
try:
an = get_typed_class(virt, "ElementCapabilities")
elc = assoc.AssociatorNames(server,
@@ -91,35 +92,52 @@
return status
if len(elc) == 0:
- logger.error("ElementCapabilities association failed, excepted at least one
instance")
- return FAIL
+ logger.error("'%s' association failed, excepted at least one
instance",
+ an)
+ if host_ccn == 'Linux_ComputerSystem':
+ return XFAIL_RC(bug_sblim)
+ else:
+ return FAIL
for i in elc:
if i.classname not in valid_elc_name:
- logger.error("ElementCapabilities association classname error")
+ logger.error("'%s' association classname error", an)
return FAIL
if i['InstanceID'] not in valid_elc_id:
- logger.error("ElementCapabilities association InstanceID error ")
+ logger.error("'%s' association InstanceID error ", an)
return FAIL
+
+ virtxml = vxml.get_class(virt)
+ cxml = virtxml(test_dom)
+ ret = cxml.cim_define(server)
+ if not ret:
+ logger.error("Failed to define the dom: %s", test_dom)
+ status = FAIL
+ return status
cs = live.domain_list(server, virt)
ccn = get_typed_class(virt, "ComputerSystem")
for system in cs:
try:
- elec = assoc.AssociatorNames(server,
- an, ccn, Name = system,
+ elec = assoc.AssociatorNames(server, an, ccn, Name = system,
CreationClassName = ccn)
except Exception:
logger.error(CIM_ERROR_ASSOCIATORNAMES % system)
+ cxml.undefine(server)
return FAIL
+
cn = get_typed_class(virt, "EnabledLogicalElementCapabilities")
if elec[0].classname != cn:
- logger.error("ElementCapabilities association classname error")
+ cxml.undefine(server)
+ logger.error("'%s' association classname error", an)
return FAIL
elif elec[0].keybindings['InstanceID'] != system:
logger.error("ElementCapabilities association InstanceID error")
+ cxml.undefine(server)
+ logger.error("'%s' association InstanceID error", an)
return FAIL
+ cxml.undefine(server)
return PASS
if __name__ == "__main__":
diff -r b710ecb26adf -r 13af302129be
suites/libvirt-cim/cimtest/ElementCapabilities/02_reverse.py
--- a/suites/libvirt-cim/cimtest/ElementCapabilities/02_reverse.py Fri Oct 03 06:34:29
2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementCapabilities/02_reverse.py Mon Oct 06 03:42:28
2008 -0700
@@ -26,26 +26,30 @@
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 @@
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 b710ecb26adf -r 13af302129be suites/libvirt-cim/lib/XenKvmLib/enumclass.py
--- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Fri Oct 03 06:34:29 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Mon Oct 06 03:42:28 2008 -0700
@@ -336,6 +336,25 @@
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