[Libvirt-cim] [PATCH 1 of 9] [TEST] Have get_host_info() return the host instance

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Mon Nov 17 21:10:28 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1226705448 28800
# Node ID 87ae0e86a0e1e3eecf218f11ec079958449a95fc
# Parent  ac693577d27b1b5f24fdc6c50272b11d02c91c7f
[TEST] Have get_host_info() return the host instance.

Have check_sblim() store the original namespace (since the test might be using
root/virt or root/interop).

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r ac693577d27b -r 87ae0e86a0e1 suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py	Fri Nov 14 12:48:36 2008 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py	Fri Nov 14 15:30:48 2008 -0800
@@ -205,41 +205,24 @@
 
     return PASS, dom_cs 
 
-def get_host_info(server, virt="Xen"):
-    status = PASS
-    host_name = ''
-    host_ccn  = ''
-    keys = ['Name', 'CreationClassName']
+def get_host_info(server, virt):
+    try:
+        status, linux_cs = check_sblim(server)
+        if status == PASS:
+            return status, linux_cs
 
-    try:
-
-        # This following modification is req to accomadate the 
-        # sblim-base-provider provider related changes
-
-        ret, linux_cs = check_sblim(server)
         hs_class = get_typed_class(virt, 'HostSystem')
         host_info = enumclass.EnumInstances(server, hs_class)
-        if ret == PASS:
-            host_sys = linux_cs
-        elif len(host_info) == 1:
-            host_sys = host_info[0]
+        if len(host_info) == 1:
+            return PASS, host_info[0]
         else:
-            logger.error("Error in getting HostSystem information, Exiting...")
-            return FAIL,  host_name, host_ccn
-
-        if host_sys.Name == "":
-            logger.error("HostName seems to be empty")
-            status = FAIL
-        else:
-            # Instance of the HostSystem
-            host_ccn = host_sys.CreationClassName
-            host_name = host_sys.Name
+            logger.error("Error in getting HostSystem instance")
+            return FAIL, None 
 
     except Exception,detail:
-        logger.error(CIM_ERROR_ENUMERATE, 'Hostsystem')
         logger.error("Exception: %s", detail)
-        status = FAIL
-    return status, host_name, host_ccn
+
+    return FAIL, None 
 
 def try_assoc(conn, classname, assoc_classname, keys, field_name, \
                                               expr_values, bug_no):
@@ -497,6 +480,7 @@
 
 def check_sblim(server, virt='Xen'):
     status = FAIL
+    prev_namespace = Globals.CIM_NS
     Globals.CIM_NS = 'root/cimv2'
     keys = ['Name', 'CreationClassName']
     linux_cs = None
@@ -512,5 +496,5 @@
         logger.error(CIM_ERROR_ENUMERATE, 'Linux_ComputerSystem')
         logger.error("Exception: %s", detail)
 
-    Globals.CIM_NS = 'root/virt'
+    Globals.CIM_NS = prev_namespace 
     return status, linux_cs 




More information about the Libvirt-cim mailing list