[Libvirt-cim] [PATCH] [TEST] #2 Update RASD -t 04_disk_rasd_size.py to user cim_define()

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Thu Jan 8 23:02:51 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1231455763 28800
# Node ID ea39f5d207a8fbade59995cd5041a10cb58b0aa0
# Parent  59af62c3ec5696d019e505a05032616af9b12fcd
[TEST] #2 Update RASD -t 04_disk_rasd_size.py to user cim_define()

Also, reorganize the test slighly so that there's no need to pass cxml to a
function for the define call.

Updates:
  -Improve error message
  -Fixed some formatting issues

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 59af62c3ec56 -r ea39f5d207a8 suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py
--- a/suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py	Thu Jan 08 14:36:28 2009 -0800
+++ b/suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py	Thu Jan 08 15:02:43 2009 -0800
@@ -29,11 +29,9 @@
 from XenKvmLib.const import do_main
 from CimTest.Globals import logger
 from VirtLib import utils
-from XenKvmLib.test_doms import undefine_test_domain
-from XenKvmLib.common_util import create_using_definesystem
-from XenKvmLib import vsms
 from XenKvmLib import enumclass
 from XenKvmLib.classes import get_typed_class
+from XenKvmLib.vxml import get_class 
 
 def make_image(ip, size):
     s, fn = utils.run_remote(ip, "mktemp")
@@ -54,52 +52,22 @@
 
 def check_rasd_size(rasd, size):
     if rasd["AllocationUnits"] != "Bytes":
-        logger.error("AllocationUnits != Bytes?")
+        logger.error("Got %s units, exp Bytes", rasd["AllocationUnits"])
         return FAIL
 
     try:
         cim_size = int(rasd["VirtualQuantity"])
-    except Exception, e:
-        logger.error("Failed to get DiskRASD size: %s" % e)
+    except Exception, details:
+        logger.error("Failed to get DiskRASD size: %s" % details)
         return FAIL
 
     if cim_size != size:
-        logger.error("CIM reports %i bytes, but should be %i bytes" % (cim_size,
-                                                                       size))
+        logger.error("CIM reports %i bytes, but should be %i bytes", cim_size,
+                     size)
         return FAIL
-    else:
-        logger.info("Verified %i bytes" % cim_size)
-        return PASS
 
-def test_rasd(options, temp, test_size):
-    vssd = vsms.get_vssd_mof(options.virt, default_dom)
-
-    drasd_class = vsms.get_dasd_class(options.virt)
-    drasd = drasd_class("hda", temp, default_dom)
-
-    mrasd_class = vsms.get_masd_class(options.virt)
-    mrasd = mrasd_class(name=default_dom, megabytes=32)
-
-    params = {
-        "vssd" : vssd,
-        "rasd" : [drasd.mof(), mrasd.mof()]
-        }
-
-    create_using_definesystem(default_dom,
-                              options.ip,
-                              params=params,
-                              virt=options.virt)
-
-    cn = get_typed_class(options.virt, 'DiskResourceAllocationSettingData') 
-    rasds = enumclass.EnumInstances(options.ip, cn, ret_cim_inst=True)
-
-    status = FAIL
-    for rasd in rasds:
-        if rasd["Address"] == temp:
-            status = check_rasd_size(rasd, test_size)
-            break
-
-    return status
+    logger.info("Verified %i bytes" % cim_size)
+    return PASS
 
 @do_main(sup_types)
 def main():
@@ -113,14 +81,30 @@
         return FAIL
 
     logger.info("Created temp disk %s of size %i bytes" % (temp, test_size))
+   
+    virtxml = get_class(options.virt)
+    cxml = virtxml(default_dom, mem=32, disk_file_path=temp, disk="hda")
 
     try:
-        status = test_rasd(options, temp, test_size)
-    except Exception, e:
-        logger.error("Failed to test RASD: %s" % e)
+        ret = cxml.cim_define(options.ip)
+        if not ret:
+            raise Exception("Failed to define the dom: %s" % default_dom)
 
-    undefine_test_domain(default_dom, options.ip, options.virt)
+        cn = get_typed_class(options.virt, 'DiskResourceAllocationSettingData') 
+        rasds = enumclass.EnumInstances(options.ip, cn, ret_cim_inst=True)
+
+        status = FAIL
+        for rasd in rasds:
+            if rasd["Address"] == temp:
+                status = check_rasd_size(rasd, test_size)
+                break
+
+    except Exception, details:
+        logger.error("Failed to test RASD: %s" % details)
+        status = FAIL
+
     kill_image(options.ip, temp)
+    cxml.undefine(options.ip)
 
     return status
 




More information about the Libvirt-cim mailing list