# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1223669037 25200
# Node ID 3e4bbcff3c709620d9d86860b417be4a9b563842
# Parent 419ea0c270bf4be5be590e68edc96f0311df7d03
[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 419ea0c270bf -r 3e4bbcff3c70 suites/libvirt-cim/lib/XenKvmLib/classes.py
--- a/suites/libvirt-cim/lib/XenKvmLib/classes.py Fri Oct 10 13:17:01 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 419ea0c270bf -r 3e4bbcff3c70 suites/libvirt-cim/lib/XenKvmLib/enumclass.py
--- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Fri Oct 10 13:17:01 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Fri Oct 10 13:03:57 2008 -0700
@@ -495,7 +495,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.'''
@@ -504,6 +504,9 @@
try:
inst = CIM_CimtestClass(host, ref)
+
+ if ret_cim_inst:
+ inst = inst.inst
except pywbem.CIMError, arg:
print arg[1]