[Libvirt-cim] [PATCH] [TEST]updating 02_alloccap_gi_errs.py to use of the lib fn conf_file(), cleanup_restore() and create_diskpool_file()

Deepti B. Kalakeri deeptik at linux.vnet.ibm.com
Wed Apr 23 14:22:19 UTC 2008


# HG changeset patch
# User Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>
# Date 1208960532 -19800
# Node ID 91d726c978e3fcc360774c34293a67166bc3b9e6
# Parent  70e13e2a2abf57a666c8e4d5029d06ecd017ea69
[TEST]updating 02_alloccap_gi_errs.py to use of the lib fn conf_file(), cleanup_restore() and create_diskpool_file()

Signed-off-by: Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>

diff -r 70e13e2a2abf -r 91d726c978e3 suites/libvirt-cim/cimtest/AllocationCapabilities/02_alloccap_gi_errs.py
--- a/suites/libvirt-cim/cimtest/AllocationCapabilities/02_alloccap_gi_errs.py	Wed Apr 23 19:48:18 2008 +0530
+++ b/suites/libvirt-cim/cimtest/AllocationCapabilities/02_alloccap_gi_errs.py	Wed Apr 23 19:52:12 2008 +0530
@@ -62,10 +62,9 @@ from XenKvmLib.test_doms import create_v
 from XenKvmLib.test_doms import create_vnet
 from CimTest.Globals import do_main, platform_sup
 from XenKvmLib.classes import get_typed_class
+from XenKvmLib.common_util import cleanup_restore, test_dpath, \
+create_diskpool_file
 
-test_dpath = "foo"
-disk_file = '/tmp/diskpool.conf'
-back_disk_file = disk_file + "." + "alloccap_err" 
 diskid = "%s/%s" % ("DiskPool", test_dpath)
 memid = "%s/%s" % ("MemoryPool", 0)
 procid = "%s/%s" % ("ProcessorPool", 0)
@@ -75,46 +74,19 @@ expr_values = {
                 "invalid_instid_keyvalue" :  { 'rc'   : pywbem.CIM_ERR_NOT_FOUND, \
                                                'desc' : 'Instance not found' }
               }
-def conf_file():
-    """
-       Creating diskpool.conf file.
-    """
-    try:
-        f = open(disk_file, 'w')
-        f.write('%s %s' % (test_dpath, '/'))
-        f.close()
-    except Exception,detail:
-        logger.error("Exception: %s", detail)
-        status = SKIP 
-        sys.exit(status)
-
-def clean_up_restore():
-    """
-        Restoring back the original diskpool.conf 
-        file.
-    """
-    try: 
-        if os.path.exists(back_disk_file):
-            os.remove(disk_file)
-            move_file(back_disk_file, disk_file)
-    except Exception, detail:
-        logger.error("Exception: %s", detail)
-        status = SKIP 
-        sys.exit(status)
     
 @do_main(platform_sup)     
 def main():
 
     options = main.options
-    status = PASS
     server = options.ip
-    os.system("rm -f %s" % back_disk_file )
-    if not (os.path.exists(disk_file)):
-        conf_file()
-    else:
-        move_file(disk_file, back_disk_file)
-        conf_file()
 
+    # Verify DiskPool on machine
+    status = create_diskpool_file()
+    if status != PASS:
+        return status
+
+    #Verify the virtual Network on the machine
     vir_network = net_list(server)
     if len(vir_network) > 0:
         test_network = vir_network[0]
@@ -127,6 +99,7 @@ def main():
             logger.error("Failed to create the Virtual Network '%s'", \
                                                                     test_network)
             return SKIP
+
     net_instid = 'NetworkPool/%s' %test_network
     instid_list = ['ProcessorPool/0', 'MemoryPool/0', 'DiskPool/foo', net_instid]
     conn = assoc.myWBEMConnection('http://%s' % options.ip, (CIM_USER, CIM_PASS), CIM_NS)
@@ -151,7 +124,7 @@ def main():
             status = ret_value
         if status != PASS: 
             break
-    clean_up_restore()
+    cleanup_restore()
     return status
 if __name__ == "__main__":
     sys.exit(main())




More information about the Libvirt-cim mailing list