[Libvirt-cim] [PATCH 2/3] HostSystem: Remove call to check_sblim

John Ferlan jferlan at redhat.com
Tue May 20 18:26:27 UTC 2014


Following the lead of commit id 'd669e64e', remove the check_sblim().  Then
rework the remaining code to remove the "ret == PASS" section which was only
done when check_sblim() was a valid function.

Also removed spurious whitespace and reworked failure checks to check
and message each condition separately - otherwise it was possible to get
a message where expected and got values were the same if either failed.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 suites/libvirt-cim/cimtest/HostSystem/01_enum.py | 52 ++++++++----------------
 1 file changed, 16 insertions(+), 36 deletions(-)

diff --git a/suites/libvirt-cim/cimtest/HostSystem/01_enum.py b/suites/libvirt-cim/cimtest/HostSystem/01_enum.py
index 75d6f5d..8ddc8b2 100644
--- a/suites/libvirt-cim/cimtest/HostSystem/01_enum.py
+++ b/suites/libvirt-cim/cimtest/HostSystem/01_enum.py
@@ -28,9 +28,8 @@
 import sys
 from XenKvmLib import enumclass
 from XenKvmLib.classes import get_typed_class
-from VirtLib.live import full_hostname 
+from VirtLib.live import full_hostname
 from VirtLib import utils
-from XenKvmLib.common_util import check_sblim
 from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
 from XenKvmLib.const import do_main
 from CimTest.ReturnCodes import PASS, FAIL
@@ -42,48 +41,29 @@ def main():
     options = main.options
     host = full_hostname()
 
-    status = FAIL
     keys = ['Name', 'CreationClassName']
     name = get_typed_class(options.virt, 'HostSystem')
-    
-    ret, linux_cs = check_sblim(options.ip, options.virt)
+
     try:
         hs = enumclass.EnumInstances(options.ip, name)
     except Exception, details:
         logger.error("%s %s: %s", CIM_ERROR_ENUMERATE, name, details)
-        status = FAIL
+        return FAIL
+
+    if len(hs) != 1:
+        logger.error("Expected 1 %s instance returned got %d", name, len(hs))
+        return FAIL
 
-    if ret == PASS:
-        if len(hs) != 0:
-            if hs[0].CreationClassName != name or hs[0].Name != host:
-                logger.error("Exp %s, got %s", name, hs[0].CreationClassName)
-                logger.error("Exp %s, got %s", host, hs[0].Name)
-                return FAIL
-            else:
-                return PASS
-        else:
-            if linux_cs.CreationClassName != 'Linux_ComputerSystem'\
-              or linux_cs.Name != host:
-                logger.error("Exp Linux_ComputerSystem, got %s",
-                             linux_cs.CreationClassName)
-                logger.error("Exp %s, got %s", host, system.Name)
-                return FAIL
-            else:
-                return PASS
-    else:
-        if len(hs) != 1:
-            logger.error("Expected 1 %s instance returned", name)
-            return FAIL
-   
-        system = hs[0]
+    system = hs[0]
 
-        if system.CreationClassName != name or system.Name != host:
-            logger.error("Exp %s, got %s", name, system.CreationClassName)
-            logger.error("Exp %s, got %s", host, system.Name)
-            status = FAIL
-        else:
-            logger.info("%s is %s", name, host)
-            status = PASS
+    status = PASS
+    logger.info("%s is %s", name, host)
+    if system.CreationClassName != name:
+        status = FAIL
+        logger.error("Exp %s, got %s", name, system.CreationClassName)
+    if system.Name != host:
+        logger.error("Exp %s, got %s", host, system.Name)
+        status = FAIL
 
     return status
 
-- 
1.9.0




More information about the Libvirt-cim mailing list