# HG changeset patch
# User Deepti B. Kalakeri<dkalaker(a)in.ibm.com>
# Date 1220507675 25200
# Node ID 35606858bd9c61b1a1b66b8438b75be9f3ca3e88
# Parent 3c04faaa67e001ecaf578a13da75f88235257576
[TEST] #2 Updating VSMC 01_enum.py to verify the SynchronousMethodsSupported values.
Changes
-------
Patch 2:
-------
1) Updated the lines which were crossing 80 column lenght.
Patch 1:
--------
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 3c04faaa67e0 -r 35606858bd9c
suites/libvirt-cim/cimtest/VirtualSystemManagementCapabilities/01_enum.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementCapabilities/01_enum.py Tue Sep 02
23:10:52 2008 -0700
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementCapabilities/01_enum.py Wed Sep 03
22:54:35 2008 -0700
@@ -23,35 +23,60 @@
#
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())