[Libvirt-cim] [PATCH 1 of 3] [TEST] KVM support and refactor to Profile.01

zli at linux.vnet.ibm.com zli at linux.vnet.ibm.com
Wed Apr 16 08:30:13 UTC 2008


# HG changeset patch
# User Zhengang Li <lizg at cn.ibm.com>
# Date 1208329494 -28800
# Node ID 7c20d87e25c0cd53deba4dc8c48529d84bb740d9
# Parent  68de226362a6f903a2e66537278733ac17c3551f
[TEST] KVM support and refactor to Profile.01

Signed-off-by: Zhengang Li <lizg at cn.ibm.com>

diff -r 68de226362a6 -r 7c20d87e25c0 suites/libvirt-cim/cimtest/Profile/01_enum.py
--- a/suites/libvirt-cim/cimtest/Profile/01_enum.py	Wed Apr 16 10:49:55 2008 +0800
+++ b/suites/libvirt-cim/cimtest/Profile/01_enum.py	Wed Apr 16 15:04:54 2008 +0800
@@ -28,77 +28,52 @@ import sys
 import sys
 import pywbem
 from XenKvmLib import enumclass
+from XenKvmLib.classes import get_typed_class
 from CimTest import Globals
-from CimTest.Globals import do_main
+from CimTest.Globals import do_main, logger
+from CimTest.ReturnCodes import PASS, FAIL
 
-sup_types = ['Xen']
+sup_types = ['Xen', 'KVM']
 
 @do_main(sup_types)
 def main():
     options = main.options
 
-    registeredOrganization = 2
-    registeredname = ['System Virtualization', \
-                      'Virtual System Profile' ]
-    inst_id = ['CIM:DSP1042-SystemVirtualization-1.0.0', \
-                      'CIM:DSP1057-VirtualSystem-1.0.0a']
-    registeredversion = [ '1.0.0', '1.0.0a'] 
-    cn = 'Xen_RegisteredProfile'
-    index = 0 
+    explist = [['CIM:DSP1042-SystemVirtualization-1.0.0', 2,
+                'System Virtualization', '1.0.0'],
+               ['CIM:DSP1057-VirtualSystem-1.0.0a', 2,
+                'Virtual System Profile', '1.0.0a']]
+    cn = 'RegisteredProfile'
 
-    status = 0
+    status = PASS
     prev_namespace = Globals.CIM_NS
     Globals.CIM_NS = 'root/interop'
 
     Globals.log_param()
     try: 
         key_list = ["InstanceID"]
-        proflist = enumclass.enumerate(options.ip, \
-                                    enumclass.Xen_RegisteredProfile, \
-                                    key_list) 
+        proflist = enumclass.enumerate(options.ip, cn, key_list, options.virt)
+    except Exception, detail:
+        logger.error(Globals.CIM_ERROR_ENUMERATE, get_typed_class(options.virt,
+                     cn))
+        logger.error("Exception: %s", detail)
+        status = FAIL
+        Globals.CIM_NS = prev_namespace
+        return status
+    
+    Globals.CIM_NS = prev_namespace
 
-    # For each of the instances verify : 
-    # -RegisteredOrganization = 2
-    # -InstanceID="CIM:DSP1042-SystemVirtualization-1.0.0"
-    # -RegisteredName="System Virtualization"
-    # -RegisteredVersion="1.0.0"
+    checklist = [[x.InstanceID, x.RegisteredOrganization, 
+                  x.RegisteredName, x.RegisteredVersion] for x in proflist]
+    for exp_prof in explist:
+        if exp_prof in checklist:
+            continue
+        else:
+            logger.error("Profile %s is not found" % exp_prof[0])
+            status = FAIL
 
-        for profile in proflist:
-            Globals.logger.log(int(Globals.logging.PRINT),"Verifying the \
-fields for :%s", profile.RegisteredName)
-            if profile.InstanceID == "" :
-                Globals.logger.error("InstanceID is %s instead of %s", \
-                   'NULL', inst_id[index])
-                status = 1  
-            if inst_id[index] != profile.InstanceID :
-                Globals.logger.error("InstanceID is %s instead of %s", \
-                   profile.InstanceID, inst_id[index])
-                status = 1  
-            if registeredOrganization != profile.RegisteredOrganization:
-                Globals.logger.error("RegisteredOrganization is %s instead of %s"\
-                   , profile.RegisteredOrganization, registeredOrganization)
-                status = 1
-            if registeredname[index] != profile.RegisteredName:
-                 Globals.logger.error("RegisteredName is %s instead of %s", \
-                   profile.RegisteredName, registeredname[index])
-                 status = 1  
-            if registeredversion[index] != profile.RegisteredVersion:
-                 Globals.logger.error("RegisteredVersion is %s instead of \
-%s", profile.RegisteredVersion, registeredversion[index])
-                 status = 1
-            if status != 0:
-                Globals.CIM_NS = prev_namespace
-                return status 
-            index = index + 1 
-    except Exception, detail:
-        Globals.logger.error(Globals.CIM_ERROR_ENUMERATE, 'Xen_RegisteredProfile')
-        Globals.logger.error("Exception: %s", detail)
-        status = 1
-        return status 
-
-# The execution will reach here only if all the checks are successful       
-    Globals.logger.log(int(Globals.logging.PRINT), "Verification of the properties \
-for the class '%s' was successful", cn)
+    if status == PASS:
+        logger.info("Properties check for %s passed" % cn)
     return status
 
 if __name__ == "__main__":




More information about the Libvirt-cim mailing list