
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1234339844 28800 # Node ID dd59a8d6a123417a82434ebfa4f6ed54def5256f # Parent 1bb347c22e6ed03032f359c8c28e59e94b7316c2 [TEST] Update libraries present to follow the new coding style 1) Use commas instead of percent signs when passing parameters to logger.error() and logger.info() 2) Split lines to 80-char width limit Tested for KVM/LXC with current sources Signed-off-by: Guolian Yun<yunguol@cn.ibm.com> diff -r 1bb347c22e6e -r dd59a8d6a123 suites/libvirt-cim/lib/XenKvmLib/assoc.py --- a/suites/libvirt-cim/lib/XenKvmLib/assoc.py Mon Feb 09 21:47:35 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/assoc.py Wed Feb 11 00:10:44 2009 -0800 @@ -139,8 +139,8 @@ val = eval('exp_inst.' + key) if prop_vals[i][1] != val: - logger.error("%s val mismatch: got %s, expected %s" % (key, - prop_vals[i][1], val)) + logger.error("%s val mismatch: got %s, expected %s", key, + prop_vals[i][1], val) return FAIL return PASS diff -r 1bb347c22e6e -r dd59a8d6a123 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Feb 09 21:47:35 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Feb 11 00:10:44 2009 -0800 @@ -60,7 +60,7 @@ cs = enumclass.GetInstance(ip, cs_class, keys) if cs.Name != domain_name: - logger.error("VS %s is not found" % domain_name) + logger.error("VS %s is not found", domain_name) return (1, cs) except Exception, detail: @@ -104,11 +104,11 @@ return PASS return FAIL - logger.error('Unexpected rc code %s and description:\n %s' % (rc, desc)) + logger.error('Unexpected rc code %s and description:\n %s', rc, desc) return FAIL except Exception, details: - logger.error('Error invoke method `DefineSystem\'. %s' % details) + logger.error('Error invoke method `DefineSystem\'. %s', details) return FAIL if exp_err != None: @@ -150,7 +150,7 @@ TimeoutPeriod=pywbem.cim_types.CIMDateTime(time)) except Exception, detail: - logger.error("Exception: %s" % detail) + logger.error("Exception: %s", detail) return FAIL return PASS @@ -189,16 +189,16 @@ break except Exception, detail: - logger.error("Exception: %s" % detail) + logger.error("Exception: %s", detail) return FAIL, dom_cs if dom_cs is None or dom_cs.Name != dom: - logger.error("CS instance not returned for %s." % dom) + logger.error("CS instance not returned for %s.", dom) return FAIL, dom_cs if dom_cs.EnabledState != exp_state: - logger.error("EnabledState is %i instead of %i." % (dom_cs.EnabledState, - exp_state)) + logger.error("EnabledState is %i instead of %i.", dom_cs.EnabledState, + exp_state) logger.error("Try to increase the timeout and run the test again") return FAIL, dom_cs diff -r 1bb347c22e6e -r dd59a8d6a123 suites/libvirt-cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py Mon Feb 09 21:47:35 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Wed Feb 11 00:10:44 2009 -0800 @@ -140,8 +140,8 @@ destroy_and_undefine_all(options.ip, options.virt) rc = f() except Exception, e: - logger.error('%s : %s' % (e.__class__.__name__, e)) - logger.error("%s" % traceback.print_exc()) + logger.error('%s : %s', e.__class__.__name__, e) + logger.error("%s", traceback.print_exc()) rc = FAIL return rc setattr(do_try, 'options', options) diff -r 1bb347c22e6e -r dd59a8d6a123 suites/libvirt-cim/lib/XenKvmLib/test_xml.py --- a/suites/libvirt-cim/lib/XenKvmLib/test_xml.py Mon Feb 09 21:47:35 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/test_xml.py Wed Feb 11 00:10:44 2009 -0800 @@ -48,7 +48,8 @@ def testxml(test_dom="domU1", mem = 128, vcpus = 1, mac = default_mac, \ disk_file_path = disk_path, disk = "xvda"): if not (os.path.exists(kernel_path) and os.path.exists(init_path)) : - logger.error("ERROR: Either the kernel image or the init_path does not exist") + logger.error("ERROR: Either the kernel image or the \ + init_path does not exist") sys.exit(SKIP) test_xml = """ <domain type='xen' id='23'> @@ -76,8 +77,8 @@ </disk> </devices> </domain> - """ % ( test_dom, set_uuid(), kernel_path, init_path, mem*1024, vcpus, mac, \ - disk_file_path, disk ) + """ % ( test_dom, set_uuid(), kernel_path, init_path, mem*1024, vcpus, \ + mac, disk_file_path, disk ) return test_xml def testxml_bl(test_dom="domU1", mem = 128, vcpus = 1, mac = default_mac, \ @@ -88,7 +89,8 @@ specify either localhost or remote machine ip/name " ) sys.exit(SKIP) if not (os.path.exists(kernel_path) and os.path.exists(init_path)) : - logger.error("ERROR: Either the kernel image or the init_path does not exist") + logger.error("ERROR: Either the kernel image or the \ + init_path does not exist") sys.exit(SKIP) test_xml = """ <domain type='xen' id='23'> @@ -125,7 +127,8 @@ mac = default_mac, disk_file_path = disk_path, disk = "xvda", server = ""): if not (os.path.exists(kernel_path) and os.path.exists(init_path)) : - logger.error("ERROR: Either the kernel image or the init_path does not exist") + logger.error("ERROR: Either the kernel image or the \ + init_path does not exist") sys.exit(SKIP) vir_network = net_list(server) if len(vir_network) > 0 : @@ -140,7 +143,8 @@ net_xml, bridge = netxml(server, bridgename, networkname) ret = create_vnet(server, net_xml) if not ret: - logger.error("Failed to create the Virtual Network '%s'", networkname) + logger.error("Failed to create the Virtual Network '%s'", + networkname) sys.exit(SKIP) test_xml = """ @@ -179,7 +183,8 @@ if bridgename in bridges: bridge_name = bridgename + str(random.randint(1, 100)) if bridge_name in bridges: - logger.error("Need to give different bridge name since it alreay exists") + logger.error("Need to give different bridge name since \ + it alreay exists") sys.exit(SKIP) else: bridge_name = bridgename diff -r 1bb347c22e6e -r dd59a8d6a123 suites/libvirt-cim/lib/XenKvmLib/vsmigrations.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsmigrations.py Mon Feb 09 21:47:35 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsmigrations.py Wed Feb 11 00:10:44 2009 -0800 @@ -78,7 +78,7 @@ DestinationHost=ip) except Exception, details: logger.error("Error invoke 'CheckVirtualSystemIsMigratableToHost\'.") - logger.error("%s" % details) + logger.error("%s", details) return FAIL if rc == None or rc[1]['IsMigratable'] != True: @@ -142,7 +142,7 @@ status = FAIL if status != PASS: - logger.error("%s migrate failed" % test_dom) + logger.error("%s migrate failed", test_dom) return FAIL return PASS @@ -155,7 +155,7 @@ for i in range(0, 50): if job_inst.JobState == 7: if job_inst.Status != "Completed": - logger.error("%s migrate failed" % test_dom) + logger.error("%s migrate failed", test_dom) return FAIL list_after = domain_list(ip) status = verify_domain_list(list_after, local_migrate, test_dom) diff -r 1bb347c22e6e -r dd59a8d6a123 suites/libvirt-cim/lib/XenKvmLib/vsms_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Mon Feb 09 21:47:35 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Wed Feb 11 00:10:44 2009 -0800 @@ -28,7 +28,7 @@ get_bridge_from_network_xml def print_mod_err_msg(func_str, details): - logger.error('Error invoking ModifyRS: %s' % func_str) + logger.error('Error invoking ModifyRS: %s', func_str) logger.error(details) def mod_disk_res(server, service, cxml, dasd, ndpath): @@ -37,7 +37,7 @@ cxml.dumpxml(server) dpath = cxml.xml_get_disk_source() if dpath != ndpath: - logger.error("Got %s, exp %s." % (dpath, ndpath)) + logger.error("Got %s, exp %s.", dpath, ndpath) raise Exception('Error changing rs for disk path') logger.info('good status for disk path') except Exception, details: @@ -61,8 +61,8 @@ name = network_by_bridge(br_name, server, virt) if type != ntype or name != net_name: - logger.error('Got %s, exp %s. Got %s, exp %s' % - (type, ntype, name, net_name)) + logger.error('Got %s, exp %s. Got %s, exp %s', + type, ntype, name, net_name) raise Exception('Error changing rs for net mac') logger.info('good status for net mac') except Exception, details: @@ -77,7 +77,7 @@ cxml.dumpxml(server) mem = cxml.xml_get_mem() if int(mem) != int(nmem) * 1024: - logger.error("Got %d, exp %d." % (int(mem), (int(nmem) * 1024))) + logger.error("Got %d, exp %d.", int(mem), (int(nmem) * 1024)) raise Exception('Error changing rs for mem') logger.info('good status for mem') except Exception, details: @@ -96,7 +96,7 @@ logger.info("Unable to get vcpuinfo from virsh, using XML values") cpu = cxml.xml_get_vcpu() if int(cpu) != int(ncpu): - logger.error("Got %d, exp %d." % (int(cpu), int(ncpu))) + logger.error("Got %d, exp %d.", int(cpu), int(ncpu)) raise Exception('Error changing rs for vcpu') logger.info('good status for vcpu') except Exception, details: @@ -106,7 +106,7 @@ return PASS def print_add_err_msg(func_str, details): - logger.error('Error invoking AddRS: %s' % func_str) + logger.error('Error invoking AddRS: %s', func_str) logger.error(details) def add_disk_res(server, service, cxml, vssd_ref, dasd, attr): @@ -119,8 +119,8 @@ dpath = cxml.get_value_xpath( '/domain/devices/disk/source/@file[. = "%s"]' % attr['src_path']) if disk_dev != attr['nddev'] or dpath != attr['src_path']: - logger.error("Got %s, exp %s. Got %s, exp %s" % (disk_dev, - attr['nddev'], dpath, attr['src_path'])) + logger.error("Got %s, exp %s. Got %s, exp %s", disk_dev, + attr['nddev'], dpath, attr['src_path']) raise Exception('Error adding rs for disk_dev') logger.info('good status for disk path') except Exception, details: @@ -154,8 +154,8 @@ name = attr['net_name'] if mac != attr['nmac'] or name != attr['net_name']: - logger.error("Got %s, exp %s. Got %s, exp %s." % (mac, - attr['nmac'], name, attr['net_name'])) + logger.error("Got %s, exp %s. Got %s, exp %s.", mac, + attr['nmac'], name, attr['net_name']) raise Exception('Error adding rs for net mac') logger.info('good status for net_mac') diff -r 1bb347c22e6e -r dd59a8d6a123 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon Feb 09 21:47:35 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Feb 11 00:10:44 2009 -0800 @@ -525,14 +525,14 @@ ResourceSettings=res_settings, ReferenceConfiguration=ref_conf) except pywbem.CIMError, (rc, desc): - logger.error('Got CIM error %s with return code %s' % (desc, rc)) + logger.error('Got CIM error %s with return code %s', desc, rc) self.err_rc = rc self.err_desc = desc return False except Exception, details: - logger.error('Got error %s with exception %s' \ - % (details, details.__class__.__name__)) + logger.error('Got error %s with exception %s', + details, details.__class__.__name__) return False set_uuid(viruuid(self.domain_name, ip, self.virt)) @@ -546,15 +546,15 @@ try: ret = service.DestroySystem(AffectedSystem=target) except pywbem.CIMError, (rc, desc): - logger.error('Got CIM error %s with return code %s' % (desc, rc)) + logger.error('Got CIM error %s with return code %s', desc, rc) self.err_rc = rc self.err_desc = desc return False except Exception, details: logger.error('Error invoking DestroySystem') - logger.error('Got error %s with exception %s' \ - % (details, details.__class__.__name__)) + logger.error('Got error %s with exception %s', + details, details.__class__.__name__) return False return ret[0] == 0 @@ -580,7 +580,7 @@ except Exception, detail: logger.error("Unable to check guest state") - logger.error("Exception: %s" % detail) + logger.error("Exception: %s", detail) return FAIL return PASS @@ -604,7 +604,7 @@ TimeoutPeriod=time_period) except pywbem.CIMError, (rc, desc): - logger.error('Got CIM error %s with return code %s' % (desc, rc)) + logger.error('Got CIM error %s with return code %s', desc, rc) self.err_rc = rc self.err_desc = desc return FAIL