[PATCH] [TEST] Moving conf_file, clean_up_restore() and print_error to library

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1208959848 -19800 # Node ID 0123ff5809dc099c0b7840fce65eca5bce0921e6 # Parent 254b9bf3dacaf1dc3b89a08069cad74ee1b3122f [TEST] Moving conf_file, clean_up_restore() and print_error to library. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 254b9bf3daca -r 0123ff5809dc 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 Wed Apr 23 19:40:48 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,14 @@ 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) + logger.error("Returned %s instead of %s", ret_value, exp_value) def get_cs_instance(domain_name, ip, virt='Xen'): try: @@ -230,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)): + logger.info("Entering .....") + move_file(disk_file, back_disk_file) + + return conf_file() +

Deepti B. Kalakeri wrote:
# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1208959848 -19800 # Node ID 0123ff5809dc099c0b7840fce65eca5bce0921e6 # Parent 254b9bf3dacaf1dc3b89a08069cad74ee1b3122f [TEST] Moving conf_file, clean_up_restore() and print_error to library.
Sorry Deepti - I missed you mail saying to ignore the print_error patch. I already applied that patch. I was confused because SDC 04 and 05 depended on this change. While missing this is completely my error - I should note that it helps to send related / dependent patches in a set. Since the SDC 04 and 05 patches were dependent on the print_error change, they could have been sent together. Doing this helps indicate that the patches have an order they need to be applied in. Sometimes mail relays slow down, and so the patches don't always arrive at the same time. Anyway - sorry to make you rework this! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Deepti B. Kalakeri
-
Kaitlin Rupert