# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1224235974 25200
# Node ID a59563b0aa73db1b5e3cb3b5f84ac3e2aff3649b
# Parent 6985c0d24577f59bba4229fbed339d280ed06e63
[TEST] Fixing and updating 02_reverse.py of ElementConforms to work with/without
sblim-base-provider.
Tested with Xen, XenFV, KVM with current sources, with/without sblim-base-provider.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 6985c0d24577 -r a59563b0aa73
suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py
--- a/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Fri Oct 17 01:48:06 2008
-0700
+++ b/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Fri Oct 17 02:32:54 2008
-0700
@@ -31,7 +31,7 @@
# wbemcli ain -ac Xen_ElementConformsToProfile \
# 'http://localhost:5988/root/virt:Xen_HostSystem.\
-#
CreationClassName="Xen_HostSystem",Name="elm3b24.beaverton.ibm.com"'
+# CreationClassName="Xen_HostSystem",Name="lm3b24"'
#
# Date : 07-12-2007
@@ -41,21 +41,22 @@ from XenKvmLib.test_xml import testxml
from XenKvmLib.test_xml import testxml
from VirtLib import utils
from CimTest import Globals
-from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, CIM_ERROR_ASSOCIATORS
+from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, CIM_ERROR_ASSOCIATORS
from XenKvmLib.const import do_main
from XenKvmLib import enumclass
from XenKvmLib import assoc
from XenKvmLib.test_doms import destroy_and_undefine_all
-from XenKvmLib.test_doms import destroy_and_undefine_all
from XenKvmLib import enumclass
from XenKvmLib.vxml import XenXML, KVMXML, get_class
from XenKvmLib.classes import get_typed_class
-from CimTest.ReturnCodes import PASS, FAIL
-from XenKvmLib.common_util import libvirt_cached_data_poll, get_cs_instance
+from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
+from XenKvmLib.common_util import libvirt_cached_data_poll, get_cs_instance, \
+ get_host_info
sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']
-test_dom = "domgst"
+test_dom ="domgst"
+bug_sblim ='00007'
def build_exp_prof_list(proflist, virt="Xen"):
list = {}
@@ -77,91 +78,98 @@ def verify_profile(inst, exp_inst):
return FAIL
if inst['RegisteredVersion'] != exp_inst.RegisteredVersion:
return FAIL
-
return PASS
@do_main(sup_types)
def main():
options = main.options
+ server = options.ip
+ virt = options.virt
status = FAIL
- destroy_and_undefine_all(options.ip)
- virt_xml = get_class(options.virt)
+ destroy_and_undefine_all(server)
+ virt_xml = get_class(virt)
cxml = virt_xml(test_dom)
- ret = cxml.define(options.ip)
+ ret = cxml.define(server)
if not ret:
logger.error("ERROR: Failed to Define the dom: %s" % test_dom)
return status
- inst_list = []
+ inst_list = {}
- rc, cs = get_cs_instance(test_dom, options.ip, options.virt)
+ rc, cs = get_cs_instance(test_dom, server, virt)
if rc != 0:
- sys = libvirt_cached_data_poll(options.ip, options.virt, test_dom)
+ cs = libvirt_cached_data_poll(server, virt, test_dom)
if sys is None:
logger.error("Instance for %s not created" % test_dom)
+ cxml.undefine(server)
return FAIL
- inst_list.append(sys)
- keys = ['Name', 'CreationClassName']
+ inst_list[cs.CreationClassName] = cs.Name
+
try:
- #Getting the hostname, to verify with the value returned by the assoc.
- cn = get_typed_class(options.virt, 'HostSystem')
- host_sys = enumclass.EnumInstances(options.ip, cn)
+ status, host_name, classname = get_host_info(server, virt)
+ if status != PASS:
+ logger.error("Unable to get host information")
+ cxml.undefine(server)
+ return status
+ except Exception, details:
+ logger.error("DEBUG Exception: %s" % details)
+ cxml.undefine(server)
+ return FAIL
- if len(host_sys) < 1:
- logger.error("ERROR: Enumerate returned 0 host instances")
- return FAIL
-
- inst_list.append(host_sys[0])
-
- except Exception, details:
- logger.error("Exception: %s" % details)
- return FAIL
+ inst_list[classname] = host_name
prev_namespace = Globals.CIM_NS
Globals.CIM_NS = 'root/interop'
try:
- cn = get_typed_class(options.virt, 'RegisteredProfile')
- proflist = enumclass.EnumInstances(options.ip, cn)
+ cn = get_typed_class(virt, 'RegisteredProfile')
+ proflist = enumclass.EnumInstances(server, cn)
except Exception, details:
logger.error(CIM_ERROR_ENUMERATE, cn)
logger.error("Exception: %s", details)
+ cxml.undefine(server)
return status
Globals.CIM_NS = prev_namespace
- exp_list = build_exp_prof_list(proflist, options.virt)
+ exp_list = build_exp_prof_list(proflist, virt)
# Loop through the assoc results returned on test_dom and hostsystem
try:
- for item in inst_list:
- cn = item.CreationClassName
- name = item.Name
- an = get_typed_class(options.virt, "ElementConformsToProfile")
- profs = assoc.Associators(options.ip,
+ for cn, sys_name in inst_list.iteritems():
+ name = sys_name
+ an = get_typed_class(virt, "ElementConformsToProfile")
+ profs = assoc.Associators(server,
an,
cn,
CreationClassName=cn,
Name=name)
if len(profs) != 1:
- logger.error("ElementConformsToProfile assoc failed")
- return FAIL
+ if cn == 'Linux_ComputerSystem':
+ status = XFAIL_RC(bug_sblim)
+ else:
+ logger.error("ElementConformsToProfile assoc failed")
+ status = FAIL
+
+ if status != PASS:
+ cxml.undefine(server)
+ return status
status = verify_profile(profs[0], exp_list[cn])
if status != PASS:
logger.error("Verification of profile instance failed")
+ cxml.undefine(server)
return FAIL
except Exception, detail:
- logger.error(CIM_ERROR_ASSOCIATORS,
- get_typed_class(options.virt, 'RegisteredProfile'))
+ logger.error(CIM_ERROR_ASSOCIATORS, an)
logger.error("Exception: %s", detail)
status = FAIL
- cxml.undefine(options.ip)
+ cxml.undefine(server)
return status
if __name__ == "__main__":