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

yunguol at cn.ibm.com yunguol at cn.ibm.com
Wed Mar 11 08:13:23 UTC 2009


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


This tc verify disk and network devices now, follow up patch will verify input and graphics devices

Tested for KVM/Xen/XenFV with current sources and rpm

Signed-off-by: Guolian Yun<yunguol at cn.ibm.com>

diff -r a78b6f23ebaa -r 0e350cf7bbab 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	Wed Mar 11 01:13:16 2009 -0700
@@ -0,0 +1,109 @@
+#!/usr/bin/python
+#
+# Copyright 2008 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
+import pywbem
+import random
+from pywbem.cim_obj import CIMInstanceName
+from XenKvmLib import vsms
+from XenKvmLib import vxml
+from XenKvmLib.classes import get_typed_class
+from CimTest.Globals import logger
+from XenKvmLib.const import do_main, get_provider_version, default_network_name
+from CimTest.ReturnCodes import FAIL, PASS
+from XenKvmLib.common_util import create_netpool_conf, destroy_netpool
+from XenKvmLib.xm_virt_util import get_bridge_from_network_xml
+
+sup_types = ['Xen', 'KVM', 'XenFV']
+default_dom = 'domain'
+libvirt_cim_dev_xml = 828
+ntype = 'network'
+nmac = '00:11:22:33:44:55'
+npool_name = default_network_name + str(random.randint(1, 100))
+
+ at do_main(sup_types)
+def main():
+    options = main.options
+
+    if options.virt == 'KVM':
+        nddev = 'hdb'
+    else:
+        nddev = 'xvdb'
+
+    cxml = vxml.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
+
+    drasd = get_typed_class(options.virt, 'DiskResourceAllocationSettingData')
+    drasd_id = '%s/%s' % (default_dom, nddev)
+    dkeys = {'InstanceID' : drasd_id}
+   
+    nrasd = get_typed_class(options.virt, 'NetResourceAllocationSettingData')
+    nrasd_id = '%s/%s' % (default_dom, nmac)
+    nkeys = {'InstanceID' : nrasd_id}
+
+    status, net_name = create_netpool_conf(options.ip, options.virt,
+                                           use_existing=False,
+                                           net_name=npool_name)
+    if status != PASS:
+        logger.error('Unable to create network pool')
+        return FAIL
+
+    dresource = CIMInstanceName(drasd, keybindings = dkeys)
+    nresource = CIMInstanceName(nrasd, keybindings = nkeys)
+
+    service = vsms.get_vsms_class(options.virt)(options.ip) 
+    try:
+        service.RemoveResourceSettings(ResourceSettings=[dresource, nresource])
+    except Exception, details:
+        logger.error('Failed to remove % or %s', dresource, nresource)
+        logger.error(details)
+        cxml.undefine(options.ip)
+        destroy_netpool(options.ip, options.virt, net_name)
+        return FAIL
+    
+    cxml.dumpxml(options.ip) 
+    disk = cxml.get_value_xpath('/domain/devices/disk/target/@dev[. = "%s"]'
+                                % nddev)
+    if options.virt == 'KVM':
+        net = cxml.get_value_xpath(
+              '/domain/devices/interface/source/@network[. = "%s"]' % nmac)
+    else:
+        br = get_bridge_from_network_xml(net_name, options.ip, options.virt)
+        net = cxml.get_value_xpath(
+              '/domain/devices/interface/source/@bridge[. = "%s"]' % br)
+
+    curr_cim_rev, changeset = get_provider_version(options.virt, options.ip) 
+    if disk != None and net != None and curr_cim_rev >= libvirt_cim_dev_xml:
+        logger.error('The resource is not removerd successfully')
+        cxml.undefine(options.ip)
+        destroy_netpool(options.ip, options.virt, net_name)
+        return FAIL
+
+    cxml.undefine(options.ip)
+    destroy_netpool(options.ip, options.virt, net_name)
+    return PASS
+
+if __name__ == "__main__":
+    sys.exit(main())




More information about the Libvirt-cim mailing list