# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1212494097 25200
# Node ID 22f10ada8a6af53e1fad84fb6b137182ccdc2179
# Parent 05e8d5b17fd7e4d7eb3a6f1903fd834fcebcd311
[TEST] #3 Fixing 02_reverse.py of RAPF.
Changes:
From 2 to 3 patch:
1) Passed the req_nettype arg to virtxml that
can be used to specify the network type, when we
need a guest with a network details other than the default network types.
This patch will require the vxml.py changes that was submitted today.
From 1 to 2 patch:
1) Used getInstance instead of enumerate for
RASD info.
2) Used the changeset no to reflect the ProcRASD InstanceID changes.
Added the following extra steps:
1) Defining a domain.
2) creating diskpool, netpool.
Without the steps 1 and 2 the tc used to simply pass.
The tc will fail on KVM with old libvirt-cim rpm as expected and will pass with the latest
source.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 05e8d5b17fd7 -r 22f10ada8a6a
suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py
--- a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py Tue Jun 03
04:40:42 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/02_reverse.py Tue Jun 03
04:54:57 2008 -0700
@@ -6,6 +6,7 @@
# Guolian Yun <yunguol(a)cn.ibm.com>
# Kaitlin Rupert <karupert(a)us.ibm.com>
# Zhengang Li <lizg(a)cn.ibm.com>
+# Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
@@ -25,69 +26,165 @@ import sys
import sys
from VirtLib import utils
from XenKvmLib import assoc
-from XenKvmLib import devices
+from XenKvmLib.test_doms import destroy_and_undefine_all
+from XenKvmLib.vxml import get_class
from XenKvmLib.classes import get_typed_class
+from XenKvmLib.const import CIM_REV
from CimTest import Globals
from CimTest.Globals import logger, do_main
-from CimTest.ReturnCodes import PASS, FAIL, XFAIL
+from CimTest.ReturnCodes import PASS, FAIL
+from XenKvmLib import enumclass
+from XenKvmLib.common_util import cleanup_restore, create_diskpool_conf, \
+create_netpool_conf
+
sup_types = ['Xen', 'XenFV', 'KVM']
+test_dom = "RAFP_dom"
+test_vcpus = 1
+test_mem = 128
+test_mac = "00:11:22:33:44:aa"
+proc_instid_rev = 590
+
+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)
+ vsxml = virtxml(test_dom, mem=test_mem, vcpus = test_vcpus,
+ mac = test_mac, disk = test_disk,
+ req_nettype='network')
+ 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):
+
+ if CIM_REV < proc_instid_rev:
+ procid = '%s/%s' % (test_dom, 0)
+ else:
+ procid = '%s/%s' % (test_dom, 'proc')
+
+ proc = { 'rasd_id' : procid,
+ '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
+ }
+
+ 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_pool_from_RAFP(server, virt, inst, pool_id, cn):
+ pool = []
+ try:
+ pool = assoc.AssociatorNames(server, "ResourceAllocationFromPool",
+ cn, virt, InstanceID = inst.InstanceID)
+ except Exception:
+ logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES, inst.InstanceID)
+ return FAIL
+
+ if len(pool) != 1:
+ logger.error("No associated pool for %s", inst.InstanceID)
+ return FAIL
+
+ if pool[0]['InstanceID'] != pool_id:
+ logger.error("InstanceID Mismatch")
+ logger.error("Returned %s instead of %s", pool[0]['InstanceID']
,
+ pool_id)
+ return FAIL
+
+ return PASS
+
+def get_rasdinst_verify_pool_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_pool_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
+ server = options.ip
+ virt = options.virt
+
+ status, vsxml, test_disk = setup_env(server, virt)
+ if status != PASS:
+ return status
- key_list = ["DeviceID", "CreationClassName",
"SystemName",
- "SystemCreationClassName"]
- try:
- mem = devices.enumerate(options.ip, 'Memory', key_list, options.virt)
- except Exception:
- logger.error(Globals.CIM_ERROR_ENUMERATE % 'Memory')
- return FAIL
+ status, diskid = create_diskpool_conf(server, virt)
+ if status != PASS:
+ return status
- try:
- proc = devices.enumerate(options.ip, 'Processor', key_list,
options.virt)
- except Exception:
- logger.error(Globals.CIM_ERROR_ENUMERATE % 'Processor')
- return FAIL
-
- for i in range(len(mem)):
- try:
- mempool = assoc.AssociatorNames(options.ip,
"ResourceAllocationFromPool",
- "MemResourceAllocationSettingData",
- options.virt,
- InstanceID = mem[i].DeviceID)
- except Exception:
- logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES % mem[i].DeviceID)
- status = FAIL
+ status, test_network = create_netpool_conf(server, virt)
+ if status != PASS:
+ return status
- if len(mempool) < 1:
- logger.error("No associated pool for %s" % mem[i].DeviceID)
- return FAIL
+ cn_id_list = init_list(test_disk, diskid, test_network)
- if mempool[0].keybindings['InstanceID'] != "MemoryPool/0":
- logger.error("MemResourceAllocationSettingData association error")
- return FAIL
-
- for j in range(len(proc)):
- try:
- procpool = assoc.AssociatorNames(options.ip,
"ResourceAllocationFromPool",
-
"ProcResourceAllocationSettingData",
- options.virt,
- InstanceID = proc[j].DeviceID)
- except Exception:
- logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES % proc[j].DeviceID)
- return FAIL
-
- if len(procpool) < 1:
- logger.error("No associated pool for %s" % proc[j].DeviceID)
- return FAIL
+ for rasd_cn, id_info in cn_id_list.iteritems():
+ status = get_rasdinst_verify_pool_from_RAFP(server, virt, vsxml,
+ rasd_cn, id_info)
+ if status != PASS:
+ return status
- if procpool[0].keybindings['InstanceID'] != "ProcessorPool/0":
- logger.error("ProcResourceAllocationSettingData association
failed")
- status = FAIL
-
+ cleanup_restore(server, virt)
+ vsxml.undefine(server)
return status
if __name__ == "__main__":