[Libvirt-cim] [PATCH] [TEST]updating 04_hs_to_EAPF.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:27:13 UTC 2008


# HG changeset patch
# User Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>
# Date 1208960819 -19800
# Node ID 413ef6a636d51ab12f16588268c8debe4d952f05
# Parent  3bf33b37a58657888f404b87a1504b0453b7761c
[TEST]updating 04_hs_to_EAPF.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 3bf33b37a586 -r 413ef6a636d5 suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py
--- a/suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py	Wed Apr 23 19:54:10 2008 +0530
+++ b/suites/libvirt-cim/cimtest/HostSystem/04_hs_to_EAPF.py	Wed Apr 23 19:56:59 2008 +0530
@@ -60,6 +60,8 @@ from VirtLib.live import network_by_brid
 from VirtLib.live import network_by_bridge
 from XenKvmLib.logicaldevices import verify_proc_values, verify_mem_values, \
 verify_net_values, verify_disk_values
+from XenKvmLib.common_util import cleanup_restore, test_dpath, \
+create_diskpool_file
 
 sup_types = ['Xen']
 
@@ -68,9 +70,6 @@ test_mem   = 128
 test_mem   = 128 
 test_vcpus = 1 
 test_disk  = "xvdb"
-test_dpath = "foo"
-disk_file = '/tmp/diskpool.conf'
-back_disk_file = disk_file + "." + "ccex4" 
 diskid = "%s/%s" % ("DiskPool", test_dpath)
 memid = "%s/%s" % ("MemoryPool", 0)
 procid = "%s/%s" % ("ProcessorPool", 0)
@@ -102,32 +101,6 @@ def print_err(err, detail, cn):
     logger.error(err % cn)
     logger.error("Exception: %s", detail)
 
-
-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)
-        return SKIP
-    return PASS 
-
-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)
-
 def field_err(assoc_info, field_list, fieldname):
     logger.error("%s Mismatch", fieldname)
     logger.error("Returned %s instead of %s", assoc_info[fieldname], field_list[fieldname])
@@ -149,33 +122,34 @@ def pool_init_list(pool_assoc):
 
 def eapf_list():
     disk  = {
-              'SystemName'        : test_dom, \
-              'CreationClassName' : "Xen_LogicalDisk", \
-              'DeviceID'          : "%s/%s" % (test_dom,test_disk), \
+              'SystemName'        : test_dom, 
+              'CreationClassName' : "Xen_LogicalDisk", 
+              'DeviceID'          : "%s/%s" % (test_dom,test_disk), 
               'Name'              : test_disk 
             }    
     proc = {
-              'SystemName'        : test_dom, \
-              'CreationClassName' : "Xen_Processor", \
+              'SystemName'        : test_dom, 
+              'CreationClassName' : "Xen_Processor", 
               'DeviceID'          : "%s/%s" % (test_dom,0)
            }    
     net =  {
-              'SystemName'        : test_dom, \
-              'CreationClassName' : "Xen_NetworkPort", \
-              'DeviceID'          : "%s/%s" % (test_dom, test_mac), \
+              'SystemName'        : test_dom, 
+              'CreationClassName' : "Xen_NetworkPort", 
+              'DeviceID'          : "%s/%s" % (test_dom, test_mac), 
               'NetworkAddresses'  : test_mac 
            }
     mem =  {
-              'SystemName'        : test_dom, \
-              'CreationClassName' : "Xen_Memory", \
-              'DeviceID'          : "%s/%s" % (test_dom, "mem"), \
+              'SystemName'        : test_dom, 
+              'CreationClassName' : "Xen_Memory", 
+              'DeviceID'          : "%s/%s" % (test_dom, "mem"), 
               'NumberOfBlocks'    : test_mem 
            }
-    eaf_values = {  "Xen_Processor"   : proc, \
-                    "Xen_LogicalDisk" : disk, \
-                    "Xen_NetworkPort" : net, \
+    eaf_values = {  "Xen_Processor"   : proc, 
+                    "Xen_LogicalDisk" : disk, 
+                    "Xen_NetworkPort" : net, 
                     "Xen_Memory"      : mem
                   }
+    print eaf_values
     return eaf_values 
 
 def get_inst_for_dom(assoc_val):
@@ -205,7 +179,7 @@ def get_assocname_info(server, cn, an, q
         status = FAIL
 
     if status != PASS:
-        clean_up_restore()
+        cleanup_restore()
         test_domain_function(test_dom, server, "destroy")
 
     return status, assoc_info
@@ -225,10 +199,7 @@ def verify_eafp_values(server, in_pllist
     eapf_values = eapf_list()
     for cn,  instid in sorted(in_pllist.items()):
         try:
-            assoc_info = Associators(server, \
-                                          an, \
-                                           cn, \
-                             InstanceID = instid)  
+            assoc_info = Associators(server, an, cn, InstanceID = instid)  
             inst_list = get_inst_for_dom(assoc_info)
             status = check_len(an, inst_list, qcn, exp_len)
             if status != PASS:
@@ -250,7 +221,7 @@ def verify_eafp_values(server, in_pllist
         except Exception, detail:
             logger.error(CIM_ERROR_ASSOCIATORS, an)
             logger.error("Exception: %s", detail)
-            clean_up_restore()
+            cleanup_restore()
             status = FAIL
     return status
 
@@ -258,42 +229,41 @@ def main():
 def main():
     options= main.options
     server = options.ip
-# Get the host info 
+
+    # Get the host info 
     status, host_name, classname = get_host_info(server)
     if status != PASS:
         return status
-    # 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.
-    os.system("rm -f %s" % back_disk_file )
-    if not (os.path.exists(disk_file)):
-        status = conf_file()
-    else:
-        move_file(disk_file, back_disk_file)
-        status = conf_file()
+
+    # Verify DiskPool on machine
+    status = create_diskpool_file() 
     if status != PASS:
         return status
-# Get the hostedResourcePool info first
+
+    # Get the hostedResourcePool info first
     cn  = classname
     an  = "Xen_HostedResourcePool"
     qcn = "Device Pool"
     status, pool = get_assocname_info(server, cn, an, qcn, host_name)
     if status != PASS:
         return status
-# One pool for each Device type, hence len should be 4 
+
+    # One pool for each Device type, hence len should be 4 
     exp_len = 4
     status = status = check_len(an, pool, qcn, exp_len)
     if status != PASS:
         return FAIL
+
     status = setup_env(server)
     if status != PASS:
-        clean_up_restore()
+        cleanup_restore()
         test_domain_function(test_dom, server, cmd = "destroy")
         return status
+
     in_pllist = pool_init_list(pool)
     status = verify_eafp_values(server, in_pllist)
     ret = test_domain_function(test_dom, server, cmd = "destroy")
-    clean_up_restore()
+    cleanup_restore()
     return status
 if __name__ == "__main__":
     sys.exit(main())




More information about the Libvirt-cim mailing list