# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1233350611 28800
# Node ID d1443d4847e3f9711b2db016d20676ca35f57243
# Parent fd464f0d24d0f4173cefd9d7ee8d27e6fc48ac55
[TEST] #2 Update VSMS 11_define_memrasdunits.py to use cim_define()
Use template RASD when defining guest. Some minor changes so that the test
fits with the style conventions of other test cases.
Removed some extraneous debug from assoc.py
Updates:
-Only undefine the guest if hasn't been done so already
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r fd464f0d24d0 -r d1443d4847e3
suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py
---
a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Thu
Jan 29 08:37:46 2009 -0800
+++
b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Fri
Jan 30 13:23:31 2009 -0800
@@ -21,17 +21,14 @@
#
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 pywbem.cim_types import Uint64
+from XenKvmLib.classes import get_typed_class, inst_to_mof
from XenKvmLib import enumclass
from XenKvmLib.const import do_main
from CimTest.Globals import logger
from CimTest.ReturnCodes import FAIL, PASS
+from XenKvmLib.vxml import get_class
+from XenKvmLib.rasd import get_default_rasds
sup_types = ['Xen', 'XenFV', 'KVM']
default_dom = "memrasd_test"
@@ -45,30 +42,38 @@
("GigaBytes", 30),
]
-def try_define(options, vssd, units, value):
- mrasd_class = vsms.get_masd_class(options.virt)
- mrasd = mrasd_class(megabytes=value, mallocunits=units,
- name=default_dom)
+def try_define(options, units, value, cxml):
+ mrasd_cn = get_typed_class(options.virt,
"MemResourceAllocationSettingData")
- params = {
- "vssd" : vssd,
- "rasd" : [mrasd.mof()],
- }
+ rasds = get_default_rasds(options.ip, options.virt)
- 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
+ rasd_list = {}
- return True
+ for rasd in rasds:
+ if rasd.classname == mrasd_cn:
+ rasd['VirtualQuantity'] = Uint64(value)
+ rasd['AllocationUnits'] = units
+ rasd_list[mrasd_cn] = inst_to_mof(rasd)
+ else:
+ rasd_list[rasd.classname] = None
+
+ if rasd_list[mrasd_cn] is None:
+ logger.error("Unable to get template MemRASD")
+ return FAIL
+
+ cxml.set_res_settings(rasd_list)
+
+ logger.info("Defining with %s = %i", units, value)
+
+ ret = cxml.cim_define(options.ip)
+ if not ret:
+ logger.error("DefineSystem with (%s) units failed" % units)
+ return FAIL
+
+ return PASS
def check_value(options):
- mrasd_cn = get_typed_class(options.virt, rasd.masd_cn)
+ mrasd_cn = get_typed_class(options.virt,
"MemResourceAllocationSettingData")
rasds = enumclass.EnumInstances(options.ip, mrasd_cn, ret_cim_inst=True)
the_rasd = None
@@ -80,46 +85,50 @@
if not the_rasd:
logger.error("Did not find test RASD on server")
- return False
+ return FAIL
if the_rasd["AllocationUnits"] != "KiloBytes":
logger.error("MRASD units are not kilobytes?")
- return False
+ return FAIL
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
+ return FAIL
logger.info("Verified %i KB" % mem_kb)
- return True
+ return PASS
@do_main(sup_types)
def main():
options = main.options
- vssd = vsms.get_vssd_mof(options.virt, default_dom)
+ cxml = get_class(options.virt)(default_dom)
- status = PASS
+ status = FAIL
+ guest_is_undefined = None
for units, shift in values:
+ guest_is_undefined = False
+
value = mem_bytes >> shift
- if not try_define(options, vssd, units, value):
- status = FAIL
+ status = try_define(options, units, value, cxml)
+ if status != PASS:
break
- if not check_value(options):
- status = FAIL
+ status = check_value(options)
+ if status != PASS:
break
- undefine_test_domain(default_dom, options.ip, virt=options.virt)
+ cxml.undefine(options.ip)
+ guest_is_undefined = True
- undefine_test_domain(default_dom, options.ip, virt=options.virt)
-
+ if guest_is_undefined != True:
+ cxml.undefine(options.ip)
return status
diff -r fd464f0d24d0 -r d1443d4847e3 suites/libvirt-cim/lib/XenKvmLib/assoc.py
--- a/suites/libvirt-cim/lib/XenKvmLib/assoc.py Thu Jan 29 08:37:46 2009 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/assoc.py Fri Jan 30 13:23:31 2009 -0800
@@ -49,7 +49,6 @@
names = []
try:
- logger.info("DEBUG instanceref, is %s", instanceref)
names = conn.AssociatorNames(instanceref, AssocClass=assoc_cn)
except pywbem.CIMError, arg:
print arg[1]
@@ -79,7 +78,6 @@
names = []
try:
- logger.info("DEBUG instanceref, is %s", instanceref)
names = conn.Associators(instanceref, AssocClass=assoc_cn)
except pywbem.CIMError, arg:
print arg[1]