[PATCH] [TEST] Rebasing and adding conf_file(), clean_up_restore(), create_diskpool_file() to library

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1209036114 -19800 # Node ID 8067f7e535408298176f2cabf7b038fa36767cff # Parent dd59f067c3831b252f30f5e46f8baff5016129a3 [TEST] Rebasing and adding conf_file(), clean_up_restore(), create_diskpool_file() to library. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r dd59f067c383 -r 8067f7e53540 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Apr 23 15:28:53 2008 +0530 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Thu Apr 24 16:51:54 2008 +0530 @@ -21,6 +21,7 @@ # import os import pywbem +from distutils.file_util import move_file from XenKvmLib.test_xml import * from XenKvmLib.test_doms import * from XenKvmLib import vsms @@ -31,6 +32,10 @@ from XenKvmLib.classes import get_typed_ from XenKvmLib.classes import get_typed_class from CimTest.Globals import logger, log_param, CIM_ERROR_ENUMERATE from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC + +test_dpath = "foo" +disk_file = '/tmp/diskpool.conf' +back_disk_file = disk_file + "." + "backup" def print_field_error(fieldname, ret_value, exp_value): logger.error("%s Mismatch", fieldname) @@ -234,3 +239,50 @@ def profile_init_list(): } return profiles + +def conf_file(): + """ + Creating diskpool.conf file. + """ + status = PASS + try: + f = open(disk_file, 'w') + f.write('%s %s' % (test_dpath, '/')) + f.close() + except Exception,detail: + logger.error("Exception: %s", detail) + status = SKIP + if status != PASS: + logger.error("Creation of Disk Conf file Failed") + return status + + +def cleanup_restore(): + """ + Restoring back the original diskpool.conf + file. + """ + status = PASS + 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 + if status != PASS: + logger.error("Failed to restore the original Disk Conf file") + return status + +def create_diskpool_file(): + # Taking care of already existing diskconf file + # Creating diskpool.conf if it does not exist + # Otherwise backing up the prev file and create new one. + if (os.path.exists(back_disk_file)): + os.unlink(back_disk_file) + + if (os.path.exists(disk_file)): + move_file(disk_file, back_disk_file) + + return conf_file() +
participants (1)
-
Deepti B. Kalakeri