kkaempf / cmpi-bindings Goto Github PK
View Code? Open in Web Editor NEWUsing SWIG to write CIM (CMPI) providers in any (scripting) language
Home Page: openlmi.org
License: Other
Using SWIG to write CIM (CMPI) providers in any (scripting) language
Home Page: openlmi.org
License: Other
I traced it down to get_property_at. It was returning a tuple of 2 values, the first one being NULL (not None).
Looking at swig/cmpi_types.i, right in the TARGET_THREAD_BEGIN_BLOCK, looks like tdata could get set to Target_Null if the property is not set, which (for SWIGPYTHON) is NULL. So later down in the #if defined (SWIGPYTHON) section, tdata is set as the first item of the tuple, and therein lies the problem. Looking at the #define sections, I believe that should have been Target_Void. Looks like Target_Null and Target_Void are identical in Ruby, but they're not in python.
Also, you should incref Py_None before you pass it to PyTuple_SetItem, since PyTuple_SetItem steals the reference (in other words, it doesn't incref itself).
If the value of a property is not set, the following code inside cmpi2pywbem_inst fails:
data, name = cmpiinst.get_property_at(i)
_type, is_array = _cmpi_type2string(data.type)
This is because data is None, so it has no data.type
I think data_data is at fault again, right now it does:
else if (dp->state & CMPI_nullValue) {
result = Target_Null;
Target_INCREF(result);
}
when it should really return dp.
I noticed that providers cannot execute a query as upcall to CIMOM, is this an intention? Looking at CMPI API it looks it should be possible, but CMPIProxyProvider.exec_query explicitly returns CIM_ERR_NOT_SUPPORTED.
(opening new issue with the last 2 comments from #1)
I'm looking at data_data in swig/cmpi.i. Just trying to clarify something for myself.
I think there is an unnecessary INCREF here:
else if ((dp->type) & CMPI_ARRAY) {
int size = CMGetArrayCount(dp->value.array, NULL);
int i;
result = Target_SizedArray(size);
for (i = 0; i < size; --i) {
CMPIData data = CMGetArrayElementAt(dp->value.array, i, NULL);
Target_Append(result, data_data(&data));
}
Target_INCREF(result);
}
To my knowledge, PyList_New (which is what Target_SizedArray is defined to) will return a "protected" object (a new reference). So the last Target_INCREF will leak memory.
(same problem in data_value)
...
I am even more confused now. Target_SizedArray will return a Python list of the specified size. We shouldn't append to that list (which is what Target_Append does), I think we should use PyList_SetItem. Or you could define an empty list initially and then append to it, although I would expect the former approach to be more memory-efficient.
Documentation at http://sourceforge.net/apps/mediawiki/pywbem/index.php?title=Upcalls#InvokeMethod says, that InvokeMethod() should be called with simple parameters like this:
InvokeMethod(myInstanceName, 'HelloWorld', firstParam = pywbem.Uint16(0))
However, this raises an exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cmpi_pywbem_bindings.py", line 82, in __call__
return self.meth(*args, **kwds)
File "/usr/lib/python2.7/site-packages/cmpi_pywbem_bindings.py", line 595, in invoke_method
op, method, pinargs)
File "/usr/lib/python2.7/site-packages/pywbem/cim_provider2.py", line 2011, in MI_invokeMethod
(env, objectName, methodName, inputParams)
File "/usr/lib/python2.7/site-packages/pywbem/cim_provider2.py", line 878, in MI_invokeMethod
**new_inputs)
File "/usr/lib/python2.7/site-packages/pycim/ASP_StorageConfigurationService.py", line 1963, in cim_method_createraid
(ret, outparams) = cliconn.InvokeMethod(partService, 'SetPartitionStyle', Extent = disk, PartitionStyle = partStyle)
File "/usr/lib/python2.7/site-packages/cmpi_pywbem_bindings.py", line 313, in InvokeMethod
inargs=self.proxy.pywbem2cmpi_args(params)
File "/usr/lib/python2.7/site-packages/cmpi_pywbem_bindings.py", line 727, in pywbem2cmpi_args
for name, (_type, pval) in pargs.items():
File "/usr/lib/python2.7/site-packages/pywbem/cim_obj.py", line 533, in __getitem__
def __getitem__(self, key): return self.keybindings[key]
File "/usr/lib/python2.7/site-packages/pywbem/cim_obj.py", line 76, in __getitem__
return self.data[k][1]
InvokeMethod() tries to convert *_params to cmpi format using pywbem2cmpi_args, and pywbem2cmpi_args expects, that *_params is dictionary of (type, value) tuples. And it is not. Either the documentation or the code is wrong.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.