# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1233646768 28800
# Node ID 847fc58984293f69ef35a4c5294737cf1f8e7156
# Parent 912b7615d48c8303fd3daa6e55669c6d66af23e4
[TEST]Fixing VSMS/05_migratable_host_errs.py tc by modifying it to use cim_define() and
cim_start().
Also,
1) removed unnecessary import statements, Exception block.
2) Used meaningful variable names
3) Indented the tc to fit in 80 columns.
4) Added the missing destroy and undefine() calls.
Tested for Xen with current sources.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 912b7615d48c -r 847fc5898429
suites/libvirt-cim/cimtest/VirtualSystemMigrationService/05_migratable_host_errs.py
---
a/suites/libvirt-cim/cimtest/VirtualSystemMigrationService/05_migratable_host_errs.py Mon
Feb 02 04:45:23 2009 -0800
+++
b/suites/libvirt-cim/cimtest/VirtualSystemMigrationService/05_migratable_host_errs.py Mon
Feb 02 23:39:28 2009 -0800
@@ -21,14 +21,12 @@
#
import sys
-import pywbem
from pywbem.cim_obj import CIMInstanceName
-from VirtLib import utils
from XenKvmLib import vxml
from XenKvmLib import vsmigrations
from CimTest.Globals import logger
from XenKvmLib.const import do_main
-from CimTest.ReturnCodes import PASS, FAIL, XFAIL
+from CimTest.ReturnCodes import PASS, FAIL
sup_types = ['Xen', 'XenFV']
@@ -39,49 +37,57 @@ exp_desc = 'Missing key (Name) in Comput
@do_main(sup_types)
def main():
options = main.options
+ server = options.ip
virt_xml = vxml.get_class(options.virt)
cxml = virt_xml(test_dom)
- ret = cxml.create(options.ip)
+ ret = cxml.cim_define(server)
if not ret:
- logger.error("Error create domain %s" % test_dom )
+ logger.error("Error define domain %s" % test_dom )
return FAIL
+ status = cxml.cim_start(server)
+ if status != PASS:
+ cxml.undefine(server)
+ logger.error("Error start domain %s" % test_dom )
+ return status
+
status = FAIL
- rc = -1
+ mig_successful = False
try:
- service = vsmigrations.Xen_VirtualSystemMigrationService(options.ip)
+ service = vsmigrations.Xen_VirtualSystemMigrationService(server)
except Exception:
- logger.error("Error when go to the class of
Xen_VirtualSystemMigrationService")
+ logger.error("Error using Xen_VirtualSystemMigrationService")
+ cxml.destroy(server)
+ cxml.undefine(server)
return FAIL
classname = 'Xen_ComputerSystem'
- cs_ref = CIMInstanceName(classname, keybindings = {
- 'Wrong':test_dom,
- 'CreationClassName':classname})
+ cs_ref = CIMInstanceName(classname,
+ keybindings = { 'Wrong':test_dom,
+ 'CreationClassName':classname})
try:
service.CheckVirtualSystemIsMigratableToHost(ComputerSystem=cs_ref,
- DestinationHost=options.ip)
+ DestinationHost=server)
service.MigrateVirtualSystemToHost(ComputerSystem=cs_ref,
- DestinationHost=options.ip)
- rc = 0
- except pywbem.CIMError, (rc, desc):
+ DestinationHost=server)
+ mig_successful = True
+ except Exception, (rc, desc):
if rc == exp_rc and desc.find(exp_desc) >= 0:
- logger.info('Got expected rc code and error string.')
+ logger.info('Got expected rc code :%s', rc)
+ logger.info('Got expected error string:%s', desc)
status = PASS
else:
- logger.error('Unexpected rc code %s and description:\n %s' % (rc,
desc))
- except Exception, details:
- logger.error('Unknown exception happened')
- logger.error(details)
+ logger.error('Unexpected rc code %s and description: %s', rc, desc)
- if rc == 0:
- logger.error('Migrate to host method should NOT return OK with a wrong key
input')
+ if mig_successful == True:
+ logger.error('Migrate to host method should NOT return OK '
+ 'since wrong key was supplied')
- cxml.destroy(options.ip)
- cxml.undefine(options.ip)
+ cxml.destroy(server)
+ cxml.undefine(server)
return status
Show replies by date