[Libvirt-cim] [PATCH 1 of 2] [TEST] Fixing and updating 01_forward.py of ElementCapabilities to work with and without sblim-base-provider

Deepti B. Kalakeri deeptik at linux.vnet.ibm.com
Wed Oct 1 17:04:51 UTC 2008


# HG changeset patch
# User Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>
# Date 1222853363 25200
# Node ID 530d3dab93cd36a2b68e1fb42c71c9a1cfe755fc
# Parent  fb10c72ed404aa96715e2d013b0ee3502046496f
[TEST] Fixing and updating 01_forward.py of ElementCapabilities to work with and without sblim-base-provider.

1) 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) Used get_host_info() for getting the host information.
5) Updated the tc to use cim.undefine().

Tested with Xen, XenFV, KVM on current sources and with/without sblim-base-provider installed.

Signed-off-by: Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>

diff -r fb10c72ed404 -r 530d3dab93cd suites/libvirt-cim/cimtest/ElementCapabilities/01_forward.py
--- a/suites/libvirt-cim/cimtest/ElementCapabilities/01_forward.py	Wed Oct 01 02:22:53 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementCapabilities/01_forward.py	Wed Oct 01 02:29:23 2008 -0700
@@ -23,16 +23,19 @@ import sys
 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']
@@ -61,21 +64,21 @@ def main():
     server = options.ip
     virt = options.virt
     keys = ['Name', 'CreationClassName']
-    try:
-        host_sys = enumclass.enumerate(server, 'HostSystem', keys, virt)[0]
-    except Exception:
-        logger.error(CIM_ERROR_ENUMERATE, get_typed_class(virt, 'HostSystem'))
-        return FAIL
+
+
+    status, host_name, host_ccn = get_host_info(server, virt)
+    if status != PASS:
+        logger.error("Failed to get host info")
+        return status
+
+    assoc_cn  = get_typed_class(virt, "ElementCapabilities")
 
     try:
-        elc = assoc.AssociatorNames(server,
-                                     "ElementCapabilities",
-                                     "HostSystem", 
-                                     virt,
-                                     Name = host_sys.Name,
-                                     CreationClassName = host_sys.CreationClassName)
+        elc = assoc.AssociatorNames(server, assoc_cn, host_ccn,
+                                    Name = host_name,
+                                    CreationClassName = host_ccn)
     except Exception:
-        logger.error(CIM_ERROR_ASSOCIATORNAMES % host_sys.Name)
+        logger.error(CIM_ERROR_ASSOCIATORNAMES, assoc_cn)
         return FAIL
 
 
@@ -91,38 +94,52 @@ def main():
         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",
+                     assoc_cn)
+        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", assoc_cn)
             return FAIL
         if i['InstanceID'] not in valid_elc_id:
-            logger.error("ElementCapabilities association InstanceID error ")
+            logger.error("'%s' association InstanceID error ", assoc_cn)
             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,
-                                         "ElementCapabilities",
-                                         "ComputerSystem",
-                                         virt,
+            elec = assoc.AssociatorNames(server, assoc_cn, ccn, 
                                          Name = system,
                                          CreationClassName = ccn)
-  	except Exception:
+        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", assoc_cn)
             return FAIL
         elif elec[0].keybindings['InstanceID'] != system:
-            logger.error("ElementCapabilities association InstanceID error")
+            cxml.undefine(server)
+            logger.error("'%s' association InstanceID error", assoc_cn)
             return FAIL
 
+    cxml.undefine(server)
     return PASS
 
 if __name__ == "__main__":




More information about the Libvirt-cim mailing list