[Libvirt-cim] [PATCH 1 of 3] [TEST] Update inst_to_mof() to convert CIM_CimtestClass instances to inst

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Wed Oct 29 23:17:39 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1223669037 25200
# Node ID 5809c74c1bfa4458ce4fe72c4741d509215cd312
# Parent  408dbb3a61b43bd0def587a9ea7e648105def002
[TEST] Update inst_to_mof() to convert CIM_CimtestClass instances to inst

Also update GetInstance so it returns both CIMInstance and CIM_CimtestClass objects.

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

diff -r 408dbb3a61b4 -r 5809c74c1bfa suites/libvirt-cim/lib/XenKvmLib/classes.py
--- a/suites/libvirt-cim/lib/XenKvmLib/classes.py	Mon Oct 27 20:03:31 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/classes.py	Fri Oct 10 13:03:57 2008 -0700
@@ -18,6 +18,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 #
+import pywbem
 
 virt_types = ['Xen', 'KVM', 'XenFV', 'LXC']
 
@@ -47,6 +48,9 @@
 #FIXME This function is only needed for libcmpiutil versions 0.4 and later.
 #Once version 0.4 is obsolete, this function should be removed.
 def inst_to_mof(inst):
+    if not isinstance(inst, pywbem.cim_obj.CIMInstance):
+        inst = inst.inst
+
     mof_str = inst.tomof()
 
     mof_inst = ""
diff -r 408dbb3a61b4 -r 5809c74c1bfa suites/libvirt-cim/lib/XenKvmLib/enumclass.py
--- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py	Mon Oct 27 20:03:31 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py	Fri Oct 10 13:03:57 2008 -0700
@@ -103,7 +103,7 @@
  
     return list
 
-def GetInstance(host, cn, keys):
+def GetInstance(host, cn, keys, ret_cim_inst=False):
     '''Resolve the enumeration given the @cn.
     Return a list of CIMInstance objects.'''
 
@@ -112,6 +112,9 @@
 
     try:
         inst = CIM_CimtestClass(host, ref)
+
+        if ret_cim_inst:
+            inst = inst.inst
     except pywbem.CIMError, arg:
         print arg[1]
 




More information about the Libvirt-cim mailing list