# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1213711825 25200
# Node ID 73d199833bce1a21f374a1c8c95885a749e955cc
# Parent 9700e5130a511e8a5457ba3033eb57d7b0b6a656
[TEST] Fixed the tc 05_RAPF_err.py.
1) Added support for verifying the exception when an invalid network name is passed.
2) Modified get_unique_bridge() to now return non-existing bridgename/networkpoolnmae.
3) Modified the code to occupy 80 columns only.
4) Removed the global declaration of the virt and server and passed them as parameters to
fn instead.
This tc passed on KVM with latest sources and libvirt-cim rpm on F9.
This tc fails for Xen/XenFV when an invalid networkpoolname.
The libvirt does not support definining the Xen/XenFV guest with invalid network name.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 9700e5130a51 -r 73d199833bce
suites/libvirt-cim/cimtest/ResourceAllocationFromPool/05_RAPF_err.py
--- a/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/05_RAPF_err.py Tue Jun 17
06:59:09 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ResourceAllocationFromPool/05_RAPF_err.py Tue Jun 17
07:10:25 2008 -0700
@@ -53,48 +53,65 @@
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 import vxml
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))
+def get_unique_interface(server, virt, nettype='network'):
+ interface = "wrong-int"
+ if nettype == 'bridge':
+ int_list = live.available_bridges(server)
+ else:
+ int_list = live.net_list(server, virt)
+
+ while interface in int_list:
+ interface = interface + str(random.randint(1, 100))
- return bridge
+ return interface
-def setup_env():
+def setup_env(server, virt, nettype='network'):
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)
+ virt_xml = vxml.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)
+ int_name = vsxml_info.xml_get_net_network()
+ if int_name == None:
+ devices = vsxml_info.get_node('/domain/devices')
+ vsxml_info.set_interface_details(devices, test_mac, nettype, virt)
-# Get a bridge name that is not used by any of the virtual network pool on the machine.
- bridge_name = get_unique_bridge()
+ int_name = get_unique_interface(server, virt, nettype)
+ vsxml_net_type = vsxml_info.xml_get_net_type()
+ if vsxml_net_type == 'bridge':
+ vsxml_info.set_bridge_name(int_name)
+ else:
+ vsxml_info.set_net_name(int_name)
-# Assigning the bridge that does not belong to any networkpool.
- vsxml_info.set_bridge_name(bridge_name)
+ if vsxml_net_type != 'bridge' and nettype == 'bridge':
+ vsxml_info.set_nettype(nettype)
+ in_string = 'network="%s"' %int_name
+ out_string = 'bridge="%s"' %int_name
+ vsxml_replace = (vsxml_info.xml_string.replace(in_string, out_string))
+ vsxml_info.xml_string = vsxml_replace
+
ret = vsxml_info.define(server)
if not ret:
- Globals.logger.error("Failed to define the dom: %s", test_dom)
+ Globals.logger.error("Failed to define the dom '%s' for '%s'
type"
+ " interface", test_dom, nettype)
return FAIL, vsxml_info
return PASS, vsxml_info
-def get_inst_from_list(vsxml, classname, rasd_list, filter_name, exp_val):
+def get_inst_from_list(server, vsxml, classname, rasd_list, filter_name,
+ exp_val):
status = PASS
ret = FAIL
inst = []
@@ -112,14 +129,14 @@
return status, inst
-def get_netrasd_instid(vsxml, classname):
+def get_netrasd_instid(server, virt, 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))
+ 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)
@@ -132,21 +149,22 @@
# 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)
+ status, rasd_info = get_inst_from_list(server, vsxml, classname,
+ rasd_list, "InstanceID", test_dom)
return status, rasd_info
-def verify_rapf_err(vsxml):
+def verify_rapf_err(server, virt, vsxml):
status = PASS
try:
classname = get_typed_class(virt, 'NetResourceAllocationSettingData')
- status, net_rasd_list = get_netrasd_instid(vsxml, classname)
+ status, net_rasd_list = get_netrasd_instid(server, virt, 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))
+ logger.error("%s returned %i instances, excepted atleast 1 "
+ "instance", classname, len(net_rasd_list))
return FAIL
@@ -160,12 +178,14 @@
keys = { "InstanceID" : instid }
expr_values = {
'rapf_err' : {
- 'desc' : "Unable to determine pool of
`%s'" %instid,
+ '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="")
+ 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)
@@ -175,21 +195,23 @@
@do_main(platform_sup)
def main():
- global virt, server
options = main.options
server = options.ip
virt = options.virt
destroy_and_undefine_all(server)
+ in_list = [ 'bridge', 'network' ]
- status, vsxml = setup_env()
- if status != PASS:
- logger.error("Failed to setup the domain")
- return status
+ for interface in in_list:
+ status, vsxml = setup_env(server, virt, interface)
+ 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
+ ret = verify_rapf_err(server, virt, vsxml)
+ if ret:
+ logger.error("------FAILED: to verify the RAFP.------")
+ vsxml.undefine(server)
+ return ret
vsxml.undefine(server)
return status