
try: - cs = computersystem.get_cs_class(virt)(ip, domain_name) + cs = get_typed_class(virt, 'ComputerSystem')(ip, domain_name)
Sorry Daisy, I didn't catch that this piece was attempting to get the CS instance. I misread this the first time around. This won't work because the __init__ for CIM_MyClass doesn't include the proper keys in the CIMInstanceName call. What you'll need to do is use something like: cn = get_typed_class(virt, 'ComputerSystem') keys = {"Name" : domain_name, "CreationClassName" : cn } cs = eval('enumclass.' + cn)(ip, keys) Or you can use the getInstance() function in enumclass, which is probably a better way to go because I'd like to avoid using eval where possible. Deepti - I think this is what's causing the issues you were seeing with the other two patches.
if cs.Name != domain_name: logger.error("VS %s is not found" % domain_name) @@ -169,7 +168,7 @@
def poll_for_state_change(server, virt, dom, exp_state, timeout=30): dom_cs = None - cs = computersystem.get_cs_class(virt) + cs = get_typed_class(virt, 'ComputerSystem')
This also won't work, because of the following bit of code in the for loop: dom_cs = cs(server, name=dom) Instead, you should use getInstance() here as well.
try: for i in range(1, (timeout + 1)): diff -r 946fd46b9686 -r 57b15d9bb761 suites/libvirt-cim/lib/XenKvmLib/enumclass.py --- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Thu Aug 28 14:07:25 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Sun Aug 31 19:17:56 2008 -0700 @@ -26,7 +26,7 @@ import pywbem from pywbem.cim_obj import CIMInstanceName from XenKvmLib.devices import CIM_Instance -from XenKvmLib.classes import get_typed_class +from XenKvmLib.classes import get_typed_class, virt_types from CimTest import Globals
class CIM_MyClass(CIM_Instance): @@ -45,7 +45,32 @@
CIM_Instance.__init__(self, inst)
+ def __invoke(self, method, params): + try: + return self.conn.InvokeMethod(method, + self.ref, + **params)
If you're using self.conn, etc - you'll need to store these variables during the __init__ call.
+ except pywbem.CIMError, arg: + print 'InvokeMethod(%s): %s' % (method, arg[1]) + raise + + def __getattr__(self, attr): + if self.inst.has_key(attr): + return self.inst[attr] + else: + return CimExt._Method(self.__invoke, attr) +
You'll need to import CimExt. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com