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
Swig based CMPI bindings ------------------------ This implements a CMPI-compliant provider interface for various languages via SWIG. Currently supported languages - Ruby - Python - Perl (beginning support) Implementation -------------- cmpi-bindings is implemented as a single CMPI-compliant provider (per supported language) that serves as a "multiplexer" to the instrumented language-specific providers. Using a python provider for class Py_Foo as an example, cmpi-bindings project provides a cmpi-compliant provider (libpyCmpiProvider.so) that will be registered with the cimom as the provider that handles Py_Foo requests. When libpyCmpiProvider gets the request, it will then forward it on to the python module that instruments the Py_Foo class. cmpi-bindings also provides supported-language-interfaces for the Provider Environment and BrokerCIMOMHandle, so that providers can make "up-calls" into the cimom. For the stack discussion below, use the following 'type' abbreviations: Ruby: rb Python: py Perl: pl The cmpi-bindings provider interfaces under CMPI consist of the following stack: CIMOM -> lib<type>CmpiProvider.so -> cmpi_<type>wbem_bindings.<type> -> <python: pywbem/cim_provider2.py> -> language-specific provider module Build / Installation -------------------- The build scripts will only build the modules for which you have appropriate devel packages. It will skip any others. Requirements ------------ cmake 2.4 or later CMPI header files, e.g. from sblim-cmpi-devel Python interface requires: python-devel, pywbem-0.7.0 Perl interface requires: perl Ruby interface requires: ruby ruby-devel (1.8, 1.9, or 2.0) Build ----- From root of tarball's source tree, create a directory 'build' and move (cd) into that directory 'cmake ..' 'make' 'sudo make install' You can pass various parameters to cmake to control the build, e.g. cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_C_FLAGS_RELEASE:STRING="-Wall -O2 -g" -DCMAKE_CXX_FLAGS_RELEASE:STRING="-Wall -O2 -g" -DCMAKE_BUILD_TYPE=Release Test ---- For each language, there is a test/<language> directory. Within that directory, there should be test providers, scripts that use the test providers, and scripts to register the mofs and providers with CIMOMs. Testing ------- The test/ subdir contains a couple of tests and some sample code. If you have Ruby, rake, sblim-sfcb, sblim-sfcc and sfcc.gem installed, test/rake gives you a more complete testsuite. See test/rake/README for details. Language-specific documentation ------------------------------- Python ----- Visit http://pywbem.wiki.sourceforge.net/Provider+Home for QuickStart Guide, Tutorials, sample providers, etc.
when gcc updated to gcc14, the compile failed:
src/target_python.c:168:21: error: passing argument 1 of 'Py_SetProgramName' from incompatible pointer type [-Wincompatible-pointer-types]
| 168 | Py_SetProgramName("cmpi_swig");
| | ^~~~~~~~~~~
| | |
| | char *
(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.
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).
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.
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.
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.
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.