# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1213685796 -28800
# Node ID 72d19c4c969b8b4239a5cdf2107fa279782f9d96
# Parent 6652ca49942c0314ec1b2b1da504810325097250
[TEST] Update RAFP.01 for LXC support, also fix Diskpool and NetworkPool missing
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 6652ca49942c -r 72d19c4c969b
suites/libvirt-cim/cimtest/ResourceAllocationFromPool/01_forward.py
--- a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/01_forward.py Thu Jun 12
17:13:23 2008 +0800
+++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/01_forward.py Tue Jun 17
14:56:36 2008 +0800
@@ -24,70 +24,164 @@
import sys
from VirtLib import utils
+from XenKvmLib.test_doms import destroy_and_undefine_all
+from XenKvmLib.vxml import get_class
from XenKvmLib import assoc
from XenKvmLib import enumclass
from XenKvmLib.classes import get_typed_class
from CimTest import Globals
from CimTest.Globals import logger, do_main
+from XenKvmLib.common_util import cleanup_restore, create_diskpool_conf, \
+create_netpool_conf
from CimTest.ReturnCodes import PASS, FAIL, XFAIL
-sup_types = ['Xen', 'XenFV', 'KVM']
+sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']
+
+test_dom = 'RAFP_domain'
+test_mac = '00:11:22:33:44:55'
+
+def setup_env(server, virt):
+ destroy_and_undefine_all(server)
+ vsxml = None
+ if virt == "Xen":
+ test_disk = "xvda"
+ else:
+ test_disk = "hda"
+
+ virtxml = get_class(virt)
+ if virt == 'LXC':
+ vsxml = virtxml(test_dom)
+ else:
+ vsxml = virtxml(test_dom, disk = test_disk)
+ try:
+ ret = vsxml.define(server)
+ if not ret:
+ logger.error("Failed to Define the domain: %s", test_dom)
+ return FAIL, vsxml, test_disk
+
+ except Exception, details:
+ logger.error("Exception : %s", details)
+ return FAIL, vsxml, test_disk
+
+ return PASS, vsxml, test_disk
+
+def init_list(test_disk, diskid, test_network, virt='Xen'):
+
+ proc = { 'rasd_id' : '%s/%s' % (test_dom, 'proc'),
+ 'pool_id' : 'ProcessorPool/0'
+ }
+
+ mem = { 'rasd_id' : '%s/%s' % (test_dom,'mem'),
+ 'pool_id' : 'MemoryPool/0'
+ }
+
+ net = {
+ 'rasd_id' : '%s/%s' % (test_dom, test_mac),
+ 'pool_id' : 'NetworkPool/%s' %test_network
+ }
+
+ disk = { 'rasd_id' : '%s/%s' % (test_dom, test_disk),
+ 'pool_id' : diskid
+ }
+
+ if virt == 'LXC':
+ cn_id_list = {
+ 'MemResourceAllocationSettingData' : mem,
+ }
+ else:
+ cn_id_list = {
+ 'MemResourceAllocationSettingData' : mem,
+ 'ProcResourceAllocationSettingData' : proc,
+ 'NetResourceAllocationSettingData' : net,
+ 'DiskResourceAllocationSettingData' : disk
+ }
+
+ return cn_id_list
+
+def get_rasd_instance(server, virt, key_list, cn):
+ inst = None
+ try:
+ inst = enumclass.getInstance(server, cn, key_list, virt)
+ except Exception, details:
+ logger.error(Globals.CIM_ERROR_GETINSTANCE, cn)
+ logger.error("Exception details: %s", details)
+ return inst, FAIL
+
+ return inst, PASS
+
+def verify_rasd_from_RAFP(server, virt, inst, rasd_id, cn):
+ rasd = []
+ try:
+ rasd = assoc.AssociatorNames(server, "ResourceAllocationFromPool",
+ cn, virt, InstanceID = inst.InstanceID)
+ except Exception:
+ logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES, inst.InstanceID)
+ return FAIL
+
+ if len(rasd) != 1:
+ logger.error("No associated rasd for %s", inst.InstanceID)
+ return FAIL
+
+ if rasd[0]['InstanceID'] != rasd_id:
+ logger.error("InstanceID Mismatch")
+ logger.error("Returned %s instead of %s", rasd[0]['InstanceID']
,
+ pool_id)
+ return FAIL
+
+ return PASS
+
+def get_rasdinst_verify_rasd_from_RAFP(server, virt, vsxml, cn, id_info):
+ try:
+ key_list = { 'InstanceID' : id_info['rasd_id'] }
+ rasd_cn = get_typed_class(virt, cn)
+ rasdinst, status = get_rasd_instance(server, virt, key_list, rasd_cn)
+ if status != PASS or rasdinst.InstanceID == None:
+ vsxml.undefine(server)
+ return status
+
+ status = verify_rasd_from_RAFP(server, virt, rasdinst,
+ id_info['pool_id'], cn)
+ except Exception, details:
+ logger.error("Exception in get_rasdinst_verify_pool_from_RAFP() fn")
+ logger.error("Exception Details %s", details)
+ status = FAIL
+
+ if status != PASS:
+ vsxml.undefine(server)
+
+ return status
@do_main(sup_types)
def main():
options = main.options
status = PASS
- try:
- key_list = { 'InstanceID' : "MemoryPool/0" }
- mempool = enumclass.getInstance(options.ip,
- "MemoryPool",
- key_list,
- options.virt)
- except Exception:
- logger.error(Globals.CIM_ERROR_GETINSTANCE % "MemoryPool")
- return FAIL
+ server = options.ip
+ virt = options.virt
- try:
- key_list = { 'InstanceID' : "ProcessorPool/0" }
- procpool = enumclass.getInstance(options.ip,
- "ProcessorPool",
- key_list,
- options.virt)
- except Exception:
- logger.error(Globals.CIM_ERROR_GETINSTANCE % "ProcessorPool")
- return FAIL
-
- try:
- memdata = assoc.AssociatorNames(options.ip,
"ResourceAllocationFromPool",
- "MemoryPool",
- options.virt,
- InstanceID = mempool.InstanceID)
- except Exception:
- logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES % mempool.InstanceID)
- status = FAIL
-
- for i in range(len(memdata)):
- if memdata[i].classname != get_typed_class(options.virt,
"MemResourceAllocationSettingData"):
- logger.error("ERROR: Association result error")
- status = FAIL
-
- try:
- procdata = assoc.AssociatorNames(options.ip,
"ResourceAllocationFromPool",
- "ProcessorPool",
- options.virt,
- InstanceID = procpool.InstanceID)
- except Exception:
- logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES % procpool.InstanceID)
- status = FAIL
-
- for j in range(len(procdata)):
- if procdata[j].classname != get_typed_class(options.virt,
"ProcResourceAllocationSettingData"):
- logger.error("ERROR: Association result error")
- status = FAIL
+ status, vsxml, test_disk = setup_env(server, virt)
+ if status != PASS:
+ return status
- return status
-
-
+ status, diskid = create_diskpool_conf(server, virt)
+ if status != PASS:
+ return status
+
+ status, test_network = create_netpool_conf(server, virt)
+ if status != PASS:
+ return status
+
+ cn_id_list = init_list(test_disk, diskid, test_network, options.virt)
+
+ for rasd_cn, id_info in cn_id_list.iteritems():
+ status = get_rasdinst_verify_rasd_from_RAFP(server, virt, vsxml,
+ rasd_cn, id_info)
+ if status != PASS:
+ return status
+
+ cleanup_restore(server, virt)
+ vsxml.undefine(server)
+ return status
+
if __name__ == "__main__":
sys.exit(main())