[PATCH 0 of 2] Temp work around for stale libvirt info

This will work temporarily until all (or most) of the tests are converted for using virsh to define the guests to using the providers.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1217542638 25200 # Node ID 3f73022d65dc1385ba90a2de874c878c631e7aee # Parent 01e5197b144a873a55bb0c088fc29cd31a5a9b0e (#2) Add function to poll for a guest This function is a work around to deal with a stale data issue seen with libvirt on RHEL 5.x. -Updates: -Changed name of polling function for clarity. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 01e5197b144a -r 3f73022d65dc suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Aug 06 09:15:45 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Thu Jul 31 15:17:18 2008 -0700 @@ -33,10 +33,12 @@ from pywbem.cim_obj import CIMInstanceName from XenKvmLib.devices import CIM_Instance from XenKvmLib.classes import get_typed_class -from CimTest.Globals import logger, log_param, CIM_ERROR_ENUMERATE +from CimTest.Globals import logger, log_param, CIM_ERROR_ENUMERATE, \ + CIM_ERROR_GETINSTANCE from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC -from VirtLib.live import diskpool_list, virsh_version, net_list +from VirtLib.live import diskpool_list, virsh_version, net_list, domain_list from XenKvmLib.vxml import PoolXML, NetXML +from XenKvmLib.enumclass import getInstance test_dpath = "foo" disk_file = '/etc/libvirt/diskpool.conf' @@ -57,7 +59,7 @@ return (1, cs) except Exception, detail: - logger.error(Globals.CIM_ERROR_GETINSTANCE, + logger.error(CIM_ERROR_GETINSTANCE, get_typed_class(virt, 'ComputerSystem')) logger.error("Exception: %s", detail) return (1, cs) @@ -397,3 +399,18 @@ return PASS +def libvirt_cached_data_poll(ip, virt, dom_name): + cs = None + + dom_list = domain_list(ip, virt) + if dom_name in dom_list: + timeout = 10 + + for i in range(0, timeout): + rc, cs = get_cs_instance(dom_name, ip, virt) + if rc == 0: + return cs + + sleep(1) + + return cs

+1 for me. Best, Regards Daisy (运国莲) VSM Team, China Systems & Technology Labs (CSTL) E-mail: yunguol@cn.ibm.com TEL: (86)-21-60922403 Building 10, 399 Ke Yuan Rd, Pudong Shanghai, 201203 libvirt-cim-bounces@redhat.com wrote on 2008-08-07 03:19:44:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1217542638 25200 # Node ID 3f73022d65dc1385ba90a2de874c878c631e7aee # Parent 01e5197b144a873a55bb0c088fc29cd31a5a9b0e (#2) Add function to poll for a guest
This function is a work around to deal with a stale data issue seen with libvirt on RHEL 5.x.
-Updates: -Changed name of polling function for clarity.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r 01e5197b144a -r 3f73022d65dc suites/libvirt- cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Aug 06 09:15:45 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Thu Jul 31 15:17:18 2008 -0700 @@ -33,10 +33,12 @@ from pywbem.cim_obj import CIMInstanceName from XenKvmLib.devices import CIM_Instance from XenKvmLib.classes import get_typed_class -from CimTest.Globals import logger, log_param, CIM_ERROR_ENUMERATE +from CimTest.Globals import logger, log_param, CIM_ERROR_ENUMERATE, \ + CIM_ERROR_GETINSTANCE from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC -from VirtLib.live import diskpool_list, virsh_version, net_list +from VirtLib.live import diskpool_list, virsh_version, net_list, domain_list from XenKvmLib.vxml import PoolXML, NetXML +from XenKvmLib.enumclass import getInstance
test_dpath = "foo" disk_file = '/etc/libvirt/diskpool.conf' @@ -57,7 +59,7 @@ return (1, cs)
except Exception, detail: - logger.error(Globals.CIM_ERROR_GETINSTANCE, + logger.error(CIM_ERROR_GETINSTANCE, get_typed_class(virt, 'ComputerSystem')) logger.error("Exception: %s", detail) return (1, cs) @@ -397,3 +399,18 @@
return PASS
+def libvirt_cached_data_poll(ip, virt, dom_name): + cs = None + + dom_list = domain_list(ip, virt) + if dom_name in dom_list: + timeout = 10 + + for i in range(0, timeout): + rc, cs = get_cs_instance(dom_name, ip, virt) + if rc == 0: + return cs + + sleep(1) + + return cs
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1217542648 25200 # Node ID 40afbdebb121e53b37e3a8d357afa8de86ff09cb # Parent 3f73022d65dc1385ba90a2de874c878c631e7aee (#2) Update ElementConforms 02 to use check_virsh_poll() work around. Also clean this test case some. Updates: -Fix log messages so that they print the proper class prefix -Updated poll function name. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 3f73022d65dc -r 40afbdebb121 suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py --- a/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Thu Jul 31 15:17:18 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Thu Jul 31 15:17:28 2008 -0700 @@ -52,6 +52,7 @@ 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 sup_types = ['Xen', 'XenFV', 'KVM', 'LXC'] @@ -96,51 +97,42 @@ inst_list = [] + rc, cs = get_cs_instance(test_dom, options.ip, options.virt) + if rc != 0: + sys = libvirt_cached_data_poll(options.ip, options.virt, test_dom) + if sys is None: + logger.error("Instance for %s not created" % test_dom) + return FAIL + + inst_list.append(sys) + try: - cs_list = computersystem.enumerate(options.ip, options.virt) - # The len should be atleast two, as the CS returns info - # one regarding VS and the other one for Domain-0. - if len(cs_list) < 1: - logger.error("ERROR: Wrong number of instances returned") - return status - for item in cs_list: - if item.Name == test_dom: - inst_list.append(item) - break - - if len(inst_list) != 1: - logger.error("ERROR: Instance for %s not created" % test_dom) - return status - #Getting the hostname, to verify with the value returned by the assoc. host_sys = hostsystem.enumerate(options.ip, options.virt) if len(host_sys) < 1: logger.error("ERROR: Enumerate returned 0 host instances") - return status - elif host_sys[0].Name == "": - logger.error("ERROR: HostName seems to be empty") - return status - else: - # Instance of the HostSystem - inst_list.append(host_sys[0]) - except Exception , detail: - logger.error("Exception: %s" % detail) - return status + return FAIL + + inst_list.append(host_sys[0]) + + except Exception, details: + logger.error("Exception: %s" % details) + return FAIL prev_namespace = Globals.CIM_NS Globals.CIM_NS = 'root/interop' try: key_list = ["InstanceID"] - proflist = enumclass.enumerate(options.ip, \ - "RegisteredProfile", \ + proflist = enumclass.enumerate(options.ip, + "RegisteredProfile", key_list, options.virt) - except Exception, detail: - logger.error(CIM_ERROR_ENUMERATE, \ - 'RegisteredProfile') - logger.error("Exception: %s", detail) + except Exception, details: + logger.error(CIM_ERROR_ENUMERATE, + get_typed_class(options.virt, 'RegisteredProfile')) + logger.error("Exception: %s", details) return status Globals.CIM_NS = prev_namespace @@ -160,14 +152,16 @@ Name=name) if len(profs) != 1: logger.error("ElementConformsToProfile assoc failed") - return status + return FAIL status = verify_profile(profs[0], exp_list[cn]) if status != PASS: logger.error("Verification of profile instance failed") + return FAIL except Exception, detail: - logger.error(CIM_ERROR_ASSOCIATORS, 'RegisteredProfile') + logger.error(CIM_ERROR_ASSOCIATORS, + get_typed_class(options.virt, 'RegisteredProfile')) logger.error("Exception: %s", detail) status = FAIL

+1 for me. Best, Regards Daisy (运国莲) VSM Team, China Systems & Technology Labs (CSTL) E-mail: yunguol@cn.ibm.com TEL: (86)-21-60922403 Building 10, 399 Ke Yuan Rd, Pudong Shanghai, 201203 libvirt-cim-bounces@redhat.com wrote on 2008-08-07 03:19:45:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1217542648 25200 # Node ID 40afbdebb121e53b37e3a8d357afa8de86ff09cb # Parent 3f73022d65dc1385ba90a2de874c878c631e7aee (#2) Update ElementConforms 02 to use check_virsh_poll() work around.
Also clean this test case some.
Updates: -Fix log messages so that they print the proper class prefix -Updated poll function name.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r 3f73022d65dc -r 40afbdebb121 suites/libvirt- cim/cimtest/ElementConforms/02_reverse.py --- a/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Thu Jul 31 15:17:18 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Thu Jul 31 15:17:28 2008 -0700 @@ -52,6 +52,7 @@ 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
sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']
@@ -96,51 +97,42 @@
inst_list = []
+ rc, cs = get_cs_instance(test_dom, options.ip, options.virt) + if rc != 0: + sys = libvirt_cached_data_poll(options.ip, options.virt, test_dom) + if sys is None: + logger.error("Instance for %s not created" % test_dom) + return FAIL + + inst_list.append(sys) + try: - cs_list = computersystem.enumerate(options.ip, options.virt) - # The len should be atleast two, as the CS returns info - # one regarding VS and the other one for Domain-0. - if len(cs_list) < 1: - logger.error("ERROR: Wrong number of instances returned") - return status - for item in cs_list: - if item.Name == test_dom: - inst_list.append(item) - break - - if len(inst_list) != 1: - logger.error("ERROR: Instance for %s not created" % test_dom) - return status - #Getting the hostname, to verify with the value returned bythe assoc. host_sys = hostsystem.enumerate(options.ip, options.virt)
if len(host_sys) < 1: logger.error("ERROR: Enumerate returned 0 host instances") - return status - elif host_sys[0].Name == "": - logger.error("ERROR: HostName seems to be empty") - return status - else: - # Instance of the HostSystem - inst_list.append(host_sys[0]) - except Exception , detail: - logger.error("Exception: %s" % detail) - return status + return FAIL + + inst_list.append(host_sys[0]) + + except Exception, details: + logger.error("Exception: %s" % details) + return FAIL
prev_namespace = Globals.CIM_NS Globals.CIM_NS = 'root/interop'
try: key_list = ["InstanceID"] - proflist = enumclass.enumerate(options.ip, \ - "RegisteredProfile", \ + proflist = enumclass.enumerate(options.ip, + "RegisteredProfile", key_list, options.virt) - except Exception, detail: - logger.error(CIM_ERROR_ENUMERATE, \ - 'RegisteredProfile') - logger.error("Exception: %s", detail) + except Exception, details: + logger.error(CIM_ERROR_ENUMERATE, + get_typed_class(options.virt, 'RegisteredProfile')) + logger.error("Exception: %s", details) return status
Globals.CIM_NS = prev_namespace @@ -160,14 +152,16 @@ Name=name) if len(profs) != 1: logger.error("ElementConformsToProfile assoc failed") - return status + return FAIL
status = verify_profile(profs[0], exp_list[cn]) if status != PASS: logger.error("Verification of profile instance failed") + return FAIL
except Exception, detail: - logger.error(CIM_ERROR_ASSOCIATORS, 'RegisteredProfile') + logger.error(CIM_ERROR_ASSOCIATORS, + get_typed_class(options.virt, 'RegisteredProfile')) logger.error("Exception: %s", detail) status = FAIL
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (2)
-
Guo Lian Yun
-
Kaitlin Rupert