# HG changeset patch
# User Deepti B. Kalakeri<deeptik(a)linux.vnet.ibm.com>
# Date 1220346904 -19800
# Node ID f956aa699a3e3ea6df8f2d6e423ed9cf032d61c5
# Parent 946fd46b96866adaab356876f9c8bbf937f0b3d6
[TEST] Updating VSMC 01_enum.py to verify the SynchronousMethodsSupported values.
Changes
-------
1) Also modified the tc to use do_main from const.py instead of Globals.py.
2) Used print_field_error() to print the error messages.
3) Removed Globals.py.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 946fd46b9686 -r f956aa699a3e
suites/libvirt-cim/cimtest/VirtualSystemManagementCapabilities/01_enum.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementCapabilities/01_enum.py Thu Aug 28
14:07:25 2008 -0700
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementCapabilities/01_enum.py Tue Sep 02
14:45:04 2008 +0530
@@ -23,35 +23,58 @@
#
import sys
+from sets import Set
from XenKvmLib import enumclass
-from CimTest import Globals
-from CimTest.Globals import do_main
+from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
+from XenKvmLib.const import do_main
from XenKvmLib.classes import get_typed_class
+from CimTest.ReturnCodes import PASS, FAIL
+from XenKvmLib.common_util import print_field_error
sup_types=['Xen', 'KVM', 'XenFV', 'LXC']
@do_main(sup_types)
def main():
options = main.options
+ server = options.ip
+ virt = options.virt
+ cn = get_typed_class(virt, 'VirtualSystemManagementCapabilities')
+
+ # Methods which are considered as synchronous
+ # where 1 = ADD_RESOURCES , 2 = DEFINE_SYSTEM , 3 = DESTROY_SYSTEM,
+ # 4 = DESTROY_SYS_CONFIG, 5 = MOD_RESOURCE_SETTINGS,
+ # 6 = MOD_SYS_SETTINGS, 7 = RM_RESOURCES
+ sync_method_val = Set([ 1L, 2L, 3L, 5L, 6L, 7L ])
try:
key_list = ["InstanceID"]
- vsmc = enumclass.enumerate(options.ip,
+ vsmc = enumclass.enumerate(server,
"VirtualSystemManagementCapabilities",
key_list,
- options.virt)
+ virt)
except Exception:
- Globals.logger.error(Globals.CIM_ERROR_ENUMERATE,
- get_typed_class(options.virt,
'VirtualSystemManagementCapabilities'))
- return 1
-
- if len(vsmc) != 1:
- Globals.logger.error("VirtualSystemManagementCapabilities return %i
instance, excepted only 1" % len(vsmc))
- return 1
- if vsmc[0].InstanceID != "ManagementCapabilities":
- Globals.logger.error( "error result of enum
VirtualSystemManagementCapabilities")
- return 1
+ logger.error(CIM_ERROR_ENUMERATE, cn)
+ return FAIL
+ try:
+ if len(vsmc) != 1:
+ logger.error("'%s' returned '%d' instance, excepted only
1", cn, len(vsmc))
+ return FAIL
+
+ if vsmc[0].InstanceID != "ManagementCapabilities":
+ print_field_error('InstanceID', vsmc[0].InstanceID,
'ManagementCapabilities')
+ return FAIL
+ vsmc_sync_val = Set(vsmc[0].SynchronousMethodsSupported)
+ if len(vsmc_sync_val - sync_method_val) != 0:
+ print_field_error('SynchronousMethodsSupported', vsmc_sync_val,
+ sync_method_val)
+ return FAIL
+
+ except Exception, details:
+ logger.error("Exception: details %s", details)
+ return FAIL
+
+ return PASS
if __name__ == "__main__":
sys.exit(main())