[Libvirt-cim] [PATCH] [TEST] #4 Update VSSDC.01 for KVM/XenFV/LXC support

yunguol at cn.ibm.com yunguol at cn.ibm.com
Wed Jul 23 06:00:02 UTC 2008


# HG changeset patch
# User Guolian Yun <yunguol at cn.ibm.com>
# Date 1216792796 25200
# Node ID f311f3dfa6451c7e5efeda76582e36cd119a46d4
# Parent  3703b7be5a107c67e901546978e974546b3d5562
[TEST] #4 Update VSSDC.01 for KVM/XenFV/LXC support

The test defines non-bootloader guests for all platform types, also remove the
part of thet test that verifies the bootloader

Updates from 1 to 2:
Pass test_disk and test_mac as parameters into init_list() function.

Updates from 2 to 3:
Remove build_vssd_info() and call compare_all_prop() in assoc_values()

Updates from 3 to 4:
1) Remove otiose rlist define line for LXC option
2) change assoc_values comments, it verifies all of the values of instance
3) check compare_all_prop return, if it return fail, print a log message

Signed-off-by: Guolian Yun <yunguol at cn.ibm.com>

diff -r 3703b7be5a10 -r f311f3dfa645 suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/01_forward.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/01_forward.py	Wed Jul 16 07:23:32 2008 -0700
+++ b/suites/libvirt-cim/cimtest/VirtualSystemSettingDataComponent/01_forward.py	Tue Jul 22 22:59:56 2008 -0700
@@ -52,32 +52,31 @@
 import sys
 from XenKvmLib import enumclass
 from VirtLib import utils
-from XenKvmLib.test_doms import test_domain_function, destroy_and_undefine_all 
-from XenKvmLib.test_xml import testxml_bl
-from XenKvmLib.test_xml import xml_get_dom_bootloader 
+from XenKvmLib.test_doms import destroy_and_undefine_all
+from XenKvmLib.assoc import compare_all_prop 
 from CimTest import Globals 
 from XenKvmLib import assoc
+from XenKvmLib import vxml
+from XenKvmLib.classes import get_typed_class
 from CimTest.Globals import logger, do_main
 from CimTest.ReturnCodes import FAIL, PASS
 
-sup_types = ['Xen']
+sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
 
 test_dom    = "VSSDC_dom"
 test_vcpus  = 2
 test_mac    = "00:11:22:33:44:aa"
 test_disk   = 'xvda'
-status      = 0
-VSType      = "Xen"
 
-def init_list():
+def init_list(test_disk, test_mac, virt='Xen'):
     """
         Creating the lists that will be used for comparisons.
     """
 
-    rlist = ['Xen_DiskResourceAllocationSettingData',
-             'Xen_MemResourceAllocationSettingData',
-             'Xen_NetResourceAllocationSettingData',
-             'Xen_ProcResourceAllocationSettingData'
+    rlist = [get_typed_class(virt, 'DiskResourceAllocationSettingData'),
+             get_typed_class(virt, 'MemResourceAllocationSettingData'),
+             get_typed_class(virt, 'NetResourceAllocationSettingData'),
+             get_typed_class(virt, 'ProcResourceAllocationSettingData')
             ]
 
     prop_list = {rlist[0] : "%s/%s"  % (test_dom, test_disk),
@@ -85,57 +84,33 @@
                  rlist[2] : "%s/%s" % (test_dom, test_mac),
                  rlist[3] : "%s/%s" % (test_dom, "proc")
                 }
+    if virt == 'LXC':
+        prop_list = {rlist[1] : "%s/%s" % (test_dom, "mem")}        
 
     return prop_list
 
-def build_vssd_info(ip, vssd):
-    """
-        Creating the vssd fileds lists that will be used for comparisons.
-    """
-
-    if vssd.Bootloader == "" or vssd.Caption == "" or \
-      vssd.InstanceID == "" or vssd.ElementName == "" or \
-      vssd.VirtualSystemIdentifier == "" or vssd.VirtualSystemType == "":
-        logger.error("One of the required VSSD details seems to be empty")
-        test_domain_function(test_dom, ip, "undefine")
-        return FAIL
- 
-    vssd_vals = {'Bootloader'			: vssd.Bootloader,
-                 'Caption'			: vssd.Caption,
-                 'InstanceID'			: vssd.InstanceID,
-                 'ElementName'			: vssd.ElementName,
-                 'VirtualSystemIdentifier'	: vssd.VirtualSystemIdentifier,
-                 'VirtualSystemType'		: vssd.VirtualSystemType
-                }
-
-    return vssd_vals
-
-def assoc_values(ip, assoc_info, cn, an, vals):
+def assoc_values(ip, assoc_info, cn, an, vssd):
     """
         The association info of 
         Xen_VirtualSystemSettingDataComponent with every RASDclass is
-        verified for following fields:
-        Caption, InstanceID, ElementName, VirtualSystemIdentifier,
-        VirtualSystemType, Bootloader
+        verified all of the values
     """
 
     try: 
         if len(assoc_info) != 1:
-            Globals.logger.error("%s returned %i resource objects for '%s'" % \
-                                 (an, len(assoc_info), cn))
+            logger.error("%s returned %i resource objects for '%s'" % \
+                         (an, len(assoc_info), cn))
             return FAIL 
-
-        for prop, val in vals.iteritems():
-            if assoc_info[0][prop] != val:
-                Globals.logger.error("%s mismatch: returned %s instead of %s" %\
-                                     (prop, assoc_info[0][prop], val))
-                return FAIL
-
-        return PASS
-
+        status = compare_all_prop(assoc_info[0], vssd)
+        if status != PASS:
+            logger.error("Verification error: got %s, expect %s" % \
+                         (assoc_info[0], vssd))
+            return FAIL
     except  Exception, detail :
         logger.error("Exception in assoc_values function: %s" % detail)
-        return FAIL 
+        return FAIL
+
+    return PASS 
 
 @do_main(sup_types)
 def main():
@@ -143,49 +118,53 @@
     status = FAIL
 
     destroy_and_undefine_all(options.ip)
-    test_xml = testxml_bl(test_dom, vcpus = test_vcpus, \
-                          mac = test_mac, disk = test_disk, \
-                          server = options.ip,\
-                          gtype = 0)
-    ret = test_domain_function(test_xml, options.ip, cmd = "define")
+    prop_list = init_list(test_disk, test_mac, options.virt)
+    virt_xml = vxml.get_class(options.virt)
+    if options.virt == 'LXC':
+        cxml = virt_xml(test_dom)
+    else:
+        cxml = virt_xml(test_dom, vcpus = test_vcpus, \
+                        mac = test_mac, disk = test_disk)
+    ret = cxml.define(options.ip)
     if not ret:
         logger.error("Failed to define the dom: %s", test_dom)
         return FAIL 
 
-    instIdval = "%s:%s" % (VSType, test_dom)
+    if options.virt == 'XenFV':
+        instIdval = "Xen:%s" % test_dom
+    else:
+        instIdval = "%s:%s" % (options.virt, test_dom)
+
     keyname = "InstanceID"
+    key_list = { 'InstanceID' : instIdval }
+    vssd_cn = get_typed_class(options.virt, 'VirtualSystemSettingData')
 
-    key_list = { 'InstanceID' : instIdval }
     try:
         vssd = enumclass.getInstance(options.ip, \
-                                    enumclass.Xen_VirtualSystemSettingData, \
-                                    key_list)
+                                     'VirtualSystemSettingData', \
+                                     key_list, \
+                                     options.virt)
         if vssd is None:
             logger.error("VSSD instance for %s not found" % test_dom)
-            test_domain_function(test_dom, options.ip, "undefine")
+            cxml.undefine(options.ip)
             return FAIL
-
-        vssd_vals = build_vssd_info(options.ip, vssd)
-
     except  Exception, detail :
-        logger.error(Globals.CIM_ERROR_GETINSTANCE, \
-                     'Xen_VirtualSystemSettingData')
+        logger.error(Globals.CIM_ERROR_GETINSTANCE, vssd_cn)
         logger.error("Exception : %s" % detail)
-        test_domain_function(test_dom, options.ip, "undefine")
+        cxml.undefine(options.ip)
         return FAIL 
 
-    prop_list = init_list()
 
     try:
         # Looping through the RASD_cllist, call association 
         # Xen_VirtualSystemSettingDataComponent with each class in RASD_cllist
-        an = 'Xen_VirtualSystemSettingDataComponent'
+        an = get_typed_class(options.virt, 'VirtualSystemSettingDataComponent')
         for rasd_cname, prop in prop_list.iteritems():
             assoc_info = assoc.Associators(options.ip, an, rasd_cname,
-                                           InstanceID = prop)
+                                           options.virt, InstanceID = prop)
             # Verify the association fields returned for particular rasd_cname.
             status = assoc_values(options.ip, assoc_info, rasd_cname, an, 
-                                  vssd_vals)
+                                  vssd)
             if status != PASS:
                 break
  
@@ -194,7 +173,7 @@
         logger.error("Exception : %s" % detail)
         status = FAIL
 
-    test_domain_function(test_dom, options.ip, "undefine")
+    cxml.undefine(options.ip)
     return status
 
 if __name__ == "__main__":




More information about the Libvirt-cim mailing list