[Libvirt-cim] [PATCH] [TEST] Add new tc to validate that the Disk child pool can be deleted through the providers

yunguol at cn.ibm.com yunguol at cn.ibm.com
Mon Apr 27 10:17:18 UTC 2009


# HG changeset patch
# User Guolian Yun <yunguol at cn.ibm.com>
# Date 1240827432 25200
# Node ID 43a14ac09f6fe1f55c2be730c62ea2f3fac24140
# Parent  e8dc06eefada41252ba8d27b08fcef8ef6604251
[TEST] Add new tc to validate that the Disk child pool can be deleted through the providers


Tested for KVM with current sources
Signed-off-by: Guolian Yun<yunguol at cn.ibm.com>

diff -r e8dc06eefada -r 43a14ac09f6f suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteResourcePool_Disk.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/09_DeleteResourcePool_Disk.py	Mon Apr 27 03:17:12 2009 -0700
@@ -0,0 +1,121 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+#    Deepti B. Kalakeri<dkalaker at in.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 test case should test the  DeleteResourcePool service 
+# supplied by the RPCS provider. 
+# The DeleteResourcePool is used to delete a resource pool. 
+# DeleteResourcePool() details:
+# Input 
+# -----
+# IN -- Pool -- CIM_ResourcePool REF -- The resource pool to delete 
+# 
+# Output
+# ------
+# OUT -- Job -- CIM_ConcreteJob REF -- Returned job if started
+# OUT -- Error-- String -- Encoded error instance if the operation 
+#                          failed and did not return a job.
+#
+# Exception details before Revision 841
+# -----
+# Error code: CIM_ERR_NOT_SUPPORTED 
+#
+# After revision 841, the service is implemented
+# 
+#                                                  -Date: 20.02.2008
+
+
+import sys
+import pywbem 
+from XenKvmLib import rpcs_service
+from CimTest.Globals import logger, CIM_NS
+from CimTest.ReturnCodes import FAIL, PASS
+from XenKvmLib.const import do_main, platform_sup, get_provider_version
+from pywbem.cim_obj import CIMInstanceName, CIMInstance
+from XenKvmLib.enumclass import EnumInstances
+from XenKvmLib.classes import get_typed_class
+from pywbem.cim_types import Uint16
+
+cim_errno  = pywbem.CIM_ERR_NOT_SUPPORTED
+cim_mname  = "DeleteResourcePool"
+libvirt_cim_child_pool_rev = 841
+test_pool = "dir_pool"
+
+ at do_main(platform_sup)
+def main():
+    status = FAIL
+    options = main.options
+    rpcs_conn = eval("rpcs_service." + get_typed_class(options.virt, \
+                      "ResourcePoolConfigurationService"))(options.ip)
+    curr_cim_rev, changeset = get_provider_version(options.virt, options.ip)
+    if curr_cim_rev < libvirt_cim_child_pool_rev:
+        try:
+            rpcs_conn.DeleteResourcePool()
+        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)
+                return FAIL
+    elif curr_cim_rev >= libvirt_cim_child_pool_rev:
+        dprasd = get_typed_class(options.virt,
+                                 'DiskPoolResourceAllocationSettingData')
+        dp = get_typed_class(options.virt, 'DiskPool')                          
+        dp_id = 'DiskPool/%s' % test_pool
+        iname = CIMInstanceName(dprasd,
+                                namespace = CIM_NS,
+                                keybindings = {'InstanceID':dp_id})
+        dp_prop = {"Path" : "/tmp"}
+        if test_pool == "dir_pool":
+            dp_prop["Type"] = Uint16(1)
+        drasd = CIMInstance(dprasd, path = iname, properties = dp_prop)     
+        try:
+            rpcs_conn.CreateChildResourcePool(ElementName=test_pool,
+                                              Settings=[drasd.tomof()])
+            diskpool = EnumInstances(options.ip, dp)
+            for i in range(0, len(diskpool)):
+                ret_pool = diskpool[i].InstanceID
+                if ret_pool == dp_id:
+                    break
+                elif ret_pool != dp_id and i == len(diskpool) - 1:
+                    raise Exception("Can not find expected pool")
+
+            pool = CIMInstanceName(dp, keybindings = {'InstanceID':dp_id})
+            rpcs_conn.DeleteResourcePool(Pool = pool)
+            diskpool = EnumInstances(options.ip, dp)
+            for i in range(0, len(diskpool)):
+                ret_pool = diskpool[i].InstanceID
+                if ret_pool == dp_id:
+                    raise Exception("Failed to delete %s" % test_pool)
+                    break
+                elif ret_pool != dp_id and i == len(diskpool) -1:
+                    status = PASS
+        except Exception, details:
+            logger.error(details)
+            return status
+                 
+        return status
+if __name__ == "__main__":
+    sys.exit(main())




More information about the Libvirt-cim mailing list