[Libvirt-cim] [PATCH] [TEST] #3 Add tc to verify VSMS.RemoveResourceSettings() with correct resource

yunguol at cn.ibm.com yunguol at cn.ibm.com
Wed Mar 18 02:23:24 UTC 2009


# HG changeset patch
# User Guolian Yun <yunguol at cn.ibm.com>
# Date 1237342979 25200
# Node ID fc062835ef35568b7379edb2e99f173f7833d3a6
# Parent  daccd46e12ccf2afce3295a41510d7e94ff48d7b
[TEST] #3 Add tc to verify VSMS.RemoveResourceSettings() with correct resource



Updates from 2 to 3:
1) Capture the return of RemoveResourceSettings() and check for an error.
2) Verify InputRASD

Updates from 1 to 2:
Get RASD instances by SystemDevice and SettingsDefineState associaton

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

diff -r daccd46e12cc -r fc062835ef35 suites/libvirt-cim/cimtest/VirtualSystemManagementService/16_removeresource.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/16_removeresource.py	Tue Mar 17 19:22:59 2009 -0700
@@ -0,0 +1,112 @@
+#!/usr/bin/python
+#
+# Copyright 2009 IBM Corp.
+#
+# Authors:
+#    Guolian Yun <yunguol at cn.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
+#
+
+import sys
+from XenKvmLib.vsms import get_vsms_class
+from XenKvmLib.vxml import get_class
+from XenKvmLib.classes import get_typed_class
+from XenKvmLib.assoc import AssociatorNames
+from CimTest.Globals import logger
+from XenKvmLib.const import do_main, get_provider_version
+from CimTest.ReturnCodes import FAIL, PASS
+
+sup_types = ['Xen', 'KVM', 'XenFV']
+default_dom = 'domain'
+rem_res_err_rev_start = 779
+rem_res_err_rev_end = 828
+ntype = 'network'
+nmac = '00:11:22:33:44:55'
+
+ at do_main(sup_types)
+def main():
+    options = main.options
+
+    if options.virt == 'KVM':
+        nddev = 'hdb'
+    else:
+        nddev = 'xvdb'
+
+    cxml = get_class(options.virt)(default_dom, disk=nddev, mac=nmac)
+    ret = cxml.cim_define(options.ip)
+    if not ret:
+        logger.error("Failed to define the dom: %s", default_dom)
+        return FAIL
+   
+    try:
+        # Get system devices through SystemDevice assocation
+        sd_classname = get_typed_class(options.virt, 'SystemDevice')
+        cs_classname = get_typed_class(options.virt, 'ComputerSystem')
+
+        devs = AssociatorNames(options.ip, sd_classname, cs_classname,
+                               Name=default_dom, CreationClassName=cs_classname)
+        
+        if len(devs) == 0:
+            raise Exception("No devices returned")
+
+        # Get RASD instances through SettingsDefineState
+        sds_classname = get_typed_class(options.virt, 'SettingsDefineState')
+        mem = get_typed_class(options.virt, 'Memory')
+        proc = get_typed_class(options.virt, 'Processor')
+        dev_not_rem = [mem, proc] 
+                
+        service = get_vsms_class(options.virt)(options.ip)
+        for dev in devs:
+            if dev['CreationClassName'] in dev_not_rem:
+                continue
+            else:
+                ccn = dev['CreationClassName']
+                sccn = dev['SystemCreationClassName']
+                rasd = AssociatorNames(options.ip, sds_classname, ccn,
+                                       DeviceID = dev['DeviceID'],
+                                       CreationClassName = ccn,
+                                       SystemName = dev['SystemName'],
+                                       SystemCreationClassName = sccn)
+                if len(rasd) != 1:
+                    raise Exception("%i RASD insts for %s", len(rasd), dev.DeviceID)
+                # Invoke RemoveResourceSettings() to remove resource
+                ret = service.RemoveResourceSettings(ResourceSettings=[rasd[0]])
+                if ret[0] != 0:
+                    raise Exception("Remove %s error, please check", rasd[0])
+    except Exception, details:       
+        logger.error(details)
+        cxml.undefine(options.ip)
+        return FAIL
+
+    cxml.dumpxml(options.ip) 
+    device = cxml.get_value_xpath('/domain/@devices')
+    curr_cim_rev, changeset = get_provider_version(options.virt, options.ip)
+
+    if device == None:
+        return PASS
+    elif device != None and curr_cim_rev >= rem_res_err_rev_start and\
+        curr_cim_rev < rem_res_err_rev_end:
+        return SKIP
+    else:
+        logger.error('The devices are not removed successfully')
+        cxml.undefine(options.ip)
+        return FAIL
+
+    cxml.undefine(options.ip)
+    return PASS
+
+if __name__ == "__main__":
+    sys.exit(main())




More information about the Libvirt-cim mailing list