[PATCH] [TEST] add a try..except to get_value_xpath()
by zli@linux.vnet.ibm.com
# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1207733009 -28800
# Node ID 87913147308d5075130dcae5b5648cc3f0158681
# Parent 262153788503c8b10c76c77719bba081df9a7b88
[TEST] add a try..except to get_value_xpath()
A 'None' return is more elegant than a pure exception error.
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r 262153788503 -r 87913147308d suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Apr 08 17:58:44 2008 +0530
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 09 17:23:29 2008 +0800
@@ -115,7 +115,12 @@ class XMLClass:
return self.xdoc.toprettyxml()
def get_value_xpath(self, xpathStr):
- node = self.get_node(xpathStr)
+ try:
+ node = self.get_node(xpathStr)
+ except LoopUpError:
+ raise Exception('Zero or multiple node found')
+ return None
+
if node.nodeType == Node.ATTRIBUTE_NODE:
return node.value
if node.nodeType == Node.TEXT_NODE:
16 years, 8 months
[PATCH] [TEST] Change default KVM emulator to qemu-kvm
by zli@linux.vnet.ibm.com
# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1207709819 25200
# Node ID b5857217c64a081450cd21219035084eac455d85
# Parent 262153788503c8b10c76c77719bba081df9a7b88
[TEST] Change default KVM emulator to qemu-kvm
We're more close to KVM full coverage support. It makes
sense to set the default emulator to a real one instead
of a pure-qemu version.
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r 262153788503 -r b5857217c64a suites/libvirt-cim/lib/XenKvmLib/const.py
--- a/suites/libvirt-cim/lib/XenKvmLib/const.py Tue Apr 08 17:58:44 2008 +0530
+++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Tue Apr 08 19:56:59 2008 -0700
@@ -43,7 +43,7 @@
Xen_default_net_type = 'ethernet'
# vxml.KVMXML
-KVM_default_emulator = '/usr/bin/qemu'
+KVM_default_emulator = '/usr/bin/qemu-kvm'
KVM_disk_path = os.path.join(_image_dir, 'default-kvm-dimage')
KVM_secondary_disk_path = os.path.join(_image_dir, 'default-kvm-dimage.2ND')
KVM_default_disk_dev = 'hda'
16 years, 8 months
[PATCH] [TEST]Adding xml_get_net_bridge() function which returns the bridge info associated with domain
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1207743568 -19800
# Node ID 55d6e89ebb1ad9ae063814807a8ee8a20cb13656
# Parent c1d26f7e6a2223d995264d7cc3f43ec9327b753e
[TEST]Adding xml_get_net_bridge() function which returns the bridge info associated with domain.
This is required by the 05_RAPF_err.py tc.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r c1d26f7e6a22 -r 55d6e89ebb1a suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 09 17:45:41 2008 +0530
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 09 17:49:28 2008 +0530
@@ -342,7 +342,11 @@ class VirtXML(Virsh, XMLClass):
@_x2str('/domain/devices/interface/mac/@address')
def xml_get_net_mac(self):
pass
-
+
+ def xml_get_net_bridge(self):
+ bridgeStr = self.get_value_xpath('/domain/devices/interface/source/@bridge')
+ return bridgeStr
+
def dumpxml(self, ip):
cmd = 'virsh -c %s dumpxml %s' % (self.vuri, self.dname)
s, o = utils.run_remote(ip, cmd)
16 years, 8 months
[PATCH] [TEST] #3 Adding 05_RAPF_err.py to verify RAPF
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1207744214 -19800
# Node ID bbd146681ade6826d2df00853750ea9eac03d6d4
# Parent 55d6e89ebb1ad9ae063814807a8ee8a20cb13656
[TEST] #3 Adding 05_RAPF_err.py to verify RAPF.
1) The test :
creates a guest with a network device that is not part of a known pool.
Then call ResourceAllocatedFromPool with the reference to that device.
Verifies for the error.
2) Used the xml_get_net_bridge() function to verify for the bridge info if already present.
3) Made the set_bridge_name() common to all virt types.
4) Addressed the comments.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 55d6e89ebb1a -r bbd146681ade suites/libvirt-cim/cimtest/ResourceAllocationFromPool/05_RAPF_err.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/05_RAPF_err.py Wed Apr 09 18:00:14 2008 +0530
@@ -0,0 +1,198 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+# 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# This tc is used to verify the that the
+# ResourceAllocationFromPool asscoiation returns error
+# when guest is associated to a non-existing virtual network pool.
+#
+# The does the following:
+# 1) creates a guest with a network device that is not part of a known pool,
+# 2) call ResourceAllocatedFromPool with the reference to that device.
+# 3) Verifies for the following error:
+#
+# Command:
+# --------
+# wbemcli ain -ac KVM_ResourceAllocationFromPool
+# 'http://localhost:5988/root/virt:KVM_NetResourceAllocationSettingData.
+# InstanceID="test-kvm/24:42:53:21:52:45"'
+#
+#
+# Output:
+# -------
+# error no : CIM_ERR_FAILED
+# error desc : "Unable to determine pool of `test-kvm/24:42:53:21:52:45';"
+#
+# Date : 04-04-2008
+#
+import sys
+import pywbem
+import random
+from VirtLib import live
+from XenKvmLib import assoc, enumclass
+from XenKvmLib.common_util import try_assoc
+from XenKvmLib.test_doms import destroy_and_undefine_all
+from CimTest import Globals
+from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
+from CimTest.ReturnCodes import PASS, FAIL
+from CimTest.Globals import do_main, platform_sup
+from XenKvmLib.vxml import get_class
+from XenKvmLib.classes import get_typed_class
+
+test_dom = "RAPF_domain"
+test_mac = "00:11:22:33:44:aa"
+test_vcpus = 1
+
+def get_unique_bridge():
+ bridge = "invalid-bridge"
+ bridge_list = live.available_bridges(server)
+ while bridge in bridge_list:
+ bridge = bridge + str(random.randint(1, 100))
+
+ return bridge
+
+def setup_env():
+ vsxml_info = None
+ if virt == "Xen":
+ test_disk = "xvda"
+ else:
+ test_disk = "hda"
+
+ virt_xml = get_class(virt)
+ vsxml_info = virt_xml(test_dom, vcpus = test_vcpus, mac = test_mac, disk = test_disk)
+
+ bridge = vsxml_info.xml_get_net_bridge()
+ if bridge == None:
+ bridge = vsxml_info.set_vbridge(server)
+
+# Get a bridge name that is not used by any of the virtual network pool on the machine.
+ bridge_name = get_unique_bridge()
+
+# Assigning the bridge that does not belong to any networkpool.
+ vsxml_info.set_bridge_name(bridge_name)
+ ret = vsxml_info.define(server)
+ if not ret:
+ Globals.logger.error("Failed to define the dom: %s", test_dom)
+ return FAIL, vsxml_info
+
+ return PASS, vsxml_info
+
+def get_inst_from_list(vsxml, classname, rasd_list, filter_name, exp_val):
+ status = PASS
+ ret = FAIL
+ inst = []
+
+ for rec in rasd_list:
+ record = rec[filter_name]
+ if exp_val in record:
+ inst.append(rec)
+ ret = PASS
+
+ if ret != PASS:
+ logger.error("%s with %s was not returned" % (classname, exp_val))
+ vsxml.undefine(server)
+ status = FAIL
+
+ return status, inst
+
+def get_netrasd_instid(vsxml, classname):
+ rasd_list = []
+ status = PASS
+ try:
+ rasd_list = enumclass.enumerate_inst(server, classname, virt)
+ if len(rasd_list) < 1:
+ logger.error("%s returned %i instances, excepted atleast 1 instance", classname,
+ len(rasd_list))
+ status = FAIL
+ except Exception, detail:
+ logger.error(CIM_ERROR_ENUMERATE, classname)
+ logger.error("Exception: %s", detail)
+ status = FAIL
+
+ if status != PASS:
+ return status, rasd_list
+
+ # Get the RASD info related to the domain "ONLY".
+ # We should get ONLY one record.
+ rasd_info = []
+ status, rasd_info = get_inst_from_list(vsxml, classname, rasd_list, "InstanceID", test_dom)
+
+ return status, rasd_info
+
+def verify_rapf_err(vsxml):
+ status = PASS
+ try:
+
+ classname = get_typed_class(virt, 'NetResourceAllocationSettingData')
+ status, net_rasd_list = get_netrasd_instid(vsxml, classname)
+ if status != PASS or len(net_rasd_list) == 0:
+ return status
+ if len(net_rasd_list) != 1:
+ logger.error("%s returned %i instances, excepted atleast 1 instance", classname,
+ len(net_rasd_list))
+ return FAIL
+
+
+ conn = assoc.myWBEMConnection('http://%s' % server,
+ (Globals.CIM_USER,
+ Globals.CIM_PASS),
+ Globals.CIM_NS)
+ assoc_classname = get_typed_class(virt, "ResourceAllocationFromPool")
+ classname = net_rasd_list[0].classname
+ instid = net_rasd_list[0]['InstanceID']
+ keys = { "InstanceID" : instid }
+ expr_values = {
+ 'rapf_err' : {
+ 'desc' : "Unable to determine pool of `%s'" %instid,
+ 'rc' : pywbem.CIM_ERR_FAILED
+ }
+ }
+ status = try_assoc(conn, classname, assoc_classname, keys, field_name="InstanceID",
+ expr_values=expr_values['rapf_err'], bug_no="")
+
+ except Exception, detail:
+ logger.error("Exception: %s", detail)
+ status = FAIL
+
+ return status
+
+@do_main(platform_sup)
+def main():
+ global virt, server
+ Globals.log_param()
+ options = main.options
+ server = options.ip
+ virt = options.virt
+ destroy_and_undefine_all(server)
+
+ status, vsxml = setup_env()
+ if status != PASS:
+ logger.error("Failed to setup the domain")
+ return status
+
+ ret = verify_rapf_err(vsxml)
+ if ret:
+ logger.error("------FAILED: to verify the RAFP.------")
+ status = ret
+
+ vsxml.undefine(server)
+ return status
+if __name__ == "__main__":
+ sys.exit(main())
16 years, 8 months
[PATCH] [TEST] Fixing the tc 03_proc_gi_errs.py
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1207742984 -19800
# Node ID 11b2cbd3aaac45ccedf7619d390c236014fd7690
# Parent cc4020f5ed18fa1134b8c63c3c9f9f828d3df23f
[TEST] Fixing the tc 03_proc_gi_errs.py.
It was failing with XenFV.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r cc4020f5ed18 -r 11b2cbd3aaac suites/libvirt-cim/cimtest/Processor/03_proc_gi_errs.py
--- a/suites/libvirt-cim/cimtest/Processor/03_proc_gi_errs.py Wed Apr 09 12:47:44 2008 +0530
+++ b/suites/libvirt-cim/cimtest/Processor/03_proc_gi_errs.py Wed Apr 09 17:39:44 2008 +0530
@@ -5,6 +5,7 @@
# Authors:
# Anoop V Chakkalakkal<anoop.vijayan(a)in.ibm.com>
# Guolian Yun <yunguol(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
@@ -123,11 +124,10 @@
import sys
import pywbem
-from VirtLib import utils
from XenKvmLib import assoc
from XenKvmLib.common_util import try_getinstance
from XenKvmLib.classes import get_typed_class
-from XenKvmLib.vxml import XenXML, KVMXML, get_class
+from XenKvmLib.vxml import get_class
from XenKvmLib.test_doms import destroy_and_undefine_all
from CimTest.ReturnCodes import PASS, FAIL
from CimTest.Globals import log_param, logger, CIM_USER
@@ -137,15 +137,15 @@ sup_types = ['Xen', 'KVM', 'XenFV']
sup_types = ['Xen', 'KVM', 'XenFV']
expr_values = {
- "invalid_ccname" : {'rc' : pywbem.CIM_ERR_NOT_FOUND, \
- 'desc' : "No such instance (CreationClassName)" }, \
- "invalid_devid_keyname" : {'rc' : pywbem.CIM_ERR_FAILED, \
- 'desc' : "No DeviceID specified" }, \
- "invalid_devid_keyvalue" : {'rc' : pywbem.CIM_ERR_NOT_FOUND, \
- 'desc' : "No such instance (INVALID_DevID_Keyvalue)" }, \
- "invalid_sccname" : {'rc' : pywbem.CIM_ERR_NOT_FOUND, \
- 'desc' : "No such instance (SystemCreationClassName)" }, \
- "invalid_sysname" : {'rc' : pywbem.CIM_ERR_NOT_FOUND, \
+ "invalid_ccname" : {'rc' : pywbem.CIM_ERR_NOT_FOUND,
+ 'desc' : "No such instance (CreationClassName)" },
+ "invalid_devid_keyname" : {'rc' : pywbem.CIM_ERR_FAILED,
+ 'desc' : "No DeviceID specified" },
+ "invalid_devid_keyvalue" : {'rc' : pywbem.CIM_ERR_NOT_FOUND,
+ 'desc' : "No such instance (INVALID_DevID_Keyvalue)" },
+ "invalid_sccname" : {'rc' : pywbem.CIM_ERR_NOT_FOUND,
+ 'desc' : "No such instance (SystemCreationClassName)" },
+ "invalid_sysname" : {'rc' : pywbem.CIM_ERR_NOT_FOUND,
'desc' : "No such instance (SystemName)" }
}
@@ -185,27 +185,26 @@ def main():
if not ret:
logger.error("Failed to Create the dom: %s", test_dom)
return FAIL
-
global conn
conn = assoc.myWBEMConnection('http://%s' % options.ip, (CIM_USER, CIM_PASS), CIM_NS)
global name_val
global classname
- classname = '%s_Processor' % options.virt
+ classname = get_typed_class(options.virt, 'Processor')
name_val = [
- 'CreationClassName', classname, \
- 'DeviceID', devid, \
- 'SystemCreationClassName', get_typed_class(options.virt, 'ComputerSystem'), \
+ 'CreationClassName', classname,
+ 'DeviceID', devid,
+ 'SystemCreationClassName', get_typed_class(options.virt, 'ComputerSystem'),
'SystemName', test_dom
]
- tc_scen = { 'INVALID_CCName_Keyname' : 'invalid_ccname', \
- 'INVALID_CCName_Keyvalue' : 'invalid_ccname', \
- 'INVALID_DevID_Keyname' : 'invalid_devid_keyname', \
- 'INVALID_DevID_Keyvalue' : 'invalid_devid_keyvalue', \
- 'INVALID_SCCName_Keyname' : 'invalid_sccname', \
- 'INVALID_SCCName_Keyvalue' : 'invalid_sccname', \
- 'INVALID_SysName_Keyname' : 'invalid_sysname', \
+ tc_scen = { 'INVALID_CCName_Keyname' : 'invalid_ccname',
+ 'INVALID_CCName_Keyvalue' : 'invalid_ccname',
+ 'INVALID_DevID_Keyname' : 'invalid_devid_keyname',
+ 'INVALID_DevID_Keyvalue' : 'invalid_devid_keyvalue',
+ 'INVALID_SCCName_Keyname' : 'invalid_sccname',
+ 'INVALID_SCCName_Keyvalue' : 'invalid_sccname',
+ 'INVALID_SysName_Keyname' : 'invalid_sysname',
'INVALID_SysName_Keyvalue' : 'invalid_sysname'
}
16 years, 8 months
[PATCH] [TEST][Resubmitting]Adding 05_RAPF_err.py to verify RAPF
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1207651996 -19800
# Node ID 6e8932e6628a5475b39e196bb8b5182b5c5a3f11
# Parent 7b3c5acdddf0cb83c8135903b5148962a32cab81
[TEST][Resubmitting]Adding 05_RAPF_err.py to verify RAPF.
1) The test :
creates a guest with a network device that is not part of a known pool.
Then call ResourceAllocatedFromPool with the reference to that device.
Verifies for the error.
2) Addressed the comments.
3) Made the set_bridge_name() common to all virt types.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 7b3c5acdddf0 -r 6e8932e6628a suites/libvirt-cim/cimtest/ResourceAllocationFromPool/05_RAPF_err.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/05_RAPF_err.py Tue Apr 08 16:23:16 2008 +0530
@@ -0,0 +1,196 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+# 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# This tc is used to verify the that the
+# ResourceAllocationFromPool asscoiation returns error
+# when guest is associated to a non-existing virtual network pool.
+#
+# The does the following:
+# 1) creates a guest with a network device that is not part of a known pool,
+# 2) call ResourceAllocatedFromPool with the reference to that device.
+# 3) Verifies for the following error:
+#
+# Command:
+# --------
+# wbemcli ain -ac KVM_ResourceAllocationFromPool
+# 'http://localhost:5988/root/virt:KVM_NetResourceAllocationSettingData.
+# InstanceID="test-kvm/24:42:53:21:52:45"'
+#
+#
+# Output:
+# -------
+# error no : CIM_ERR_FAILED
+# error desc : "Unable to determine pool of `test-kvm/24:42:53:21:52:45';"
+#
+# Date : 04-04-2008
+#
+import sys
+import pywbem
+import random
+from VirtLib import live
+from XenKvmLib import assoc, enumclass
+from XenKvmLib.common_util import try_assoc
+from XenKvmLib.test_doms import destroy_and_undefine_all
+from CimTest import Globals
+from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
+from CimTest.ReturnCodes import PASS, FAIL
+from CimTest.Globals import do_main, platform_sup
+from XenKvmLib.vxml import get_class
+from XenKvmLib.classes import get_typed_class
+
+test_dom = "RAPF_domain"
+test_mac = "00:11:22:33:44:aa"
+test_vcpus = 1
+
+def get_unique_bridge():
+ bridge = "invalid-bridge"
+ bridge_list = live.available_bridges(server)
+ while bridge in bridge_list:
+ bridge = bridge + str(random.randint(1, 100))
+
+ return bridge
+
+def setup_env():
+ vsxml_info = None
+ if virt == "Xen":
+ test_disk = "xvda"
+ else:
+ test_disk = "hda"
+
+ virt_xml = get_class(virt)
+ vsxml_info = virt_xml(test_dom, vcpus = test_vcpus, mac = test_mac, disk = test_disk)
+ bridge = vsxml_info.set_vbridge(server)
+
+# Get a bridge name that is not used by any of the virtual network pool on the machine.
+ bridge_name = get_unique_bridge()
+
+# Assigning the bridge that does not belong to any networkpool.
+ vsxml_info.set_bridge_name(bridge_name)
+
+ ret = vsxml_info.define(server)
+ if not ret:
+ Globals.logger.error("Failed to define the dom: %s", test_dom)
+ return FAIL, vsxml_info
+
+ return PASS, vsxml_info
+
+def get_inst_from_list(classname, rasd_list, filter_name, exp_val):
+ status = PASS
+ ret = FAIL
+ inst = []
+
+ for rec in rasd_list:
+ record = rec[filter_name]
+ if exp_val in record:
+ inst.append(rec)
+ ret = PASS
+
+ if ret != PASS:
+ logger.error("%s with %s was not returned" % (classname, exp_val))
+ vsxml.undefine(server)
+ status = FAIL
+
+ return status, inst
+
+def get_netrasd_instid(classname):
+ rasd_list = []
+ status = PASS
+ try:
+ rasd_list = enumclass.enumerate_inst(server, classname, virt)
+ if len(rasd_list) < 1:
+ logger.error("%s returned %i instances, excepted atleast 1 instance", classname,
+ len(rasd_list))
+ status = FAIL
+ except Exception, detail:
+ logger.error(CIM_ERROR_ENUMERATE, classname)
+ logger.error("Exception: %s", detail)
+ status = FAIL
+
+ if status != PASS:
+ return status, rasd_list
+
+ # Get the RASD info related to the domain "ONLY".
+ # We should get ONLY one record.
+ rasd_info = []
+ status, rasd_info = get_inst_from_list(classname, rasd_list, "InstanceID", test_dom)
+
+ return status, rasd_info
+
+def verify_rapf_err():
+ status = PASS
+ try:
+
+ classname = get_typed_class(virt, 'NetResourceAllocationSettingData')
+ status, net_rasd_list = get_netrasd_instid(classname)
+ if status != PASS or len(net_rasd_list) == 0:
+ return status
+ if len(net_rasd_list) != 1:
+ logger.error("%s returned %i instances, excepted atleast 1 instance", classname,
+ len(net_rasd_list))
+ return FAIL
+
+
+ conn = assoc.myWBEMConnection('http://%s' % server,
+ (Globals.CIM_USER,
+ Globals.CIM_PASS),
+ Globals.CIM_NS)
+ assoc_classname = get_typed_class(virt, "ResourceAllocationFromPool")
+ classname = net_rasd_list[0].classname
+ instid = net_rasd_list[0]['InstanceID']
+ keys = { "InstanceID" : instid }
+ expr_values = {
+ 'rapf_err' : {
+ 'desc' : "Unable to determine pool of `%s'" %instid,
+ 'rc' : pywbem.CIM_ERR_FAILED
+ }
+ }
+ status = try_assoc(conn, classname, assoc_classname, keys, field_name="InstanceID",
+ expr_values=expr_values['rapf_err'], bug_no="")
+
+ except Exception, detail:
+ logger.error("Exception: %s", detail)
+ status = FAIL
+
+ return status
+
+@do_main(platform_sup)
+def main():
+ global virt, vsxml, server
+ Globals.log_param()
+ options = main.options
+ server = options.ip
+ virt = options.virt
+ destroy_and_undefine_all(server)
+
+ status, vsxml = setup_env()
+ if status != PASS:
+ logger.error("Failed to setup the domain")
+ return status
+
+ ret = verify_rapf_err()
+ if ret:
+ logger.error("------FAILED: to verify the RAFP.------")
+ status = ret
+
+ vsxml.undefine(server)
+ return status
+if __name__ == "__main__":
+ sys.exit(main())
16 years, 8 months
[PATCH] [TEST] .#3 add a try..except to get_value_xpath()
by zli@linux.vnet.ibm.com
# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1207740687 -28800
# Node ID 74f907a44c1d7d764aa06a388ae40b5d078c2b6a
# Parent 262153788503c8b10c76c77719bba081df9a7b88
[TEST] .#3 add a try..except to get_value_xpath()
A 'None' return is more elegant than a pure exception error.
Changed to use logger.info
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r 262153788503 -r 74f907a44c1d suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Apr 08 17:58:44 2008 +0530
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 09 19:31:27 2008 +0800
@@ -115,7 +115,12 @@ class XMLClass:
return self.xdoc.toprettyxml()
def get_value_xpath(self, xpathStr):
- node = self.get_node(xpathStr)
+ try:
+ node = self.get_node(xpathStr)
+ except Exception:
+ logger.info('Zero or multiple node found')
+ return None
+
if node.nodeType == Node.ATTRIBUTE_NODE:
return node.value
if node.nodeType == Node.TEXT_NODE:
16 years, 8 months
[PATCH] [TEST] .#2 add a try..except to get_value_xpath()
by zli@linux.vnet.ibm.com
# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1207737380 -28800
# Node ID fb3e043e7425a319730e6e11d05ee031ce4ab1ca
# Parent 262153788503c8b10c76c77719bba081df9a7b88
[TEST] .#2 add a try..except to get_value_xpath()
A 'None' return is more elegant than a pure exception error.
Use logger.error
typo fix. :)
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r 262153788503 -r fb3e043e7425 suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Apr 08 17:58:44 2008 +0530
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 09 18:36:20 2008 +0800
@@ -115,7 +115,12 @@ class XMLClass:
return self.xdoc.toprettyxml()
def get_value_xpath(self, xpathStr):
- node = self.get_node(xpathStr)
+ try:
+ node = self.get_node(xpathStr)
+ except LookUpError:
+ logger.error('Zero or multiple node found')
+ return None
+
if node.nodeType == Node.ATTRIBUTE_NODE:
return node.value
if node.nodeType == Node.TEXT_NODE:
16 years, 8 months