# HG changeset patch
# User Yun Guo Lian <yunguol(a)cn.ibm.com>
# Date 1242728480 25200
# Node ID 8de9a3fab292ea47563bc3c3617c7a8f9ea6753b
# Parent 6dc2d815e480237c91115cd0d86f6325503e33f7
[TEST] #4 Update RPCS/04 with the latest updates of pool verification
Tested for KVM with current sources
Signed-off-by: Guolian Yun<yunguol(a)cn.ibm.com
diff -r 6dc2d815e480 -r 8de9a3fab292
suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py
---
a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py Sun
May 17 23:34:58 2009 -0700
+++
b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/04_CreateChildResourcePool.py Tue
May 19 03:21:20 2009 -0700
@@ -39,45 +39,71 @@
# OUT -- Error -- String -- Encoded error instance if the operation
# failed and did not return a job
#
-# REVISIT :
-# --------
-# As of now the CreateChildResourcePool() simply throws an Exception.
-# We must improve this tc once the service is implemented.
-#
-# -Date:
20.02.2008
-
+# Exception details before Revision 837
+# -----
+# Error code: CIM_ERR_NOT_SUPPORTED
+#
+# After revision 837, the service is implemented
+#
+# -Date: 20.02.2008
import sys
-import pywbem
-from XenKvmLib import rpcs_service
+import random
from CimTest.Globals import logger
from CimTest.ReturnCodes import FAIL, PASS
from XenKvmLib.const import do_main, platform_sup
from XenKvmLib.classes import get_typed_class
+from XenKvmLib.common_util import destroy_netpool
+from XenKvmLib.pool import create_netpool, verify_pool, undefine_netpool
-cim_errno = pywbem.CIM_ERR_NOT_SUPPORTED
-cim_mname = "CreateChildResourcePool"
+test_pool = "testpool"
@do_main(platform_sup)
def main():
options = main.options
- rpcs_conn = eval("rpcs_service." + get_typed_class(options.virt, \
- "ResourcePoolConfigurationService"))(options.ip)
- try:
- rpcs_conn.CreateChildResourcePool()
- except pywbem.CIMError, (err_no, desc):
- if err_no == cim_errno :
- logger.info("Got expected exception for '%s' service",
cim_mname)
- logger.info("Errno is '%s' ", err_no)
- logger.info("Error string is '%s'", desc)
- return PASS
- else:
- logger.error("Unexpected rc code %s and description %s\n",
- err_no, desc)
+
+ np = get_typed_class(options.virt, 'NetworkPool')
+ np_id = "NetworkPool/%s" % test_pool
+
+ subnet = '192.168.0.'
+ ip_base = random.randint(1, 100)
+ addr = subnet+'%d' % ip_base
+ range_addr_start = subnet+'%d' % (ip_base + 1)
+ range_addr_end = subnet+'%d' %(ip_base + 10)
+ pool_attr = {
+ "Address" : addr,
+ "Netmask" : "255.255.255.0",
+ "IPRangeStart" : range_addr_start,
+ "IPRangeEnd" : range_addr_end
+ }
+ for item in range(0, 3):
+ status = create_netpool(options.ip, options.virt,
+ test_pool, pool_attr, mode_type=item)
+ if status != PASS:
+ logger.error("Error in networkpool creation")
return FAIL
-
- logger.error("The execution should not have reached here!!")
- return FAIL
+
+ status = verify_pool(options.ip, options.virt, np,
+ test_pool, pool_attr, mode_type=item)
+ if status != PASS:
+ logger.error("Error in networkpool verification")
+ destroy_netpool(options.ip, options.virt, test_pool)
+ undefine_netpool(options.ip, options.virt, test_pool)
+ return FAIL
+
+ status = destroy_netpool(options.ip, options.virt, test_pool)
+ if status != PASS:
+ logger.error("Unable to destroy networkpool %s", test_pool)
+ return FAIL
+
+ status = undefine_netpool(options.ip, options.virt, test_pool)
+ if status != PASS:
+ logger.error("Unable to undefine networkpool %s", test_pool)
+ return FAIL
+
+ status = PASS
+
+ return status
+
if __name__ == "__main__":
sys.exit(main())
-
diff -r 6dc2d815e480 -r 8de9a3fab292 suites/libvirt-cim/lib/XenKvmLib/pool.py
--- a/suites/libvirt-cim/lib/XenKvmLib/pool.py Sun May 17 23:34:58 2009 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/pool.py Tue May 19 03:21:20 2009 -0700
@@ -144,7 +144,7 @@
return PASS
-def create_netpool(server, virt, test_pool, pool_attr_list):
+def create_netpool(server, virt, test_pool, pool_attr_list, mode_type=0):
status = PASS
rpcs = get_typed_class(virt, "ResourcePoolConfigurationService")
rpcs_conn = eval("rpcs_service." + rpcs)(server)
@@ -177,11 +177,14 @@
logger.error("We can not get NetPoolRASDs")
return FAIL
else:
- net_pool_rasds[0]['PoolID'] = "NetworkPool/%s" % test_pool
- for attr, val in pool_attr_list.iteritems():
- net_pool_rasds[0][attr] = val
-
- pool_settings = inst_to_mof(net_pool_rasds[0])
+ for i in range(0, len(net_pool_rasds)):
+ if net_pool_rasds[i]['ForwardMode'] == mode_type:
+ net_pool_rasds[i]['PoolID'] = "NetworkPool/%s" %
test_pool
+ for attr, val in pool_attr_list.iteritems():
+ net_pool_rasds[i][attr] = val
+ break
+
+ pool_settings = inst_to_mof(net_pool_rasds[i])
try:
rpcs_conn.CreateChildResourcePool(ElementName=test_pool,
@@ -194,7 +197,7 @@
return status
-def verify_pool(server, virt, pooltype, poolname, pool_attr_list):
+def verify_pool(server, virt, pooltype, poolname, pool_attr_list, mode_type=0):
status = FAIL
pool_list = EnumInstances(server, pooltype)
if len(pool_list) < 1:
@@ -210,6 +213,15 @@
net_xml = NetXML(server, virt=virt, networkname=poolname,
is_new_net=False)
+
+ ret_mode = net_xml.xml_get_netpool_mode()
+ if mode_type == 1 and ret_mode != "nat":
+ logger.error("Got error when verify nat type")
+ return FAIL
+ elif mode_type == 2 and ret_mode != "route":
+ logger.error("Got error when verify route type")
+ return FAIL
+
ret_pool_attr_list = net_xml.xml_get_netpool_attr_list()
for i in range(0, len(ret_pool_attr_list)):
diff -r 6dc2d815e480 -r 8de9a3fab292 suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Sun May 17 23:34:58 2009 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue May 19 03:21:20 2009 -0700
@@ -271,16 +271,18 @@
npoolname = self.get_value_xpath('/network/name')
return npoolname
+ def xml_get_netpool_mode(self):
+ npoolmode = self.get_value_xpath('/network/forward/@mode')
+ return npoolmode
+
def xml_get_netpool_attr_list(self):
pool_attr_list = []
- npoolmode = self.get_value_xpath('/network/forward/@mode')
npooladdr = self.get_value_xpath('/network/ip/@address')
npoolmask = self.get_value_xpath('/network/ip/@netmask')
npoolstart = self.get_value_xpath('/network/ip/dhcp/range/@start')
npoolend = self.get_value_xpath('/network/ip/dhcp/range/@end')
- pool_attr_list.append(npoolmode)
pool_attr_list.append(npooladdr)
pool_attr_list.append(npoolmask)
pool_attr_list.append(npoolstart)