[Libvirt-cim] [PATCH] [TEST] #2 Verify functionality of MemoryRASD units specification for VSMS

Dan Smith danms at us.ibm.com
Wed Jul 30 14:02:18 UTC 2008


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1217426536 25200
# Node ID dcffd5acd5e13b447a9eb0fd1fb3ee79586ad975
# Parent  e3d4987d295d2905b921a1a3980430cd7bb03735
[TEST] #2 Verify functionality of MemoryRASD units specification for VSMS

Changes:
 - Removed dead code
 - Removed unneeded try..except block

Signed-off-by: Dan Smith <danms at us.ibm.com>

diff -r e3d4987d295d -r dcffd5acd5e1 suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py	Wed Jul 30 07:02:16 2008 -0700
@@ -0,0 +1,130 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+#    Dan Smith <danms at us.ibm.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+#
+
+import sys
+import pywbem
+from VirtLib import live
+from XenKvmLib import vsms
+from XenKvmLib.test_doms import undefine_test_domain
+from XenKvmLib.common_util import create_using_definesystem
+from XenKvmLib import rasd
+from XenKvmLib.classes import get_typed_class
+from XenKvmLib import enumclass
+from CimTest.Globals import do_main
+from CimTest.Globals import logger
+from CimTest.ReturnCodes import FAIL, PASS
+
+sup_types = ['Xen', 'XenFV', 'KVM']
+default_dom = "memrasd_test"
+
+mem_bytes = 2 << 30
+
+values = [
+    ("Bytes",      0),
+    ("KiloBytes", 10),
+    ("MegaBytes", 20),
+    ("GigaBytes", 30),
+    ]
+
+def try_define(options, vssd, units, value):
+    mrasd_class = vsms.get_masd_class(options.virt)
+    mrasd = mrasd_class(None, default_dom)
+    
+    mrasd.AllocationUnits = units
+    mrasd.VirtualQuantity = value
+
+    params = { 
+        "vssd" : vssd.mof(),
+        "rasd" : [mrasd.mof()],
+        }
+
+    logger.info("Defining with %s = %i" % (units, value))
+    rc = create_using_definesystem(default_dom,
+                                   options.ip,
+                                   params=params,
+                                   virt=options.virt)
+                                   
+    if rc != PASS:
+        logger.error("DefineSystem (%s) failed" % units)
+        return False
+
+    return True
+
+def check_value(options):
+    mrasd_cn = get_typed_class(options.virt, rasd.masd_cn)
+    rasds = enumclass.enumerate_inst(options.ip, mrasd_cn, options.virt)
+
+    the_rasd = None
+    mem_kb = mem_bytes >> 10
+
+    for _rasd in rasds:
+        if _rasd["InstanceID"] == "%s/mem" % default_dom:
+            the_rasd = _rasd
+    
+    if not the_rasd:
+        logger.error("Did not find test RASD on server")
+        return False
+
+    if the_rasd["AllocationUnits"] != "KiloBytes":
+        logger.error("MRASD units are not kilobytes?")
+        return False
+
+    cim_kb = int(the_rasd["VirtualQuantity"])
+
+    if cim_kb != mem_kb:
+        logger.error("CIM reports %i KB instead of %i KB" % (cim_kb, mem_kb))
+        return False
+
+    logger.info("Verified %i KB" % mem_kb)
+
+    return True
+
+
+ at do_main(sup_types)
+def main():
+    options = main.options
+
+    vssd_class = vsms.get_vssd_class(options.virt)
+    vssd = vssd_class(name=default_dom, virt=options.virt)
+
+    status = PASS
+
+    for units, shift in values:
+        value = mem_bytes >> shift
+
+        if not try_define(options, vssd, units, value):
+            status = FAIL
+            break
+
+        if not check_value(options):
+            status = FAIL
+            break
+
+        undefine_test_domain(default_dom, options.ip, virt=options.virt)
+
+    undefine_test_domain(default_dom, options.ip, virt=options.virt)
+
+
+    return status
+
+if __name__ == "__main__":
+    sys.exit(main())




More information about the Libvirt-cim mailing list