[Libvirt-cim] [PATCH] [TEST] updating 03_reverse_errs.py, 04_forward_errs.py

Deepti B. Kalakeri deeptik at linux.vnet.ibm.com
Tue Apr 29 12:58:26 UTC 2008


# HG changeset patch
# User Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>
# Date 1209473865 25200
# Node ID 5bcadaf4ab9957800fce7a564ef4f13851fcf5c8
# Parent  2b83c1992dfc44573ba0c00729e36311355807ad
[TEST] updating 03_reverse_errs.py, 04_forward_errs.py

1) To use lib fn conf_file(), cleanup_restore() and create_diskpool_file()
2) Addressed Indentation.
3) Tested on latest source for Xen, XenFV, KVM.
4) Need to test with binary rpm on F9 and include the revision string for 04_forward_errs.py.

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

diff -r 2b83c1992dfc -r 5bcadaf4ab99 suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py	Sun Apr 27 19:22:03 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/03_reverse_errs.py	Tue Apr 29 05:57:45 2008 -0700
@@ -29,29 +29,26 @@
 #                                                Date : 30-12-2007
 
 import sys
-import os
-from distutils.file_util import move_file
 import pywbem
 from XenKvmLib import assoc
 from CimTest import Globals
 from XenKvmLib.test_doms import destroy_and_undefine_all
 from XenKvmLib.common_util import try_assoc
 from CimTest.ReturnCodes import PASS, FAIL	
-from CimTest.Globals import do_main, platform_sup
+from CimTest.Globals import do_main, platform_sup, logger
 from XenKvmLib.vxml import get_class
 from XenKvmLib.classes import get_typed_class
+from XenKvmLib.common_util import cleanup_restore, test_dpath, \
+create_diskpool_file
 
 bug_no     = "88651"
 test_dom   = "hd_domain"
 test_mac   = "00:11:22:33:44:aa"
 test_vcpus = 1 
-id1        = "DiskPool/foo"
+id1        = "DiskPool/%s" %test_dpath
 id2        = "MemoryPool/0"
 id3        = "NetworkPool/xenbr0"
 id4        = "ProcessorPool/0"
-test_dpath = "foo"
-disk_file = '/tmp/diskpool.conf'
-back_disk_file = disk_file + "." + "02_reverse"
 expr_values = {
                  "invalid_keyname" : {
                                         'rc'    : pywbem.CIM_ERR_FAILED, \
@@ -62,34 +59,6 @@ expr_values = {
                                         'desc'  : 'No such instance'
                                     } 
               }
-
-def conf_file():
-    """
-       Creating diskpool.conf file.
-    """
-    try:
-        f = open(disk_file, 'w')
-        f.write('%s %s' % (test_dpath, '/'))
-        f.close()
-    except Exception,detail:
-        Globals.logger.error("Exception: %s", detail)
-        status = FAIL
-        sys.exit(status)
-
-def clean_up_restore(ip):
-    """
-        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:
-        Globals.logger.error("Exception: %s", detail)
-        status = FAIL
-        vsxml.undefine(ip)
-        sys.exit(status)
 
 def err_invalid_ccname():
 # This is used to verify the that the  
@@ -119,8 +88,8 @@ def err_invalid_ccname():
     for classname, instdid in sorted(lelist.items()):
         keys  = { "InstanceID" : instdid}
         field = "ClassName"
-        status = try_assoc(conn, classname, assoc_classname, keys, field_name=field, \
-                               expr_values=expr_values['invalid_keyvalue'], bug_no="")
+        status = try_assoc(conn, classname, assoc_classname, keys, field_name=field, 
+                           expr_values=expr_values['invalid_keyvalue'], bug_no="")
         if status != PASS:
             break
     return status
@@ -153,8 +122,8 @@ def err_invalid_keyname():
     for classname, instdid in sorted(lelist.items()):
         keys = { "InvalidID" : instdid }
         field = "InstanceID_KeyName"    
-        status = try_assoc(conn, classname, assoc_classname, keys, field_name=field, \
-                               expr_values=expr_values['invalid_keyname'], bug_no="")
+        status = try_assoc(conn, classname, assoc_classname, keys, field_name=field, 
+                           expr_values=expr_values['invalid_keyname'], bug_no="")
         if status != PASS:
             break
     return status
@@ -189,8 +158,8 @@ def err_invalid_keyvalue():
     for classname in sorted(lelist):
         keys = { "InstanceID" : "InvalidKeyValue" }
         field = "InstanceID_KeyValue"    
-        status = try_assoc(conn, classname, assoc_classname, keys, field_name=field, \
-                               expr_values=expr_values['invalid_keyvalue'], bug_no="")
+        status = try_assoc(conn, classname, assoc_classname, keys, field_name=field, 
+                           expr_values=expr_values['invalid_keyvalue'], bug_no="")
         if status != PASS:
             break
     return status
@@ -209,38 +178,36 @@ def main():
         test_disk = "xvda"
     else:
         test_disk = "hda"
+    virt_type = get_class(virt)
+    vsxml = virt_type (test_dom, vcpus = test_vcpus, mac = test_mac, 
+                       disk = test_disk)
 
-    vsxml = get_class(virt)(test_dom, vcpus = test_vcpus, mac = test_mac, \
-                                                          disk = test_disk)
-    if (os.path.exists(back_disk_file)):
-        os.unlink(back_disk_file)
+    # Verify DiskPool on machine
+    status = create_diskpool_file()
+    if status != PASS:
+        return status
 
-    if not (os.path.exists(disk_file)):
-        conf_file()
-    else:
-        move_file(disk_file, back_disk_file)
-        conf_file()
     ret = vsxml.define(options.ip)
     if not ret:
-        Globals.logger.error("Failed to define the dom: %s", test_dom)
+        logger.error("Failed to define the dom: %s", test_dom)
         return FAIL
     conn = assoc.myWBEMConnection('http://%s' % options.ip,
-                            (Globals.CIM_USER, Globals.CIM_PASS),
-                                                  Globals.CIM_NS)
+                                 (Globals.CIM_USER, Globals.CIM_PASS),
+                                 Globals.CIM_NS)
     assoc_classname = get_typed_class(virt, "ElementAllocatedFromPool")
     ret = err_invalid_keyname()
     if ret: 
-        Globals.logger.error("------FAILED: Invalid KeyName.------")
+        logger.error("------FAILED: Invalid KeyName.------")
         return ret
     ret = err_invalid_keyvalue()
     if ret: 
-        Globals.logger.error("------FAILED: Invalid KeyValue.------")
+        logger.error("------FAILED: Invalid KeyValue.------")
         return ret
     ret = err_invalid_ccname()
     if ret: 
-        Globals.logger.error("------FAILED: Invalid CCName.------")
+        logger.error("------FAILED: Invalid CCName.------")
         return ret
-    clean_up_restore(options.ip)
+    cleanup_restore()
     vsxml.undefine(options.ip)
     return PASS
 if __name__ == "__main__":
diff -r 2b83c1992dfc -r 5bcadaf4ab99 suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py
--- a/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py	Sun Apr 27 19:22:03 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ElementAllocatedFromPool/04_forward_errs.py	Tue Apr 29 05:57:45 2008 -0700
@@ -29,8 +29,6 @@
 #
 
 import sys
-import os
-from distutils.file_util import move_file
 import pywbem
 from pywbem.cim_obj import CIMInstanceName
 from XenKvmLib import assoc
@@ -41,6 +39,8 @@ from CimTest.Globals import do_main, pla
 from CimTest.Globals import do_main, platform_sup
 from XenKvmLib.vxml import get_class
 from XenKvmLib.classes import get_typed_class
+from XenKvmLib.common_util import cleanup_restore, test_dpath, \
+create_diskpool_file
 
 sup_types = ['Xen', 'KVM', 'XenFV']
 bug_no             = "88651"
@@ -49,49 +49,16 @@ test_mac   = "00:11:22:33:44:aa"
 test_mac   = "00:11:22:33:44:aa"
 test_vcpus = 1
 exp_list = [
-             {'desc' : "No such instance (SystemName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, \
-             {'desc' : "No DeviceID specified", 'rc' : pywbem.CIM_ERR_FAILED}, \
-             {'desc' : "No such instance", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, \
-             {'desc' : "One or more parameter values passed to the method were invalid", \
-                                                       'rc' : pywbem.CIM_ERR_INVALID_PARAMETER}, \
-             {'desc' : "No such instance (CreationClassName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND }, \
-             {'desc' : "No such instance (SystemCreationClassName)", 'rc' : \
-                                                                         pywbem.CIM_ERR_NOT_FOUND },  
+             {'desc' : "No such instance (SystemName)", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, 
+             {'desc' : "No DeviceID specified", 'rc' : pywbem.CIM_ERR_FAILED}, 
+             {'desc' : "No such instance", 'rc' : pywbem.CIM_ERR_NOT_FOUND}, 
+             {'desc' : "CIM_ERR_INVALID_PARAMETER", 
+                'rc' : pywbem.CIM_ERR_INVALID_PARAMETER}, 
+             {'desc' : "No such instance (CreationClassName)",
+                'rc' : pywbem.CIM_ERR_NOT_FOUND }, 
+             {'desc' : "No such instance (SystemCreationClassName)", 
+                'rc' :  pywbem.CIM_ERR_NOT_FOUND },  
             ]
-
-
-test_dpath = "foo"
-disk_file = '/tmp/diskpool.conf'
-back_disk_file = disk_file + "." + "02_reverse"
-
-
-def conf_file():
-    """
-        Creating diskpool.conf file.
-    """
-    try:
-        f = open(disk_file, 'w')
-        f.write('%s %s' % (test_dpath, '/'))
-        f.close()
-    except Exception,detail:
-        Globals.logger.error("Exception: %s", detail)
-        status = FAIL
-        sys.exit(status)
-
-def clean_up_restore(ip):
-    """
-         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:
-        Globals.logger.error("Exception: %s", detail)
-        status = FAIL
-        vsxml.undefine(ip) 
-        sys.exit(status)
 
 def try_assoc(conn, exp_ret, dev_dom_name, invalid_keyname_list, test_vals, log_msg):
 
@@ -102,9 +69,9 @@ def try_assoc(conn, exp_ret, dev_dom_nam
     procid = "%s/%s" % (dev_dom_name, 0)
     
     lelist = {
-                  get_typed_class(virt, "LogicalDisk") : diskid, \
-                  get_typed_class(virt, "NetworkPort") : netid, \
-                  get_typed_class(virt, "Memory"     ) : memid, \
+                  get_typed_class(virt, "LogicalDisk") : diskid, 
+                  get_typed_class(virt, "NetworkPort") : netid, 
+                  get_typed_class(virt, "Memory"     ) : memid, 
                   get_typed_class(virt, "Processor"  ) : procid
              }
 
@@ -125,9 +92,9 @@ def try_assoc(conn, exp_ret, dev_dom_nam
     else:
         snkeyname = "SystemName"
  
-    test_keys = { devkeyname  : devkeyname, \
-                  ccnkeyname  : ccnkeyname, \
-                  sccnkeyname : sccnkeyname, \
+    test_keys = { devkeyname  : devkeyname, 
+                  ccnkeyname  : ccnkeyname, 
+                  sccnkeyname : sccnkeyname, 
                   snkeyname   : snkeyname 
                 }
     for cn, devid in sorted(lelist.items()):
@@ -142,20 +109,20 @@ def try_assoc(conn, exp_ret, dev_dom_nam
         else:
             ccn = cn
 
-        keys = { test_keys[devkeyname]  : dev_id, \
-                 test_keys[ccnkeyname]  : ccn, \
-                 test_keys[sccnkeyname] : test_vals['sccn'], \
-                 test_keys[snkeyname]   :  test_vals['sn'] 
+        keys = { test_keys[devkeyname]  : dev_id, 
+                 test_keys[ccnkeyname]  : ccn, 
+                 test_keys[sccnkeyname] : test_vals['sccn'], 
+                 test_keys[snkeyname]   : test_vals['sn'] 
                }
-
+        print "test_keys", keys
         if test_vals['cn'] != "valid":
             inst_cn = "InvalidClassName"
         else:
             inst_cn = cn
         instanceref = CIMInstanceName(inst_cn, keybindings=keys)
         try:
-            assoc_info = conn.AssociatorNames(instanceref, \
-                                  AssocClass=assoc_classname)
+            assoc_info = conn.AssociatorNames(instanceref, 
+                                              AssocClass=assoc_classname)
         except pywbem.CIMError, (err_no, desc):
             if err_no == exp_ret['rc'] and desc.find(exp_ret['desc']) >= 0:
                 logger.info("Got expected exception where ")
@@ -165,6 +132,7 @@ def try_assoc(conn, exp_ret, dev_dom_nam
                 logger.error("Unexpected rc code %s and description \
 %s\n" %(err_no, desc))
                 status = FAIL
+        print "assos", assoc_info
         if len(assoc_info) != 0:
             logger.error("%s association \
 should NOT have returned records. '%s'", assoc_classname, log_msg)
@@ -196,22 +164,21 @@ def err_invalid_sysname_keyname(conn, ex
 # 
 #
 # 
-    test_keys = { 'DeviceID' : "valid", \
-                   'CreationClassName' : "valid", \
-                   'SystemCreationClassName' : "valid", \
-                   'SystemName' : "invalid" \
+    test_keys = { 'DeviceID' : "valid", 
+                   'CreationClassName' : "valid", 
+                   'SystemCreationClassName' : "valid", 
+                   'SystemName' : "invalid" 
                  } 
-    test_vals = { 'devid' : "valid", \
-                   'sccn' : get_typed_class(virt, "ComputerSystem"), \
-                   'sn' : test_dom, \
-                   'ccn' : "valid", \
+    test_vals = { 'devid' : "valid", 
+                   'sccn' : get_typed_class(virt, "ComputerSystem"), 
+                   'sn' : test_dom, 
+                   'ccn' : "valid", 
                    'cn' : "valid"
                  }
 
     log_msg = "Invalid SystemName Key Name was supplied."
 
-    return try_assoc(conn, exp_ret, test_dom, test_keys, \
-                                         test_vals, log_msg)
+    return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg)
 
 def err_invalid_sysname_keyvalue(conn, exp_ret):
 
@@ -232,22 +199,21 @@ def err_invalid_sysname_keyvalue(conn, e
 #
 # Similarly we check for Memory,Network,Processor.
 # 
-    test_keys = { 'DeviceID' : "valid", \
-                   'CreationClassName' : "valid", \
-                   'SystemCreationClassName' : "valid", \
-                   'SystemName' : "valid" \
+    test_keys = { 'DeviceID' : "valid", 
+                   'CreationClassName' : "valid", 
+                   'SystemCreationClassName' : "valid", 
+                   'SystemName' : "valid" 
                  } 
-    test_vals = { 'devid' : "valid", \
-                   'sccn' : get_typed_class(virt, "ComputerSystem"), \
-                   'sn' : "invalid", \
-                   'ccn' : "valid", \
+    test_vals = { 'devid' : "valid", 
+                   'sccn' : get_typed_class(virt, "ComputerSystem"), 
+                   'sn' : "invalid", 
+                   'ccn' : "valid", 
                    'cn' : "valid"
                  }
 
     log_msg = "Non-existing SystemName was supplied."
 
-    return try_assoc(conn, exp_ret, test_dom, test_keys, \
-                                         test_vals, log_msg)
+    return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg)
 
 def err_invalid_devid_keyname(conn, exp_ret):
 # This is used to verify the that the
@@ -271,22 +237,21 @@ def err_invalid_devid_keyname(conn, exp_
 #
 #
 
-    test_keys = { 'DeviceID' : "invalid", \
-                   'CreationClassName' : "valid", \
-                   'SystemCreationClassName' : "valid", \
-                   'SystemName' : "valid" \
+    test_keys = { 'DeviceID' : "invalid", 
+                   'CreationClassName' : "valid", 
+                   'SystemCreationClassName' : "valid", 
+                   'SystemName' : "valid" 
                  } 
-    test_vals = { 'devid' : "valid", \
-                   'sccn' : get_typed_class(virt, "ComputerSystem"), \
-                   'sn' : test_dom, \
-                   'ccn' : "valid", \
+    test_vals = { 'devid' : "valid", 
+                   'sccn' : get_typed_class(virt, "ComputerSystem"), 
+                   'sn' : test_dom, 
+                   'ccn' : "valid",
                    'cn' : "valid"
                  }
 
     log_msg = "Invalid deviceid keyname was supplied."
 
-    return try_assoc(conn, exp_ret, test_dom, test_keys, \
-                                         test_vals, log_msg)
+    return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg)
 
 def err_invalid_devid_keyvalue(conn, exp_ret):
 
@@ -309,22 +274,22 @@ def err_invalid_devid_keyvalue(conn, exp
 # Similarly we check for Network.
 # 
 # 
-    test_keys = { 'DeviceID' : "valid", \
-                   'CreationClassName' : "valid", \
-                   'SystemCreationClassName' : "valid", \
-                   'SystemName' : "valid" \
+    test_keys = { 'DeviceID' : "valid", 
+                   'CreationClassName' : "valid", 
+                   'SystemCreationClassName' : "valid", 
+                   'SystemName' : "valid" 
                  } 
-    test_vals = { 'devid' : "invalid", \
-                   'sccn' : get_typed_class(virt, "ComputerSystem"), \
-                   'sn' : test_dom, \
-                   'ccn' : "valid", \
+    test_vals = { 'devid' : "invalid", 
+                   'sccn' : get_typed_class(virt, "ComputerSystem"), 
+                   'sn' : test_dom, 
+                   'ccn' : "valid",
                    'cn' : "valid"
                  }
 
     log_msg = "Invalid deviceid keyvalue was supplied."
 
-    return try_assoc(conn, exp_ret, test_dom_invalid, test_keys, \
-                                                test_vals, log_msg)
+    return try_assoc(conn, exp_ret, test_dom_invalid, test_keys, test_vals, 
+                                                                   log_msg)
 
 def err_invalid_classname(conn, exp_ret):
 
@@ -348,22 +313,21 @@ def err_invalid_classname(conn, exp_ret)
 # Similarly we check for Memory,Network,Processor.
 # 
 # 
-    test_keys = { 'DeviceID' : "valid", \
-                   'CreationClassName' : "valid", \
-                   'SystemCreationClassName' : "valid", \
-                   'SystemName' : "valid" \
+    test_keys = { 'DeviceID' : "valid", 
+                   'CreationClassName' : "valid", 
+                   'SystemCreationClassName' : "valid", 
+                   'SystemName' : "valid" 
                  } 
-    test_vals = { 'devid' : "valid", \
-                   'sccn' : get_typed_class(virt, "ComputerSystem"), \
-                   'sn' : test_dom, \
-                   'ccn' : "valid", \
+    test_vals = { 'devid' : "valid", 
+                   'sccn' : get_typed_class(virt, "ComputerSystem"), 
+                   'sn' : test_dom, 
+                   'ccn' : "valid", 
                    'cn' : "invalid"
                  }
 
     log_msg = "Invalid classname value was supplied."
 
-    return try_assoc(conn, exp_ret, test_dom, test_keys, \
-                                         test_vals, log_msg)
+    return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg)
 
 def err_invalid_creationclassname_keyname(conn, exp_ret):
 
@@ -388,22 +352,21 @@ def err_invalid_creationclassname_keynam
 # Similarly we check for Memory,Network,Processor.
 # 
 
-    test_keys = { 'DeviceID' : "valid", \
-                   'CreationClassName' : "invalid", \
-                   'SystemCreationClassName' : "valid", \
-                   'SystemName' : "valid" \
+    test_keys = { 'DeviceID' : "valid", 
+                   'CreationClassName' : "invalid", 
+                   'SystemCreationClassName' : "valid", 
+                   'SystemName' : "valid" 
                  } 
-    test_vals = { 'devid' : "valid", \
-                   'sccn' : get_typed_class(virt, "ComputerSystem"), \
-                   'sn' : test_dom, \
-                   'ccn' : "valid", \
+    test_vals = { 'devid' : "valid", 
+                   'sccn' : get_typed_class(virt, "ComputerSystem"), 
+                   'sn' : test_dom, 
+                   'ccn' : "valid", 
                    'cn' : "valid"
                  }
 
     log_msg = "Invalid creationclassname keyname was supplied."
 
-    return try_assoc(conn, exp_ret, test_dom, test_keys, \
-                                         test_vals, log_msg)
+    return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg)
 
 def err_invalid_creationclassname_keyvalue(conn, exp_ret):
 
@@ -426,22 +389,21 @@ def err_invalid_creationclassname_keyval
 # Similarly we check for Memory,Network,Processor.
 # 
 
-    test_keys = { 'DeviceID' : "valid", \
-                   'CreationClassName' : "valid", \
-                   'SystemCreationClassName' : "valid", \
-                   'SystemName' : "valid" \
+    test_keys = { 'DeviceID' : "valid", 
+                   'CreationClassName' : "valid", 
+                   'SystemCreationClassName' : "valid", 
+                   'SystemName' : "valid" 
                  } 
-    test_vals = { 'devid' : "valid", \
-                   'sccn' : get_typed_class(virt, "ComputerSystem"), \
-                   'sn' : test_dom, \
-                   'ccn' : "invalid", \
+    test_vals = { 'devid' : "valid", 
+                   'sccn' : get_typed_class(virt, "ComputerSystem"), 
+                   'sn' : test_dom, 
+                   'ccn' : "invalid", 
                    'cn' : "valid"
                  }
 
     log_msg = "Invalid creatioclassname keyvalue was supplied."
 
-    return try_assoc(conn, exp_ret, test_dom, test_keys, \
-                                         test_vals, log_msg)
+    return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg)
 
 def err_invalid_syscreationclassname_keyname(conn, exp_ret):
 
@@ -464,22 +426,21 @@ def err_invalid_syscreationclassname_key
 # Similarly we check for Memory,Network,Processor.
 # 
 
-    test_keys = { 'DeviceID' : "valid", \
-                   'CreationClassName' : "valid", \
-                   'SystemCreationClassName' : "invalid", \
-                   'SystemName' : "valid" \
+    test_keys = { 'DeviceID' : "valid", 
+                   'CreationClassName' : "valid", 
+                   'SystemCreationClassName' : "invalid", 
+                   'SystemName' : "valid" 
                  } 
-    test_vals = { 'devid' : "valid", \
-                   'sccn' : get_typed_class(virt, "ComputerSystem"), \
-                   'sn' : test_dom, \
-                   'ccn' : "valid", \
+    test_vals = { 'devid' : "valid", 
+                   'sccn' : get_typed_class(virt, "ComputerSystem"), 
+                   'sn' : test_dom, 
+                   'ccn' : "valid", 
                    'cn' : "valid"
                  }
 
     log_msg = "Invalid system creatioclassname keyvalue was supplied."
 
-    return try_assoc(conn, exp_ret, test_dom, test_keys, \
-                                         test_vals, log_msg)
+    return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg)
 
 def err_invalid_syscreationclassname_keyvalue(conn, exp_ret):
 
@@ -502,22 +463,21 @@ def err_invalid_syscreationclassname_key
 # Similarly we check for Memory,Network,Processor.
 # 
 
-    test_keys = { 'DeviceID' : "valid", \
-                   'CreationClassName' : "valid", \
-                   'SystemCreationClassName' : "valid", \
-                   'SystemName' : "valid" \
+    test_keys = { 'DeviceID' : "valid", 
+                   'CreationClassName' : "valid", 
+                   'SystemCreationClassName' : "valid", 
+                   'SystemName' : "valid" 
                  } 
-    test_vals = { 'devid' : "valid", \
-                   'sccn' : "invalid", \
-                   'sn' : test_dom, \
-                   'ccn' : "valid", \
+    test_vals = { 'devid' : "valid", 
+                   'sccn' : "invalid", 
+                   'sn' : test_dom, 
+                   'ccn' : "valid", 
                    'cn' : "valid"
                  }
 
     log_msg = "Invalid system creatioclassname keyvalue was supplied."
 
-    return try_assoc(conn, exp_ret, test_dom, test_keys, \
-                                         test_vals, log_msg)
+    return try_assoc(conn, exp_ret, test_dom, test_keys, test_vals, log_msg)
 
 @do_main(platform_sup)
 def main():
@@ -539,18 +499,15 @@ def main():
     destroy_and_undefine_all(options.ip)
     vsxml = get_class(virt)(test_dom, vcpus = test_vcpus, mac = test_mac, \
                                                           disk = test_disk)
-    if (os.path.exists(back_disk_file)):
-        os.unlink(back_disk_file)
+    # Verify DiskPool on machine
+    status = create_diskpool_file()
+    if status != PASS:
+        return status
 
-    if not (os.path.exists(disk_file)):
-        conf_file()
-    else:
-        move_file(disk_file, back_disk_file)
-        conf_file()
     bridge = vsxml.set_vbridge(options.ip)
     ret = vsxml.define(options.ip)
     if not ret:
-        Globals.logger.error("Failed to define the dom: %s", test_dom)
+        logger.error("Failed to define the dom: %s", test_dom)
         return FAIL
     conn = assoc.myWBEMConnection('http://%s' % options.ip,
                             (Globals.CIM_USER, Globals.CIM_PASS),
@@ -558,48 +515,48 @@ def main():
     assoc_classname = get_typed_class(virt, "ElementAllocatedFromPool")
     ret = err_invalid_sysname_keyname(conn, exp_list[0])
     if ret:
-        Globals.logger.error("------FAILED: Invalid SystemName Key Name.------")
+        logger.error("------FAILED: Invalid SystemName Key Name.------")
         return ret
     ret = err_invalid_sysname_keyvalue(conn, exp_list[0])
     if ret:
-        Globals.logger.error("------FAILED: Invalid SystemName Key Value.------")
+        logger.error("------FAILED: Invalid SystemName Key Value.------")
         return ret
     ret = err_invalid_devid_keyname(conn, exp_list[1])
     if ret: 
-        Globals.logger.error("------FAILED: Invalid DeviceID \
+        logger.error("------FAILED: Invalid DeviceID \
 Keyname.------")
         return ret
     ret = err_invalid_devid_keyvalue(conn, exp_list[2])
     if ret: 
-        Globals.logger.error("------FAILED: Invalid DeviceID \
+        logger.error("------FAILED: Invalid DeviceID \
 Keyvalue.------")
         return ret
     ret = err_invalid_classname(conn, exp_list[3])
     if ret:
-        Globals.logger.error("------FAILED: Invalid classname\
+        logger.error("------FAILED: Invalid classname\
 Keyname.------")
         return ret
     ret = err_invalid_creationclassname_keyname(conn, exp_list[4])
     if ret:
-        Globals.logger.error("------FAILED: Invalid creationclassname\
+        logger.error("------FAILED: Invalid creationclassname\
 Keyname.------")
         return ret
     ret = err_invalid_creationclassname_keyvalue(conn, exp_list[4]) 
     if ret: 
-        Globals.logger.error("------FAILED: Invalid creationclassname\
+        logger.error("------FAILED: Invalid creationclassname\
 Keyvalue.------")
         return ret
     ret = err_invalid_syscreationclassname_keyname(conn, exp_list[5]) 
     if ret: 
-        Globals.logger.error("------FAILED: Invalid System creationclassname\
+        logger.error("------FAILED: Invalid System creationclassname\
 Keyname.------")
         return ret
     ret = err_invalid_syscreationclassname_keyvalue(conn, exp_list[5]) 
     if ret: 
-        Globals.logger.error("------FAILED: Invalid System creationclassname\
+        logger.error("------FAILED: Invalid System creationclassname\
 Keyvalue.------")
         return ret
-    clean_up_restore(options.ip)
+    cleanup_restore()
     vsxml.undefine(options.ip)
     return PASS
 if __name__ == "__main__":




More information about the Libvirt-cim mailing list