From: <np...@us...> - 2008-10-21 16:36:53
|
Revision: 1115 http://omc.svn.sourceforge.net/omc/?rev=1115&view=rev Author: npaxton Date: 2008-10-21 16:36:45 +0000 (Tue, 21 Oct 2008) Log Message: ----------- add ModifyInstance, refactor CreateInstance(remove path parameter), yank obsolete calls (from v1 that cmpi doesn't support) that were no-ops Modified Paths: -------------- cmpi-bindings/trunk/swig/cmpi_callbacks.i cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py cmpi-bindings/trunk/test/python/UpcallAtomProvider.py Modified: cmpi-bindings/trunk/swig/cmpi_callbacks.i =================================================================== --- cmpi-bindings/trunk/swig/cmpi_callbacks.i 2008-10-20 16:41:46 UTC (rev 1114) +++ cmpi-bindings/trunk/swig/cmpi_callbacks.i 2008-10-21 16:36:45 UTC (rev 1115) @@ -101,11 +101,13 @@ return result; } - /* - CMPIStatus setInstance(const CMPIContext* ctx, const CMPIObjectPath* op, const CMPIInstance* inst, const char** properties) { - return CBSetInstance($self, ctx, op, inst, properties); + void modifyInstance( + const CMPIContext *ctx, + const CMPIObjectPath *op, + const CMPIInstance *inst) + { + RAISE_IF(CBModifyInstance($self, ctx, op, inst)); } - */ void deleteInstance( const CMPIContext * ctx, Modified: cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py =================================================================== --- cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-10-20 16:41:46 UTC (rev 1114) +++ cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-10-21 16:36:45 UTC (rev 1115) @@ -314,23 +314,13 @@ rslt = (outrc,outargs) return rslt - def GetClass(self, *args, **kwargs): - raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) - - def EnumerateClassNames(self, *args, **kwargs): - raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) - - def EnumerateClasses(self, *args, **kwargs): - raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) - - def CreateClass(self, *args, **kwargs): - raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) - - def DeleteClass(self, *args, **kwargs): - raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) - - def CreateInstance(self, path, instance): - cop = self.proxy.pywbem2cmpi_instname(path) + def CreateInstance(self, instance): + if instance.path is None or not instance.path: + # no INVALID_PATH error... INVALID_NAMESPACE is best option + raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_NAMESPACE) + if instance.path.namespace is None or not instance.path.namespace: + raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_NAMESPACE) + cop = self.proxy.pywbem2cmpi_instname(instance.path) inst = self.proxy.pywbem2cmpi_inst(instance) ciname = self.broker.createInstance(self.ctx, cop, inst) if ciname is None: @@ -341,13 +331,20 @@ cop = self.proxy.pywbem2cmpi_instname(path) return self.broker.deleteInstance(self.ctx, cop) + def ModifyInstance(self, instance): + if instance.path is None or not instance.path: + # no INVALID_PATH error... INVALID_NAMESPACE is best option + raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_NAMESPACE) + if instance.path.namespace is None or not instance.path.namespace: + raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_NAMESPACE) + cop = self.proxy.pywbem2cmpi_instname(instance.path) + inst = self.proxy.pywbem2cmpi_inst(instance) + return self.broker.modifyInstance(self.ctx, cop, inst) + def DeliverIndication(self, ns, instance): inst = self.proxy.pywbem2cmpi_inst(instance) return self.broker.deliverIndication(self.ctx, ns, inst) - ### Not sure whether this should be on BrokerCIMOMHandle or - ### on ProviderEnvironment - ### We may want to move it ? def is_subclass(self, ns, super, sub): subObjPath=self.broker.new_object_path(ns, sub) return bool(self.broker.classPathIsA(subObjPath,super)) @@ -391,12 +388,6 @@ return Logger(self.proxy.broker, self.proxy.miname) def get_cimom_handle(self): return BrokerCIMOMHandle(self.proxy, self.ctx.cmpicontext) - def get_user_name(self): - pass - def get_context_value(self, key): - pass - def set_context_value(self, key, value): - pass g_proxies = {} Modified: cmpi-bindings/trunk/test/python/UpcallAtomProvider.py =================================================================== --- cmpi-bindings/trunk/test/python/UpcallAtomProvider.py 2008-10-20 16:41:46 UTC (rev 1114) +++ cmpi-bindings/trunk/test/python/UpcallAtomProvider.py 2008-10-21 16:36:45 UTC (rev 1115) @@ -238,7 +238,7 @@ try: msg = '' - cipath = ch.CreateInstance(cop, new_instance) + cipath = ch.CreateInstance(new_instance) new_instance.path = cipath _inst_paths.append(cipath) @@ -513,7 +513,7 @@ cop['id'] = 'One' new_instance.path = cop try: - cipath=ch.CreateInstance(cop, new_instance) + cipath=ch.CreateInstance(new_instance) new_instance.path = cipath gotinst = ch.GetInstance(cipath) @@ -589,6 +589,27 @@ except pywbem.CIMError, arg: raise "**** CreateInstance Failed ****" + + # now make sure throws appropriate exception if path not set + try: + new_instance = pywbem.CIMInstance('Test_Atom') + new_instance['Name'] = 'Failure' + # DO NOT set new_instance.path for this test... expect a failure + new_instance['boolProp'] = True + + try: + cipath = ch.CreateInstance(new_instance) + #if I got here, then it's a failure + raise "Expected INVALID_NAMESPACE error but didn't get it" + + except pywbem.CIMError, args: + if args[0] != pywbem.CIM_ERR_INVALID_NAMESPACE: + #not what we were looking for + raise + #else success + except: + raise + ################################################################################ #test_3_enum_instances #Test enumeration of instances and then compare them with the local @@ -679,7 +700,6 @@ ################################################################################ #test_6_modify_instance - ''' print "####### test_6_modify_instance ########" #Create an instance of "Boron" and then modify it to Helium # Once modified, get_instance returns it and then check the values of it @@ -712,7 +732,7 @@ mod_instance['Name'] = 'Boron' try: - ch.ModifyInstance(ch.default_namespace, mod_instance) + ch.ModifyInstance(mod_instance) except pywbem.CIMError, arg: raise @@ -742,8 +762,8 @@ else: raise "ModifyInstance Failed!!" _cleanup(ch) - ''' + ################################################################################ #test_7_delete log_debug("######## test_7_delete #######", logger) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |