You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(26) |
Dec
(13) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(5) |
Feb
(16) |
Mar
(5) |
Apr
(5) |
May
(13) |
Jun
(12) |
Jul
(1) |
Aug
(2) |
Sep
(13) |
Oct
(6) |
Nov
(1) |
Dec
(29) |
2008 |
Jan
(2) |
Feb
(2) |
Mar
(2) |
Apr
(57) |
May
(35) |
Jun
(45) |
Jul
(132) |
Aug
(87) |
Sep
(141) |
Oct
(86) |
Nov
(17) |
Dec
(2) |
2009 |
Jan
(3) |
Feb
(2) |
Mar
(3) |
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2010 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <kk...@us...> - 2008-09-02 19:08:50
|
Revision: 907 http://omc.svn.sourceforge.net/omc/?rev=907&view=rev Author: kkaempf Date: 2008-09-02 19:08:45 +0000 (Tue, 02 Sep 2008) Log Message: ----------- init Python threads Modified Paths: -------------- cmpi-bindings/trunk/src/cmpi_provider_python.c Modified: cmpi-bindings/trunk/src/cmpi_provider_python.c =================================================================== --- cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-09-02 19:06:53 UTC (rev 906) +++ cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-09-02 19:08:45 UTC (rev 907) @@ -697,6 +697,7 @@ #endif Py_SetProgramName("cmpi_swig"); + PyEval_InitThreads(); Py_Initialize(); SWIG_init(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kk...@us...> - 2008-09-02 19:06:50
|
Revision: 906 http://omc.svn.sourceforge.net/omc/?rev=906&view=rev Author: kkaempf Date: 2008-09-02 19:06:53 +0000 (Tue, 02 Sep 2008) Log Message: ----------- thread-protect string->python conversion Modified Paths: -------------- cmpi-bindings/trunk/src/cmpi_provider_python.c Modified: cmpi-bindings/trunk/src/cmpi_provider_python.c =================================================================== --- cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-09-02 15:32:01 UTC (rev 905) +++ cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-09-02 19:06:53 UTC (rev 906) @@ -31,6 +31,8 @@ static char _CLASSNAME[] = "CmpiInstanceSwig"; +#define WITH_SWIG_THREADS 0 + #include <stdio.h> #include <stdarg.h> @@ -98,27 +100,51 @@ static int PyInitialize(PyProviderMIHandle* hdl, CMPIStatus* st); #define PY_CMPI_INIT { if (((PyProviderMIHandle*)(self->hdl))->pyMod == NULL) if (PyInitialize(((PyProviderMIHandle*)(self->hdl)), &status) != 0) return status; } -static PyObject* proplist2py(const char** cplist) +static PyObject* +proplist2py(const char** cplist) { - if (cplist == NULL) - { - Py_RETURN_NONE; - } - PyObject* pl; - //SWIG_PYTHON_THREAD_BEGIN_BLOCK; - pl = PyList_New(0); - for (; *cplist != NULL; ++cplist) - { - PyList_Append(pl, PyString_FromString(*cplist)); - } - //SWIG_PYTHON_THREAD_END_BLOCK; - return pl; + if (cplist == NULL) + { + Py_RETURN_NONE; + } + PyObject* pl; +#if WITH_SWIG_THREADS + SWIG_PYTHON_THREAD_BEGIN_BLOCK; +#endif + + pl = PyList_New(0); + for (; *cplist != NULL; ++cplist) + { + PyList_Append(pl, PyString_FromString(*cplist)); + } +#if WITH_SWIG_THREADS + SWIG_PYTHON_THREAD_END_BLOCK +#endif + + return pl; } +static PyObject * +string2py(const char *s) +{ + PyObject *obj; +#if WITH_SWIG_THREADS + SWIG_PYTHON_THREAD_BEGIN_BLOCK; +#endif + + obj = PyString_FromString(s); +#if WITH_SWIG_THREADS + SWIG_PYTHON_THREAD_END_BLOCK +#endif + + return obj; +} + #define TB_ERROR(str) {tbstr = str; goto cleanup;} -static CMPIString* get_exc_trace() +static CMPIString* +get_exc_trace() { char *tbstr = NULL; @@ -133,7 +159,7 @@ PyObject *type, *value, *traceback; _SBLIM_TRACE(1, ("PyErr_Occurred() %d", PyErr_Occurred())); - //SWIG_PYTHON_THREAD_BEGIN_BLOCK; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_Fetch(&type, &value, &traceback); _SBLIM_TRACE(1,("** type %p, value %p, traceback %p", type, value, traceback)); PyErr_Print(); @@ -178,8 +204,8 @@ TB_ERROR("getvalue() did not return a string"); args = PyTuple_New(2); - PyTuple_SetItem(args, 0, PyString_FromString("\n")); - PyTuple_SetItem(args, 1, PyString_FromString("<br>")); + PyTuple_SetItem(args, 0, string2py("\n")); + PyTuple_SetItem(args, 1, string2py("<br>")); func = PyObject_GetAttrString(obstr, "replace"); //newstr = PyObject_CallMethod(obstr, "replace", args); @@ -193,7 +219,6 @@ cleanup: PyErr_Restore(type, value, traceback); - //SWIG_PYTHON_THREAD_END_BLOCK; if (rv == NULL) { @@ -209,6 +234,7 @@ Py_DecRef(tbmod); + SWIG_PYTHON_THREAD_END_BLOCK; return rv; } @@ -222,14 +248,17 @@ va_list vargs; PyObject *pyargs = NULL; PyObject *pyfunc = NULL; - PyObject *prv = NULL; - //SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyObject *prv = NULL; +#if WITH_SWIG_THREADS + SWIG_PYTHON_THREAD_BEGIN_BLOCK; +#endif + pyargs = PyTuple_New(nargs); pyfunc = PyObject_GetAttrString(hdl->pyMod, opname); if (pyfunc == NULL) { - PyErr_Print(); - PyErr_Clear(); + PyErr_Print(); + PyErr_Clear(); char* str = fmtstr("Python module does not contain \"%s\"", opname); _SBLIM_TRACE(1,(str)); st->rc = CMPI_RC_ERR_FAILED; @@ -317,7 +346,10 @@ Py_DecRef(pyargs); Py_DecRef(pyfunc); Py_DecRef(prv); - //SWIG_PYTHON_THREAD_END_BLOCK; +#if WITH_SWIG_THREADS + SWIG_PYTHON_THREAD_END_BLOCK +#endif + return rc; } @@ -335,11 +367,17 @@ _SBLIM_TRACE(1,("Cleanup() called")); - //SWIG_PYTHON_THREAD_BEGIN_BLOCK; +#if WITH_SWIG_THREADS + SWIG_PYTHON_THREAD_BEGIN_BLOCK; +#endif + Py_DecRef(_PYPROVMOD); Py_Finalize(); - // TODO should release come before finalize? - //SWIG_PYTHON_THREAD_END_BLOCK; + // TODO should release come before finalize? +#if WITH_SWIG_THREADS + SWIG_PYTHON_THREAD_END_BLOCK +#endif + _SBLIM_TRACE(1,("Cleanup(Python) called")); if (miHdl != NULL) @@ -548,13 +586,13 @@ _SBLIM_TRACE(1,("SetInstance(Python) called, context %p, results %p, reference %p, newinstance %p, properties %p", context, results, reference, newinstance, properties)); - PY_CMPI_INIT + PY_CMPI_INIT PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); PyObject *pyresult = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); PyObject *pynewinst = SWIG_NewPointerObj((void*) newinstance, SWIGTYPE_p__CMPIInstance, 0); - PyObject *plist = proplist2py(properties); + PyObject *plist = proplist2py(properties); call_py_provider((PyProviderMIHandle*)self->hdl, &status, "set_instance", 5, pycontext, @@ -621,8 +659,8 @@ PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); PyObject *pyresult = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); - PyObject *pyquery = PyString_FromString(query); - PyObject *pylang = PyString_FromString(language); + PyObject *pyquery = string2py(query); + PyObject *pylang = string2py(language); call_py_provider((PyProviderMIHandle*)self->hdl, &status, "exec_query", 5, pycontext, @@ -653,43 +691,63 @@ _SBLIM_TRACE(1,("Python: Loading")); + +#if WITH_SWIG_THREADS + SWIG_PYTHON_THREAD_BEGIN_BLOCK; +#endif + Py_SetProgramName("cmpi_swig"); Py_Initialize(); + SWIG_init(); - _PYPROVMOD = PyImport_ImportModule("pycmpi_provider"); - if (_PYPROVMOD == NULL) - { - _SBLIM_TRACE(1,("Python: _PYPROVMOD at %p", _PYPROVMOD)); - PY_CMPI_SETFAIL(get_exc_trace()); - return -1; - } - _SBLIM_TRACE(1,("Python: _PYPROVMOD at %p", _PYPROVMOD)); - PyObject* provclass = PyObject_GetAttrString(_PYPROVMOD, + _PYPROVMOD = PyImport_ImportModule("pycmpi_provider"); + if (_PYPROVMOD == NULL) + { + _SBLIM_TRACE(1,("Python: _PYPROVMOD at %p", _PYPROVMOD)); + PY_CMPI_SETFAIL(get_exc_trace()); +#if WITH_SWIG_THREADS + SWIG_PYTHON_THREAD_END_BLOCK; +#endif + return -1; + } + _SBLIM_TRACE(1,("Python: _PYPROVMOD at %p", _PYPROVMOD)); + PyObject* provclass = PyObject_GetAttrString(_PYPROVMOD, "CMPIProvider"); - if (provclass == NULL) - { - PY_CMPI_SETFAIL(get_exc_trace()); - return -1; - } - PyObject* broker = SWIG_NewPointerObj((void*) _BROKER, SWIGTYPE_p__CMPIBroker, 0); - PyObject* args = PyTuple_New(2); + if (provclass == NULL) + { + PY_CMPI_SETFAIL(get_exc_trace()); +#if WITH_SWIG_THREADS + SWIG_PYTHON_THREAD_END_BLOCK; +#endif + return -1; + } + PyObject* broker = SWIG_NewPointerObj((void*) _BROKER, SWIGTYPE_p__CMPIBroker, 0); + PyObject* args = PyTuple_New(2); _SBLIM_TRACE(1,("\n>>>>> PyInitialize(Python) called, MINAME=%s\n", hdl->miName)); - PyTuple_SetItem(args, 0, PyString_FromString(hdl->miName)); - PyTuple_SetItem(args, 1, broker); - PyObject* provinst = PyObject_CallObject(provclass, args); - Py_DecRef(args); - Py_DecRef(provclass); - if (provinst == NULL) - { - PY_CMPI_SETFAIL(get_exc_trace()); - return -1; - } + PyTuple_SetItem(args, 0, string2py(hdl->miName)); + PyTuple_SetItem(args, 1, broker); + PyObject* provinst = PyObject_CallObject(provclass, args); + Py_DecRef(args); + Py_DecRef(provclass); + if (provinst == NULL) + { + PY_CMPI_SETFAIL(get_exc_trace()); +#if WITH_SWIG_THREADS + SWIG_PYTHON_THREAD_END_BLOCK; +#endif + return -1; + } - hdl->pyMod = provinst; + hdl->pyMod = provinst; - _SBLIM_TRACE(1,("PyInitialize() succeeded")); - return 0; +#if WITH_SWIG_THREADS + SWIG_PYTHON_THREAD_END_BLOCK +#endif + + + _SBLIM_TRACE(1,("PyInitialize() succeeded")); + return 0; } @@ -722,19 +780,19 @@ PyObject* pyresultRole = NULL; if (assocClass != NULL) { - pyassocClass = PyString_FromString(assocClass); + pyassocClass = string2py(assocClass); } if (resultClass != NULL) { - pyresultClass = PyString_FromString(resultClass); + pyresultClass = string2py(resultClass); } if (role != NULL) { - pyrole = PyString_FromString(role); + pyrole = string2py(role); } if (resultRole != NULL) { - pyresultRole = PyString_FromString(resultRole); + pyresultRole = string2py(resultRole); } call_py_provider((PyProviderMIHandle*)self->hdl, &status, "associator_names", 7, @@ -782,19 +840,19 @@ PyObject* pyresultRole = NULL; if (assocClass != NULL) { - pyassocClass = PyString_FromString(assocClass); + pyassocClass = string2py(assocClass); } if (resultClass != NULL) { - pyresultClass = PyString_FromString(resultClass); + pyresultClass = string2py(resultClass); } if (role != NULL) { - pyrole = PyString_FromString(role); + pyrole = string2py(role); } if (resultRole != NULL) { - pyresultRole = PyString_FromString(resultRole); + pyresultRole = string2py(resultRole); } call_py_provider((PyProviderMIHandle*)self->hdl, &status, "associators", 8, @@ -837,11 +895,11 @@ PyObject* pyrole = NULL; if (role != NULL) { - pyrole = PyString_FromString(role); + pyrole = string2py(role); } if (resultClass != NULL) { - pyresultClass = PyString_FromString(resultClass); + pyresultClass = string2py(resultClass); } call_py_provider((PyProviderMIHandle*)self->hdl, &status, "reference_names", 5, @@ -883,11 +941,11 @@ PyObject* pyresultClass = NULL; if (role != NULL) { - pyrole = PyString_FromString(role); + pyrole = string2py(role); } if (resultClass != NULL) { - pyresultClass = PyString_FromString(resultClass); + pyresultClass = string2py(resultClass); } PyObject *pyprops = proplist2py(properties); @@ -924,7 +982,7 @@ PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); PyObject *pyrslt = SWIG_NewPointerObj((void*) rslt, SWIGTYPE_p__CMPIResult, 0); PyObject *pyobjName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0); - PyObject *pymethod = PyString_FromString(method); + PyObject *pymethod = string2py(method); PyObject *pyin = SWIG_NewPointerObj((void*) in, SWIGTYPE_p__CMPIArgs, 0); PyObject *pyout = SWIG_NewPointerObj((void*) out, SWIGTYPE_p__CMPIArgs, 0); @@ -960,8 +1018,8 @@ PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); PyObject *pyfilter = SWIG_NewPointerObj((void*) filter, SWIGTYPE_p__CMPISelectExp, 0); PyObject *pyclassPath = SWIG_NewPointerObj((void*) classPath, SWIGTYPE_p__CMPIObjectPath, 0); - PyObject *pyclassName = PyString_FromString(className); - PyObject *pyowner = PyString_FromString(owner); + PyObject *pyclassName = string2py(className); + PyObject *pyowner = string2py(owner); call_py_provider((PyProviderMIHandle*)self->hdl, &status, "authorize_filter", 5, pyctx, @@ -994,7 +1052,7 @@ PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); PyObject *pyfilter = SWIG_NewPointerObj((void*) filter, SWIGTYPE_p__CMPISelectExp, 0); PyObject *pyclassPath = SWIG_NewPointerObj((void*) classPath, SWIGTYPE_p__CMPIObjectPath, 0); - PyObject *pyclassName = PyString_FromString(className); + PyObject *pyclassName = string2py(className); PyObject *pyfirstActivation = PyBool_FromLong(firstActivation); call_py_provider((PyProviderMIHandle*)self->hdl, &status, "activate_filter", 5, @@ -1028,7 +1086,7 @@ PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); PyObject *pyfilter = SWIG_NewPointerObj((void*) filter, SWIGTYPE_p__CMPISelectExp, 0); PyObject *pyclassPath = SWIG_NewPointerObj((void*) classPath, SWIGTYPE_p__CMPIObjectPath, 0); - PyObject *pyclassName = PyString_FromString(className); + PyObject *pyclassName = string2py(className); PyObject *pylastActivation = PyBool_FromLong(lastActivation); call_py_provider((PyProviderMIHandle*)self->hdl, &status, "deactivate_filter", 5, @@ -1067,7 +1125,7 @@ //PyObject *pyrslt = SWIG_NewPointerObj((void*) rslt, SWIGTYPE_p__CMPIResult, 0); PyObject *pyfilter = SWIG_NewPointerObj((void*) filter, SWIGTYPE_p__CMPISelectExp, 0); PyObject *pyclassPath = SWIG_NewPointerObj((void*) classPath, SWIGTYPE_p__CMPIObjectPath, 0); - PyObject *pyclassName = PyString_FromString(className); + PyObject *pyclassName = string2py(className); call_py_provider((PyProviderMIHandle*)self->hdl, &status, "must_poll", 4, pyctx, @@ -1223,4 +1281,3 @@ SWIG_CMPI_MI_FACTORY(Method) SWIG_CMPI_MI_FACTORY(Association) SWIG_CMPI_MI_FACTORY(Indication) - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kk...@us...> - 2008-09-02 15:31:53
|
Revision: 905 http://omc.svn.sourceforge.net/omc/?rev=905&view=rev Author: kkaempf Date: 2008-09-02 15:32:01 +0000 (Tue, 02 Sep 2008) Log Message: ----------- provide CMPIBroker constructor Modified Paths: -------------- cmpi-bindings/trunk/swig/cmpi_callbacks.i Modified: cmpi-bindings/trunk/swig/cmpi_callbacks.i =================================================================== --- cmpi-bindings/trunk/swig/cmpi_callbacks.i 2008-09-02 15:16:46 UTC (rev 904) +++ cmpi-bindings/trunk/swig/cmpi_callbacks.i 2008-09-02 15:32:01 UTC (rev 905) @@ -9,71 +9,72 @@ %extend CMPIBroker { + CMPIBroker() { return _BROKER; } void LogMessage(int severity, const char *id, const char *text) { - CMLogMessage(_BROKER, severity, id, text, NULL); + CMLogMessage($self, severity, id, text, NULL); } unsigned long capabilities() { - return CBGetCapabilities(_BROKER); + return CBGetCapabilities($self); } int version() { - return CBBrokerVersion(_BROKER); + return CBBrokerVersion($self); } const char *name() { - return CBBrokerName(_BROKER); + return CBBrokerName($self); } CMPIStatus deliverIndication(const CMPIContext * ctx, const char * ns, const CMPIInstance * ind) { - return CBDeliverIndication(_BROKER, ctx, ns, ind); + return CBDeliverIndication($self, ctx, ns, ind); } CMPIEnumeration* enumInstanceNames(const CMPIContext * ctx, const CMPIObjectPath * op) { - return CBEnumInstanceNames(_BROKER, ctx, op, NULL); + return CBEnumInstanceNames($self, ctx, op, NULL); } CMPIEnumeration *enumInstances(const CMPIContext * ctx, const CMPIObjectPath * op, const char **properties) { - return CBEnumInstances(_BROKER, ctx, op, properties, NULL); + return CBEnumInstances($self, ctx, op, properties, NULL); } CMPIInstance *getInstance(const CMPIContext * ctx, const CMPIObjectPath * op, const char **properties) { - return CBGetInstance(_BROKER, ctx, op, properties, NULL); + return CBGetInstance($self, ctx, op, properties, NULL); } CMPIObjectPath *createInstance(const CMPIContext * ctx, const CMPIObjectPath * op, const CMPIInstance * inst) { - return CBCreateInstance(_BROKER, ctx, op, inst, NULL); + return CBCreateInstance($self, ctx, op, inst, NULL); } /* CMPIStatus setInstance(const CMPIContext* ctx, const CMPIObjectPath* op, const CMPIInstance* inst, const char** properties) { - return CBSetInstance(_BROKER, ctx, op, inst, properties); + return CBSetInstance($self, ctx, op, inst, properties); } */ CMPIStatus deleteInstance(const CMPIContext * ctx, const CMPIObjectPath * op) { - return CBDeleteInstance(_BROKER, ctx, op); + return CBDeleteInstance($self, ctx, op); } CMPIEnumeration *execQuery(const CMPIContext * ctx, const CMPIObjectPath * op, const char *query, const char *lang) { - return CBExecQuery(_BROKER, ctx, op, query, lang, NULL); + return CBExecQuery($self, ctx, op, query, lang, NULL); } CMPIEnumeration *associators(const CMPIContext * ctx, const CMPIObjectPath * op, const char *assocClass, const char *resultClass, const char *role, const char *resultRole, const char **properties) { - return CBAssociators(_BROKER, ctx, op, assocClass, resultClass, role, resultRole, properties, NULL); + return CBAssociators($self, ctx, op, assocClass, resultClass, role, resultRole, properties, NULL); } CMPIEnumeration *associatorNames(const CMPIContext * ctx, const CMPIObjectPath * op, const char *assocClass, const char *resultClass, const char *role, const char *resultRole) { - return CBAssociatorNames (_BROKER, ctx, op, assocClass, resultClass, role, resultRole, NULL); + return CBAssociatorNames ($self, ctx, op, assocClass, resultClass, role, resultRole, NULL); } CMPIEnumeration *references(const CMPIContext * ctx, const CMPIObjectPath * op, const char *resultClass, const char *role, const char **properties) { - return CBReferences(_BROKER, ctx, op, resultClass, role, properties, NULL); + return CBReferences($self, ctx, op, resultClass, role, properties, NULL); } CMPIEnumeration *referenceNames(const CMPIContext * ctx, const CMPIObjectPath * op, const char *resultClass, const char *role) { - return CBReferenceNames(_BROKER, ctx, op, resultClass, role, NULL); + return CBReferenceNames($self, ctx, op, resultClass, role, NULL); } CMPIData invokeMethod(const CMPIContext * ctx, const CMPIObjectPath * op, const char *method, const CMPIArgs * in, CMPIArgs * out) { - return CBInvokeMethod(_BROKER, ctx, op, method, in, out, NULL); + return CBInvokeMethod($self, ctx, op, method, in, out, NULL); } CMPIStatus setProperty(const CMPIContext * ctx, const CMPIObjectPath * op, const char *name, const CMPIValue * value, const CMPIType type) { - return CBSetProperty(_BROKER, ctx, op, name, (CMPIValue *)value, type); + return CBSetProperty($self, ctx, op, name, (CMPIValue *)value, type); } CMPIData getProperty(const CMPIContext * ctx, const CMPIObjectPath *op, const char *name) { - return CBGetProperty(_BROKER, ctx, op, name, NULL); + return CBGetProperty($self, ctx, op, name, NULL); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kk...@us...> - 2008-09-02 15:16:40
|
Revision: 904 http://omc.svn.sourceforge.net/omc/?rev=904&view=rev Author: kkaempf Date: 2008-09-02 15:16:46 +0000 (Tue, 02 Sep 2008) Log Message: ----------- document the tests a bit Added Paths: ----------- cmpi-bindings/trunk/test/python/README Added: cmpi-bindings/trunk/test/python/README =================================================================== --- cmpi-bindings/trunk/test/python/README (rev 0) +++ cmpi-bindings/trunk/test/python/README 2008-09-02 15:16:46 UTC (rev 904) @@ -0,0 +1,36 @@ +These are tests for the various CMPI interface functions + + +Setup +----- + +- Be sure you have the latest pywbem from + https://pywbem.svn.sourceforge.net/svnroot/pywbem/pywbem/trunk + (svn co https://pywbem.svn.sourceforge.net/svnroot/pywbem/pywbem/trunk pywbem) + + [Debug setup: + x86_64 + # cd pywbem + # rm /usr/lib64/python/site-packages/pywbem/*.py + # ln -s `pwd`/*.py /usr/lib64/python/site-packages/pywbem/ + + x86 + # cd pywbem + # rm /usr/lib/python/site-packages/pywbem/*.py + # ln -s `pwd`/*.py /usr/lib/python/site-packages/pywbem/ + ] + +- Create symlinks for sfcb mof/reg + + sudo ./setup.sh + + This also runs "sfcbrepos -f" + +- Restart sfcbd + +- now run TestMethod_Test.py, TestAtomProvider_Test.py as root. + (they only need to run as root because they use the passwordless local unix connection). + those two tests should all pass. + test_assoc.py should partially pass. + + ["Property Not Found in PropertyList: uint64" is an expected error] \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kk...@us...> - 2008-09-02 14:38:06
|
Revision: 903 http://omc.svn.sourceforge.net/omc/?rev=903&view=rev Author: kkaempf Date: 2008-09-02 14:38:17 +0000 (Tue, 02 Sep 2008) Log Message: ----------- rename according to systemsmanagement:wbem:unstable in openSUSE build service Modified Paths: -------------- cmpi-bindings/trunk/package/cmpi-bindings.spec.in Modified: cmpi-bindings/trunk/package/cmpi-bindings.spec.in =================================================================== --- cmpi-bindings/trunk/package/cmpi-bindings.spec.in 2008-09-02 10:31:33 UTC (rev 902) +++ cmpi-bindings/trunk/package/cmpi-bindings.spec.in 2008-09-02 14:38:17 UTC (rev 903) @@ -48,26 +48,26 @@ %clean %{__rm} -rf %{buildroot} -%package -n ruby-cmpi-bindings +%package -n cmpi-bindings-ruby Summary: Ruby bindings for cmpi Group: Development/Languages/Ruby -%description -n ruby-cmpi-bindings +%description -n cmpi-bindings-ruby - -%files -n ruby-cmpi-bindings +%files -n cmpi-bindings-ruby %defattr(-,root,root,-) %{_libdir}/cmpi/librbCmpiProvider.so %{_libdir}/ruby/vendor_ruby/%{rb_ver}/rcmpi_instance.rb -%package -n python-cmpi-bindings +%package -n cmpi-bindings-pywbem Summary: Python bindings for cmpi Group: Development/Languages/Python -%description -n python-cmpi-bindings +%description -n cmpi-bindings-pywbem - -%files -n python-cmpi-bindings +%files -n cmpi-bindings-pywbem %defattr(-,root,root,-) %{_libdir}/cmpi/libpyCmpiProvider.so %{py_sitedir}/pycmpi_provider.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kk...@us...> - 2008-09-02 10:31:39
|
Revision: 902 http://omc.svn.sourceforge.net/omc/?rev=902&view=rev Author: kkaempf Date: 2008-09-02 10:31:33 +0000 (Tue, 02 Sep 2008) Log Message: ----------- fix file list Modified Paths: -------------- cmpi-bindings/trunk/package/cmpi-bindings.spec.in Modified: cmpi-bindings/trunk/package/cmpi-bindings.spec.in =================================================================== --- cmpi-bindings/trunk/package/cmpi-bindings.spec.in 2008-09-02 10:31:06 UTC (rev 901) +++ cmpi-bindings/trunk/package/cmpi-bindings.spec.in 2008-09-02 10:31:33 UTC (rev 902) @@ -17,9 +17,10 @@ Summary: Bindings for cmpi Group: Development/Sources BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: cmake gcc-c++ ruby-devel swig -BuildRequires: sblim-sfcb-devel +BuildRequires: cmake gcc-c++ ruby-devel python-devel swig +BuildRequires: sblim-sfcb Source: %{name}-%{version}.tar.bz2 +Prefix: /usr %description - @@ -47,38 +48,29 @@ %clean %{__rm} -rf %{buildroot} -%package -n cmpi-ruby +%package -n ruby-cmpi-bindings Summary: Ruby bindings for cmpi Group: Development/Languages/Ruby -%description -n cmpi-ruby +%description -n ruby-cmpi-bindings - -%files -n cmpi-ruby +%files -n ruby-cmpi-bindings %defattr(-,root,root,-) -%{_libdir}/ruby/vendor_ruby/%{rb_ver}/%{rb_arch}/yui.so +%{_libdir}/cmpi/librbCmpiProvider.so +%{_libdir}/ruby/vendor_ruby/%{rb_ver}/rcmpi_instance.rb -#%package -n python-yui -#Summary: Python bindings for cmpi -#Group: Development/Languages/Python -#%description -n python-yui -#- -# -#%files -n python-yui -#%defattr(-,root,root,-) -#%{_libdir}/python2.5/site-packages/_yui.so -#%{_libdir}/python2.5/site-packages/yui.py +%package -n python-cmpi-bindings +Summary: Python bindings for cmpi +Group: Development/Languages/Python -#%package -n perl-yui -#Summary: Perl bindings for cmpi -#Group: Development/Languages/Perl -# -#%description -n perl-yui -#- -# -#%files -n perl-yui -#%defattr(-,root,root,-) -#/usr/lib/perl5/*/*/yui.pm -#/usr/lib/perl5/*/*/yui.so +%description -n python-cmpi-bindings +- +%files -n python-cmpi-bindings +%defattr(-,root,root,-) +%{_libdir}/cmpi/libpyCmpiProvider.so +%{py_sitedir}/pycmpi_provider.py +%{py_sitedir}/cmpi.py + %changelog This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kk...@us...> - 2008-09-02 10:31:11
|
Revision: 901 http://omc.svn.sourceforge.net/omc/?rev=901&view=rev Author: kkaempf Date: 2008-09-02 10:31:06 +0000 (Tue, 02 Sep 2008) Log Message: ----------- remove empty constructors/destructors Modified Paths: -------------- cmpi-bindings/trunk/swig/cmpi_callbacks.i cmpi-bindings/trunk/swig/cmpi_types.i Modified: cmpi-bindings/trunk/swig/cmpi_callbacks.i =================================================================== --- cmpi-bindings/trunk/swig/cmpi_callbacks.i 2008-09-02 09:57:14 UTC (rev 900) +++ cmpi-bindings/trunk/swig/cmpi_callbacks.i 2008-09-02 10:31:06 UTC (rev 901) @@ -9,8 +9,6 @@ %extend CMPIBroker { - CMPIBroker() { return _BROKER; } - ~CMPIBroker() { } void LogMessage(int severity, const char *id, const char *text) { CMLogMessage(_BROKER, severity, id, text, NULL); } Modified: cmpi-bindings/trunk/swig/cmpi_types.i =================================================================== --- cmpi-bindings/trunk/swig/cmpi_types.i 2008-09-02 09:57:14 UTC (rev 900) +++ cmpi-bindings/trunk/swig/cmpi_types.i 2008-09-02 10:31:06 UTC (rev 901) @@ -123,7 +123,7 @@ ~CMPIError() { } /* Gets the type of this Error */ CMPIErrorType type() { - CMGetErrorType( $self, NULL ); + return CMGetErrorType( $self, NULL ); } /* Sets the error type of this error object. */ #if defined(SWIGRUBY) @@ -282,9 +282,11 @@ %extend _CMPIMsgFileHandle { CMPIMsgFileHandle(const char *msgFile) { - CMPIMsgFileHandle handle; - CMPIStatus st = CMOpenMessageFile(_BROKER, msgFile, &handle); - /* FIXME */ + CMPIMsgFileHandle *handle = calloc(1, sizeof( CMPIMsgFileHandle )); + CMPIStatus st = CMOpenMessageFile(_BROKER, msgFile, handle); + if (st.rc != CMPI_RC_OK) + abort(); + return handle; } ~CMPIMsgFileHandle() { CMCloseMessageFile( _BROKER, $self ); @@ -766,8 +768,6 @@ # CMPISelectCond %extend _CMPISelectCond { - CMPISelectCond() { } - ~CMPISelectCond() { } const char* to_s() { CMPIString *s = CDToString(_BROKER, $self, NULL); return CMGetCharPtr(s); @@ -779,8 +779,6 @@ # CMPISubCond %extend _CMPISubCond { - CMPISubCond() { } - ~CMPISubCond() { } } #----------------------------------------------------- @@ -788,8 +786,6 @@ # CMPIPredicate %extend _CMPIPredicate { - CMPIPredicate() { } - ~CMPIPredicate() { } const char* to_s() { CMPIString *s = CDToString(_BROKER, $self, NULL); return CMGetCharPtr(s); @@ -801,8 +797,6 @@ # CMPIEnumeration %extend _CMPIEnumeration { - CMPIEnumeration() { } - ~CMPIEnumeration() { } #if defined(SWIGRUBY) %alias length "size"; #endif @@ -846,7 +840,6 @@ CMPIArray(int count, CMPIType type ) { return CMNewArray( _BROKER, count, type, NULL); } - CMPIArray( ) { } const char* to_s() { CMPIString *s = CDToString(_BROKER, $self, NULL); return CMGetCharPtr(s); @@ -883,7 +876,6 @@ CMPIString(const char *s) { return CMNewString(_BROKER, s, NULL); } - CMPIString() { } const char* to_s() { return CMGetCharPtr($self); } @@ -894,8 +886,6 @@ # CMPIContext %extend _CMPIContext { - CMPIContext() { } - ~CMPIContext() { } const char* to_s() { CMPIString *s = CDToString(_BROKER, $self, NULL); return CMGetCharPtr(s); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kk...@us...> - 2008-09-02 09:57:05
|
Revision: 900 http://omc.svn.sourceforge.net/omc/?rev=900&view=rev Author: kkaempf Date: 2008-09-02 09:57:14 +0000 (Tue, 02 Sep 2008) Log Message: ----------- don't generate .spec within build environment Modified Paths: -------------- cmpi-bindings/trunk/CMakeLists.txt Modified: cmpi-bindings/trunk/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/CMakeLists.txt 2008-09-02 09:24:52 UTC (rev 899) +++ cmpi-bindings/trunk/CMakeLists.txt 2008-09-02 09:57:14 UTC (rev 900) @@ -88,10 +88,12 @@ #################################################################### MACRO(SPECFILE) + IF (NOT EXISTS /.buildenv) MESSAGE(STATUS "Writing spec file...") CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/package/${PACKAGE}.spec.in ${CMAKE_BINARY_DIR}/package/${PACKAGE}.spec @ONLY) #MESSAGE(STATUS "I hate you rpm-lint...!!!") #CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/package/${PACKAGE}-rpmlint.in ${CMAKE_BINARY_DIR}/package/${PACKAGE}-rpmlintrc @ONLY) + ENDIF (NOT EXISTS /.buildenv) ENDMACRO(SPECFILE) SPECFILE() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kk...@us...> - 2008-09-02 09:24:43
|
Revision: 899 http://omc.svn.sourceforge.net/omc/?rev=899&view=rev Author: kkaempf Date: 2008-09-02 09:24:52 +0000 (Tue, 02 Sep 2008) Log Message: ----------- - add license - prepare packaging Modified Paths: -------------- cmpi-bindings/trunk/CMakeLists.txt Added Paths: ----------- cmpi-bindings/trunk/LICENSE.BSD cmpi-bindings/trunk/package/ cmpi-bindings/trunk/package/cmpi-bindings.changes cmpi-bindings/trunk/package/cmpi-bindings.spec.in Removed Paths: ------------- cmpi-bindings/trunk/cmpi-bindings.spec.cmake Modified: cmpi-bindings/trunk/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/CMakeLists.txt 2008-09-02 08:46:44 UTC (rev 898) +++ cmpi-bindings/trunk/CMakeLists.txt 2008-09-02 09:24:52 UTC (rev 899) @@ -82,15 +82,37 @@ ADD_SUBDIRECTORY(swig) ADD_SUBDIRECTORY(mof) -SET( SRCPACKAGE_COMMAND + +#################################################################### +# RPM SPEC # +#################################################################### + +MACRO(SPECFILE) + MESSAGE(STATUS "Writing spec file...") + CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/package/${PACKAGE}.spec.in ${CMAKE_BINARY_DIR}/package/${PACKAGE}.spec @ONLY) + #MESSAGE(STATUS "I hate you rpm-lint...!!!") + #CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/package/${PACKAGE}-rpmlint.in ${CMAKE_BINARY_DIR}/package/${PACKAGE}-rpmlintrc @ONLY) +ENDMACRO(SPECFILE) + +SPECFILE() + +ADD_CUSTOM_TARGET( svncheck + COMMAND cd $(CMAKE_SOURCE_DIR) && ! LC_ALL=C svn status --show-updates --quiet | grep -v '^Status against revision' +) + +SET( AUTOBUILD_COMMAND + COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2 COMMAND ${CMAKE_MAKE_PROGRAM} package_source - COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package/ + COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/${PACKAGE}.changes" "${CMAKE_BINARY_DIR}/package/${PACKAGE}.changes" ) +ADD_CUSTOM_TARGET( srcpackage_local + ${AUTOBUILD_COMMAND} +) + ADD_CUSTOM_TARGET( srcpackage - ${SRCPACKAGE_COMMAND} + COMMAND ${CMAKE_MAKE_PROGRAM} svncheck + ${AUTOBUILD_COMMAND} ) - -MESSAGE(STATUS "Writing spec file...") -CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmpi-bindings.spec.cmake ${CMAKE_BINARY_DIR}/package/cmpi-bindings.spec @ONLY) Added: cmpi-bindings/trunk/LICENSE.BSD =================================================================== --- cmpi-bindings/trunk/LICENSE.BSD (rev 0) +++ cmpi-bindings/trunk/LICENSE.BSD 2008-09-02 09:24:52 UTC (rev 899) @@ -0,0 +1,28 @@ + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of Novell nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + Deleted: cmpi-bindings/trunk/cmpi-bindings.spec.cmake =================================================================== --- cmpi-bindings/trunk/cmpi-bindings.spec.cmake 2008-09-02 08:46:44 UTC (rev 898) +++ cmpi-bindings/trunk/cmpi-bindings.spec.cmake 2008-09-02 09:24:52 UTC (rev 899) @@ -1,84 +0,0 @@ -# -# spec file for package cmpi-bindings -# -# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany. -# This file and all modifications and additions to the pristine -# package are under the same license as the package itself. -# -# Please submit bugfixes or comments via http://bugs.opensuse.org/ -# - -# nodebuginfo - -Name: @PACKAGE@ -Version: @VERSION@ -Release: 0 -License: GPL -Summary: Bindings for cmpi -Group: Development/Sources -BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: cmake gcc-c++ ruby-devel swig -BuildRequires: sblim-sfcb-devel -Source: %{name}-%{version}.tar.bz2 - -%description -- - -%prep -%setup -q - -%build -mkdir build -cd build -cmake -DCMAKE_INSTALL_PREFIX=%{prefix} \ - -DLIB=%{_lib} \ - -DCMAKE_VERBOSE_MAKEFILE=TRUE \ - -DCMAKE_C_FLAGS_RELEASE:STRING="%{optflags}" \ - -DCMAKE_CXX_FLAGS_RELEASE:STRING="%{optflags}" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_SKIP_RPATH=1 \ - .. -make %{?jobs:-j %jobs} - -%install -cd build -make install DESTDIR=$RPM_BUILD_ROOT - -%clean -%{__rm} -rf %{buildroot} - -%package -n cmpi-ruby -Summary: Ruby bindings for cmpi -Group: Development/Languages/Ruby - -%description -n cmpi-ruby -- - -%files -n cmpi-ruby -%defattr(-,root,root,-) -%{_libdir}/ruby/vendor_ruby/%{rb_ver}/%{rb_arch}/yui.so - -#%package -n python-yui -#Summary: Python bindings for cmpi -#Group: Development/Languages/Python -#%description -n python-yui -#- -# -#%files -n python-yui -#%defattr(-,root,root,-) -#%{_libdir}/python2.5/site-packages/_yui.so -#%{_libdir}/python2.5/site-packages/yui.py - -#%package -n perl-yui -#Summary: Perl bindings for cmpi -#Group: Development/Languages/Perl -# -#%description -n perl-yui -#- -# -#%files -n perl-yui -#%defattr(-,root,root,-) -#/usr/lib/perl5/*/*/yui.pm -#/usr/lib/perl5/*/*/yui.so - -%changelog Added: cmpi-bindings/trunk/package/cmpi-bindings.changes =================================================================== --- cmpi-bindings/trunk/package/cmpi-bindings.changes (rev 0) +++ cmpi-bindings/trunk/package/cmpi-bindings.changes 2008-09-02 09:24:52 UTC (rev 899) @@ -0,0 +1,5 @@ +------------------------------------------------------------------- +Tue Sep 2 11:10:23 CEST 2008 - kk...@su... + +- Initial package. + Copied: cmpi-bindings/trunk/package/cmpi-bindings.spec.in (from rev 895, cmpi-bindings/trunk/cmpi-bindings.spec.cmake) =================================================================== --- cmpi-bindings/trunk/package/cmpi-bindings.spec.in (rev 0) +++ cmpi-bindings/trunk/package/cmpi-bindings.spec.in 2008-09-02 09:24:52 UTC (rev 899) @@ -0,0 +1,84 @@ +# +# spec file for package cmpi-bindings +# +# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + +# nodebuginfo + +Name: @PACKAGE@ +Version: @VERSION@ +Release: 0 +License: GPL +Summary: Bindings for cmpi +Group: Development/Sources +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: cmake gcc-c++ ruby-devel swig +BuildRequires: sblim-sfcb-devel +Source: %{name}-%{version}.tar.bz2 + +%description +- + +%prep +%setup -q + +%build +mkdir build +cd build +cmake -DCMAKE_INSTALL_PREFIX=%{prefix} \ + -DLIB=%{_lib} \ + -DCMAKE_VERBOSE_MAKEFILE=TRUE \ + -DCMAKE_C_FLAGS_RELEASE:STRING="%{optflags}" \ + -DCMAKE_CXX_FLAGS_RELEASE:STRING="%{optflags}" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_SKIP_RPATH=1 \ + .. +make %{?jobs:-j %jobs} + +%install +cd build +make install DESTDIR=$RPM_BUILD_ROOT + +%clean +%{__rm} -rf %{buildroot} + +%package -n cmpi-ruby +Summary: Ruby bindings for cmpi +Group: Development/Languages/Ruby + +%description -n cmpi-ruby +- + +%files -n cmpi-ruby +%defattr(-,root,root,-) +%{_libdir}/ruby/vendor_ruby/%{rb_ver}/%{rb_arch}/yui.so + +#%package -n python-yui +#Summary: Python bindings for cmpi +#Group: Development/Languages/Python +#%description -n python-yui +#- +# +#%files -n python-yui +#%defattr(-,root,root,-) +#%{_libdir}/python2.5/site-packages/_yui.so +#%{_libdir}/python2.5/site-packages/yui.py + +#%package -n perl-yui +#Summary: Perl bindings for cmpi +#Group: Development/Languages/Perl +# +#%description -n perl-yui +#- +# +#%files -n perl-yui +#%defattr(-,root,root,-) +#/usr/lib/perl5/*/*/yui.pm +#/usr/lib/perl5/*/*/yui.so + +%changelog This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kk...@us...> - 2008-09-02 08:46:38
|
Revision: 898 http://omc.svn.sourceforge.net/omc/?rev=898&view=rev Author: kkaempf Date: 2008-09-02 08:46:44 +0000 (Tue, 02 Sep 2008) Log Message: ----------- don't force '-g' as cflags Modified Paths: -------------- cmpi-bindings/trunk/swig/python/CMakeLists.txt cmpi-bindings/trunk/swig/ruby/CMakeLists.txt Modified: cmpi-bindings/trunk/swig/python/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-09-02 08:46:14 UTC (rev 897) +++ cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-09-02 08:46:44 UTC (rev 898) @@ -30,7 +30,7 @@ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../../src/*.c ) -SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -g" ) +SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" ) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/.. ) INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_PATH} ) Modified: cmpi-bindings/trunk/swig/ruby/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/swig/ruby/CMakeLists.txt 2008-09-02 08:46:14 UTC (rev 897) +++ cmpi-bindings/trunk/swig/ruby/CMakeLists.txt 2008-09-02 08:46:44 UTC (rev 898) @@ -23,7 +23,7 @@ ) -SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -g" ) +SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" ) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/.. ) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include/cmpi ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kk...@us...> - 2008-09-02 08:46:07
|
Revision: 897 http://omc.svn.sourceforge.net/omc/?rev=897&view=rev Author: kkaempf Date: 2008-09-02 08:46:14 +0000 (Tue, 02 Sep 2008) Log Message: ----------- find Python interpreter Modified Paths: -------------- cmpi-bindings/trunk/swig/CMakeLists.txt Modified: cmpi-bindings/trunk/swig/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/swig/CMakeLists.txt 2008-09-02 08:38:47 UTC (rev 896) +++ cmpi-bindings/trunk/swig/CMakeLists.txt 2008-09-02 08:46:14 UTC (rev 897) @@ -12,6 +12,8 @@ FIND_PACKAGE(PythonLibs) IF (PYTHON_LIBRARY) + FIND_PACKAGE(PythonInterp REQUIRED) + MESSAGE(STATUS "Found PythonLibs...") FIND_PACKAGE(PythonLinkLibs) IF (PYTHON_LINK_LIBS) MESSAGE(STATUS "Building Python...") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kk...@us...> - 2008-09-02 08:38:37
|
Revision: 896 http://omc.svn.sourceforge.net/omc/?rev=896&view=rev Author: kkaempf Date: 2008-09-02 08:38:47 +0000 (Tue, 02 Sep 2008) Log Message: ----------- ignore build and *~ Property Changed: ---------------- cmpi-bindings/trunk/ Property changes on: cmpi-bindings/trunk ___________________________________________________________________ Added: svn:ignore + build *~ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kk...@us...> - 2008-09-02 06:11:13
|
Revision: 895 http://omc.svn.sourceforge.net/omc/?rev=895&view=rev Author: kkaempf Date: 2008-09-02 06:11:21 +0000 (Tue, 02 Sep 2008) Log Message: ----------- add code to determine Python version, deduce shared lib from there (unfinished, but should cope with all versions of Python on Linux) Modified Paths: -------------- cmpi-bindings/trunk/CMakeLists.txt cmpi-bindings/trunk/swig/CMakeLists.txt cmpi-bindings/trunk/swig/python/CMakeLists.txt Added Paths: ----------- cmpi-bindings/trunk/cmake/ cmpi-bindings/trunk/cmake/modules/ cmpi-bindings/trunk/cmake/modules/FindPythonLinkLibs.cmake Modified: cmpi-bindings/trunk/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/CMakeLists.txt 2008-08-30 00:02:46 UTC (rev 894) +++ cmpi-bindings/trunk/CMakeLists.txt 2008-09-02 06:11:21 UTC (rev 895) @@ -14,7 +14,7 @@ endif(COMMAND cmake_policy) # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked -#SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) +SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) #SET(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules ${CMAKE_MODULE_PATH}) # Library Added: cmpi-bindings/trunk/cmake/modules/FindPythonLinkLibs.cmake =================================================================== --- cmpi-bindings/trunk/cmake/modules/FindPythonLinkLibs.cmake (rev 0) +++ cmpi-bindings/trunk/cmake/modules/FindPythonLinkLibs.cmake 2008-09-02 06:11:21 UTC (rev 895) @@ -0,0 +1,17 @@ +# +# FindPythonLinkLibs.cmake +# +# Find Python libraries to link against +# +# See http://www.itk.org/Bug/view.php?id=2257 for a complete thread on +# the problem +# + +# python -c 'import distutils.sysconfig as s; c = s.get_config_var; print c("LOCALMODLIBS"), c("LIBS")' +EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "from sys import stdout; import distutils.sysconfig as s; c = s.get_config_var; stdout.write(c(\"LOCALMODLIBS\")); stdout.write(c(\"LIBS\"))" OUTPUT_VARIABLE PYTHON_LINK_LIBS) +EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(str(sys.version_info[0]));" OUTPUT_VARIABLE PYTHON_MAJOR_VERSION) +EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(str(sys.version_info[1]));" OUTPUT_VARIABLE PYTHON_MINOR_VERSION) + +#SET(PYTHON_SHARED_LIBRARY "-lpython${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}") +#SET(PYTHON_LINK_LIBS "${PYTHON_SHARED_LIBRARY} ${PYTHON_LINK_LIBS}") +#MESSAGE(STATUS "Python link libs: ${PYTHON_LINK_LIBS}") Modified: cmpi-bindings/trunk/swig/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/swig/CMakeLists.txt 2008-08-30 00:02:46 UTC (rev 894) +++ cmpi-bindings/trunk/swig/CMakeLists.txt 2008-09-02 06:11:21 UTC (rev 895) @@ -12,6 +12,9 @@ FIND_PACKAGE(PythonLibs) IF (PYTHON_LIBRARY) - MESSAGE(STATUS "Building Python...") - ADD_SUBDIRECTORY(python) + FIND_PACKAGE(PythonLinkLibs) + IF (PYTHON_LINK_LIBS) + MESSAGE(STATUS "Building Python...") + ADD_SUBDIRECTORY(python) + ENDIF (PYTHON_LINK_LIBS) ENDIF (PYTHON_LIBRARY) Modified: cmpi-bindings/trunk/swig/python/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-08-30 00:02:46 UTC (rev 894) +++ cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-09-02 06:11:21 UTC (rev 895) @@ -14,7 +14,7 @@ MESSAGE(STATUS "Python executable: ${PYTHON_EXECUTABLE}") MESSAGE(STATUS "Python inc dir: ${PYTHON_INCLUDE_PATH}") MESSAGE(STATUS "Python lib dir: ${PYTHON_LIB_DIR}") -MESSAGE(STATUS "Python libraries: ${PYTHON_LIBRARIES}") +#MESSAGE(STATUS "Python libraries: ${PYTHON_LIBRARIES}") MESSAGE(STATUS "Python site dir: ${PYTHON_LIB_DIR}/site-packages") SET( SWIG_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmpi_wrap.c" ) @@ -45,8 +45,9 @@ SET( NAME pyCmpiProvider ) ADD_LIBRARY( ${NAME} SHARED ${SWIG_OUTPUT}) #TARGET_LINK_LIBRARIES( ${NAME} ${PYTHON_LIBRARIES} ) -TARGET_LINK_LIBRARIES( ${NAME} python2.5 ) -TARGET_LINK_LIBRARIES( ${NAME} m ) +TARGET_LINK_LIBRARIES( ${NAME} python${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION} ) +TARGET_LINK_LIBRARIES( ${NAME} pthread ) +TARGET_LINK_LIBRARIES( ${NAME} dl ) TARGET_LINK_LIBRARIES( ${NAME} util ) INSTALL(TARGETS ${NAME} LIBRARY DESTINATION ${CMPI_LIBRARY_DIR}) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mik...@us...> - 2008-08-30 00:02:36
|
Revision: 894 http://omc.svn.sourceforge.net/omc/?rev=894&view=rev Author: mike-brasher Date: 2008-08-30 00:02:46 +0000 (Sat, 30 Aug 2008) Log Message: ----------- Updated install script. Modified Paths: -------------- cmpi-bindings/trunk/test/python/setup.sh Modified: cmpi-bindings/trunk/test/python/setup.sh =================================================================== --- cmpi-bindings/trunk/test/python/setup.sh 2008-08-29 23:46:27 UTC (rev 893) +++ cmpi-bindings/trunk/test/python/setup.sh 2008-08-30 00:02:46 UTC (rev 894) @@ -15,8 +15,10 @@ exit 1 fi + echo "rm -f $dir/$fn" rm -f $dir/$fn - ln -s $fn $dir + echo "ln -s `pwd`/$fn $dir" + ln -s `pwd`/$fn $dir } __install TestMethod.mof /var/lib/sfcb/stage/mofs/root/cimv2 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mik...@us...> - 2008-08-29 23:46:17
|
Revision: 893 http://omc.svn.sourceforge.net/omc/?rev=893&view=rev Author: mike-brasher Date: 2008-08-29 23:46:27 +0000 (Fri, 29 Aug 2008) Log Message: ----------- New files to setup providers registraiton etc. Added Paths: ----------- cmpi-bindings/trunk/test/python/setup.sh Added: cmpi-bindings/trunk/test/python/setup.sh =================================================================== --- cmpi-bindings/trunk/test/python/setup.sh (rev 0) +++ cmpi-bindings/trunk/test/python/setup.sh 2008-08-29 23:46:27 UTC (rev 893) @@ -0,0 +1,34 @@ +#!/bin/sh + +function __install { + + fn=$1 + dir=$2 + + if [ ! -f "$fn" ]; then + echo "no such file: $fn" + exit 1 + fi + + if [ ! -d "$dir" ]; then + echo "no such directory: $dir" + exit 1 + fi + + rm -f $dir/$fn + ln -s $fn $dir +} + +__install TestMethod.mof /var/lib/sfcb/stage/mofs/root/cimv2 +__install TestAssoc.mof /var/lib/sfcb/stage/mofs/root/cimv2 +__install TestAtom.mof /var/lib/sfcb/stage/mofs/root/cimv2 + +__install TestMethod.py /usr/lib/pycim +__install TestAssocProvider.py /usr/lib/pycim +__install TestAtomProvider.py /usr/lib/pycim + +__install TestAssocProvider.sfcb.reg /var/lib/sfcb/stage/regs +__install TestMethod.sfcb.reg /var/lib/sfcb/stage/regs +__install TestAtomProvider.sfcb.reg /var/lib/sfcb/stage/regs + +sfcbrepos -f Property changes on: cmpi-bindings/trunk/test/python/setup.sh ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-08-29 20:04:03
|
Revision: 892 http://omc.svn.sourceforge.net/omc/?rev=892&view=rev Author: bartw Date: 2008-08-29 20:04:11 +0000 (Fri, 29 Aug 2008) Log Message: ----------- do not install test stuff Modified Paths: -------------- cmpi-bindings/trunk/CMakeLists.txt cmpi-bindings/trunk/mof/CMakeLists.txt Modified: cmpi-bindings/trunk/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/CMakeLists.txt 2008-08-29 20:03:53 UTC (rev 891) +++ cmpi-bindings/trunk/CMakeLists.txt 2008-08-29 20:04:11 UTC (rev 892) @@ -86,7 +86,6 @@ COMMAND ${CMAKE_MAKE_PROGRAM} package_source COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package/ COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/${PACKAGE}.changes" "${CMAKE_BINARY_DIR}/package/${PACKAGE}.changes" ) ADD_CUSTOM_TARGET( srcpackage Modified: cmpi-bindings/trunk/mof/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/mof/CMakeLists.txt 2008-08-29 20:03:53 UTC (rev 891) +++ cmpi-bindings/trunk/mof/CMakeLists.txt 2008-08-29 20:04:11 UTC (rev 892) @@ -1,13 +1,13 @@ # # # -SET( CMPI_MOF_DIR /var/lib/sfcb/stage/mofs ) -SET( CMPI_REG_DIR /var/lib/sfcb/stage/regs ) +#SET( CMPI_MOF_DIR /var/lib/sfcb/stage/mofs ) +#SET( CMPI_REG_DIR /var/lib/sfcb/stage/regs ) -INSTALL(FILES Swig_Generic.mof DESTINATION ${CMPI_MOF_DIR}/root/cimv2) -INSTALL(FILES Py_UnixProcess.mof DESTINATION ${CMPI_MOF_DIR}/root/cimv2) -INSTALL(FILES Swig_Generic.reg DESTINATION ${CMPI_REG_DIR}) -INSTALL(FILES Py_UnixProcess.reg DESTINATION ${CMPI_REG_DIR}) -INSTALL(CODE "MESSAGE(\"Now run 'sfcbrepos -f'.\")") +#INSTALL(FILES Swig_Generic.mof DESTINATION ${CMPI_MOF_DIR}/root/cimv2) +#INSTALL(FILES Py_UnixProcess.mof DESTINATION ${CMPI_MOF_DIR}/root/cimv2) +#INSTALL(FILES Swig_Generic.reg DESTINATION ${CMPI_REG_DIR}) +#INSTALL(FILES Py_UnixProcess.reg DESTINATION ${CMPI_REG_DIR}) +#INSTALL(CODE "MESSAGE(\"Now run 'sfcbrepos -f'.\")") #INSTALL(SCRIPT "sfcbrepos -f") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-08-29 20:03:43
|
Revision: 891 http://omc.svn.sourceforge.net/omc/?rev=891&view=rev Author: bartw Date: 2008-08-29 20:03:53 +0000 (Fri, 29 Aug 2008) Log Message: ----------- working on concurrency issues Modified Paths: -------------- cmpi-bindings/trunk/src/cmpi_provider_python.c cmpi-bindings/trunk/swig/cmpi_types.i cmpi-bindings/trunk/swig/python/CMakeLists.txt Modified: cmpi-bindings/trunk/src/cmpi_provider_python.c =================================================================== --- cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-08-29 17:43:11 UTC (rev 890) +++ cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-08-29 20:03:53 UTC (rev 891) @@ -94,6 +94,7 @@ return str; } + static int PyInitialize(PyProviderMIHandle* hdl, CMPIStatus* st); #define PY_CMPI_INIT { if (((PyProviderMIHandle*)(self->hdl))->pyMod == NULL) if (PyInitialize(((PyProviderMIHandle*)(self->hdl)), &status) != 0) return status; } @@ -103,11 +104,14 @@ { Py_RETURN_NONE; } - PyObject* pl = PyList_New(0); + PyObject* pl; + //SWIG_PYTHON_THREAD_BEGIN_BLOCK; + pl = PyList_New(0); for (; *cplist != NULL; ++cplist) { PyList_Append(pl, PyString_FromString(*cplist)); } + //SWIG_PYTHON_THREAD_END_BLOCK; return pl; } @@ -129,6 +133,7 @@ PyObject *type, *value, *traceback; _SBLIM_TRACE(1, ("PyErr_Occurred() %d", PyErr_Occurred())); + //SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_Fetch(&type, &value, &traceback); _SBLIM_TRACE(1,("** type %p, value %p, traceback %p", type, value, traceback)); PyErr_Print(); @@ -188,6 +193,7 @@ cleanup: PyErr_Restore(type, value, traceback); + //SWIG_PYTHON_THREAD_END_BLOCK; if (rv == NULL) { @@ -217,6 +223,7 @@ PyObject *pyargs = NULL; PyObject *pyfunc = NULL; PyObject *prv = NULL; + //SWIG_PYTHON_THREAD_BEGIN_BLOCK; pyargs = PyTuple_New(nargs); pyfunc = PyObject_GetAttrString(hdl->pyMod, opname); if (pyfunc == NULL) @@ -310,6 +317,7 @@ Py_DecRef(pyargs); Py_DecRef(pyfunc); Py_DecRef(prv); + //SWIG_PYTHON_THREAD_END_BLOCK; return rc; } @@ -327,8 +335,11 @@ _SBLIM_TRACE(1,("Cleanup() called")); + //SWIG_PYTHON_THREAD_BEGIN_BLOCK; Py_DecRef(_PYPROVMOD); Py_Finalize(); + // TODO should release come before finalize? + //SWIG_PYTHON_THREAD_END_BLOCK; _SBLIM_TRACE(1,("Cleanup(Python) called")); if (miHdl != NULL) Modified: cmpi-bindings/trunk/swig/cmpi_types.i =================================================================== --- cmpi-bindings/trunk/swig/cmpi_types.i 2008-08-29 17:43:11 UTC (rev 890) +++ cmpi-bindings/trunk/swig/cmpi_types.i 2008-08-29 20:03:53 UTC (rev 891) @@ -626,9 +626,11 @@ #TODO memory leak alert (clone_data) PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 0); + SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject* pl = PyTuple_New(2); PyTuple_SetItem(pl, 0, pydata); PyTuple_SetItem(pl, 1, PyString_FromString(CMGetCharPtr(s))); + SWIG_PYTHON_THREAD_END_BLOCK; return pl; #endif } @@ -722,9 +724,11 @@ #TODO memory leak alert (clone_data) PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 0); + SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyObject* pl = PyTuple_New(2); PyTuple_SetItem(pl, 0, pydata); PyTuple_SetItem(pl, 1, PyString_FromString(CMGetCharPtr(s))); + SWIG_PYTHON_THREAD_END_BLOCK; return pl; #endif } Modified: cmpi-bindings/trunk/swig/python/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-08-29 17:43:11 UTC (rev 890) +++ cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-08-29 20:03:53 UTC (rev 891) @@ -23,7 +23,7 @@ ADD_CUSTOM_COMMAND ( OUTPUT ${SWIG_OUTPUT} COMMAND ${CMAKE_COMMAND} -E echo_append "Creating wrapper code for Python ..." - COMMAND ${SWIG_EXECUTABLE} -python -features autodoc -o ${SWIG_OUTPUT} -I${CMPI_INCLUDE_DIR} ${SWIG_INPUT} + COMMAND ${SWIG_EXECUTABLE} -python -threads -features autodoc -o ${SWIG_OUTPUT} -I${CMPI_INCLUDE_DIR} ${SWIG_INPUT} COMMAND ${CMAKE_COMMAND} -E echo "Done." WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../*.i @@ -57,4 +57,4 @@ # pycmpi_provider.py: provider implementation # INSTALL(FILES pycmpi_provider.py DESTINATION ${PYTHON_LIB_DIR}/site-packages ) -INSTALL(FILES Py_UnixProcessProvider.py DESTINATION /usr/lib/pycim ) +#INSTALL(FILES Py_UnixProcessProvider.py DESTINATION /usr/lib/pycim ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mik...@us...> - 2008-08-29 17:43:01
|
Revision: 890 http://omc.svn.sourceforge.net/omc/?rev=890&view=rev Author: mike-brasher Date: 2008-08-29 17:43:11 +0000 (Fri, 29 Aug 2008) Log Message: ----------- Fixed problem with failing cmpi.CMPIBroker() (needs to return _BROKER). Modified Paths: -------------- cmpi-bindings/trunk/swig/cmpi_callbacks.i cmpi-bindings/trunk/swig/python/pycmpi_provider.py Modified: cmpi-bindings/trunk/swig/cmpi_callbacks.i =================================================================== --- cmpi-bindings/trunk/swig/cmpi_callbacks.i 2008-08-29 16:15:57 UTC (rev 889) +++ cmpi-bindings/trunk/swig/cmpi_callbacks.i 2008-08-29 17:43:11 UTC (rev 890) @@ -9,7 +9,7 @@ %extend CMPIBroker { - CMPIBroker() { } + CMPIBroker() { return _BROKER; } ~CMPIBroker() { } void LogMessage(int severity, const char *id, const char *text) { CMLogMessage(_BROKER, severity, id, text, NULL); @@ -78,4 +78,4 @@ CMPIData getProperty(const CMPIContext * ctx, const CMPIObjectPath *op, const char *name) { return CBGetProperty(_BROKER, ctx, op, name, NULL); } -} \ No newline at end of file +} Modified: cmpi-bindings/trunk/swig/python/pycmpi_provider.py =================================================================== --- cmpi-bindings/trunk/swig/python/pycmpi_provider.py 2008-08-29 16:15:57 UTC (rev 889) +++ cmpi-bindings/trunk/swig/python/pycmpi_provider.py 2008-08-29 17:43:11 UTC (rev 890) @@ -112,6 +112,7 @@ def __init__(self, miname, broker): print 'called CMPIProvider(', miname, ',', broker, ')' + broker = cmpi.CMPIBroker() self.broker = broker self.miname = miname self.env = ProviderEnvironment(self.broker) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-08-29 16:15:48
|
Revision: 889 http://omc.svn.sourceforge.net/omc/?rev=889&view=rev Author: bartw Date: 2008-08-29 16:15:57 +0000 (Fri, 29 Aug 2008) Log Message: ----------- fixed exec_query to return not_supported to the CIMOM will fall back to enumInstances and do the filtering. Modified Paths: -------------- cmpi-bindings/trunk/swig/python/pycmpi_provider.py Modified: cmpi-bindings/trunk/swig/python/pycmpi_provider.py =================================================================== --- cmpi-bindings/trunk/swig/python/pycmpi_provider.py 2008-08-29 00:59:51 UTC (rev 888) +++ cmpi-bindings/trunk/swig/python/pycmpi_provider.py 2008-08-29 16:15:57 UTC (rev 889) @@ -205,7 +205,7 @@ def exec_query(self, ctx, rslt, objname, query, lang): - pass + return (pywbem.CIM_ERR_NOT_SUPPORTED, '') def associator_names(self, ctx, rslt, objName, assocClass, resultClass, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mik...@us...> - 2008-08-29 00:59:40
|
Revision: 888 http://omc.svn.sourceforge.net/omc/?rev=888&view=rev Author: mike-brasher Date: 2008-08-29 00:59:51 +0000 (Fri, 29 Aug 2008) Log Message: ----------- Fixed crash in _Broker_name() swig function caused by creating explicit CMPIBroker() python object. Modified Paths: -------------- cmpi-bindings/trunk/swig/python/CMakeLists.txt cmpi-bindings/trunk/swig/python/pycmpi_provider.py Modified: cmpi-bindings/trunk/swig/python/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-08-29 00:55:28 UTC (rev 887) +++ cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-08-29 00:59:51 UTC (rev 888) @@ -45,7 +45,7 @@ SET( NAME pyCmpiProvider ) ADD_LIBRARY( ${NAME} SHARED ${SWIG_OUTPUT}) #TARGET_LINK_LIBRARIES( ${NAME} ${PYTHON_LIBRARIES} ) -TARGET_LINK_LIBRARIES( ${NAME} python2.4 ) +TARGET_LINK_LIBRARIES( ${NAME} python2.5 ) TARGET_LINK_LIBRARIES( ${NAME} m ) TARGET_LINK_LIBRARIES( ${NAME} util ) Modified: cmpi-bindings/trunk/swig/python/pycmpi_provider.py =================================================================== --- cmpi-bindings/trunk/swig/python/pycmpi_provider.py 2008-08-29 00:55:28 UTC (rev 887) +++ cmpi-bindings/trunk/swig/python/pycmpi_provider.py 2008-08-29 00:59:51 UTC (rev 888) @@ -117,7 +117,6 @@ self.env = ProviderEnvironment(self.broker) self.proxy = ProviderProxy(self.env, '/usr/lib/pycim/'+miname+'.py') - broker = cmpi.CMPIBroker() print '*** broker.name()', broker.name() print '*** broker.capabilities()', broker.capabilities() print '*** broker.version()', broker.version() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mik...@us...> - 2008-08-29 00:55:18
|
Revision: 887 http://omc.svn.sourceforge.net/omc/?rev=887&view=rev Author: mike-brasher Date: 2008-08-29 00:55:28 +0000 (Fri, 29 Aug 2008) Log Message: ----------- Development helper script to register and copy everything into place. Added Paths: ----------- cmpi-bindings/trunk/register.sh Added: cmpi-bindings/trunk/register.sh =================================================================== --- cmpi-bindings/trunk/register.sh (rev 0) +++ cmpi-bindings/trunk/register.sh 2008-08-29 00:55:28 UTC (rev 887) @@ -0,0 +1,7 @@ +#!/bin/sh +cp ./build/swig/python/cmpi.py ./swig/python/pycmpi_provider.py /usr/lib64/python2.5/site-packages +cp ./mof/Py_UnixProcess.reg /var/lib/sfcb/stage/regs +cp ./mof/Py_UnixProcess.mof /var/lib/sfcb/stage/mofs/root/cimv2 +cp ./build/swig/python/libpyCmpiProvider.so /usr/lib64/ +cp ./swig/python/Py_UnixProcessProvider.py /usr/lib/pycim +sfcbrepos -f Property changes on: cmpi-bindings/trunk/register.sh ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <np...@us...> - 2008-08-28 19:53:39
|
Revision: 886 http://omc.svn.sourceforge.net/omc/?rev=886&view=rev Author: npaxton Date: 2008-08-28 19:53:49 +0000 (Thu, 28 Aug 2008) Log Message: ----------- create a providerMIHandle for each provider module/type Modified Paths: -------------- cmpi-bindings/trunk/src/cmpi_provider_python.c Modified: cmpi-bindings/trunk/src/cmpi_provider_python.c =================================================================== --- cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-08-27 19:57:38 UTC (rev 885) +++ cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-08-28 19:53:49 UTC (rev 886) @@ -62,9 +62,16 @@ /* Global handle to the CIM broker. This is initialized by the CIMOM when the provider is loaded */ static const CMPIBroker * _BROKER = NULL; -static char* _MINAME = NULL; +//static char* _MINAME = NULL; PyObject* _PYPROVMOD = NULL; + +typedef struct __PyProviderMIHandle +{ + char *miName; + PyObject *pyMod; +} PyProviderMIHandle; + static char* fmtstr(const char* fmt, ...) { va_list ap; @@ -87,8 +94,8 @@ return str; } -static int PyInitialize(PyObject** self, CMPIStatus* st); -#define PY_CMPI_INIT { if (self->hdl == NULL) if (PyInitialize((PyObject**)&(self->hdl), &status) != 0) return status; } +static int PyInitialize(PyProviderMIHandle* hdl, CMPIStatus* st); +#define PY_CMPI_INIT { if (((PyProviderMIHandle*)(self->hdl))->pyMod == NULL) if (PyInitialize(((PyProviderMIHandle*)(self->hdl)), &status) != 0) return status; } static PyObject* proplist2py(const char** cplist) { @@ -202,7 +209,7 @@ static int -call_py_provider(PyObject* hdl, CMPIStatus* st, +call_py_provider(PyProviderMIHandle* hdl, CMPIStatus* st, const char* opname, int nargs, ...) { int rc = 1; @@ -211,7 +218,7 @@ PyObject *pyfunc = NULL; PyObject *prv = NULL; pyargs = PyTuple_New(nargs); - pyfunc = PyObject_GetAttrString(hdl, opname); + pyfunc = PyObject_GetAttrString(hdl->pyMod, opname); if (pyfunc == NULL) { PyErr_Print(); @@ -312,21 +319,24 @@ // ---------------------------------------------------------------------------- static CMPIStatus Cleanup( + PyProviderMIHandle * miHdl, const CMPIContext * context, CMPIBoolean terminating) { - CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ + CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ - _SBLIM_TRACE(1,("Cleanup() called")); + _SBLIM_TRACE(1,("Cleanup() called")); - Py_DecRef(_PYPROVMOD); - Py_Finalize(); + Py_DecRef(_PYPROVMOD); + Py_Finalize(); _SBLIM_TRACE(1,("Cleanup(Python) called")); - if (_MINAME != NULL) + if (miHdl != NULL) { - free(_MINAME); - _MINAME = NULL; + _SBLIM_TRACE(1,("\n>>>>> Cleanup(Python) called, freeing PyProviderMIHandle (%s)\n", miHdl->miName)); + free(miHdl->miName); + free(miHdl); + miHdl = NULL; } /* Finished. */ @@ -340,7 +350,7 @@ const CMPIContext * context, CMPIBoolean terminating) { - return Cleanup(context, terminating); + return Cleanup((PyProviderMIHandle*)self->hdl, context, terminating); } static CMPIStatus AssocCleanup( @@ -348,7 +358,7 @@ const CMPIContext * context, CMPIBoolean terminating) { - return Cleanup(context, terminating); + return Cleanup((PyProviderMIHandle*)self->hdl, context, terminating); } static CMPIStatus MethodCleanup( @@ -356,7 +366,7 @@ const CMPIContext * context, CMPIBoolean terminating) { - return Cleanup(context, terminating); + return Cleanup((PyProviderMIHandle*)self->hdl, context, terminating); } static CMPIStatus IndicationCleanup( @@ -364,7 +374,7 @@ const CMPIContext * context, CMPIBoolean terminating) { - return Cleanup(context, terminating); + return Cleanup((PyProviderMIHandle*)self->hdl, context, terminating); } // ---------------------------------------------------------------------------- @@ -389,7 +399,7 @@ PyObject *pyresult = SWIG_NewPointerObj((void*) result, SWIGTYPE_p__CMPIResult, 0); PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); - call_py_provider((PyObject*)self->hdl, &status, "enum_instance_names", 3, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "enum_instance_names", 3, pycontext, pyresult, pyreference); @@ -423,7 +433,7 @@ PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); PyObject *pyproperties = proplist2py(properties); - call_py_provider((PyObject*)self->hdl, &status, "enum_instances", 4, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "enum_instances", 4, pycontext, pyresult, pyreference, @@ -457,7 +467,7 @@ PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); PyObject *pyproperties = proplist2py(properties); - call_py_provider((PyObject*)self->hdl, &status, "get_instance", 4, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "get_instance", 4, pycontext, pyresult, pyreference, @@ -493,7 +503,7 @@ PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); PyObject *pynewinst = SWIG_NewPointerObj((void*) newinstance, SWIGTYPE_p__CMPIInstance, 0); - call_py_provider((PyObject*)self->hdl, &status, "create_instance", 4, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "create_instance", 4, pycontext, pyresult, pyreference, @@ -535,7 +545,7 @@ PyObject *pynewinst = SWIG_NewPointerObj((void*) newinstance, SWIGTYPE_p__CMPIInstance, 0); PyObject *plist = proplist2py(properties); - call_py_provider((PyObject*)self->hdl, &status, "set_instance", 5, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "set_instance", 5, pycontext, pyresult, pyreference, @@ -568,7 +578,7 @@ PyObject *pyresult = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); - call_py_provider((PyObject*)self->hdl, &status, "delete_instance", 3, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "delete_instance", 3, pycontext, pyresult, pyreference); @@ -603,7 +613,7 @@ PyObject *pyquery = PyString_FromString(query); PyObject *pylang = PyString_FromString(language); - call_py_provider((PyObject*)self->hdl, &status, "exec_query", 5, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "exec_query", 5, pycontext, pyresult, pyreference, @@ -623,7 +633,7 @@ #define PY_CMPI_SETFAIL(msgstr) {if (st != NULL) st->rc = CMPI_RC_ERR_FAILED; st->msg = msgstr; } -static int PyInitialize(PyObject** self, CMPIStatus* st) +static int PyInitialize(PyProviderMIHandle* hdl, CMPIStatus* st) { int rc = 0; SWIGEXPORT void SWIG_init(void); @@ -653,7 +663,8 @@ } PyObject* broker = SWIG_NewPointerObj((void*) _BROKER, SWIGTYPE_p__CMPIBroker, 0); PyObject* args = PyTuple_New(2); - PyTuple_SetItem(args, 0, PyString_FromString(_MINAME)); + _SBLIM_TRACE(1,("\n>>>>> PyInitialize(Python) called, MINAME=%s\n", hdl->miName)); + PyTuple_SetItem(args, 0, PyString_FromString(hdl->miName)); PyTuple_SetItem(args, 1, broker); PyObject* provinst = PyObject_CallObject(provclass, args); Py_DecRef(args); @@ -664,7 +675,7 @@ return -1; } - *self = provinst; + hdl->pyMod = provinst; _SBLIM_TRACE(1,("PyInitialize() succeeded")); return 0; @@ -715,7 +726,7 @@ pyresultRole = PyString_FromString(resultRole); } - call_py_provider((PyObject*)self->hdl, &status, "associator_names", 7, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "associator_names", 7, pyctx, pyrslt, pyobjName, @@ -775,7 +786,7 @@ pyresultRole = PyString_FromString(resultRole); } - call_py_provider((PyObject*)self->hdl, &status, "associators", 8, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "associators", 8, pyctx, pyrslt, pyobjName, @@ -822,7 +833,7 @@ pyresultClass = PyString_FromString(resultClass); } - call_py_provider((PyObject*)self->hdl, &status, "reference_names", 5, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "reference_names", 5, pyctx, pyrslt, pyobjName, @@ -869,7 +880,7 @@ } PyObject *pyprops = proplist2py(properties); - call_py_provider((PyObject*)self->hdl, &status, "references", 6, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "references", 6, pyctx, pyrslt, pyobjName, @@ -906,7 +917,7 @@ PyObject *pyin = SWIG_NewPointerObj((void*) in, SWIGTYPE_p__CMPIArgs, 0); PyObject *pyout = SWIG_NewPointerObj((void*) out, SWIGTYPE_p__CMPIArgs, 0); - call_py_provider((PyObject*)self->hdl, &status, "invoke_method", 6, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "invoke_method", 6, pyctx, pyrslt, pyobjName, @@ -941,7 +952,7 @@ PyObject *pyclassName = PyString_FromString(className); PyObject *pyowner = PyString_FromString(owner); - call_py_provider((PyObject*)self->hdl, &status, "authorize_filter", 5, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "authorize_filter", 5, pyctx, pyfilter, pyclassName, @@ -975,7 +986,7 @@ PyObject *pyclassName = PyString_FromString(className); PyObject *pyfirstActivation = PyBool_FromLong(firstActivation); - call_py_provider((PyObject*)self->hdl, &status, "activate_filter", 5, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "activate_filter", 5, pyctx, pyfilter, pyclassName, @@ -1009,7 +1020,7 @@ PyObject *pyclassName = PyString_FromString(className); PyObject *pylastActivation = PyBool_FromLong(lastActivation); - call_py_provider((PyObject*)self->hdl, &status, "deactivate_filter", 5, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "deactivate_filter", 5, pyctx, pyfilter, pyclassName, @@ -1047,7 +1058,7 @@ PyObject *pyclassPath = SWIG_NewPointerObj((void*) classPath, SWIGTYPE_p__CMPIObjectPath, 0); PyObject *pyclassName = PyString_FromString(className); - call_py_provider((PyObject*)self->hdl, &status, "must_poll", 4, + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "must_poll", 4, pyctx, //pyrslt, pyfilter, @@ -1074,7 +1085,7 @@ PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); - call_py_provider((PyObject*)self->hdl, &status, "enable_indications", 1, pyctx); + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "enable_indications", 1, pyctx); /* Finished. */ exit: @@ -1096,7 +1107,7 @@ PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); - call_py_provider((PyObject*)self->hdl, &status, "disable_indications", 1, pyctx); + call_py_provider((PyProviderMIHandle*)self->hdl, &status, "disable_indications", 1, pyctx); /* Finished. */ exit: @@ -1168,8 +1179,9 @@ static void createInit(const CMPIBroker* broker, const CMPIContext* context, const char* miname, CMPIStatus* st) { + _SBLIM_TRACE(1,("\n>>>>> createInit(Python) called, miname= %s (ctx=%p)\n", miname, context)); _BROKER = broker; - _MINAME = strdup(miname); + //_MINAME = strdup(miname); /* * We can't initialize Python here and load Python modules, because * SFCB passes a NULL CMPIStatus* st, which means we can't report @@ -1182,12 +1194,18 @@ CMPI##ptype##MI* _Generic_Create_##ptype##MI(const CMPIBroker* broker, \ const CMPIContext* context, const char* miname, CMPIStatus* st)\ { \ - static CMPI##ptype##MI mi={ \ - NULL, \ - &ptype##MIFT__, \ - }; \ + PyProviderMIHandle *hdl = (PyProviderMIHandle*)malloc(sizeof(PyProviderMIHandle)); \ + if (hdl) { \ + hdl->pyMod = NULL; \ + hdl->miName = strdup(miname); \ + } \ + CMPI##ptype##MI *mi= (CMPI##ptype##MI*)malloc(sizeof(CMPI##ptype##MI)); \ + if (mi) { \ + mi->hdl = hdl; \ + mi->ft = &ptype##MIFT__; \ + } \ createInit(broker, context, miname, st); \ - return &mi; \ + return mi; \ } SWIG_CMPI_MI_FACTORY(Instance) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <np...@us...> - 2008-08-27 19:57:28
|
Revision: 885 http://omc.svn.sourceforge.net/omc/?rev=885&view=rev Author: npaxton Date: 2008-08-27 19:57:38 +0000 (Wed, 27 Aug 2008) Log Message: ----------- separate out cmpi_provider.c into type/language specific files for python and ruby Added Paths: ----------- cmpi-bindings/trunk/src/cmpi_provider_python.c cmpi-bindings/trunk/src/cmpi_provider_ruby.c Added: cmpi-bindings/trunk/src/cmpi_provider_python.c =================================================================== --- cmpi-bindings/trunk/src/cmpi_provider_python.c (rev 0) +++ cmpi-bindings/trunk/src/cmpi_provider_python.c 2008-08-27 19:57:38 UTC (rev 885) @@ -0,0 +1,1197 @@ +/***************************************************************************** +* Copyright (C) 2008 Novell Inc. All rights reserved. +* Copyright (C) 2008 SUSE Linux Products GmbH. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* - Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* - Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* - Neither the name of Novell Inc. nor of SUSE Linux Products GmbH nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL Novell Inc. OR SUSE Linux Products GmbH OR +* THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +static char _CLASSNAME[] = "CmpiInstanceSwig"; + +#include <stdio.h> +#include <stdarg.h> + +/* Include the required CMPI macros, data types, and API function headers */ +#include <cmpidt.h> +#include <cmpift.h> +#include <cmpimacs.h> + +// Needed to obtain errno of failed system calls +#include <errno.h> + +/* Needed for kill() */ +#include <signal.h> + +#include <Python.h> + +/* A simple stderr logging/tracing facility. */ +#ifndef _SBLIM_TRACE +#define _SBLIM_TRACE(tracelevel,args) _logstderr args +void _logstderr(char *fmt,...) +{ + va_list ap; + va_start(ap,fmt); + vfprintf(stderr,fmt,ap); + va_end(ap); + fprintf(stderr,"\n"); +} +#endif + +/* Global handle to the CIM broker. This is initialized by the CIMOM when the provider is loaded */ +static const CMPIBroker * _BROKER = NULL; +static char* _MINAME = NULL; +PyObject* _PYPROVMOD = NULL; + +static char* fmtstr(const char* fmt, ...) +{ + va_list ap; + int len; + va_start(ap, fmt); + len = vsnprintf(NULL, 0, fmt, ap); + va_end(ap); + if (len <= 0) + { + return NULL; + } + char* str = (char*)malloc(len+1); + if (str == NULL) + { + return NULL; + } + va_start(ap, fmt); + vsnprintf(str, len+1, fmt, ap); + va_end(ap); + return str; +} + +static int PyInitialize(PyObject** self, CMPIStatus* st); +#define PY_CMPI_INIT { if (self->hdl == NULL) if (PyInitialize((PyObject**)&(self->hdl), &status) != 0) return status; } + +static PyObject* proplist2py(const char** cplist) +{ + if (cplist == NULL) + { + Py_RETURN_NONE; + } + PyObject* pl = PyList_New(0); + for (; *cplist != NULL; ++cplist) + { + PyList_Append(pl, PyString_FromString(*cplist)); + } + return pl; +} + + + +#define TB_ERROR(str) {tbstr = str; goto cleanup;} +static CMPIString* get_exc_trace() +{ + char *tbstr = NULL; + + PyObject *iostrmod = NULL; + PyObject *tbmod = NULL; + PyObject *iostr = NULL; + PyObject *obstr = NULL; + PyObject *args = NULL; + PyObject *newstr = NULL; + PyObject *func = NULL; + CMPIString* rv = NULL; + + PyObject *type, *value, *traceback; + _SBLIM_TRACE(1, ("PyErr_Occurred() %d", PyErr_Occurred())); + PyErr_Fetch(&type, &value, &traceback); + _SBLIM_TRACE(1,("** type %p, value %p, traceback %p", type, value, traceback)); + PyErr_Print(); + PyErr_Clear(); + PyErr_NormalizeException(&type, &value, &traceback); + _SBLIM_TRACE(1,("** type %p, value %p, traceback %p", type, value, traceback)); + + iostrmod = PyImport_ImportModule("StringIO"); + if (iostrmod==NULL) + TB_ERROR("can't import StringIO"); + + iostr = PyObject_CallMethod(iostrmod, "StringIO", NULL); + + if (iostr==NULL) + TB_ERROR("cStringIO.StringIO() failed"); + + tbmod = PyImport_ImportModule("traceback"); + if (tbmod==NULL) + TB_ERROR("can't import traceback"); + + obstr = PyObject_CallMethod(tbmod, "print_exception", + "(OOOOO)", + type ? type : Py_None, + value ? value : Py_None, + traceback ? traceback : Py_None, + Py_None, + iostr); + + if (obstr==NULL) + { + PyErr_Print(); + TB_ERROR("traceback.print_exception() failed"); + } + + Py_DecRef(obstr); + + obstr = PyObject_CallMethod(iostr, "getvalue", NULL); + if (obstr==NULL) + TB_ERROR("getvalue() failed."); + + if (!PyString_Check(obstr)) + TB_ERROR("getvalue() did not return a string"); + + args = PyTuple_New(2); + PyTuple_SetItem(args, 0, PyString_FromString("\n")); + PyTuple_SetItem(args, 1, PyString_FromString("<br>")); + + func = PyObject_GetAttrString(obstr, "replace"); + //newstr = PyObject_CallMethod(obstr, "replace", args); + newstr = PyObject_CallObject(func, args); + + tbstr = PyString_AsString(newstr); + + char* tmp = fmtstr("cmpi:%s", tbstr); + rv = _BROKER->eft->newString(_BROKER, tmp, NULL); + free(tmp); + +cleanup: + PyErr_Restore(type, value, traceback); + + if (rv == NULL) + { + rv = _BROKER->eft->newString(_BROKER, tbstr ? tbstr : "", NULL); + } + + Py_DecRef(func); + Py_DecRef(args); + Py_DecRef(newstr); + Py_DecRef(iostr); + Py_DecRef(obstr); + Py_DecRef(iostrmod); + Py_DecRef(tbmod); + + + return rv; +} + + + +static int +call_py_provider(PyObject* hdl, CMPIStatus* st, + const char* opname, int nargs, ...) +{ + int rc = 1; + va_list vargs; + PyObject *pyargs = NULL; + PyObject *pyfunc = NULL; + PyObject *prv = NULL; + pyargs = PyTuple_New(nargs); + pyfunc = PyObject_GetAttrString(hdl, opname); + if (pyfunc == NULL) + { + PyErr_Print(); + PyErr_Clear(); + char* str = fmtstr("Python module does not contain \"%s\"", opname); + _SBLIM_TRACE(1,(str)); + st->rc = CMPI_RC_ERR_FAILED; + st->msg = _BROKER->eft->newString(_BROKER, str, NULL); + free(str); + rc = 1; + goto cleanup; + } + if (! PyCallable_Check(pyfunc)) + { + char* str = fmtstr("Python module attribute \"%s\" is not callable", + opname); + _SBLIM_TRACE(1,(str)); + st->rc = CMPI_RC_ERR_FAILED; + st->msg = _BROKER->eft->newString(_BROKER, str, NULL); + free(str); + rc = 1; + goto cleanup; + } + + va_start(vargs, nargs); + int i; + for (i = 0; i < nargs; ++i) + { + PyObject* arg = va_arg(vargs, PyObject*); + if (arg == NULL) + { + arg = Py_None; + Py_IncRef(arg); + } + PyTuple_SET_ITEM(pyargs, i, arg); + } + va_end(vargs); + prv = PyObject_CallObject(pyfunc, pyargs); + if (PyErr_Occurred()) + { + st->rc = CMPI_RC_ERR_FAILED; + st->msg = get_exc_trace(); + PyErr_Clear(); + rc = 1; + goto cleanup; + } + + if (! PyTuple_Check(prv) || + (PyTuple_Size(prv) != 2 && PyTuple_Size(prv) != 1)) + { + char* str = fmtstr("Python function \"%s\" didn't return a two-tuple", + opname); + _SBLIM_TRACE(1,(str)); + st->rc = CMPI_RC_ERR_FAILED; + st->msg = _BROKER->eft->newString(_BROKER, str, NULL); + free(str); + rc = 1; + goto cleanup; + } + PyObject* prc = PyTuple_GetItem(prv, 0); + PyObject* prstr = Py_None; + if (PyTuple_Size(prv) == 2) + { + prstr = PyTuple_GetItem(prv, 1); + } + + if (! PyInt_Check(prc) || (! PyString_Check(prstr) && prstr != Py_None)) + { + char* str = fmtstr("Python function \"%s\" didn't return a {<int>, <str>) two-tuple", opname); + _SBLIM_TRACE(1,(str)); + st->rc = CMPI_RC_ERR_FAILED; + st->msg = _BROKER->eft->newString(_BROKER, str, NULL); + free(str); + rc = 1; + goto cleanup; + } + long pi = PyInt_AsLong(prc); + st->rc = (CMPIrc)pi; + if (prstr == Py_None) + { + st->msg = _BROKER->eft->newString(_BROKER, "", NULL); + } + else + { + st->msg = _BROKER->eft->newString(_BROKER, PyString_AsString(prstr), NULL); + } + rc = pi != 0; +cleanup: + Py_DecRef(pyargs); + Py_DecRef(pyfunc); + Py_DecRef(prv); + return rc; +} + + +// ---------------------------------------------------------------------------- +// CMPI INSTANCE PROVIDER FUNCTIONS +// ---------------------------------------------------------------------------- + +static CMPIStatus Cleanup( + const CMPIContext * context, + CMPIBoolean terminating) +{ + CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ + + _SBLIM_TRACE(1,("Cleanup() called")); + + Py_DecRef(_PYPROVMOD); + Py_Finalize(); + _SBLIM_TRACE(1,("Cleanup(Python) called")); + + if (_MINAME != NULL) + { + free(_MINAME); + _MINAME = NULL; + } + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("Cleanup() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + +static CMPIStatus InstCleanup( + CMPIInstanceMI * self, + const CMPIContext * context, + CMPIBoolean terminating) +{ + return Cleanup(context, terminating); +} + +static CMPIStatus AssocCleanup( + CMPIAssociationMI * self, + const CMPIContext * context, + CMPIBoolean terminating) +{ + return Cleanup(context, terminating); +} + +static CMPIStatus MethodCleanup( + CMPIMethodMI * self, + const CMPIContext * context, + CMPIBoolean terminating) +{ + return Cleanup(context, terminating); +} + +static CMPIStatus IndicationCleanup( + CMPIIndicationMI * self, + const CMPIContext * context, + CMPIBoolean terminating) +{ + return Cleanup(context, terminating); +} + +// ---------------------------------------------------------------------------- + + +/* EnumInstanceNames() - return a list of all the instances names (i.e. return their object paths only) */ +static CMPIStatus EnumInstanceNames( + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any */ + const CMPIResult * result, /* [in] Contains the CIM namespace and classname */ + const CMPIObjectPath * reference) /* [in] Contains the CIM namespace and classname */ +{ + CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */ + + _SBLIM_TRACE(1,("EnumInstanceNames() called")); + + _SBLIM_TRACE(1,("EnumInstancesNames(Python) called, context %p, result %p, reference %p", context, result, reference)); + + PY_CMPI_INIT + + PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyresult = SWIG_NewPointerObj((void*) result, SWIGTYPE_p__CMPIResult, 0); + PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + + call_py_provider((PyObject*)self->hdl, &status, "enum_instance_names", 3, + pycontext, + pyresult, + pyreference); + +exit: + _SBLIM_TRACE(1,("EnumInstanceNames() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + + +// ---------------------------------------------------------------------------- + + +/* EnumInstances() - return a list of all the instances (i.e. return all the instance data) */ +static CMPIStatus EnumInstances( + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any */ + const CMPIResult * result, /* [in] Contains the CIM namespace and classname */ + const CMPIObjectPath * reference, /* [in] Contains the CIM namespace and classname */ + const char ** properties) /* [in] List of desired properties (NULL=all) */ +{ + CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */ +/* char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); Our current CIM namespace */ + + _SBLIM_TRACE(1,("EnumInstances(Python) called, context %p, result %p, reference %p, properties %p", context, result, reference, properties)); + + PY_CMPI_INIT + + PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyresult = SWIG_NewPointerObj((void*) result, SWIGTYPE_p__CMPIResult, 0); + PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject *pyproperties = proplist2py(properties); + + call_py_provider((PyObject*)self->hdl, &status, "enum_instances", 4, + pycontext, + pyresult, + pyreference, + pyproperties); + +exit: + _SBLIM_TRACE(1,("EnumInstances() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + + +// ---------------------------------------------------------------------------- + + +/* GetInstance() - return the instance data for the specified instance only */ +static CMPIStatus GetInstance( + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any */ + const CMPIResult * results, /* [out] Results of this operation */ + const CMPIObjectPath * reference, /* [in] Contains the CIM namespace, classname and desired object path */ + const char ** properties) /* [in] List of desired properties (NULL=all) */ +{ + CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */ + + _SBLIM_TRACE(1,("GetInstance(Python) called, context %p, results %p, reference %p, properties %p", context, results, reference, properties)); + + PY_CMPI_INIT + + PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyresult = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); + PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject *pyproperties = proplist2py(properties); + + call_py_provider((PyObject*)self->hdl, &status, "get_instance", 4, + pycontext, + pyresult, + pyreference, + pyproperties); + +exit: + _SBLIM_TRACE(1,("GetInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + + +// ---------------------------------------------------------------------------- + + +/* CreateInstance() - create a new instance from the specified instance data. */ +static CMPIStatus CreateInstance( + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any. */ + const CMPIResult * results, /* [out] Results of this operation */ + const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and objectpath. */ + const CMPIInstance * newinstance) /* [in] Contains all the new instance data. */ +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations. */ + + /* Creating new instances is not supported for this class. */ + + _SBLIM_TRACE(1,("CreateInstance(Python) called, context %p, results %p, reference %p, newinstance %p", context, results, reference, newinstance)); + + PY_CMPI_INIT + + PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyresult = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); + PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject *pynewinst = SWIG_NewPointerObj((void*) newinstance, SWIGTYPE_p__CMPIInstance, 0); + + call_py_provider((PyObject*)self->hdl, &status, "create_instance", 4, + pycontext, + pyresult, + pyreference, + pynewinst); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("CreateInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + + +// ---------------------------------------------------------------------------- + +#ifdef CMPI_VER_100 +#define SetInstance ModifyInstance +#endif + +/* SetInstance() - save modified instance data for the specified instance. */ +static CMPIStatus SetInstance( + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ + const CMPIContext * context, /* [in] Additional context info, if any. */ + const CMPIResult * results, /* [out] Results of this operation. */ + const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and objectpath. */ + const CMPIInstance * newinstance, /* [in] Contains all the new instance data. */ + const char ** properties) /* [in] List of desired properties (NULL=all) */ +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations. */ + + /* Modifying existing instances is not supported for this class. */ + + _SBLIM_TRACE(1,("SetInstance(Python) called, context %p, results %p, reference %p, newinstance %p, properties %p", context, results, reference, newinstance, properties)); + + PY_CMPI_INIT + + PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyresult = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); + PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject *pynewinst = SWIG_NewPointerObj((void*) newinstance, SWIGTYPE_p__CMPIInstance, 0); + PyObject *plist = proplist2py(properties); + + call_py_provider((PyObject*)self->hdl, &status, "set_instance", 5, + pycontext, + pyresult, + pyreference, + pynewinst, + plist); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("SetInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + +// ---------------------------------------------------------------------------- + + +/* DeleteInstance() - delete/remove the specified instance. */ +static CMPIStatus DeleteInstance( + CMPIInstanceMI * self, + const CMPIContext * context, + const CMPIResult * results, + const CMPIObjectPath * reference) +{ + CMPIStatus status = {CMPI_RC_OK, NULL}; + + _SBLIM_TRACE(1,("DeleteInstance(Python) called, context %p, results %p, reference %p", context, results, reference)); + + PY_CMPI_INIT + + PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyresult = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); + PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + + call_py_provider((PyObject*)self->hdl, &status, "delete_instance", 3, + pycontext, + pyresult, + pyreference); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("DeleteInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + +// ---------------------------------------------------------------------------- + + +/* ExecQuery() - return a list of all the instances that satisfy the desired query filter. */ +static CMPIStatus ExecQuery( + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ + const CMPIContext * context, /* [in] Additional context info, if any. */ + const CMPIResult * results, /* [out] Results of this operation. */ + const CMPIObjectPath * reference, /* [in] Contains the target namespace and classname. */ + const char * query, /* [in] Text of the query, written in the query language. */ + const char * language) /* [in] Name of the query language (e.g. "WQL"). */ +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations. */ + + _SBLIM_TRACE(1,("ExecQuery(Python) called, context %p, results %p, reference %p, query %s, language %s", context, results, reference, query, language)); + + PY_CMPI_INIT + + PyObject *pycontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyresult = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); + PyObject *pyreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject *pyquery = PyString_FromString(query); + PyObject *pylang = PyString_FromString(language); + + call_py_provider((PyObject*)self->hdl, &status, "exec_query", 5, + pycontext, + pyresult, + pyreference, + pyquery, + pylang); + + /* Query filtering is not supported for this class. */ + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("ExecQuery() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + + +// ---------------------------------------------------------------------------- + + +#define PY_CMPI_SETFAIL(msgstr) {if (st != NULL) st->rc = CMPI_RC_ERR_FAILED; st->msg = msgstr; } +static int PyInitialize(PyObject** self, CMPIStatus* st) +{ + int rc = 0; + SWIGEXPORT void SWIG_init(void); + + _SBLIM_TRACE(1,("PyInitialize() called")); + + + _SBLIM_TRACE(1,("Python: Loading")); + Py_SetProgramName("cmpi_swig"); + Py_Initialize(); + SWIG_init(); + + _PYPROVMOD = PyImport_ImportModule("pycmpi_provider"); + if (_PYPROVMOD == NULL) + { + _SBLIM_TRACE(1,("Python: _PYPROVMOD at %p", _PYPROVMOD)); + PY_CMPI_SETFAIL(get_exc_trace()); + return -1; + } + _SBLIM_TRACE(1,("Python: _PYPROVMOD at %p", _PYPROVMOD)); + PyObject* provclass = PyObject_GetAttrString(_PYPROVMOD, + "CMPIProvider"); + if (provclass == NULL) + { + PY_CMPI_SETFAIL(get_exc_trace()); + return -1; + } + PyObject* broker = SWIG_NewPointerObj((void*) _BROKER, SWIGTYPE_p__CMPIBroker, 0); + PyObject* args = PyTuple_New(2); + PyTuple_SetItem(args, 0, PyString_FromString(_MINAME)); + PyTuple_SetItem(args, 1, broker); + PyObject* provinst = PyObject_CallObject(provclass, args); + Py_DecRef(args); + Py_DecRef(provclass); + if (provinst == NULL) + { + PY_CMPI_SETFAIL(get_exc_trace()); + return -1; + } + + *self = provinst; + + _SBLIM_TRACE(1,("PyInitialize() succeeded")); + return 0; +} + + + +// associatorMIFT +// + +CMPIStatus associatorNames( + CMPIAssociationMI* self, + const CMPIContext* ctx, + const CMPIResult* rslt, + const CMPIObjectPath* objName, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole) +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + + _SBLIM_TRACE(1,("associatorNames(Python) called, ctx %p, rslt %p, objName %p, assocClass %s, resultClass %s, role %s, resultRole %s", ctx, rslt, objName, assocClass, resultClass, role, resultRole)); + + PY_CMPI_INIT + + PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyrslt = SWIG_NewPointerObj((void*) rslt, SWIGTYPE_p__CMPIResult, 0); + PyObject *pyobjName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject *pyassocClass = NULL; + PyObject *pyresultClass = NULL; + PyObject* pyrole = NULL; + PyObject* pyresultRole = NULL; + if (assocClass != NULL) + { + pyassocClass = PyString_FromString(assocClass); + } + if (resultClass != NULL) + { + pyresultClass = PyString_FromString(resultClass); + } + if (role != NULL) + { + pyrole = PyString_FromString(role); + } + if (resultRole != NULL) + { + pyresultRole = PyString_FromString(resultRole); + } + + call_py_provider((PyObject*)self->hdl, &status, "associator_names", 7, + pyctx, + pyrslt, + pyobjName, + pyassocClass, + pyresultClass, + pyrole, + pyresultRole); + + /* Query filtering is not supported for this class. */ + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("associatorNames() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + +/***************************************************************************/ +CMPIStatus associators( + CMPIAssociationMI* self, + const CMPIContext* ctx, + const CMPIResult* rslt, + const CMPIObjectPath* objName, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole, + const char** properties) +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + + _SBLIM_TRACE(1,("associators(Python) called, ctx %p, rslt %p, objName %p, assocClass %s, resultClass %s, role %s, resultRole %s", ctx, rslt, objName, assocClass, resultClass, role, resultRole)); + + PY_CMPI_INIT + + PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyrslt = SWIG_NewPointerObj((void*) rslt, SWIGTYPE_p__CMPIResult, 0); + PyObject *pyobjName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject *pyprops = proplist2py(properties); + PyObject *pyassocClass = NULL; + PyObject *pyresultClass = NULL; + PyObject* pyrole = NULL; + PyObject* pyresultRole = NULL; + if (assocClass != NULL) + { + pyassocClass = PyString_FromString(assocClass); + } + if (resultClass != NULL) + { + pyresultClass = PyString_FromString(resultClass); + } + if (role != NULL) + { + pyrole = PyString_FromString(role); + } + if (resultRole != NULL) + { + pyresultRole = PyString_FromString(resultRole); + } + + call_py_provider((PyObject*)self->hdl, &status, "associators", 8, + pyctx, + pyrslt, + pyobjName, + pyassocClass, + pyresultClass, + pyrole, + pyresultRole, + pyprops); + + /* Query filtering is not supported for this class. */ + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("associators() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + +/***************************************************************************/ +CMPIStatus referenceNames( + CMPIAssociationMI* self, + const CMPIContext* ctx, + const CMPIResult* rslt, + const CMPIObjectPath* objName, + const char* resultClass, + const char* role) +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + + _SBLIM_TRACE(1,("referenceNames(Python) called, ctx %p, rslt %p, objName %p, resultClass %s, role %s", ctx, rslt, objName, resultClass, role)); + + PY_CMPI_INIT + + PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyrslt = SWIG_NewPointerObj((void*) rslt, SWIGTYPE_p__CMPIResult, 0); + PyObject *pyobjName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject* pyresultClass = NULL; + PyObject* pyrole = NULL; + if (role != NULL) + { + pyrole = PyString_FromString(role); + } + if (resultClass != NULL) + { + pyresultClass = PyString_FromString(resultClass); + } + + call_py_provider((PyObject*)self->hdl, &status, "reference_names", 5, + pyctx, + pyrslt, + pyobjName, + pyresultClass, + pyrole); + + /* Query filtering is not supported for this class. */ + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("referenceNames() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + + +/***************************************************************************/ +CMPIStatus references( + CMPIAssociationMI* self, + const CMPIContext* ctx, + const CMPIResult* rslt, + const CMPIObjectPath* objName, + const char* resultClass, + const char* role, + const char** properties) +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + + _SBLIM_TRACE(1,("references(Python) called, ctx %p, rslt %p, objName %p, resultClass %s, role %s, properties %p", ctx, rslt, objName, resultClass, role, properties)); + + PY_CMPI_INIT + + PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyrslt = SWIG_NewPointerObj((void*) rslt, SWIGTYPE_p__CMPIResult, 0); + PyObject *pyobjName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject* pyrole = NULL; + PyObject* pyresultClass = NULL; + if (role != NULL) + { + pyrole = PyString_FromString(role); + } + if (resultClass != NULL) + { + pyresultClass = PyString_FromString(resultClass); + } + PyObject *pyprops = proplist2py(properties); + + call_py_provider((PyObject*)self->hdl, &status, "references", 6, + pyctx, + pyrslt, + pyobjName, + pyresultClass, + pyrole, + pyprops); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("references() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + +/***************************************************************************/ +CMPIStatus invokeMethod( + CMPIMethodMI* self, + const CMPIContext* ctx, + const CMPIResult* rslt, + const CMPIObjectPath* objName, + const char* method, + const CMPIArgs* in, + CMPIArgs* out) +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + + _SBLIM_TRACE(1,("invokeMethod(Python) called, ctx %p, rslt %p, objName %p, method %s, in %p, out %p", ctx, rslt, objName, method, in, out)); + + PY_CMPI_INIT + + PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyrslt = SWIG_NewPointerObj((void*) rslt, SWIGTYPE_p__CMPIResult, 0); + PyObject *pyobjName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject *pymethod = PyString_FromString(method); + PyObject *pyin = SWIG_NewPointerObj((void*) in, SWIGTYPE_p__CMPIArgs, 0); + PyObject *pyout = SWIG_NewPointerObj((void*) out, SWIGTYPE_p__CMPIArgs, 0); + + call_py_provider((PyObject*)self->hdl, &status, "invoke_method", 6, + pyctx, + pyrslt, + pyobjName, + pymethod, + pyin, + pyout); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("invokeMethod() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + +/***************************************************************************/ +CMPIStatus authorizeFilter( + CMPIIndicationMI* self, + const CMPIContext* ctx, + const CMPISelectExp* filter, + const char* className, + const CMPIObjectPath* classPath, + const char* owner) +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + + _SBLIM_TRACE(1,("authorizeFilter(Python) called, ctx %p, filter %p, className %s, classPath %p, owner %s", ctx, filter, className, classPath, owner)); + + PY_CMPI_INIT + + PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyfilter = SWIG_NewPointerObj((void*) filter, SWIGTYPE_p__CMPISelectExp, 0); + PyObject *pyclassPath = SWIG_NewPointerObj((void*) classPath, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject *pyclassName = PyString_FromString(className); + PyObject *pyowner = PyString_FromString(owner); + + call_py_provider((PyObject*)self->hdl, &status, "authorize_filter", 5, + pyctx, + pyfilter, + pyclassName, + pyclassPath, + pyowner); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("authorizeFilter() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + +/***************************************************************************/ +CMPIStatus activateFilter( + CMPIIndicationMI* self, + const CMPIContext* ctx, + const CMPISelectExp* filter, + const char* className, + const CMPIObjectPath* classPath, + CMPIBoolean firstActivation) +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + + _SBLIM_TRACE(1,("activateFilter(Python) called, ctx %p, filter %p, className %s, classPath %p, firstActivation %d", ctx, filter, className, classPath, firstActivation)); + + PY_CMPI_INIT + + PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyfilter = SWIG_NewPointerObj((void*) filter, SWIGTYPE_p__CMPISelectExp, 0); + PyObject *pyclassPath = SWIG_NewPointerObj((void*) classPath, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject *pyclassName = PyString_FromString(className); + PyObject *pyfirstActivation = PyBool_FromLong(firstActivation); + + call_py_provider((PyObject*)self->hdl, &status, "activate_filter", 5, + pyctx, + pyfilter, + pyclassName, + pyclassPath, + pyfirstActivation); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("activateFilter() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + +/***************************************************************************/ +CMPIStatus deActivateFilter( + CMPIIndicationMI* self, + const CMPIContext* ctx, + const CMPISelectExp* filter, + const char* className, + const CMPIObjectPath* classPath, + CMPIBoolean lastActivation) +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + + _SBLIM_TRACE(1,("deActivateFilter(Python) called, ctx %p, filter %p, className %s, classPath %p, lastActivation %d", ctx, filter, className, classPath, lastActivation)); + + PY_CMPI_INIT + + PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); + PyObject *pyfilter = SWIG_NewPointerObj((void*) filter, SWIGTYPE_p__CMPISelectExp, 0); + PyObject *pyclassPath = SWIG_NewPointerObj((void*) classPath, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject *pyclassName = PyString_FromString(className); + PyObject *pylastActivation = PyBool_FromLong(lastActivation); + + call_py_provider((PyObject*)self->hdl, &status, "deactivate_filter", 5, + pyctx, + pyfilter, + pyclassName, + pyclassPath, + pylastActivation); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("deActivateFilter() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + + +/***************************************************************************/ +// Note: sfcb doesn't support mustPoll. :( +// http://sourceforge.net/mailarchive/message.php?msg_id=OFF38FF3F9.39FD2E1F-ONC1257385.004A7122-C1257385.004BB0AF%40de.ibm.com +CMPIStatus mustPoll( + CMPIIndicationMI* self, + const CMPIContext* ctx, + //const CMPIResult* rslt, TODO: figure out who is right: spec. vs. sblim + const CMPISelectExp* filter, + const char* className, + const CMPIObjectPath* classPath) +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + + //_SBLIM_TRACE(1,("mustPoll(Python) called, ctx %p, rslt %p, filter %p, className %s, classPath %p", ctx, rslt, filter, className, classPath)); + _SBLIM_TRACE(1,("mustPoll(Python) called, ctx %p, filter %p, className %s, classPath %p", ctx, filter, className, classPath)); + + PY_CMPI_INIT + + PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); + //PyObject *pyrslt = SWIG_NewPointerObj((void*) rslt, SWIGTYPE_p__CMPIResult, 0); + PyObject *pyfilter = SWIG_NewPointerObj((void*) filter, SWIGTYPE_p__CMPISelectExp, 0); + PyObject *pyclassPath = SWIG_NewPointerObj((void*) classPath, SWIGTYPE_p__CMPIObjectPath, 0); + PyObject *pyclassName = PyString_FromString(className); + + call_py_provider((PyObject*)self->hdl, &status, "must_poll", 4, + pyctx, + //pyrslt, + pyfilter, + pyclassName, + pyclassPath); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("mustPoll() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + + +/***************************************************************************/ +CMPIStatus enableIndications( + CMPIIndicationMI* self, + const CMPIContext* ctx) +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + + _SBLIM_TRACE(1,("enableIndications(Python) called, ctx %p", ctx)); + + PY_CMPI_INIT + + PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); + + call_py_provider((PyObject*)self->hdl, &status, "enable_indications", 1, pyctx); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("enableIndications() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; + +} + +/***************************************************************************/ +CMPIStatus disableIndications( + CMPIIndicationMI* self, + const CMPIContext* ctx) +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; + + _SBLIM_TRACE(1,("disableIndications(Python) called, ctx %p", ctx)); + + PY_CMPI_INIT + + PyObject *pyctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); + + call_py_provider((PyObject*)self->hdl, &status, "disable_indications", 1, pyctx); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("disableIndications() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; + +} + + +/***************************************************************************/ + + + + + + + + + +static CMPIMethodMIFT MethodMIFT__={ + CMPICurrentVersion, + CMPICurrentVersion, + "methodCmpi_Swig", // miName + MethodCleanup, + invokeMethod, +}; + + +static CMPIIndicationMIFT IndicationMIFT__={ + CMPICurrentVersion, + CMPICurrentVersion, + "indicationCmpi_Swig", // miName + IndicationCleanup, + authorizeFilter, + mustPoll, + activateFilter, + deActivateFilter, + enableIndications, + disableIndications, +}; + + +static CMPIAssociationMIFT AssociationMIFT__={ + CMPICurrentVersion, + CMPICurrentVersion, + "instanceCmpi_Swig", // miName + AssocCleanup, + associators, + associatorNames, + references, + referenceNames, +}; + + +static CMPIInstanceMIFT InstanceMIFT__={ + CMPICurrentVersion, + CMPICurrentVersion, + "associatorCmpi_Swig", // miName + InstCleanup, + EnumInstanceNames, + EnumInstances, + GetInstance, + CreateInstance, + SetInstance, + DeleteInstance, + ExecQuery, +}; + +static void createInit(const CMPIBroker* broker, + const CMPIContext* context, const char* miname, CMPIStatus* st) +{ + _BROKER = broker; + _MINAME = strdup(miname); + /* + * We can't initialize Python here and load Python modules, because + * SFCB passes a NULL CMPIStatus* st, which means we can't report + * back error strings. Instead, we'll check and initialize in each + * MIFT function + */ +} + +#define SWIG_CMPI_MI_FACTORY(ptype) \ +CMPI##ptype##MI* _Generic_Create_##ptype##MI(const CMPIBroker* broker, \ + const CMPIContext* context, const char* miname, CMPIStatus* st)\ +{ \ + static CMPI##ptype##MI mi={ \ + NULL, \ + &ptype##MIFT__, \ + }; \ + createInit(broker, context, miname, st); \ + return &mi; \ +} + +SWIG_CMPI_MI_FACTORY(Instance) +SWIG_CMPI_MI_FACTORY(Method) +SWIG_CMPI_MI_FACTORY(Association) +SWIG_CMPI_MI_FACTORY(Indication) + Added: cmpi-bindings/trunk/src/cmpi_provider_ruby.c =================================================================== --- cmpi-bindings/trunk/src/cmpi_provider_ruby.c (rev 0) +++ cmpi-bindings/trunk/src/cmpi_provider_ruby.c 2008-08-27 19:57:38 UTC (rev 885) @@ -0,0 +1,743 @@ +/***************************************************************************** +* Copyright (C) 2008 Novell Inc. All rights reserved. +* Copyright (C) 2008 SUSE Linux Products GmbH. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* - Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* - Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* - Neither the name of Novell Inc. nor of SUSE Linux Products GmbH nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL Novell Inc. OR SUSE Linux Products GmbH OR +* THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +static char _CLASSNAME[] = "CmpiInstanceRuby"; + +#include <stdio.h> +#include <stdarg.h> + +/* Include the required CMPI macros, data types, and API function headers */ +#include <cmpidt.h> +#include <cmpift.h> +#include <cmpimacs.h> + +// Needed to obtain errno of failed system calls +#include <errno.h> + +/* Needed for kill() */ +#include <signal.h> + + +#include <ruby.h> + +/* A simple stderr logging/tracing facility. */ +#ifndef _SBLIM_TRACE +#define _SBLIM_TRACE(tracelevel,args) _logstderr args +void _logstderr(char *fmt,...) +{ + va_list ap; + va_start(ap,fmt); + vfprintf(stderr,fmt,ap); + va_end(ap); + fprintf(stderr,"\n"); +} +#endif + +/* Global handle to the CIM broker. This is initialized by the CIMOM when the provider is loaded */ +static const CMPIBroker * _BROKER = NULL; +static char* _MINAME = NULL; + +static char* fmtstr(const char* fmt, ...) +{ + va_list ap; + int len; + va_start(ap, fmt); + len = vsnprintf(NULL, 0, fmt, ap); + va_end(ap); + if (len <= 0) + { + return NULL; + } + char* str = (char*)malloc(len+1); + if (str == NULL) + { + return NULL; + } + va_start(ap, fmt); + vsnprintf(str, len+1, fmt, ap); + va_end(ap); + return str; +} + +static int RBInitialize(CMPIInstanceMI * self, CMPIStatus* st); + +static VALUE +properties2ruby( const char ** properties ) +{ + if (properties) { + VALUE rproperties = rb_ary_new(); + while (*properties) + rb_ary_push( rproperties, rb_str_new2(*properties++) ); + return rproperties; + } + return Qnil; +} + + +// ---------------------------------------------------------------------------- +// CMPI INSTANCE PROVIDER FUNCTIONS +// ---------------------------------------------------------------------------- + +static CMPIStatus Cleanup( + const CMPIContext * context, + CMPIBoolean terminating) +{ + CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */ + + _SBLIM_TRACE(1,("Cleanup() called")); + + ruby_finalize(); + _SBLIM_TRACE(1,("Cleanup(Ruby) called")); + + if (_MINAME != NULL) + { + free(_MINAME); + _MINAME = NULL; + } + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("Cleanup() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + +static CMPIStatus InstCleanup( + CMPIInstanceMI * self, + const CMPIContext * context, + CMPIBoolean terminating) +{ + return Cleanup(context, terminating); +} + +static CMPIStatus AssocCleanup( + CMPIAssociationMI * self, + const CMPIContext * context, + CMPIBoolean terminating) +{ + return Cleanup(context, terminating); +} + +static CMPIStatus MethodCleanup( + CMPIMethodMI * self, + const CMPIContext * context, + CMPIBoolean terminating) +{ + return Cleanup(context, terminating); +} + +static CMPIStatus IndicationCleanup( + CMPIIndicationMI * self, + const CMPIContext * context, + CMPIBoolean terminating) +{ + return Cleanup(context, terminating); +} + +// ---------------------------------------------------------------------------- + + +/* EnumInstanceNames() - return a list of all the instances names (i.e. return their object paths only) */ +static CMPIStatus EnumInstanceNames( + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any */ + const CMPIResult * result, /* [in] Contains the CIM namespace and classname */ + const CMPIObjectPath * reference) /* [in] Contains the CIM namespace and classname */ +{ + CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */ + + _SBLIM_TRACE(1,("EnumInstanceNames() called")); + + _SBLIM_TRACE(1,("EnumInstanceNames(Ruby) called, context %p, result %p, reference %p", context, result, reference)); + VALUE klass = (VALUE)self->hdl; + VALUE rcontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + VALUE rresult = SWIG_NewPointerObj((void*) result, SWIGTYPE_p__CMPIResult, 0); + VALUE rreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + + /* enum_instance_names instead of EnumInstanceNames to follow Ruby naming convention */ + VALUE r = rb_funcall( klass, rb_intern( "enum_instance_names" ), 3, rcontext, rresult, rreference ); + _SBLIM_TRACE(1,("r %p", r)); + +exit: + _SBLIM_TRACE(1,("EnumInstanceNames() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + + +// ---------------------------------------------------------------------------- + + +/* EnumInstances() - return a list of all the instances (i.e. return all the instance data) */ +static CMPIStatus EnumInstances( + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any */ + const CMPIResult * result, /* [in] Contains the CIM namespace and classname */ + const CMPIObjectPath * reference, /* [in] Contains the CIM namespace and classname */ + const char ** properties) /* [in] List of desired properties (NULL=all) */ +{ + CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */ +/* char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); Our current CIM namespace */ + + _SBLIM_TRACE(1,("EnumInstances(Ruby) called, context %p, result %p, reference %p, properties %p", context, result, reference, properties)); + VALUE klass = (VALUE)self->hdl; + VALUE rcontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + VALUE rresult = SWIG_NewPointerObj((void*) result, SWIGTYPE_p__CMPIResult, 0); + VALUE rreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + VALUE rproperties = properties2ruby( properties ); + /* enum_instances instead of EnumInstances to follow Ruby naming convention */ + VALUE r = rb_funcall( klass, rb_intern( "enum_instances" ), 4, rcontext, rresult, rreference, rproperties ); + _SBLIM_TRACE(1,("r %p", r)); + +exit: + _SBLIM_TRACE(1,("EnumInstances() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + + +// ---------------------------------------------------------------------------- + + +/* GetInstance() - return the instance data for the specified instance only */ +static CMPIStatus GetInstance( + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any */ + const CMPIResult * results, /* [out] Results of this operation */ + const CMPIObjectPath * reference, /* [in] Contains the CIM namespace, classname and desired object path */ + const char ** properties) /* [in] List of desired properties (NULL=all) */ +{ + CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */ + + _SBLIM_TRACE(1,("GetInstance(Ruby) called, context %p, results %p, reference %p, properties %p", context, results, reference, properties)); + VALUE klass = (VALUE)self->hdl; + VALUE rcontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + VALUE rresults = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); + VALUE rreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + VALUE rproperties = properties2ruby( properties ); + /* get_instance instead of GetInstance to follow Ruby naming convention */ + VALUE r = rb_funcall( klass, rb_intern( "get_instance" ), 4, rcontext, rresults, rreference, rproperties ); + _SBLIM_TRACE(1,("r %p", r)); + +exit: + _SBLIM_TRACE(1,("GetInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + + +// ---------------------------------------------------------------------------- + + +/* CreateInstance() - create a new instance from the specified instance data. */ +static CMPIStatus CreateInstance( + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self') */ + const CMPIContext * context, /* [in] Additional context info, if any. */ + const CMPIResult * results, /* [out] Results of this operation */ + const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and objectpath. */ + const CMPIInstance * newinstance) /* [in] Contains all the new instance data. */ +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations. */ + + /* Creating new instances is not supported for this class. */ + + _SBLIM_TRACE(1,("CreateInstance(Ruby) called, context %p, results %p, reference %p, instance %p, properties %p", context, results, reference, newinstance)); + VALUE klass = (VALUE)self->hdl; + VALUE rcontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + VALUE rresults = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); + VALUE rreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + VALUE rinstance = SWIG_NewPointerObj((void*) newinstance, SWIGTYPE_p__CMPIInstance, 0); + /* create_instance instead of CreateInstance to follow Ruby naming convention */ + VALUE r = rb_funcall( klass, rb_intern( "create_instance" ), 4, rcontext, rresults, rreference, rinstance ); + _SBLIM_TRACE(1,("r %p", r)); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("CreateInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + + +// ---------------------------------------------------------------------------- + +#ifdef CMPI_VER_100 +#define SetInstance ModifyInstance +#endif + +/* SetInstance() - save modified instance data for the specified instance. */ +static CMPIStatus SetInstance( + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ + const CMPIContext * context, /* [in] Additional context info, if any. */ + const CMPIResult * results, /* [out] Results of this operation. */ + const CMPIObjectPath * reference, /* [in] Contains the target namespace, classname and objectpath. */ + const CMPIInstance * newinstance, /* [in] Contains all the new instance data. */ + const char ** properties) /* [in] List of desired properties (NULL=all) */ +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations. */ + + /* Modifying existing instances is not supported for this class. */ + + _SBLIM_TRACE(1,("SetInstance(Ruby) called, context %p, results %p, reference %p, instance %p, properties %p", context, results, reference, newinstance, properties)); + VALUE klass = (VALUE)self->hdl; + VALUE rcontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + VALUE rresults = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); + VALUE rreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + VALUE rinstance = SWIG_NewPointerObj((void*) newinstance, SWIGTYPE_p__CMPIInstance, 0); + VALUE rproperties = properties2ruby( properties ); + /* set_instance instead of SetInstance to follow Ruby naming convention */ + VALUE r = rb_funcall( klass, rb_intern( "set_instance" ), 5, rcontext, rresults, rreference, rinstance, rproperties ); + _SBLIM_TRACE(1,("r %p", r)); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("SetInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + +// ---------------------------------------------------------------------------- + + +/* DeleteInstance() - delete/remove the specified instance. */ +static CMPIStatus DeleteInstance( + CMPIInstanceMI * self, + const CMPIContext * context, + const CMPIResult * results, + const CMPIObjectPath * reference) +{ + CMPIStatus status = {CMPI_RC_OK, NULL}; + + _SBLIM_TRACE(1,("DeleteInstance(Ruby) called, context %p, results %p, reference %p", context, results, reference)); + VALUE klass = (VALUE)self->hdl; + VALUE rcontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + VALUE rresults = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); + VALUE rreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + /* delete_instance instead of DeleteInstance to follow Ruby naming convention */ + VALUE r = rb_funcall( klass, rb_intern( "delete_instance" ), 3, rcontext, rresults, rreference ); + _SBLIM_TRACE(1,("r %p", r)); + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("DeleteInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + +// ---------------------------------------------------------------------------- + + +/* ExecQuery() - return a list of all the instances that satisfy the desired query filter. */ +static CMPIStatus ExecQuery( + CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */ + const CMPIContext * context, /* [in] Additional context info, if any. */ + const CMPIResult * results, /* [out] Results of this operation. */ + const CMPIObjectPath * reference, /* [in] Contains the target namespace and classname. */ + const char * query, /* [in] Text of the query, written in the query language. */ + const char * language) /* [in] Name of the query language (e.g. "WQL"). */ +{ + CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL}; /* Return status of CIM operations. */ + + _SBLIM_TRACE(1,("ExecQuery(Ruby) called, context %p, results %p, reference %p, query %s, language %s", context, results, reference, query, language)); + VALUE klass = (VALUE)self->hdl; + VALUE rcontext = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0); + VALUE rresults = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0); + VALUE rreference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0); + VALUE rquery = rb_str_new2( query ); + VALUE rlanguage = rb_str_new2( language ); + /* exec_query instead of ExecQuery to follow Ruby naming convention */ + VALUE r = rb_funcall( klass, rb_intern( "exec_query" ), 5, rcontext, rresults, rreference, query, language ); + _SBLIM_TRACE(1,("r %p", r)); + + /* Query filtering is not supported for this class. */ + + /* Finished. */ +exit: + _SBLIM_TRACE(1,("ExecQuery() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + return status; +} + + +// ---------------------------------------------------------------------------- + +static VALUE load_code() +{ + _SBLIM_TRACE(1,("Ruby: require 'rcmpi_instance'...")); + + rb_require("rcmpi_instance"); + + _SBLIM_TRACE(1,("Ruby: ... done")); +} + +static VALUE create_cmpi(VALUE args) +{ + VALUE *values = (VALUE *)args; + _SBLIM_TRACE(1,("Ruby: Cmpi_Instance.new ...")); + VALUE klass = rb_class_new_instance(1, values, rb_const_get(rb_cObject, rb_intern("Cmpi_Instance"))); + _SBLIM_TRACE(1,("Ruby: ... done")); + return klass; +} + +/* Initialize() - perform any necessary initialization immediately after this provider is loaded. */ +static int RBInitialize( + CMPIInstanceMI * self, CMPIStatus* st) /* [in] Handle to this provider (i.e. 'self'). */ +{ + int rc = 0; + if (st != NULL) + { + st->rc = CMPI_RC_OK; + st->msg = NULL; + } + int error = 0; + VALUE cmpiInstance; + SWIGEXPORT void SWIG_init(void); + + _SBLIM_TRACE(1,("Initialize() called")); + + _SBLIM_TRACE(1,("Ruby: Loading")); + ruby_init(); + ruby_init_loadpath(); + ruby_script("rcmpi_instance"); + SWIG_init(); + + rb_protect(load_code, Qnil, &error); + if (error) { + _SBLIM_TRACE(1,("Ruby: FAILED loading rcmpi_instance.rb")); + if (st != NULL) + { + st->rc = CMPI_RC_ERR_FAILED; + } + } + else { + _SBLIM_TRACE(1,("Ruby: loaded rcmpi_instance.rb")); + VALUE args[1]; + args[0] = rb_str_new2(_CLASSNAME); + cmpiInstance = rb_protect(create_cmpi, (VALUE)args, &error); + if (error) { + _SBLIM_TRACE(1,("Ruby: FAILED creating Cmpi")); + if (st != NULL) + { + st->rc = CMPI_RC_ERR_FAILED; + } + } + else { + _SBLIM_TRACE(1,("Ruby: cmpi at %p", cmpiI... [truncated message content] |
From: <np...@us...> - 2008-08-27 18:10:54
|
Revision: 884 http://omc.svn.sourceforge.net/omc/?rev=884&view=rev Author: npaxton Date: 2008-08-27 18:11:04 +0000 (Wed, 27 Aug 2008) Log Message: ----------- separate out cmpi_provider.c into type/language specific files for python and ruby Modified Paths: -------------- cmpi-bindings/trunk/src/CMakeLists.txt cmpi-bindings/trunk/swig/CMakeLists.txt cmpi-bindings/trunk/swig/cmpi.i cmpi-bindings/trunk/swig/python/CMakeLists.txt Modified: cmpi-bindings/trunk/src/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/src/CMakeLists.txt 2008-08-27 17:20:45 UTC (rev 883) +++ cmpi-bindings/trunk/src/CMakeLists.txt 2008-08-27 18:11:04 UTC (rev 884) @@ -5,7 +5,7 @@ SET( CMPI_INCLUDE_DIR /usr/include/cmpi ) SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -g" ) -SET(cmpi_provider_SRCS cmpi_provider.c) +SET(cmpi_provider_SRCS cmpi_provider_python.c cmpi_provider_ruby.c) ADD_DEFINITIONS(-DCMPI_PLATFORM_LINUX_GENERIC_GNU -DCMPI_VERSION=200) ADD_LIBRARY(cmpi_provider SHARED ${cmpi_provider_SRCS}) Modified: cmpi-bindings/trunk/swig/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/swig/CMakeLists.txt 2008-08-27 17:20:45 UTC (rev 883) +++ cmpi-bindings/trunk/swig/CMakeLists.txt 2008-08-27 18:11:04 UTC (rev 884) @@ -7,7 +7,7 @@ FIND_PACKAGE(Ruby) IF (RUBY_LIBRARY AND RUBY_INCLUDE_PATH) MESSAGE(STATUS "Building Ruby...") -# ADD_SUBDIRECTORY(ruby) + ADD_SUBDIRECTORY(ruby) ENDIF (RUBY_LIBRARY AND RUBY_INCLUDE_PATH) FIND_PACKAGE(PythonLibs) Modified: cmpi-bindings/trunk/swig/cmpi.i =================================================================== --- cmpi-bindings/trunk/swig/cmpi.i 2008-08-27 17:20:45 UTC (rev 883) +++ cmpi-bindings/trunk/swig/cmpi.i 2008-08-27 18:11:04 UTC (rev 884) @@ -27,8 +27,14 @@ * provider code */ -#include "../src/cmpi_provider.c" +#if defined(SWIGRUBY) +#include "../src/cmpi_provider_ruby.c" +#endif +#if defined(SWIGPYTHON) +#include "../src/cmpi_provider_python.c" +#endif + %} # Definitions Modified: cmpi-bindings/trunk/swig/python/CMakeLists.txt =================================================================== --- cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-08-27 17:20:45 UTC (rev 883) +++ cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-08-27 18:11:04 UTC (rev 884) @@ -45,7 +45,7 @@ SET( NAME pyCmpiProvider ) ADD_LIBRARY( ${NAME} SHARED ${SWIG_OUTPUT}) #TARGET_LINK_LIBRARIES( ${NAME} ${PYTHON_LIBRARIES} ) -TARGET_LINK_LIBRARIES( ${NAME} python2.5 ) +TARGET_LINK_LIBRARIES( ${NAME} python2.4 ) TARGET_LINK_LIBRARIES( ${NAME} m ) TARGET_LINK_LIBRARIES( ${NAME} util ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2008-08-27 17:20:37
|
Revision: 883 http://omc.svn.sourceforge.net/omc/?rev=883&view=rev Author: bartw Date: 2008-08-27 17:20:45 +0000 (Wed, 27 Aug 2008) Log Message: ----------- added testsuite Added Paths: ----------- cmpi-bindings/trunk/test/ cmpi-bindings/trunk/test/python/ cmpi-bindings/trunk/test/python/TestAssoc.mof cmpi-bindings/trunk/test/python/TestAssocProvider-peg.reg cmpi-bindings/trunk/test/python/TestAssocProvider.py cmpi-bindings/trunk/test/python/TestAssocProvider.reg cmpi-bindings/trunk/test/python/TestAssocProvider.sfcb.reg cmpi-bindings/trunk/test/python/TestAtom.mof cmpi-bindings/trunk/test/python/TestAtomProvider.peg.reg cmpi-bindings/trunk/test/python/TestAtomProvider.py cmpi-bindings/trunk/test/python/TestAtomProvider.reg cmpi-bindings/trunk/test/python/TestAtomProvider.sfcb.reg cmpi-bindings/trunk/test/python/TestAtomProvider_Test.py cmpi-bindings/trunk/test/python/TestMethod.mof cmpi-bindings/trunk/test/python/TestMethod.peg.reg cmpi-bindings/trunk/test/python/TestMethod.py cmpi-bindings/trunk/test/python/TestMethod.reg cmpi-bindings/trunk/test/python/TestMethod.sfcb.reg cmpi-bindings/trunk/test/python/TestMethod_Test.py cmpi-bindings/trunk/test/python/UpcallAtom-peg.mof cmpi-bindings/trunk/test/python/UpcallAtom.mof cmpi-bindings/trunk/test/python/UpcallAtom.peg.reg cmpi-bindings/trunk/test/python/UpcallAtom.reg cmpi-bindings/trunk/test/python/UpcallAtomProvider.py cmpi-bindings/trunk/test/python/lib/ cmpi-bindings/trunk/test/python/lib/ProviderSanityTest.py cmpi-bindings/trunk/test/python/lib/__init__.py cmpi-bindings/trunk/test/python/lib/wbem_connection.py cmpi-bindings/trunk/test/python/test_assoc.py Added: cmpi-bindings/trunk/test/python/TestAssoc.mof =================================================================== --- cmpi-bindings/trunk/test/python/TestAssoc.mof (rev 0) +++ cmpi-bindings/trunk/test/python/TestAssoc.mof 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,39 @@ +[ Description("Local user of the system on which the CIMOM is running")] +class TestAssoc_User +{ + [Key, Description("The user's numeric user ID")] + string UserID; + + [Required, Description("The user's username")] + string UserName; + + [Description("The user's home directory, if any")] + string HomeDirectory; + + [Description("The user's login shell, if any")] + string LoginShell; +}; + +[ Description("Local group of users on the system on which the CIMOM is running")] +class TestAssoc_Group +{ + [Key, Description("The group's numeric group ID")] + string GroupID; + + [Required, Description("The group's name")] + string GroupName; +}; + +[ Association, Description("Association that shows relationship of users and groups")] +class TestAssoc_MemberOfGroup +{ + [Key, Override("Antecedent"), Description ("The group")] + TestAssoc_Group REF Antecedent; + + [Key, Override("Dependent"), Description("The user")] + TestAssoc_User REF Dependent; + + [Required, Description("Indicates whether the associated group is the primary group for the associated user")] + boolean isPrimaryGroup; +}; + Added: cmpi-bindings/trunk/test/python/TestAssocProvider-peg.reg =================================================================== --- cmpi-bindings/trunk/test/python/TestAssocProvider-peg.reg (rev 0) +++ cmpi-bindings/trunk/test/python/TestAssocProvider-peg.reg 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,47 @@ +// Provider registration for TestAssoc +instance of PG_ProviderModule +{ + Name = "TestAssocProvider-Module"; + InterfaceType = "Python"; + InterfaceVersion = "1.0.0"; + Location = "/usr/lib/pycim/TestAssocProvider.py"; + Vendor = "Novell"; + Version = "1.0.0"; +}; + +instance of PG_Provider +{ + Name = "TestAssocProvider-Provider"; + ProviderModuleName = "TestAssocProvider-Module"; +}; + +instance of PG_ProviderCapabilities +{ + CapabilityID = "TestAssocProvider-Capability1"; + ProviderModuleName = "TestAssocProvider-Module"; + ProviderName = "TestAssocProvider-Provider"; + ClassName = "TestAssoc_User"; + Namespaces = {"root/cimv2"}; + ProviderType = {2}; // Instance +}; + +instance of PG_ProviderCapabilities +{ + CapabilityID = "TestAssocProvider-Capability2"; + ProviderModuleName = "TestAssocProvider-Module"; + ProviderName = "TestAssocProvider-Provider"; + ClassName = "TestAssoc_Group"; + Namespaces = {"root/cimv2"}; + ProviderType = {2}; // Instance +}; + +instance of PG_ProviderCapabilities +{ + CapabilityID = "TestAssocProvider-Capability3"; + ProviderModuleName = "TestAssocProvider-Module"; + ProviderName = "TestAssocProvider-Provider"; + ClassName = "TestAssoc_MemberOfGroup"; + Namespaces = {"root/cimv2"}; + ProviderType = {2,3}; // Instance/Association +}; + Added: cmpi-bindings/trunk/test/python/TestAssocProvider.py =================================================================== --- cmpi-bindings/trunk/test/python/TestAssocProvider.py (rev 0) +++ cmpi-bindings/trunk/test/python/TestAssocProvider.py 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,229 @@ +"""Python Provider for TestAssoc + +Instruments: +- TestAssoc_User (instance provider) +- TestAssoc_Group (instance provider) +- TestAssoc_MemberOfGroup (instance and association provider) + +""" + +import pywbem +import pwd +import grp + +def get_user_instance(uid, model, keys_only): + try: + pwinfo = pwd.getpwuid(uid) + #model['UserID'] = pywbem.Uint32(uid) + model['UserID'] = str(uid) + if keys_only: + return model + model['UserName'] = pwinfo[0] + model['LoginShell'] = pwinfo[6] + model['HomeDirectory'] = pwinfo[5] + return model + except KeyError: + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) + +def get_group_instance(gid, model, keys_only): + try: + grinfo = grp.getgrgid(gid) + #model['GroupID'] = pywbem.Uint32(gid) + model['GroupID'] = str(gid) + if keys_only: + return model + model['GroupName'] = grinfo[0] + return model + except KeyError: + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) + +def is_primary_user(uid, gid): + pwinfo = pwd.getpwuid(uid) + return gid == pwinfo[3] + +def is_user_in_group(uid, gid): + pwinfo = pwd.getpwuid(uid) + grinfo = grp.getgrgid(gid) + return pwinfo[0] in grinfo[3] + +def get_assoc_instance(uid, gid, model, keys_only): + try: + isPrimary = is_primary_user(uid, gid) + if not isPrimary and not is_user_in_group(uid, gid): + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) + model['Dependent'] = get_user_instance(uid, model['Dependent'], keys_only) + model['Antecedent'] = get_group_instance(gid, model['Antecedent'], keys_only) + if keys_only: + return model + model['isPrimaryGroup'] = isPrimary + return model + except KeyError: + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) + +class TestAssoc_User(pywbem.CIMProvider): + + def __init__(self, env): + self._logger = env.get_logger() + + def get_instance(self, env, model, cim_class, inst=None): + try: + uid = model['UserID'] + uid = int(uid) + return get_user_instance(uid, model, False) + except KeyError: + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) + + def enum_instances(self, env, model, cim_class, keys_only): + self._logger.log_debug("%s: enum_instances called for class %s" % (self.__class__.__name__.upper(), model.classname)) + for pwent in pwd.getpwall(): + yield get_user_instance(pwent[2], model, keys_only) + + def set_instance(self, env, instance, previous_instance, cim_class): + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) + + def delete_instance(self, env, instance_name): + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) + + + +class TestAssoc_Group(pywbem.CIMProvider): + + def __init__(self, env): + self._logger = env.get_logger() + + def get_instance(self, env, model, cim_class, inst=None): + try: + gid = model['GroupID'] + gid = int(gid) + return get_group_instance(gid, model, False) + except KeyError: + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) + + def enum_instances(self, env, model, cim_class, keys_only): + for grent in grp.getgrall(): + yield get_group_instance(grent[2], model, keys_only) + + def set_instance(self, env, instance, previous_instance, cim_class): + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) + + def delete_instance(self, env, instance_name): + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) + + +class TestAssoc_MemberOfGroup(pywbem.CIMProvider): + + def __init__(self, env): + self._logger = env.get_logger() + + def get_instance(self, env, model, cim_class, inst=None): + try: + uid = model['Dependent']['UserID'] + uid = int(uid) + gid = model['Antecedent']['GroupID'] + gid = int(gid) + return get_assoc_instance(uid, gid, model, False) + except KeyError: + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) + + def enum_instances(self, env, model, cim_class, keys_only): + self._logger.log_debug("\n%s: enum_instances called for class %s" % (self.__class__.__name__.upper(), model.classname)) + for pwent in pwd.getpwall(): + user_cin = pywbem.CIMInstanceName('TestAssoc_User', + namespace=model.path.namespace) + group_cin = pywbem.CIMInstanceName('TestAssoc_Group', + namespace=model.path.namespace) + model['Dependent'] = get_user_instance(pwent[2], user_cin, True) + model['Antecedent'] = get_group_instance(pwent[3], group_cin, True) + if not keys_only: + model['isPrimaryGroup'] = True + yield model + for grent in grp.getgrall(): + if pwent[0] in grent[3]: + model['Antecedent'] = get_group_instance(grent[2], group_cin, True) + if not keys_only: + model['isPrimaryGroup'] = False + yield model + + def set_instance(self, env, instance, previous_instance, cim_class): + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) + + def delete_instance(self, env, instance_name): + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) + + def xxx_hello(self): + pass + + def references(self, env, object_name, model, assoc_class, + result_class_name, role, result_role, keys_only): + print '!!!!!!! in TestAssoc_MemberOfGroup.references()' + self._logger.log_debug("\n%s: References called for class %s" % (self.__class__.__name__.upper(), object_name)) + ch = env.get_cimom_handle() + if pywbem.is_subclass(ch, + object_name.namespace, + sub=object_name.classname, + super='TestAssoc_User'): + if role and role.lower() == 'antecedent': + return + if result_role and result_role.lower() == 'dependent': + return + if result_class_name and not pywbem.is_subclass(ch, + object_name.namespace, + sub = 'TestAssoc_Group', + super = result_class_name): + return + model['Dependent'] = object_name + cn = pywbem.CIMInstanceName('TestAssoc_Group', + namespace=object_name.namespace) + uid = model['Dependent']['UserID'] + uid = int(uid) + pwinfo = pwd.getpwuid(uid) + model['Antecedent'] = get_group_instance(pwinfo[3], cn, True) + if not keys_only: + model['isPrimaryGroup'] = True + yield model + for grent in grp.getgrall(): + if pwinfo[0] in grent[3]: + model['Antecedent'] = get_group_instance(grent[2], cn, True) + if not keys_only: + model['isPrimaryGroup'] = False + yield model + elif pywbem.is_subclass(ch, + object_name.namespace, + sub=object_name.classname, + super='TestAssoc_Group'): + if role and role.lower() == 'dependent': + return + if result_role and result_role.lower() == 'antecedent': + return + if result_class_name and not pywbem.is_subclass(ch, + object_name.namespace, + sub = 'TestAssoc_User', + super = result_class_name): + return + model['Antecedent'] = object_name + cn = pywbem.CIMInstanceName('TestAssoc_User', + namespace=object_name.namespace) + gid = model['Antecedent']['GroupID'] + gid = int(gid) + grinfo = grp.getgrgid(gid) + for member_name in grinfo[3]: + pwinfo = pwd.getpwnam(member_name) + model['Dependent'] = get_user_instance(pwinfo[2], cn, True) + if not keys_only: + model['isPrimaryGroup'] = False + yield model + for pwent in pwd.getpwall(): + if pwent[3] == grinfo[2]: + model['Dependent'] = get_user_instance(pwent[2], cn, True) + if not keys_only: + model['isPrimaryGroup'] = True + yield model + + +def get_providers(env): + user_prov = TestAssoc_User(env) + group_prov = TestAssoc_Group(env) + mog_prov = TestAssoc_MemberOfGroup(env) + return { 'TestAssoc_User' : user_prov, + 'TestAssoc_Group' : group_prov, + 'TestAssoc_MemberOfGroup' : mog_prov } Added: cmpi-bindings/trunk/test/python/TestAssocProvider.reg =================================================================== --- cmpi-bindings/trunk/test/python/TestAssocProvider.reg (rev 0) +++ cmpi-bindings/trunk/test/python/TestAssocProvider.reg 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,27 @@ +// Provider registration for TestAssoc +instance of OpenWBEM_PyProviderRegistration +{ + InstanceID = "<Novell:ZENworks:TestAssoc:001>"; + NamespaceNames = {"root/cimv2"}; + ClassName = "TestAssoc_User"; + ProviderTypes = {1}; + ModulePath = "/usr/lib/pycim/TestAssocProvider.py"; +}; + +instance of OpenWBEM_PyProviderRegistration +{ + InstanceID = "<Novell:ZENworks:TestAssoc:002>"; + NamespaceNames = {"root/cimv2"}; + ClassName = "TestAssoc_Group"; + ProviderTypes = {1}; + ModulePath = "/usr/lib/pycim/TestAssocProvider.py"; +}; + +instance of OpenWBEM_PyProviderRegistration +{ + InstanceID = "<Novell:ZENworks:TestAssoc:003>"; + NamespaceNames = {"root/cimv2"}; + ClassName = "TestAssoc_MemberOfGroup"; + ProviderTypes = {1, 3}; + ModulePath = "/usr/lib/pycim/TestAssocProvider.py"; +}; Added: cmpi-bindings/trunk/test/python/TestAssocProvider.sfcb.reg =================================================================== --- cmpi-bindings/trunk/test/python/TestAssocProvider.sfcb.reg (rev 0) +++ cmpi-bindings/trunk/test/python/TestAssocProvider.sfcb.reg 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,17 @@ +[TestAssoc_Group] + provider: TestAssocProvider + location: pyCmpiProvider + type: instance + namespace: root/cimv2 + +[TestAssoc_User] + provider: TestAssocProvider + location: pyCmpiProvider + type: instance + namespace: root/cimv2 + +[TestAssoc_MemberOfGroup] + provider: TestAssocProvider + location: pyCmpiProvider + type: instance association + namespace: root/cimv2 Added: cmpi-bindings/trunk/test/python/TestAtom.mof =================================================================== --- cmpi-bindings/trunk/test/python/TestAtom.mof (rev 0) +++ cmpi-bindings/trunk/test/python/TestAtom.mof 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,53 @@ +[ Description("Model an atom, For use with CIMOM and PyWBEM Provider")] +class Test_Atom +{ + /* + INTRINSIC DATA TYPE INTERPRETATION + uint8 Unsigned 8-bit integer + sint8 Signed 8-bit integer + uint16 Unsigned 16-bit integer + sint16 Signed 16-bit integer + uint32 Unsigned 32-bit integer + sint32 Signed 32-bit integer + uint64 Unsigned 64-bit integer + sint64 Signed 64-bit integer + string UCS-2 string + boolean Boolean + real32 IEEE 4-byte floating-point + real64 IEEE 8-byte floating-point + datetime A string containing a date-time + <classname> ref Strongly typed reference + char16 16-bit UCS-2 character + */ + uint8 uint8Prop; + uint8 uint8Propa[]; + sint8 sint8prop; + sint8 sint8propa[]; + uint16 uint16Prop; + uint16 uint16Propa[]; + sint16 sint16Prop; + sint16 sint16Propa[]; + uint32 uint32Prop; + uint32 uint32Propa[]; + sint32 sint32Prop; + sint32 sint32Propa[]; + uint64 uint64Prop; + uint64 uint64Propa[]; + sint64 sint64Prop; + sint64 sint64Propa[]; + string stringProp; + string stringPropa[]; + real32 real32Prop; + real32 real32Propa[]; + real64 real64Prop; + real64 real64Propa[]; +// char16 char16Prop; +// char16 char16Propa[]; + datetime dateProp; + boolean boolProp; + [Key, Description("The Name of the atom.")] + string Name; + + //<classname> ref //Strongly typed reference "its value is an object path -- pointer to another instance + +}; Added: cmpi-bindings/trunk/test/python/TestAtomProvider.peg.reg =================================================================== --- cmpi-bindings/trunk/test/python/TestAtomProvider.peg.reg (rev 0) +++ cmpi-bindings/trunk/test/python/TestAtomProvider.peg.reg 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,28 @@ +// Provider registration for TestAtom +instance of PG_ProviderModule +{ + Name = "TestAtom_Module"; + Location = "TestAtomProvider"; + Vendor = "Novell"; + Version = "1.0.0"; + InterfaceType = "Python"; + InterfaceVersion = "1.0.0"; +}; + +instance of PG_Provider +{ + Name = "TestAtom_Provider"; + ProviderModuleName = "TestAtom_Module"; +}; + +instance of PG_ProviderCapabilities +{ + ProviderModuleName = "TestAtom_Module"; + ProviderName = "TestAtom_Provider"; + ClassName = "Test_Atom"; + ProviderType = { 2 }; + Namespaces = {"root/cimv2"}; + SupportedProperties = NULL; + SupportedMethods = NULL; + CapabilityID = "TestAtom-Prov-1"; +}; Added: cmpi-bindings/trunk/test/python/TestAtomProvider.py =================================================================== --- cmpi-bindings/trunk/test/python/TestAtomProvider.py (rev 0) +++ cmpi-bindings/trunk/test/python/TestAtomProvider.py 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,203 @@ +"""Python Provider for TestAtom + +Instruments the CIM class TestAtom + +""" + +import pywbem +import sys + +class TestAtomProvider(pywbem.CIMProvider): + """Instrument the CIM class TestAtom + + Model an atom, For use with CIMOM and PyWBEM Provider + + """ + def __init__ (self, env): + logger = env.get_logger() + logger.log_debug('Initializing provider %s from %s' \ + % (self.__class__.__name__, __file__)) + self.storage = {} + # If you will be filtering instances yourself according to + # property_list, role, result_role, and result_class_name + # parameters, set self.filter_results to False + # self.filter_results = False + + def get_instance(self, env, model, cim_class): + """Return an instance. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + model -- A template of the pywbem.CIMInstance to be returned. The + key properties are set on this instance to correspond to the + instanceName that was requested. The properties of the model + are already filtered according to the PropertyList from the + request. Only properties present in the model need to be + given values. If you prefer, you can set all of the + values, and the instance will be filtered for you. + cim_class -- The pywbem.CIMClass + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM + Instance does not exist in the specified namespace) + CIM_ERR_FAILED (some other unspecified error occurred) + + """ + + logger = env.get_logger() + logger.log_debug('Entering %s.get_instance()' \ + % self.__class__.__name__) + + try: + #logger.log_debug("**** GET_INSTANCE model[name]: %s ****" % model['Name']) + #print "**** GET_INSTANCE model[name]: %s ****" % str(model['Name']) + #if model['Name'] in self.storage.keys(): + inst = self.storage[model['Name']] + #else: + #print "This is not working.... ******* FIX ME" + + except KeyError: + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) + #print " **** Setting Model Properties: ****" + for k, v in inst.items(): + model.update_existing(((k, v),)) + + #return inst + return model + + + def enum_instances(self, env, model, cim_class, keys_only): + """Enumerate instances. + + The WBEM operations EnumerateInstances and EnumerateInstanceNames + are both mapped to this method. + This method is a python generator + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + model -- A template of the pywbem.CIMInstances to be generated. + The properties of the model are already filtered according to + the PropertyList from the request. Only properties present in + the model need to be given values. If you prefer, you can + always set all of the values, and the instance will be filtered + for you. + cim_class -- The pywbem.CIMClass + keys_only -- A boolean. True if only the key properties should be + set on the generated instances. + + Possible Errors: + CIM_ERR_FAILED (some other unspecified error occurred) + + """ + + logger = env.get_logger() + logger.log_debug('Entering %s.enum_instances()' \ + % self.__class__.__name__) + #for atom in self.storage.keys(): + #print "Key = %s " %str(atom) + + for key in self.storage.keys(): + #print "***** HELLO ***** " + #logger.log_debug("************ ENUM_INSTANCES ********") + #logger.log_debug(" **** model['Name'] = %s ****" % key) + #print "************ ENUM_INSTANCES ********" + #print " **** model['Name'] = %s ****" % key + model['Name'] = key + try: + yield self.get_instance(env, model, cim_class) + except pywbem.CIMError, (num, msg): + if num not in (pywbem.CIM_ERR_NOT_FOUND, + pywbem.CIM_ERR_ACCESS_DENIED): + raise + + def set_instance(self, env, instance, previous_instance, cim_class): + """Return a newly created or modified instance. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + instance -- The new pywbem.CIMInstance. If modifying an existing + instance, the properties on this instance have been filtered by + the PropertyList from the request. + previous_instance -- The previous pywbem.CIMInstance if modifying + an existing instance. None if creating a new instance. + cim_class -- The pywbem.CIMClass + + Return the new instance. The keys must be set on the new instance. + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_NOT_SUPPORTED + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only + valid if previous_instance is None, indicating that the operation + was CreateInstance) + CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid + if previous_instance is not None, indicating that the operation + was ModifyInstance) + CIM_ERR_FAILED (some other unspecified error occurred) + + """ + + logger = env.get_logger() + logger.log_debug('Entering %s.set_instance()' \ + % self.__class__.__name__) + + if previous_instance is not None:#Existing Instance or Modify + if instance['Name'] not in self.storage: + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) + inst = self.storage[instance['Name']] + inst.properties.update(instance.properties) + #logger.log_debug("***** Updating stuff :%s *****" % instance.properties) + + #loop, if it exists, throw exception (Already_Exists) + elif previous_instance is None: + if instance['Name'] in self.storage: + raise pywbem.CIMError(pywbem.CIM_ERR_ALREADY_EXISTS) + else: + #Creating a new instance + #print "Copying Instance" + #print "Instance name: %s"%str(instance['Name']) + #for key in instance.properties.keys(): + #print "key=%s"%str(key) + self.storage[instance['Name']] = instance.copy() + + return instance + + def delete_instance(self, env, instance_name): + """Delete an instance. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + instance_name -- A pywbem.CIMInstanceName specifying the instance + to delete. + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_NOT_SUPPORTED + CIM_ERR_INVALID_NAMESPACE + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified + namespace) + CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM + Instance does not exist in the specified namespace) + CIM_ERR_FAILED (some other unspecified error occurred) + + """ + logger = env.get_logger() + logger.log_debug('Entering %s.delete_instance()' \ + % self.__class__.__name__) + try: + del self.storage[instance_name['Name']] + except KeyError: + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) + +## end of class TestAtomProvider + +def get_providers(env): + testatom_prov = TestAtomProvider(env) + return {'Test_Atom': testatom_prov} Added: cmpi-bindings/trunk/test/python/TestAtomProvider.reg =================================================================== --- cmpi-bindings/trunk/test/python/TestAtomProvider.reg (rev 0) +++ cmpi-bindings/trunk/test/python/TestAtomProvider.reg 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,9 @@ +// Provider registration for TestAtom +instance of OpenWBEM_PyProviderRegistration +{ + InstanceID = "<org:product:TestAtom:unique_id>"; // TODO + NamespaceNames = {"root/cimv2"}; + ClassName = "Test_Atom"; + ProviderTypes = {1}; // Instance + ModulePath = "/usr/lib/pycim/TestAtomProvider.py"; // TODO +}; Added: cmpi-bindings/trunk/test/python/TestAtomProvider.sfcb.reg =================================================================== --- cmpi-bindings/trunk/test/python/TestAtomProvider.sfcb.reg (rev 0) +++ cmpi-bindings/trunk/test/python/TestAtomProvider.sfcb.reg 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,5 @@ +[Test_Atom] + provider: TestAtomProvider + location: pyCmpiProvider + type: instance + namespace: root/cimv2 Added: cmpi-bindings/trunk/test/python/TestAtomProvider_Test.py =================================================================== --- cmpi-bindings/trunk/test/python/TestAtomProvider_Test.py (rev 0) +++ cmpi-bindings/trunk/test/python/TestAtomProvider_Test.py 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,534 @@ +#!/usr/bin/env python +# +#Author: Kenny Woodson +#Date: Mon Sep 17, 2007 +#Description: Script to test the functions of the TestAtomProvider. +#Tests include: +# CreateInstance, EnumerateInstance, EnumerateInstanceNames, +# ModifyInstance, DeleteInstance, GetInstance +# +############################################################################### + +import pywbem +from os import path +import subprocess +import unittest +import math +from lib import wbem_connection + +_tolerance = .04 + +_atoms = {'Hydrogen': 1, + 'Helium': 2, + 'Lithium': 3, + 'Beryllium': 4, + 'Boron': 5, + 'Carbon': 6, + 'Nitrogen': 7, + 'Oxygen': 8, + 'Fluorine': 9, + 'Neon': 10 } + +_atomic_weights = {'Hydrogen': 1.00794, + 'Helium': 4.002602, + 'Lithium': 6.941, + 'Beryllium': 9.012182, + 'Boron': 10.811, + 'Carbon': 12.0107, + 'Nitrogen': 14.0067, + 'Oxygen': 15.9994, + 'Fluorine': 18.9984032, + 'Neon': 20.1797 } + +def restart_gmond(): + p = subprocess.Popen([ path.join('/etc/init.d/', "novell-gmond"), \ + "restart"], stdout=subprocess.PIPE) + p.wait() + + +def _compare_values(conn, instance, time): + types = {'boolProp': 'boolean', + 'dateProp': 'datetime', + 'real32Prop': 'real32', + 'real32Propa': 'real32', + 'real64Prop': 'real64', + 'real64Propa': 'real64', + 'sint16Prop': 'sint16', + 'sint16Propa': 'sint16', + 'sint32Prop': 'sint32', + 'sint32Propa': 'sint32', + 'sint64Prop': 'sint64', + 'sint64Propa': 'sint64', + 'sint8prop': 'sint8', + 'sint8propa': 'sint8', + 'stringProp': 'string', + 'stringPropa': 'string', + 'uint16Prop': 'uint16', + 'uint16Propa': 'uint16', + 'uint32Prop': 'uint32', + 'uint32Propa': 'uint32', + 'uint64Prop': 'uint64', + 'uint64Propa': 'uint64', + 'uint8Prop' : 'uint8', + 'uint8Propa' : 'uint8' } + + if instance['Name'] in _atoms: + #print instance['Name'] + atoms_value = _atoms.get(instance['Name']) + atoms_weight = _atomic_weights[instance['Name']] + for prop,value in instance.items(): + #print "Property=%s"%str(prop) + #Char and Char_array + if prop == 'char16Prop' or prop == 'char16Propa': + pass + #Date Property + elif prop == 'dateProp': + if str(instance[prop]) != str(time): + raise "DateProp NOT EQUAL" + #Name or stringProp + elif prop == 'Name' or prop == 'stringProp': + if instance['Name'] not in _atoms or \ + instance['stringProp'] not in _atoms: + raise "Atom Name NOT FOUND: %s" & instance['Name'] + #boolProp + elif prop == 'boolProp': + if instance[prop] != False: + raise "False NOT EQUAL False" + #All values not in lists + #real64Prop fails this check + elif (instance.properties[prop].type == types.get(prop)) and \ + type(instance.properties[prop].value) != type([]): + if prop == 'uint8Prop': + if pywbem.Uint8(atoms_value) != instance[prop]: + raise "%s Error: %s" % (prop, instance[prop]) + elif prop.startswith("real"): + if _atomic_weights[instance['Name']] != atoms_weight: + raise "%s == %s"%(_atomic_weights[instance['Name']],atoms_weight) + elif atoms_value != value: + raise "%s == %s"%(atoms_value,value) + #All list values + elif type(instance.properties[prop].value) == type([]) and \ + instance.properties[prop].type == types.get(prop): + if prop == 'stringPropa': + if value[0] != 'proton' and value[1] != 'electron' \ + and value[2] != 'neutron': + raise "String Array NOT EQUAL" + elif prop == 'uint8Propa': + for val in instance.properties[prop].value: + if pywbem.Uint8(atoms_value) != val: + raise ("Uint8 Values NOT EQUAL") + else: + #print "\n" + #print "instance.properties[prop]=%s"%str(prop) + #print "atoms_value=%s"%str(atoms_value) + for a_prop in instance.properties[prop].value: + #print "a_prop=%s"%str(a_prop) + #print "value=%s"%str(value) + for num in value: #Array + #print "Checking a_prop=%s with num=%s" % (str(a_prop),str(num)) + #print "startswith=%s"%str(prop.startswith("real")) + #if str(instance.properties[prop]).startswith("real"): + if prop.startswith("real"): + #print "Checking num=%s with atoms_weight=%s"%(str(num),str(atoms_weight)) + if math.fabs(num - atoms_weight) > _tolerance: + raise "%s NOT EQUAL %s" % (str(num), str(atoms_weight)) + elif a_prop != num: + raise "%s NOT EQUAL %s" % (atoms_value, num) + else: + raise "%s NOT EQUAL %s" % (atoms_value, value) + else: + raise "Instance of Test_Atom not Found: %s" % (instance['Name']) + + +def get_instance(conn, keybindings, propertylist=None): + if propertylist is None: + propertylist = [] + inst = None + try: + iname = pywbem.CIMInstanceName(classname='Test_Atom', \ + keybindings=(keybindings), namespace='root/cimv2') + inst = conn.GetInstance(iname, PropertyList=propertylist) + except pywbem.CIMError, arg: + raise (arg) + return inst + + +def get_instance_names(conn): + """ + Open a wbem connection and retrieve the newly created instance names. + """ + + try: + ta_list = conn.EnumerateInstanceNames('Test_Atom') + except pywbem.CIMError, arg: + raise + return None + + return ta_list + + +def get_test_instances(conn): + """ + Open a wbem connection and retrieve the newly created instances. + """ + + try: + ta_list = conn.EnumerateInstances('Test_Atom') + except pywbem.CIMError, arg: + raise + return None + + return ta_list + + +def delete_test_instances(conn, del_instances): + """ + Open a wbem connection and attempt to delete the newly created instance. + """ + + try: + for atom in del_instances: + conn.DeleteInstance(atom) + except pywbem.CIMError, arg: + raise arg + return False + + return True + +class TestAtomProvider(unittest.TestCase): + time = pywbem.CIMDateTime.now() + + def setUp(self): + self.inst_paths = [] + self.instance = None + #wconn = wbem_connection.wbem_connection() + self.conn = pywbem.PegasusUDSConnection() + self.conn = pywbem.SFCBUDSConnection() + unittest.TestCase.setUp(self) + + def tearDown(self): + for ipath in self.inst_paths: + try: + self.conn.DeleteInstance(ipath) + except pywbem.CIMError,arg: + pass + unittest.TestCase.tearDown(self) + + + + #def test_1_register(self): + # """ Test Register Provider """ + # testdir = "/usr/lib/pycim" + # reginst = pywbem.CIMInstance('OpenWBEM_PyProviderRegistration', \ + # properties={ 'InstanceID':'TestAtomProvider', \ + # 'NamespaceNames':['root/cimv2'], + # 'ClassName':'TestAtom', + # 'ProviderTypes':[pywbem.Uint16(1)], # Indication Handler + # 'ModulePath':'%s/TestAtomProvider.py' % testdir, + # }, + # path=pywbem.CIMInstanceName('OpenWBEM_PyProviderRegistration', + # namespace='Interop')) + # + # try: + # self.conn.CreateInstance(reginst) + # except pywbem.CIMError, arg: + # self.fail("Could not REGISTER %s:%s" % (reginst.classname, str(arg))) + # restart_gmond() + + + + + #def test_7_deregister(self): + # """ Test Deregister Provider """ + # self.conn.default_namespace = 'Interop' + # reglist = self.conn.EnumerateInstanceNames('OpenWBEM_PyProviderRegistration') + # for inst_name in reglist: + # if inst_name['InstanceID'] == 'TestAtomProvider': + # try: + # self.conn.DeleteInstance(inst_name) + # except pywbem.CIMError, arg: + # self.fail("Could not DEREGISTER Class") + + # restart_gmond() + + # try: + # self.conn.GetInstance(inst_name) + # except pywbem.CIMError, arg: + # self.failUnlessEqual(arg[0], pywbem.CIM_ERR_NOT_FOUND, + # 'Unexpected exception on GetInstance: %s' % str(arg)) + + + + def _create_test_instance(self, name_of_atom, number): + """ Create a TestAtom instance. """ + + weight = _atomic_weights[name_of_atom] + #new_instance['char16Prop'] = + #new_instance['char16Propa'] = Null + new_instance = pywbem.CIMInstance('Test_Atom') + new_instance['Name'] = name_of_atom + new_instance['boolProp'] = False + new_instance['dateProp'] = self.time + new_instance['real32Prop'] = pywbem.Real32(weight) + new_instance['real32Propa'] = [pywbem.Real32(weight), \ + pywbem.Real32(weight), \ + pywbem.Real32(weight)] + new_instance['real64Prop'] = pywbem.Real64(weight) + new_instance['real64Propa'] = [pywbem.Real64(weight), \ + pywbem.Real64(weight), \ + pywbem.Real64(weight)] + new_instance['sint16Prop'] = pywbem.Sint16(number) + new_instance['sint16Propa'] = [pywbem.Sint16(number), \ + pywbem.Sint16(number), \ + pywbem.Sint16(number)] + new_instance['sint32Prop'] = pywbem.Sint32(number) + new_instance['sint32Propa'] = [pywbem.Sint32(number), \ + pywbem.Sint32(number), \ + pywbem.Sint32(number)] + new_instance['sint64Prop'] = pywbem.Sint64(number) + new_instance['sint64Propa'] = [pywbem.Sint64(number), \ + pywbem.Sint64(number), \ + pywbem.Sint64(number)] + new_instance['sint8prop'] = pywbem.Sint8(number) + new_instance['sint8Propa'] = [pywbem.Sint8(number), \ + pywbem.Sint8(number), \ + pywbem.Sint8(number)] + new_instance['stringProp'] = name_of_atom + new_instance['stringPropa'] = ['proton', 'electron', 'neutron'] + new_instance['uint16Prop'] = pywbem.Uint16(number) + new_instance['uint16Propa'] = [pywbem.Uint16(number), \ + pywbem.Uint16(number), \ + pywbem.Uint16(number)] + new_instance['uint32Prop'] = pywbem.Uint32(number) + new_instance['uint32Propa'] = [pywbem.Uint32(number), \ + pywbem.Uint32(number), \ + pywbem.Uint32(number)] + new_instance['uint64Prop'] = pywbem.Uint64(number) + new_instance['uint64Propa'] = [pywbem.Uint64(number), \ + pywbem.Uint64(number), \ + pywbem.Uint64(number)] + new_instance['uint8Prop'] = pywbem.Uint64(number) + new_instance['uint8Propa'] = [pywbem.Uint64(number), \ + pywbem.Uint64(number), \ + pywbem.Uint64(number)] + + try: + cipath = self.conn.CreateInstance(new_instance) + new_instance.path = cipath + self.inst_paths.append(cipath) + + except pywbem.CIMError, arg: + return None, arg + + return new_instance, None + + + def test_2_create_instance(self): + """Test create""" + for atom_name, atomic_number in _atoms.items(): + rval, msg = self._create_test_instance(atom_name, atomic_number) + if not rval: + self.fail('%s: CreateInstance Failed.' % str(msg)) + continue + try: + ci = self.conn.GetInstance(rval.path) + except pywbem.CIMError,arg: + self.fail('GetInstance failed for instance just created') + continue + + _compare_values(self.conn, ci, self.time) + + + def test_3_enum_instances(self): + """Test enum_instances""" + insts = [] + for atom_name, atomic_number in _atoms.items(): + rval, msg = self._create_test_instance(atom_name, atomic_number) + if not rval: + self.fail('%s: CreateInstance Failed.' % str(msg)) + continue + try: + ci = self.conn.GetInstance(rval.path) + insts.append(ci) + except pywbem.CIMError,arg: + self.fail('GetInstance failed for instance just created') + continue + + try: + ta_list = self.conn.EnumerateInstances('Test_Atom') + except pywbem.CIMError, arg: + self.fail('EnumerateInstances Failed: %s' % str(arg)) + raise + + try: + paths = self.conn.EnumerateInstanceNames('Test_Atom') + except pywbem.CIMError, arg: + self.fail('EnumerateInstanceNames Failed: %s' % str(arg)) + + if len(paths) != len(ta_list): + self.fail('EnumerateInstances returned different number of ' + 'results than EnumerateInstanceNames') + + for ci in insts: + for rci in ta_list: + rci.path.host = None + if rci.path == ci.path: + _compare_values(self.conn, rci, self.time) + break + else: + self.fail('Did not get a created instance back from EnumerateInstance') + return + + + def test_4_enum_instance_names(self): + """Test enum_instance_names""" + insts = [] + for atom_name, atomic_number in _atoms.items(): + rval, msg = self._create_test_instance(atom_name, atomic_number) + if not rval: + self.fail('%s: CreateInstance Failed.' % str(msg)) + continue + try: + ci = self.conn.GetInstance(rval.path) + insts.append(ci) + except pywbem.CIMError,arg: + self.fail('GetInstance failed for instance just created') + continue + + try: + ta_list = self.conn.EnumerateInstanceNames('Test_Atom') + except pywbem.CIMError, arg: + self.fail('EnumerateInstanceNames Failed: %s' % str(arg)) + raise + + try: + instances = self.conn.EnumerateInstances('Test_Atom') + except pywbem.CIMError, arg: + self.fail('EnumerateInstances Failed: %s' % str(arg)) + + for ci in insts: + for path in ta_list: + path.host = None + if path == ci.path: + break + else: + self.fail('Did not get a created instance name back from EnumerateNames') + return + + + def test_5_get_instance_with_property_list(self): + """Test Get_Instance """ + rinst, msg = self._create_test_instance('Carbon', 6) + if not rinst: + self.fail('%s: CreateInstance Failed.' % str(msg)) + return + + propertylist = ['uint16Prop', 'dateProp', 'stringProp', 'real64Prop', \ + 'sint32Propa', 'sint32Prop'] + keybindings = {'Name': 'Carbon'} + try: + inst = get_instance(self.conn, keybindings, propertylist) + except pywbem.CIMError, arg: + raise arg + + for prop in inst.properties.keys(): + if prop not in propertylist: + #self.fail("Property Not Found in PropertyList: %s" % prop) + print "Property Not Found in PropertyList: %s" % prop + + + def test_6_modify_instance(self): + """Test modify instance""" + rinst, msg = self._create_test_instance('Boron', 5) + if not rinst: + self.fail('%s: CreateInstance Failed.' % str(msg)) + return + + propertylist = ['uint64Prop', 'dateProp', 'stringProp', 'real32Prop', \ + 'sint64Propa', 'sint64prop', 'boolProp'] + keybindings = {'Name': 'Boron'} + + mod_instance = get_instance(self.conn, keybindings, propertylist) + + weight = _atomic_weights['Boron'] + new_time = pywbem.CIMDateTime.now() + if mod_instance['boolProp']: + mod_instance['boolProp'] = False + else: + mod_instance['boolProp'] = True + mod_instance['uint64Prop'] = pywbem.Uint64(2) + mod_instance['dateProp'] = new_time + mod_instance['stringProp'] = "Helium" + mod_instance['real32Prop'] = pywbem.Real32(weight) + mod_instance['sint64Propa'] = pywbem.CIMProperty('sint64Propa', \ + value=[pywbem.Sint64(2), \ + pywbem.Sint64(2), pywbem.Sint64(2)]) + mod_instance['sint64prop'] = pywbem.Sint64(2) + mod_instance['Name'] = 'Boron' + + try: + self.conn.ModifyInstance(mod_instance) + except pywbem.CIMError, arg: + self.fail(arg) + + mod_instance = get_instance(self.conn, keybindings, propertylist) + for prop in mod_instance.properties.keys(): + if prop == 'uint64Prop' or prop == 'sint64Prop': + self.assertEqual(mod_instance[prop],2,"Values NOT EQUAL") + elif prop == "real32Prop": + self.assertTrue(math.fabs(mod_instance[prop] - weight) <\ + _tolerance,"Values NOT EQUAL") + elif prop == 'dateProp': + self.assertNotEquals(self.time,mod_instance[prop], \ + "Times ARE EQUAL") + elif prop == 'sint64Propa': + for val in mod_instance[prop]: + self.assertEquals(val, pywbem.Sint64(2), \ + ("Values NOT EQUAL: " + str(prop))) + elif prop == 'stringProp': + self.assertNotEquals(mod_instance[prop], 'Boron', \ + ("Values NOT EQUAL"+str(prop))) + elif prop == 'boolProp': + self.assertNotEqual(mod_instance['boolProp'], \ + (not mod_instance['boolProp']), \ + "ModifyInstance failed.") + + + def test_7_delete(self): + """Test delete instance""" + insts = [] + for atom_name, atomic_number in _atoms.items(): + rval, msg = self._create_test_instance(atom_name, atomic_number) + if not rval: + self.fail('%s: CreateInstance Failed.' % str(msg)) + continue + try: + ci = self.conn.GetInstance(rval.path) + insts.append(ci) + except pywbem.CIMError,arg: + self.fail('GetInstance failed for instance just created') + continue + + del_instances = get_instance_names(self.conn) + for inst in del_instances: + try: + self.conn.DeleteInstance(inst) + except pywbem.CIMError, arg: + self.fail('DeleteInstance Failed: %s' % str(arg)) + break + else: + for inst in del_instances: + try: + self.conn.DeleteInstance(inst) + except pywbem.CIMError, arg: + self.failUnlessEqual(arg[0], pywbem.CIM_ERR_NOT_FOUND, + 'Unexpected exception on delete: %s' % str(arg)) + +################################################################################ +#Return the TestAtomClass +def get_unit_test(): + return TestAtomProvider + +if __name__ == "__main__": + suite = unittest.makeSuite(TestAtomProvider) + unittest.TextTestRunner(verbosity=2).run(suite) Added: cmpi-bindings/trunk/test/python/TestMethod.mof =================================================================== --- cmpi-bindings/trunk/test/python/TestMethod.mof (rev 0) +++ cmpi-bindings/trunk/test/python/TestMethod.mof 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,264 @@ +[ Description("Class with several methods to test method provider capabilities.")] +class Test_Method +{ + [Key, Description("Unique identifier for this instance.")] + string id; + + string p_str; + sint32 p_sint32; + + sint8 genRand_sint8( + [in] sint8 min, + [in] sint8 max, + [in(false), out] boolean success + ); + sint16 genRand_sint16( + [in] sint16 min, + [in] sint16 max, + [in(false), out] boolean success + ); + sint32 genRand_sint32( + [in] sint32 min, + [in] sint32 max, + [in(false), out] boolean success + ); + sint64 genRand_sint64( + [in] sint64 min, + [in] sint64 max, + [in(false), out] boolean success + ); + uint8 genRand_uint8( + [in] uint8 min, + [in] uint8 max, + [in(false), out] boolean success + ); + uint16 genRand_uint16( + [in] uint16 min, + [in] uint16 max, + [in(false), out] boolean success + ); + uint32 genRand_uint32( + [in] uint32 min, + [in] uint32 max, + [in(false), out] boolean success + ); + uint64 genRand_uint64( + [in] uint64 min, + [in] uint64 max, + [in(false), out] boolean success + ); + real32 genRand_real32( + [in] real32 min, + [in] real32 max, + [in(false), out] boolean success + ); + real64 genRand_real64( + [in] real64 min, + [in] real64 max, + [in(false), out] boolean success + ); + + boolean genRandList_sint8( + [in, out, required] sint8 lo, + [in, out, required] sint8 hi, + [in, required] sint32 nelems, + [in(false), out] sint8 nlist[] + ); + boolean genRandList_sint16( + [in, out, required] sint16 lo, + [in, out, required] sint16 hi, + [in, required] sint32 nelems, + [in(false), out] sint16 nlist [] + ); + boolean genRandList_sint32( + [in, out, required] sint32 lo, + [in, out, required] sint32 hi, + [in, required] sint32 nelems, + [in(false), out] sint32 nlist [] + ); + boolean genRandList_sint64( + [in, out, required] sint64 lo, + [in, out, required] sint64 hi, + [in, required] sint32 nelems, + [in(false), out] sint64 nlist [] + ); + boolean genRandList_uint8( + [in, out, required] uint8 lo, + [in, out, required] uint8 hi, + [in, required] sint32 nelems, + [in(false), out] uint8 nlist [] + ); + boolean genRandList_uint16( + [in, out, required] uint16 lo, + [in, out, required] uint16 hi, + [in, required] sint32 nelems, + [in(false), out] uint16 nlist [] + ); + boolean genRandList_uint32( + [in, out, required] uint32 lo, + [in, out, required] uint32 hi, + [in, required] sint32 nelems, + [in(false), out] uint32 nlist [] + ); + boolean genRandList_uint64( + [in, out, required] uint64 lo, + [in, out, required] uint64 hi, + [in, required] sint32 nelems, + [in(false), out] uint64 nlist [] + ); + boolean genRandList_real32( + [in, out, required] real32 lo, + [in, out, required] real32 hi, + [in, required] sint32 nelems, + [in(false), out] real32 nlist [] + ); + boolean genRandList_real64( + [in, out, required] real64 lo, + [in, out, required] real64 hi, + [in, required] sint32 nelems, + [in(false), out] real64 nlist [] + ); + + boolean minmedmax_sint8( + [in, required] sint8 numlist[], + [in(false), out] sint8 min, + [in(false), out] sint8 max, + [in(false), out] sint8 med + ); + boolean minmedmax_sint16( + [in, required] sint16 numlist[], + [in(false), out] sint16 min, + [in(false), out] sint16 max, + [in(false), out] sint16 med + ); + boolean minmedmax_sint32( + [in, required] sint32 numlist[], + [in(false), out] sint32 min, + [in(false), out] sint32 max, + [in(false), out] sint32 med + ); + boolean minmedmax_sint64( + [in, required] sint64 numlist[], + [in(false), out] sint64 min, + [in(false), out] sint64 max, + [in(false), out] sint64 med + ); + boolean minmedmax_uint8( + [in, required] uint8 numlist[], + [in(false), out] uint8 min, + [in(false), out] uint8 max, + [in(false), out] uint8 med + ); + boolean minmedmax_uint16( + [in, required] uint16 numlist[], + [in(false), out] uint16 min, + [in(false), out] uint16 max, + [in(false), out] uint16 med + ); + boolean minmedmax_uint32( + [in, required] uint32 numlist[], + [in(false), out] uint32 min, + [in(false), out] uint32 max, + [in(false), out] uint32 med + ); + boolean minmedmax_uint64( + [in, required] uint64 numlist[], + [in(false), out] uint64 min, + [in(false), out] uint64 max, + [in(false), out] uint64 med + ); + boolean minmedmax_real32( + [in, required] real32 numlist[], + [in(false), out] real32 min, + [in(false), out] real32 max, + [in(false), out] real32 med + ); + boolean minmedmax_real64( + [in, required] real64 numlist[], + [in(false), out] real64 min, + [in(false), out] real64 max, + [in(false), out] real64 med + ); + + boolean strSplit( + [in, required] string str, + [in] string sep, + [in(false), out] sint32 nelems, + [in(false), out] string elems[] + ); + string strCat( + [in, required] string strs[], + [in] string sep + ); + + datetime getDate( + [in, required] string datestr + ); + boolean getDates( + [in, required] string datestrs[], + [in(false), out] sint32 nelems, + [in(false), out] datetime elems[] + ); + + char16 mkUniChar( + [in, required] sint8 c + ); + boolean mkUniCharArray( + [in, required] sint8 inArr[], + [in(false), out] char16 outArr[] + ); + string mkUniStr_sint8( + [in, required] sint8 cArr[] + ); + string mkUniStr_char16( + [in, required] char16 cArr[] + ); + + string getStrProp(); + + [ Description("Set the value of p_str. Return the previous value of " + "p_str.")] + string setStrProp( + [in, required] string value + ); + + sint32 getIntProp(); + + [ Description("Set the value of p_sint32. Return the previous value of " + "p_sint32.")] + sint32 setIntProp( + [in, required] sint32 value + ); + + [ Description("Return the instance name of any instance of Test_Method") ] + sint32 getObjectPath( + [in(false), out] Test_Method REF path + ); + + [ Description("Return instance names of all instances of Test_Method") ] + sint32 getObjectPaths( + [in(false), out] Test_Method REF paths[] + ); + + [ Description("Delete the specified instance of Test_Method") ] + sint32 delObject( + [in, required] Test_Method REF path + ); + + [ Description("Delete the specified instances of Test_Method") ] + sint32 delObjects( + [in, required] Test_Method REF paths[] + ); + + [ Description("Create the specified instance of Test_Method") ] + sint32 createObject( + [in, required, EmbeddedInstance("Test_Method")] string inst + ); + + [ Description("Create the specified instances of Test_Method") ] + sint32 createObjects( + [in, required, EmbeddedInstance("Test_Method")] string insts[] + ); + +}; + Added: cmpi-bindings/trunk/test/python/TestMethod.peg.reg =================================================================== --- cmpi-bindings/trunk/test/python/TestMethod.peg.reg (rev 0) +++ cmpi-bindings/trunk/test/python/TestMethod.peg.reg 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,28 @@ +//////// TestMethod +instance of PG_ProviderModule +{ + Name = "/usr/lib/pycim/TestMethod.py"; + InterfaceType = "Python"; + InterfaceVersion = "1.0.0"; + Location = "/usr/lib/pycim/TestMethod.py"; + Vendor = "OMC"; + Version = "0.1.0"; +}; + +instance of PG_Provider +{ + Name = "TestMethod"; + ProviderModuleName = "/usr/lib/pycim/TestMethod.py"; +}; + +instance of PG_ProviderCapabilities +{ + CapabilityID = "TestMethod"; + ProviderModuleName = "/usr/lib/pycim/TestMethod.py"; + ProviderName = "TestMethod"; + ClassName = "Test_Method"; + Namespaces = {"root/cimv2"}; + ProviderType = {2,5}; // Instance, Method +}; + + Added: cmpi-bindings/trunk/test/python/TestMethod.py =================================================================== --- cmpi-bindings/trunk/test/python/TestMethod.py (rev 0) +++ cmpi-bindings/trunk/test/python/TestMethod.py 2008-08-27 17:20:45 UTC (rev 883) @@ -0,0 +1,690 @@ +"""Python Provider for TestMethod + +Instruments the CIM class TestMethod + +""" + +import pywbem +import random + +g_insts = {} + +class TestMethodProvider(pywbem.CIMProvider): + """Instrument the CIM class TestMethod + + Class with several methods to test method provider capabilities. + + """ + + def __init__ (self, env): + logger = env.get_logger() + logger.log_debug('Initializing provider %s from %s' \ + % (self.__class__.__name__, __file__)) + # If you will be filtering instances yourself according to + # property_list, role, result_role, and result_class_name + # parameters, set self.filter_results to False + # self.filter_results = False + + def get_instance(self, env, model, cim_class): + logger = env.get_logger() + logger.log_debug('Entering %s.get_instance()' \ + % self.__class__.__name__) + + try: + inst = g_insts[model['id']] + except KeyError: + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND) + + model.update_existing(p_sint32=inst[1]) + model.update_existing(p_str=inst[0]) + return model + + def enum_instances(self, env, model, cim_class, keys_only): + logger = env.get_logger() + logger.log_debug('Entering %s.enum_instances()' \ + % self.__class__.__name__) + + for key in g_insts.keys(): + model['id'] = key + if keys_only: + ... [truncated message content] |