# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1223669037 25200
# Node ID b0fbd29f2f05c24229efc8dbc0053effe196e688
# Parent 312f2fd41802726987313f7dbb366aa91923e3e9
[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(a)us.ibm.com>
diff -r 312f2fd41802 -r b0fbd29f2f05 suites/libvirt-cim/lib/XenKvmLib/classes.py
--- a/suites/libvirt-cim/lib/XenKvmLib/classes.py Sun Oct 26 20:52:04 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 312f2fd41802 -r b0fbd29f2f05 suites/libvirt-cim/lib/XenKvmLib/enumclass.py
--- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Sun Oct 26 20:52:04 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Fri Oct 10 13:03:57 2008 -0700
@@ -429,7 +429,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.'''
@@ -438,6 +438,9 @@
try:
inst = CIM_CimtestClass(host, ref)
+
+ if ret_cim_inst:
+ inst = inst.inst
except pywbem.CIMError, arg:
print arg[1]