# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1222777504 25200
# Node ID 74c27c6878537864db0d9a2f37dcfc826abffa5b
# Parent 52f8b84c5bc6c3665b434b18707e2debbc0c0bff
[TEST] Fixing and updating 02_reverse.py of HostedDependency to work with
sblim-base-provider.
1) Updated the tc to work with/without sblim-base-provider.
2) Updated the tc to use cim_define().
3) Updated call_request_state_change() to start the domain.
3) Included the bug no 00007.
4) Used get_host_info() for getting the host information.
Tested with Xen, XenFV, KVM on current sources and with/without sblim-base-provider
installed.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 52f8b84c5bc6 -r 74c27c687853
suites/libvirt-cim/cimtest/HostedDependency/02_reverse.py
--- a/suites/libvirt-cim/cimtest/HostedDependency/02_reverse.py Tue Sep 30 05:06:02 2008
-0700
+++ b/suites/libvirt-cim/cimtest/HostedDependency/02_reverse.py Tue Sep 30 05:25:04 2008
-0700
@@ -29,7 +29,7 @@
# Example cli command is
# wbemcli ain -ac Xen_HostedDependency
# 'http://localhost:5988/root/virt:
-#
Xen_HostSystem.CreationClassName="Xen_HostSystem",Name="mx3650b.in.ibm.com"'
+#
Xen_HostSystem.CreationClassName="Xen_HostSystem",Name="3650b"'
#
# For which we get the following output
# localhost:5988/root/virt:Xen_ComputerSystem.
@@ -48,41 +48,50 @@ from XenKvmLib.classes import get_class_
from XenKvmLib.classes import get_class_basename
from CimTest.Globals import logger
from XenKvmLib.const import do_main
-from CimTest.ReturnCodes import PASS, FAIL
+from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
+from XenKvmLib.common_util import get_host_info, call_request_state_change
sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
test_dom = "hd_domain"
test_mac = "00:11:22:33:44:55"
+TIME = "00000000000000.000000:000"
+bug_sblim = "00007"
@do_main(sup_types)
def main():
options = main.options
+ virt = options.virt
+ server = options.ip
status = PASS
- virtxml = vxml.get_class(options.virt)
- if options.virt == "LXC":
+ virtxml = vxml.get_class(virt)
+ if virt == "LXC":
cxml = virtxml(test_dom)
else:
cxml = virtxml(test_dom, mac = test_mac)
- ret = cxml.create(options.ip)
+ ret = cxml.cim_define(server)
if not ret:
- logger.error("ERROR: Failed to Create the dom: %s" % test_dom)
- status = FAIL
- return status
- keys = ['Name', 'CreationClassName']
+ logger.error("Failed to define the dom: %s" % test_dom)
+ return FAIL
+
+ rc = call_request_state_change(test_dom, server, 2, TIME, virt)
+ if rc != 0:
+ logger.error("Failed to start the dom: %s" % test_dom)
+ cxml.undefine(server)
+ return FAIL
+
try:
- host_sys = enumclass.enumerate(options.ip, 'HostSystem', keys,
options.virt)
- if host_sys[0].Name == "":
- raise Exception("HostName seems to be empty")
- else:
- # Instance of the HostSystem
- host_sys = host_sys[0]
+ status, host_name, host_ccn = get_host_info(server, virt)
+ if status != PASS:
+ cxml.destroy(server)
+ cxml.undefine(server)
+ return status
keys = ['Name', 'CreationClassName']
- cs = enumclass.enumerate(options.ip, 'ComputerSystem', keys,
options.virt)
- if options.virt == 'Xen' or options.virt == 'XenFV':
+ cs = enumclass.enumerate(server, 'ComputerSystem', keys, virt)
+ if virt == 'Xen' or options.virt == 'XenFV':
# Xen honors additional domain-0
cs_list_len = 2
else:
@@ -94,19 +103,27 @@ def main():
# ComputerSystem.EnumerateInstances()
cs_names = [x.name for x in cs]
+ if host_ccn != 'Linux_ComputerSystem':
+ hs_ccn = get_class_basename(host_ccn)
+ else:
+ hs_ccn = host_ccn
+
# Get a list of ComputerSystem instances from the HostSystem instace
- host_ccn = host_sys.CreationClassName
- systems = assoc.AssociatorNames(options.ip, "HostedDependency",
- get_class_basename(host_ccn),
- options.virt,
+ systems = assoc.AssociatorNames(server, "HostedDependency",
+ hs_ccn, virt,
CreationClassName=host_ccn,
- Name=host_sys.Name)
+ Name=host_name)
+
# Compare each returned instance to make sure it's in the list
# that ComputerSystem.EnumerateInstances() returned
if len(systems) < 1:
- raise Exception("HostedDependency returned %d, expected at least 1"
%
- len(systems))
+ logger.error("HostedDependency returned %d, expected at least 1",
+ len(systems))
+ cxml.destroy(server)
+ cxml.undefine(server)
+ return XFAIL_RC(bug_sblim)
+
ccn = cs[0].CreationClassName
for guest in systems:
@@ -119,7 +136,7 @@ def main():
# checking the CreationClassName returned is Xen_ComputerSystem
if ccn != guest["CreationClassName"]:
- logger.error("ERROR: CreationClassName does not match")
+ logger.error("CreationClassName does not match")
status = FAIL
# Go through anything remaining in the
@@ -131,15 +148,12 @@ def main():
guest["Name"])
status = FAIL
- except (UnboundLocalError, NameError), detail:
- logger.error("Exception: %s" % detail)
-
except Exception, detail:
- logger.error(detail)
+ logger.error("Exception: %s", detail)
status = FAIL
- cxml.destroy(options.ip)
- cxml.undefine(options.ip)
+ cxml.destroy(server)
+ cxml.undefine(server)
return status
if __name__ == "__main__":