[Libvirt-cim] [PATCH 3 of 3] [TEST] Fix VSMS 08_modifyresource.py on Xen and KVM

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Wed Jun 11 03:27:15 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1213154736 25200
# Node ID 9f168dca6251330adcb158f6b64fea51ee72d45e
# Parent  c6fdcb5088bbe504097625265a0d8fc0c4ed73c9
[TEST] Fix VSMS 08_modifyresource.py on Xen and KVM.

This still fails on XenFV because of a provider bug.  It looks like the ModifyResource call strips the <emulator> tag from a XenFV guest.  So the test is unable to start the guest.

Updates to this test:
  -Call create_netpool_conf() to create a new network pool to use in modify calls.
  -Create network RASD instead of bridge
  -Replaced modify calls with functions from vsms_util
  -Added support for modifying a running guest (mem and vcpu only)
  -Remove XFAIL

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r c6fdcb5088bb -r 9f168dca6251 suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py	Tue Jun 10 18:26:16 2008 -0700
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/08_modifyresource.py	Tue Jun 10 20:25:36 2008 -0700
@@ -26,19 +26,25 @@
 import pywbem
 from pywbem.cim_obj import CIMInstanceName
 from VirtLib import utils
+from VirtLib.live import network_by_bridge
 from XenKvmLib import vsms
 from XenKvmLib import vxml
 from CimTest.Globals import logger
 from CimTest.Globals import do_main
 from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
+from XenKvmLib.common_util import create_netpool_conf, destroy_netpool
+from XenKvmLib import vsms_util
 
 sup_types = ['Xen', 'KVM', 'XenFV']
 default_dom = 'rstest_domain'
-ntype = 'bridge'
+ntype = 'network'
 ncpu = 3
 nmem = 78
 
-bug_cpu = '90079'
+def cleanup_env(ip, virt, cxml, net_name):
+    destroy_netpool(ip, virt, net_name)
+    cxml.destroy(ip)
+    cxml.undefine(ip)
 
 @do_main(sup_types)
 def main():
@@ -50,54 +56,65 @@
     dasd = vsms.get_dasd_class(options.virt)(dev=cxml.xml_get_disk_dev(),
                                              source=ndpath, 
                                              name=default_dom)
+    
+    status, net_name = create_netpool_conf(options.ip, options.virt, 
+                                           use_existing=False)
+    if status != PASS:
+        logger.error('Unable to create network pool')
+        return FAIL 
+
     nasd = vsms.get_nasd_class(options.virt)(type=ntype, 
                                              mac=cxml.xml_get_net_mac(),
-                                             name=default_dom)
+                                             name=default_dom,
+                                             virt_net=net_name)
     masd = vsms.get_masd_class(options.virt)(megabytes=nmem, name=default_dom)
     pasd = vsms.get_pasd_class(options.virt)(vcpu=ncpu, name=default_dom)
 
     status = FAIL
     rc = 0
-    try:
-        cxml.define(options.ip)
-        # Modify disk setting
-        service.ModifyResourceSettings(ResourceSettings = [str(dasd)])
-        cxml.dumpxml(options.ip)
-        dpath = cxml.xml_get_disk_source()
-        if dpath != ndpath:
-            raise Exception('Error changing rs for disk path')
-        logger.info('good status for disk path')
-        # Modify net setting
-        service.ModifyResourceSettings(ResourceSettings = [str(nasd)])
-        cxml.dumpxml(options.ip)
-        type = cxml.xml_get_net_type()
-        if type != ntype:
-            raise Exception('Error changing rs for net mac')
-        logger.info('good status for net mac')
-        # Modify memory resource setting
-        service.ModifyResourceSettings(ResourceSettings=[str(masd)])
-        cxml.dumpxml(options.ip)
-        mem = cxml.xml_get_mem()
-        if mem != '%i' % (nmem * 1024):
-            raise Exception('Error changing rs for mem')
-        logger.info('good status for mem')
-        # Modify cpu setting
-        service.ModifyResourceSettings(ResourceSettings = [str(pasd)])
-        cxml.dumpxml(options.ip)
-        cpu = cxml.xml_get_vcpu()
-        if cpu != '%i' % ncpu:
-            rc = -1
-            raise Exception('Error changing rs for vcpu')
-        logger.info('good status for vcpu')
-        status = PASS
-    except Exception, details:
-        logger.error('Error invoking ModifyRS')
-        logger.error(details)
-        return FAIL
+  
+    if options.virt == "KVM":
+        test_cases = ["define"]
+    else:
+        test_cases = ["define", "start"]
 
-    cxml.undefine(options.ip)
-    if rc == -1:
-        return XFAIL_RC(bug_cpu)
+    for case in test_cases:
+        cxml.undefine(options.ip)
+        ret = cxml.define(options.ip)
+        if not ret:
+            logger.error("Failed to define the dom: %s", default_dom)
+            cleanup_env(options.ip, options.virt, cxml, net_name)
+            return FAIL
+        if case == "start":
+            ret = cxml.start(options.ip)
+            if not ret:
+                logger.error("Failed to start the dom: %s", default_dom)
+                cleanup_env(options.ip, options.virt, cxml, net_name)
+                return FAIL
+
+        status = vsms_util.mod_vcpu_res(options.ip, service, cxml, pasd, ncpu)
+        if status != PASS:
+            break
+
+        status = vsms_util.mod_mem_res(options.ip, service, cxml, masd, nmem)
+        if status != PASS:
+            break
+
+        #Unable to modify net and disk devices while guest is running
+        if case == "start":
+            break
+
+        status = vsms_util.mod_disk_res(options.ip, service, cxml, dasd, ndpath)
+        if status != PASS:
+            break
+
+        status = vsms_util.mod_net_res(options.ip, service, options.virt, cxml,
+                                       nasd, ntype, net_name)
+        if status != PASS:
+            break
+
+    cleanup_env(options.ip, options.virt, cxml, net_name)
+    destroy_netpool(options.ip, options.virt, net_name)
 
     return status
 




More information about the Libvirt-cim mailing list