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: <ba...@us...> - 2008-10-08 17:46:40
|
Revision: 1078
http://omc.svn.sourceforge.net/omc/?rev=1078&view=rev
Author: bartw
Date: 2008-10-08 17:46:22 +0000 (Wed, 08 Oct 2008)
Log Message:
-----------
fixed typo
Modified Paths:
--------------
cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py
Modified: cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py
===================================================================
--- cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-10-07 15:30:48 UTC (rev 1077)
+++ cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-10-08 17:46:22 UTC (rev 1078)
@@ -53,7 +53,7 @@
desc = ex.get_description()
if code < 0 or code > 17:
- code = pywbem.CIM_ERR_ERR_FAILED
+ code = pywbem.CIM_ERR_FAILED
return pywbem.CIMError(code, desc)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kk...@us...> - 2008-10-07 15:31:37
|
Revision: 1077
http://omc.svn.sourceforge.net/omc/?rev=1077&view=rev
Author: kkaempf
Date: 2008-10-07 15:30:48 +0000 (Tue, 07 Oct 2008)
Log Message:
-----------
more progress on Perl
more cleanup
Modified Paths:
--------------
cmpi-bindings/trunk/src/cmpi_provider.c
cmpi-bindings/trunk/swig/cmpi.i
cmpi-bindings/trunk/swig/cmpi_defs.i
cmpi-bindings/trunk/swig/cmpi_types.i
cmpi-bindings/trunk/swig/perl/CMakeLists.txt
Added Paths:
-----------
cmpi-bindings/trunk/swig/perl/cmpi_plwbem_bindings.pl
cmpi-bindings/trunk/test/perl/
cmpi-bindings/trunk/test/perl/TestAtomProvider.peg.reg
cmpi-bindings/trunk/test/perl/TestAtomProvider.reg
cmpi-bindings/trunk/test/perl/TestAtomProvider.sfcb.reg
Modified: cmpi-bindings/trunk/src/cmpi_provider.c
===================================================================
--- cmpi-bindings/trunk/src/cmpi_provider.c 2008-10-06 17:17:46 UTC (rev 1076)
+++ cmpi-bindings/trunk/src/cmpi_provider.c 2008-10-07 15:30:48 UTC (rev 1077)
@@ -1137,7 +1137,3 @@
SWIG_CMPI_MI_FACTORY(Indication)
#undef _CMPI_SETFAIL
-#undef TARGET_THREAD_BEGIN_BLOCK
-#undef TARGET_THREAD_END_BLOCK
-#undef TARGET_THREAD_BEGIN_ALLOW
-#undef TARGET_THREAD_END_ALLOW
Modified: cmpi-bindings/trunk/swig/cmpi.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi.i 2008-10-06 17:17:46 UTC (rev 1076)
+++ cmpi-bindings/trunk/swig/cmpi.i 2008-10-07 15:30:48 UTC (rev 1077)
@@ -65,15 +65,24 @@
#define Target_SizedArray(len) rb_ary_new2(len)
#define Target_Append(x,y) rb_ary_push(x,y)
#define Target_DateTime(x) Qnil
-#define TARGET_THREAD_BEGIN_BLOCK
-#define TARGET_THREAD_END_BLOCK
-#define TARGET_THREAD_BEGIN_ALLOW
-#define TARGET_THREAD_END_ALLOW
+#define TARGET_THREAD_BEGIN_BLOCK do {} while(0)
+#define TARGET_THREAD_END_BLOCK do {} while(0)
+#define TARGET_THREAD_BEGIN_ALLOW do {} while(0)
+#define TARGET_THREAD_END_ALLOW do {} while(0)
#include <ruby.h>
#include <rubyio.h>
#endif
#if defined(SWIGPERL)
+#define TARGET_THREAD_BEGIN_BLOCK do {} while(0)
+#define TARGET_THREAD_END_BLOCK do {} while(0)
+#define TARGET_THREAD_BEGIN_ALLOW do {} while(0)
+#define TARGET_THREAD_END_ALLOW do {} while(0)
+
+SWIGINTERNINLINE SV *SWIG_From_long SWIG_PERL_DECL_ARGS_1(long value);
+SWIGINTERNINLINE SV *SWIG_FromCharPtr(const char *cptr);
+SWIGINTERNINLINE SV *SWIG_From_double SWIG_PERL_DECL_ARGS_1(double value);
+
#define Target_Null_p(x) (x == NULL)
#define Target_INCREF(x)
#define Target_DECREF(x)
@@ -82,19 +91,17 @@
#define Target_Null NULL
#define Target_Void NULL
#define Target_Type SV *
-#define Target_Bool(x) (x)
+#define Target_Bool(x) (x)?Target_True:Target_False
#define Target_WChar(x) NULL
-#define Target_Int(x) NULL /* should be Target_From_long(x), but Swig declares it too late. FIXME */
-#define Target_String(x) NULL /* Target_FromCharPtr(x), also */
-#define Target_Real(x) NULL
-#define Target_Array(x) NULL
-#define Target_SizedArray(len) NULL
-#define Target_Append(x,y) av_create_and_push(&x, y)
+#define Target_Int(x) SWIG_From_long(x)
+#define Target_String(x) SWIG_FromCharPtr(x)
+#define Target_Real(x) SWIG_From_double(x)
+#define Target_Array() (SV *)newAV()
+#define Target_SizedArray(len) (SV *)newAV()
+#define Target_Append(x,y) av_push(((AV *)(x)), y)
#define Target_DateTime(x) NULL
-#define TARGET_THREAD_BEGIN_BLOCK
-#define TARGET_THREAD_END_BLOCK
-#define TARGET_THREAD_BEGIN_ALLOW
-#define TARGET_THREAD_END_ALLOW
+#include <perl.h>
+#include <EXTERN.h>
#endif
Modified: cmpi-bindings/trunk/swig/cmpi_defs.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi_defs.i 2008-10-06 17:17:46 UTC (rev 1076)
+++ cmpi-bindings/trunk/swig/cmpi_defs.i 2008-10-07 15:30:48 UTC (rev 1077)
@@ -14,6 +14,10 @@
%ignore _CMPIStatus::rc;
%ignore _CMPIStatus::msg;
+#if defined(SWIGPERL)
+/* Warning(314): 'ref' is a perl keyword */
+%rename("reference") _CMPIValue::ref;
+#endif
%include "cmpidt.h"
#-----------------------------------------------------
Modified: cmpi-bindings/trunk/swig/cmpi_types.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi_types.i 2008-10-06 17:17:46 UTC (rev 1076)
+++ cmpi-bindings/trunk/swig/cmpi_types.i 2008-10-07 15:30:48 UTC (rev 1077)
@@ -455,33 +455,33 @@
#if defined (SWIGPYTHON)
PyObject*
#endif
+#if defined (SWIGPERL)
+ SV*
+#endif
get_key_at(int index) {
CMPIString *s = NULL;
CMPIStatus st = { CMPI_RC_OK, NULL };
CMPIData data = CMGetKeyAt($self, index, &s, &st);
-
-#if defined (SWIGRUBY)
- VALUE rbdata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 0);
- VALUE rl = rb_ary_new2(2);
- return rb_ary_push(rb_ary_push(rl, rbdata), rb_str_new2(CMGetCharPtr(s)));
-#endif
-#if defined (SWIGPYTHON)
-
+ Target_Type result = Target_Null;
if (st.rc)
{
RAISE_IF(st);
- return NULL;
+ return result;
}
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyObject* pydata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 1);
-
- 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;
+ TARGET_THREAD_BEGIN_BLOCK;
+ Target_Type tdata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 1);
+#if defined (SWIGPYTHON)
+ result = PyTuple_New(2);
+ PyTuple_SetItem(result, 0, tdata);
+ PyTuple_SetItem(result, 1, PyString_FromString(CMGetCharPtr(s)));
+#else
+ result = Target_SizedArray(2);
+ Target_Append(result, tdata);
+ Target_Append(result, Target_String(CMGetCharPtr(s)));
#endif
+ TARGET_THREAD_END_BLOCK;
+ return result;
}
/* Gets the number of key properties contained in this ObjectPath. */
@@ -788,34 +788,34 @@
#if defined (SWIGPYTHON)
PyObject*
#endif
+#if defined (SWIGPERL)
+ SV *
+#endif
get_property_at(int index)
{
CMPIString *s = NULL;
CMPIStatus st = { CMPI_RC_OK, NULL };
CMPIData data = CMGetPropertyAt($self, index, &s, &st);
-
-#if defined (SWIGRUBY)
- VALUE rbdata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 0);
- VALUE rl = rb_ary_new2(2);
- return rb_ary_push(rb_ary_push(rl, rbdata), rb_str_new2(CMGetCharPtr(s)));
-#endif
-#if defined (SWIGPYTHON)
-
+ Target_Type result = Target_Null;
if (st.rc)
{
RAISE_IF(st);
- return NULL;
+ return result;
}
+ Target_Type tdata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 1);
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyObject* pydata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 1);
-
- 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;
+ TARGET_THREAD_BEGIN_BLOCK;
+#if defined (SWIGPYTHON)
+ result = PyTuple_New(2);
+ PyTuple_SetItem(result, 0, tdata);
+ PyTuple_SetItem(result, 1, PyString_FromString(CMGetCharPtr(s)));
+#else
+ result = Target_SizedArray(2);
+ Target_Append(result, tdata);
+ Target_Append(result, Target_String(CMGetCharPtr(s)));
#endif
+ TARGET_THREAD_END_BLOCK;
+ return result;
}
/* Gets the number of properties contained in this Instance. */
@@ -927,35 +927,35 @@
#if defined (SWIGPYTHON)
PyObject*
#endif
+#if defined (SWIGPERL)
+ SV *
+#endif
get_arg_at(int index)
{
CMPIString *s = NULL;
CMPIStatus st = { CMPI_RC_OK, NULL };
CMPIData data = CMGetArgAt($self, index, &s, &st);
-#if defined (SWIGRUBY)
- VALUE rbdata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 0);
- VALUE rl = rb_ary_new2(2);
- return rb_ary_push(rb_ary_push(rl, rbdata), rb_str_new2(CMGetCharPtr(s)));
-#endif
-#if defined (SWIGPYTHON)
-
- RAISE_IF(st);
-
+ Target_Type result = Target_Null;
if (st.rc)
{
- return NULL;
+ RAISE_IF(st);
+ return result;
}
+ Target_Type tdata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 1);
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyObject* pydata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 1);
-
- 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;
+ TARGET_THREAD_BEGIN_BLOCK;
+#if defined (SWIGPYTHON)
+ result = PyTuple_New(2);
+ PyTuple_SetItem(result, 0, tdata);
+ PyTuple_SetItem(result, 1, PyString_FromString(CMGetCharPtr(s)));
+#else
+ result = Target_SizedArray(2);
+ Target_Append(result, tdata);
+ Target_Append(result, Target_String(CMGetCharPtr(s)));
#endif
+ TARGET_THREAD_END_BLOCK;
+ return result;
}
/* Gets the number of arguments contained in this Args. */
@@ -1033,7 +1033,10 @@
}
return l;
}
-
+#if defined(SWIGPERL)
+/* Warning(314): 'next' is a perl keyword */
+%rename("_next") next;
+#endif
CMPIData next()
{
CMPIStatus st = { CMPI_RC_OK, NULL };
@@ -1175,25 +1178,34 @@
#if defined (SWIGPYTHON)
PyObject*
#endif
+#if defined (SWIGPERL)
+ SV*
+#endif
get_entry_at(int index) {
CMPIString *s = NULL;
- CMPIData data = CMGetContextEntryAt($self, index, &s, NULL);
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIData data = CMGetContextEntryAt($self, index, &s, &st);
-#if defined (SWIGRUBY)
- VALUE rbdata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 0);
- VALUE rl = rb_ary_new2(2);
- return rb_ary_push(rb_ary_push(rl, rbdata), rb_str_new2(CMGetCharPtr(s)));
-#endif
+ Target_Type result = Target_Null;
+ if (st.rc)
+ {
+ RAISE_IF(st);
+ return result;
+ }
+ Target_Type tdata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 1);
+
+ TARGET_THREAD_BEGIN_BLOCK;
#if defined (SWIGPYTHON)
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyObject* pydata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 1);
-
- 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;
+ result = PyTuple_New(2);
+ PyTuple_SetItem(result, 0, tdata);
+ PyTuple_SetItem(result, 1, PyString_FromString(CMGetCharPtr(s)));
+#else
+ result = Target_SizedArray(2);
+ Target_Append(result, tdata);
+ Target_Append(result, Target_String(CMGetCharPtr(s)));
#endif
+ TARGET_THREAD_END_BLOCK;
+ return result;
}
CMPICount get_entry_count(void) {
Modified: cmpi-bindings/trunk/swig/perl/CMakeLists.txt
===================================================================
--- cmpi-bindings/trunk/swig/perl/CMakeLists.txt 2008-10-06 17:17:46 UTC (rev 1076)
+++ cmpi-bindings/trunk/swig/perl/CMakeLists.txt 2008-10-07 15:30:48 UTC (rev 1077)
@@ -12,6 +12,8 @@
MESSAGE(STATUS "Perl core dir: ${PERL_CORE_DIR}")
MESSAGE(STATUS "Perl vendor arch dir: ${PERL_VENDOR_ARCH}")
MESSAGE(STATUS "Perl vendor lib dir: ${PERL_VENDOR_LIB}")
+MESSAGE(STATUS "Perl cc flags: ${PERL_CCFLAGS}")
+MESSAGE(STATUS "Perl ccdl flags: ${PERL_LINK_FLAGS}")
SET( SWIG_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmpi_wrap.c" )
SET( SWIG_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/../cmpi.i" )
@@ -29,7 +31,7 @@
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../*.i
)
-SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" )
+SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC ${PERL_CCFLAGS}" )
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include/cmpi )
@@ -39,7 +41,7 @@
ADD_DEFINITIONS(-DCMPI_PLATFORM_LINUX_GENERIC_GNU -DCMPI_VERSION=200)
ADD_DEFINITIONS(-DTARGET_PERL)
-ADD_DEFINITIONS( ${PERL_CCFLAGS} -Wno-unused -Wno-error )
+ADD_DEFINITIONS( ${PERL_CCFLAGS} -Wno-unused -Wno-error -Wno-nonnull)
LINK_DIRECTORIES( ${PERL_CORE_DIR} )
#
@@ -48,7 +50,8 @@
SET( NAME plCmpiProvider )
ADD_LIBRARY( ${NAME} SHARED ${SWIG_OUTPUT})
-TARGET_LINK_LIBRARIES( ${NAME} ${PERL_LIBRARY} )
+TARGET_LINK_LIBRARIES( ${NAME} "perl" )
+SET_TARGET_PROPERTIES( ${NAME} PROPERTIES LINK_FLAGS ${PERL_LINK_FLAGS})
INSTALL(TARGETS ${NAME} LIBRARY DESTINATION ${CMPI_LIBRARY_DIR})
Added: cmpi-bindings/trunk/swig/perl/cmpi_plwbem_bindings.pl
===================================================================
--- cmpi-bindings/trunk/swig/perl/cmpi_plwbem_bindings.pl (rev 0)
+++ cmpi-bindings/trunk/swig/perl/cmpi_plwbem_bindings.pl 2008-10-07 15:30:48 UTC (rev 1077)
@@ -0,0 +1,5 @@
+#!/usr/bin/perl
+#
+# cmpi_plwbem_bindings.pl
+#
+use cmpi;
Added: cmpi-bindings/trunk/test/perl/TestAtomProvider.peg.reg
===================================================================
--- cmpi-bindings/trunk/test/perl/TestAtomProvider.peg.reg (rev 0)
+++ cmpi-bindings/trunk/test/perl/TestAtomProvider.peg.reg 2008-10-07 15:30:48 UTC (rev 1077)
@@ -0,0 +1,28 @@
+// Provider registration for TestAtom
+instance of PG_ProviderModule
+{
+ Name = "TestAtom_Module";
+ Location = "plCmpiProvider";
+ Vendor = "Novell";
+ Version = "1.0.0";
+ InterfaceType = "CMPI";
+ InterfaceVersion = "2.0.0";
+};
+
+instance of PG_Provider
+{
+ Name = "TestAtomProvider";
+ ProviderModuleName = "TestAtom_Module";
+};
+
+instance of PG_ProviderCapabilities
+{
+ ProviderModuleName = "TestAtom_Module";
+ ProviderName = "TestAtomProvider";
+ ClassName = "Test_Atom";
+ ProviderType = { 2 };
+ Namespaces = {"root/cimv2"};
+ SupportedProperties = NULL;
+ SupportedMethods = NULL;
+ CapabilityID = "TestAtom-Prov-1";
+};
Added: cmpi-bindings/trunk/test/perl/TestAtomProvider.reg
===================================================================
--- cmpi-bindings/trunk/test/perl/TestAtomProvider.reg (rev 0)
+++ cmpi-bindings/trunk/test/perl/TestAtomProvider.reg 2008-10-07 15:30:48 UTC (rev 1077)
@@ -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/plcim/TestAtomProvider.pl"; // TODO
+};
Added: cmpi-bindings/trunk/test/perl/TestAtomProvider.sfcb.reg
===================================================================
--- cmpi-bindings/trunk/test/perl/TestAtomProvider.sfcb.reg (rev 0)
+++ cmpi-bindings/trunk/test/perl/TestAtomProvider.sfcb.reg 2008-10-07 15:30:48 UTC (rev 1077)
@@ -0,0 +1,5 @@
+[Test_Atom]
+ provider: TestAtomProvider
+ location: plCmpiProvider
+ type: instance
+ namespace: root/cimv2
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2008-10-06 18:30:47
|
Revision: 1075
http://omc.svn.sourceforge.net/omc/?rev=1075&view=rev
Author: bartw
Date: 2008-10-06 17:06:55 +0000 (Mon, 06 Oct 2008)
Log Message:
-----------
logging enhancements
Modified Paths:
--------------
cmpi-bindings/trunk/swig/cmpi_callbacks.i
cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py
Modified: cmpi-bindings/trunk/swig/cmpi_callbacks.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi_callbacks.i 2008-10-06 17:05:07 UTC (rev 1074)
+++ cmpi-bindings/trunk/swig/cmpi_callbacks.i 2008-10-06 17:06:55 UTC (rev 1075)
@@ -14,7 +14,7 @@
const char *id,
const char *text)
{
- CMLogMessage($self, severity, id, text, NULL);
+ RAISE_IF(CMLogMessage($self, severity, id, text, NULL));
}
unsigned long capabilities()
Modified: cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py
===================================================================
--- cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-10-06 17:05:07 UTC (rev 1074)
+++ cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-10-06 17:06:55 UTC (rev 1075)
@@ -37,6 +37,7 @@
from pywbem.cim_provider2 import ProviderProxy
import pywbem
import types
+import syslog
##==============================================================================
##
@@ -357,25 +358,40 @@
def bummer(self):
self.broker.bummer()
+_log_pri_map = {
+ cmpi.CMPI_SEV_ERROR :syslog.LOG_ERR,
+ cmpi.CMPI_SEV_INFO :syslog.LOG_INFO,
+ cmpi.CMPI_SEV_WARNING :syslog.LOG_WARNING,
+ cmpi.CMPI_DEV_DEBUG :syslog.LOG_DEBUG,
+ }
+
class Logger(object):
- def __init__(self, broker):
+ def __init__(self, broker, miname):
#self.broker = ExceptionClassWrapper(broker)
self.broker = broker
+ self.miname = miname
+ def __log_message(self, severity, msg):
+ try:
+ self.broker.LogMessage(severity, self.miname, msg);
+ except cmpi.CMPIException, e:
+ if e.get_error_code() == cmpi.CMPI_RC_ERR_NOT_SUPPORTED:
+ syslog.syslog(syslog.LOG_DAEMON | _log_pri_map[severity],
+ '%s: %s' % (self.miname, msg))
def log_error(self, msg):
- self.broker.LogMessage(1, "ERROR", msg);
+ self.__log_message(cmpi.CMPI_SEV_ERROR, msg);
def log_info(self, msg):
- self.broker.LogMessage(2, "INFO", msg);
+ self.__log_message(cmpi.CMPI_SEV_INFO, msg);
def log_warn(self, msg):
- self.broker.LogMessage(3, "WARN", msg);
+ self.__log_message(cmpi.CMPI_SEV_WARNING, msg);
def log_debug(self, msg):
- self.broker.LogMessage(4, "DEBUG", msg);
+ self.__log_message(cmpi.CMPI_DEV_DEBUG, msg);
class ProviderEnvironment(object):
def __init__(self, proxy, ctx):
self.proxy = proxy
self.ctx = ContextWrap(proxy, ctx)
def get_logger(self):
- return Logger(self.proxy.broker)
+ return Logger(self.proxy.broker, self.proxy.miname)
def get_cimom_handle(self):
return BrokerCIMOMHandle(self.proxy, self.ctx.cmpicontext)
def get_user_name(self):
@@ -411,8 +427,6 @@
#print '*** broker.name()', broker.name()
#print '*** broker.capabilities()', broker.capabilities()
#print '*** broker.version()', broker.version()
- #broker.LogMessage(1, 'LogID',
- # '** This should go through broker.LogMessage()')
def enum_instance_names(self, ctx, rslt, objname):
print 'provider.py: In enum_instance_names()'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2008-10-06 17:18:47
|
Revision: 1076
http://omc.svn.sourceforge.net/omc/?rev=1076&view=rev
Author: bartw
Date: 2008-10-06 17:17:46 +0000 (Mon, 06 Oct 2008)
Log Message:
-----------
change namespace to root/suse
Modified Paths:
--------------
pyprofiles/powerManagement/trunk/OMC_PowerManagement.peg.reg
pyprofiles/powerManagement/trunk/OMC_PowerManagement.sfcb.reg
Modified: pyprofiles/powerManagement/trunk/OMC_PowerManagement.peg.reg
===================================================================
--- pyprofiles/powerManagement/trunk/OMC_PowerManagement.peg.reg 2008-10-06 17:06:55 UTC (rev 1075)
+++ pyprofiles/powerManagement/trunk/OMC_PowerManagement.peg.reg 2008-10-06 17:17:46 UTC (rev 1076)
@@ -20,7 +20,7 @@
ProviderModuleName = "pyCmpiProvider_OMC_PowerManagement";
ProviderName = "OMC_PowerManagementService";
ClassName = "OMC_PowerManagementService";
- Namespaces = {"root/cimv2"};
+ Namespaces = {"root/suse"};
ProviderType = {2,5}; // Instance, Method
};
@@ -35,7 +35,7 @@
ProviderModuleName = "pyCmpiProvider_OMC_PowerManagement";
ProviderName = "OMC_PowerManagementCapabilities";
ClassName = "OMC_PowerManagementCapabilities";
- Namespaces = {"root/cimv2"};
+ Namespaces = {"root/suse"};
ProviderType = {2,5}; // Instance, Method
};
@@ -50,7 +50,7 @@
ProviderModuleName = "pyCmpiProvider_OMC_PowerManagement";
ProviderName = "OMC_PowerManagementElementCapabilities";
ClassName = "OMC_PowerManagementElementCapabilities";
- Namespaces = {"root/cimv2"};
+ Namespaces = {"root/suse"};
ProviderType = {2,3}; // Instance, Associator
};
@@ -65,7 +65,7 @@
ProviderModuleName = "pyCmpiProvider_OMC_PowerManagement";
ProviderName = "OMC_HostedPowerManagementService";
ClassName = "OMC_HostedPowerManagementService";
- Namespaces = {"root/cimv2"};
+ Namespaces = {"root/suse"};
ProviderType = {2,3}; // Instance, Associator
};
@@ -80,7 +80,7 @@
ProviderModuleName = "pyCmpiProvider_OMC_PowerManagement";
ProviderName = "OMC_AssociatedPowerManagementService";
ClassName = "OMC_AssociatedPowerManagementService";
- Namespaces = {"root/cimv2"};
+ Namespaces = {"root/suse"};
ProviderType = {2,3}; // Instance, Associator
};
Modified: pyprofiles/powerManagement/trunk/OMC_PowerManagement.sfcb.reg
===================================================================
--- pyprofiles/powerManagement/trunk/OMC_PowerManagement.sfcb.reg 2008-10-06 17:06:55 UTC (rev 1075)
+++ pyprofiles/powerManagement/trunk/OMC_PowerManagement.sfcb.reg 2008-10-06 17:17:46 UTC (rev 1076)
@@ -2,29 +2,29 @@
provider: OMC_PowerManagementService
location: pyCmpiProvider
type: instance method
- namespace: root/cimv2
+ namespace: root/suse
[OMC_PowerManagementCapabilities]
provider: OMC_PowerManagementCapabilities
location: pyCmpiProvider
type: instance method
- namespace: root/cimv2
+ namespace: root/suse
[OMC_PowerManagementElementCapabilities]
provider: OMC_PowerManagementElementCapabilities
location: pyCmpiProvider
type: instance association
- namespace: root/cimv2
+ namespace: root/suse
[OMC_HostedPowerManagementService]
provider: OMC_HostedPowerManagementService
location: pyCmpiProvider
type: instance association
- namespace: root/cimv2
+ namespace: root/suse
[OMC_AssociatedPowerManagementService]
provider: OMC_AssociatedPowerManagementService
location: pyCmpiProvider
type: instance association
- namespace: root/cimv2
+ namespace: root/suse
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2008-10-06 17:09:29
|
Revision: 1074
http://omc.svn.sourceforge.net/omc/?rev=1074&view=rev
Author: bartw
Date: 2008-10-06 17:05:07 +0000 (Mon, 06 Oct 2008)
Log Message:
-----------
remove tabs
Modified Paths:
--------------
cmpi-bindings/trunk/swig/cmpi.i
Modified: cmpi-bindings/trunk/swig/cmpi.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi.i 2008-10-06 14:00:41 UTC (rev 1073)
+++ cmpi-bindings/trunk/swig/cmpi.i 2008-10-06 17:05:07 UTC (rev 1074)
@@ -9,7 +9,7 @@
*/
%}
-
+
%module cmpi
%feature("autodoc","1");
@@ -199,11 +199,11 @@
break;
case CMPI_charsptr: /* ((16+10)<<8) */
/* FIXME: unused ? */
- result = Target_Null;
+ result = Target_Null;
break;
default:
/* FIXME: raise ! */
- result = Target_Null;
+ result = Target_Null;
break;
}
Target_INCREF(result);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kk...@us...> - 2008-10-06 14:56:36
|
Revision: 1073
http://omc.svn.sourceforge.net/omc/?rev=1073&view=rev
Author: kkaempf
Date: 2008-10-06 14:00:41 +0000 (Mon, 06 Oct 2008)
Log Message:
-----------
- further Perl support: load & init Perl interpreter
Modified Paths:
--------------
cmpi-bindings/trunk/src/CMakeLists.txt
cmpi-bindings/trunk/src/cmpi_provider.c
cmpi-bindings/trunk/swig/cmpi_defs.i
cmpi-bindings/trunk/swig/perl/CMakeLists.txt
Added Paths:
-----------
cmpi-bindings/trunk/src/target_perl.c
Modified: cmpi-bindings/trunk/src/CMakeLists.txt
===================================================================
--- cmpi-bindings/trunk/src/CMakeLists.txt 2008-10-06 12:58:25 UTC (rev 1072)
+++ cmpi-bindings/trunk/src/CMakeLists.txt 2008-10-06 14:00:41 UTC (rev 1073)
@@ -16,17 +16,18 @@
#
# Ruby: build standalone module, just for testing
#
+IF (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
+ ADD_DEFINITIONS(-DTARGET_RUBY)
+ MESSAGE(STATUS "Ruby executable: ${RUBY_EXECUTABLE}")
+ MESSAGE(STATUS "Ruby vendor arch dir: ${RUBY_VENDORARCH_DIR}")
+ MESSAGE(STATUS "Ruby include path: ${RUBY_INCLUDE_PATH}")
-ADD_DEFINITIONS(-DTARGET_RUBY)
-MESSAGE(STATUS "Ruby executable: ${RUBY_EXECUTABLE}")
-MESSAGE(STATUS "Ruby vendor arch dir: ${RUBY_VENDORARCH_DIR}")
-MESSAGE(STATUS "Ruby include path: ${RUBY_INCLUDE_PATH}")
+ INCLUDE_DIRECTORIES( ${RUBY_INCLUDE_PATH} )
+ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include/cmpi )
-INCLUDE_DIRECTORIES( ${RUBY_INCLUDE_PATH} )
-INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include/cmpi )
-
-TARGET_LINK_LIBRARIES( cmpi_provider cmpi )
-TARGET_LINK_LIBRARIES( cmpi_provider ${RUBY_LIBRARY} )
+ TARGET_LINK_LIBRARIES( cmpi_provider cmpi )
+ TARGET_LINK_LIBRARIES( cmpi_provider ${RUBY_LIBRARY} )
+ENDIF (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
#
#
#
Modified: cmpi-bindings/trunk/src/cmpi_provider.c
===================================================================
--- cmpi-bindings/trunk/src/cmpi_provider.c 2008-10-06 12:58:25 UTC (rev 1072)
+++ cmpi-bindings/trunk/src/cmpi_provider.c 2008-10-06 14:00:41 UTC (rev 1073)
@@ -175,7 +175,11 @@
*
*/
+#if defined(SWIGPERL)
+static PerlInterpreter * _TARGET_INIT = 0; /* acts as a boolean - is target initialized? */
+#else
static int _TARGET_INIT = 0; /* acts as a boolean - is target initialized? */
+#endif
static int _MI_COUNT = 0; /* use count, number of MIs */
static pthread_mutex_t _CMPI_INIT_MUTEX = PTHREAD_MUTEX_INITIALIZER; /* mutex around _MI_COUNT */
static Target_Type _TARGET_MODULE = Target_Null; /* The target module (aka namespace) */
@@ -191,6 +195,10 @@
#include "target_ruby.c"
#endif
+#if defined(SWIGPERL)
+#include "target_perl.c"
+#endif
+
/*
* Cleanup
*
Added: cmpi-bindings/trunk/src/target_perl.c
===================================================================
--- cmpi-bindings/trunk/src/target_perl.c (rev 0)
+++ cmpi-bindings/trunk/src/target_perl.c 2008-10-06 14:00:41 UTC (rev 1073)
@@ -0,0 +1,129 @@
+/*
+ * target_perl.c
+ *
+ * Target language specific functions for cmpi_bindings
+ *
+ * Here: Perl
+ */
+
+/* load <RB_BINDINGS_FILE>.pl */
+#define PL_BINDINGS_FILE "cmpi_plwbem_bindings"
+
+/* expect 'module <PL_BINDINGS_MODULE>' inside */
+#define PL_BINDINGS_MODULE "Cmpi"
+
+
+/*
+ * get Perl exception trace -> CMPIString
+ *
+ */
+
+#define TB_ERROR(str) {tbstr = str; goto cleanup;}
+static CMPIString *
+get_exc_trace(const CMPIBroker* broker)
+{
+ return broker->eft->newString(broker, "Perl failed", NULL);
+}
+
+
+/*
+ * Global Perl initializer
+ * loads the Perl interpreter
+ * init threads
+ */
+
+static int
+PlGlobalInitialize(const CMPIBroker* broker, CMPIStatus* st)
+{
+ int error;
+ char *embedding[] = { "", "-e", "0" };
+
+ if (_TARGET_INIT)
+ {
+ return 0;
+ }
+
+ _SBLIM_TRACE(1,("<%d> Perl: Loading", getpid()));
+
+ _TARGET_INIT = perl_alloc();
+ perl_construct(_TARGET_INIT);
+ perl_parse(_TARGET_INIT, NULL, 3, embedding, NULL);
+ perl_run(_TARGET_INIT);
+
+ extern void SWIG_init(PerlInterpreter* my_perl, CV* cv);
+
+ SWIG_init(_TARGET_INIT, NULL);
+
+ /* load module */
+ perl_eval_pv("use cmpi", TRUE);
+
+ return 0;
+}
+
+
+/*---------------------------------------------------------------*/
+
+/*
+ * local (per MI) Perl initializer
+ * keeps track of reference count
+ */
+
+static int
+TargetInitialize(ProviderMIHandle* hdl, CMPIStatus* st)
+{
+ int error;
+
+ /* Set _CMPI_INIT, protected by _CMPI_INIT_MUTEX
+ * so we call ruby_finalize() only once.
+ */
+ if (pthread_mutex_lock(&_CMPI_INIT_MUTEX))
+ {
+ perror("Can't lock _CMPI_INIT_MUTEX");
+ abort();
+ }
+ error = PlGlobalInitialize(hdl->broker, st);
+ pthread_mutex_unlock(&_CMPI_INIT_MUTEX);
+ if (error != 0)
+ {
+ goto exit;
+ }
+
+ _SBLIM_TRACE(1,("<%d> TargetInitialize(Perl) called, miName '%s'", getpid(), hdl->miName));
+exit:
+ _SBLIM_TRACE(1,("Initialize() %s", (error == 0)? "succeeded":"failed"));
+ return error;
+}
+
+
+/*
+ * call_provider
+ *
+ */
+
+static int
+call_provider(ProviderMIHandle* hdl, CMPIStatus* st,
+ const char* opname, int nargs, ...)
+{
+ int i;
+ va_list vargs;
+
+
+ st->rc = CMPI_RC_OK;
+ return 0;
+}
+
+
+/*
+ * TargetCleanup
+ */
+
+static void
+TargetCleanup(void)
+{
+ _TARGET_MODULE = NULL;
+ perl_destruct(_TARGET_INIT);
+ perl_free(_TARGET_INIT);
+
+ return;
+}
+
Modified: cmpi-bindings/trunk/swig/cmpi_defs.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi_defs.i 2008-10-06 12:58:25 UTC (rev 1072)
+++ cmpi-bindings/trunk/swig/cmpi_defs.i 2008-10-06 14:00:41 UTC (rev 1073)
@@ -120,7 +120,7 @@
#if defined(SWIGPYTHON)
PyObject *
#endif
-#if defined(SWIGPERL5)
+#if defined(SWIGPERL)
SV *
#endif
_value()
Modified: cmpi-bindings/trunk/swig/perl/CMakeLists.txt
===================================================================
--- cmpi-bindings/trunk/swig/perl/CMakeLists.txt 2008-10-06 12:58:25 UTC (rev 1072)
+++ cmpi-bindings/trunk/swig/perl/CMakeLists.txt 2008-10-06 14:00:41 UTC (rev 1073)
@@ -23,7 +23,7 @@
ADD_CUSTOM_COMMAND (
OUTPUT ${SWIG_OUTPUT}
COMMAND ${CMAKE_COMMAND} -E echo_append "Creating wrapper code for Perl ..."
- COMMAND ${SWIG_EXECUTABLE} -perl -shadow -features autodoc -o ${SWIG_OUTPUT} -I${CMPI_INCLUDE_DIR} ${SWIG_INPUT}
+ COMMAND ${SWIG_EXECUTABLE} -perl5 -shadow -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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kk...@us...> - 2008-10-06 13:27:22
|
Revision: 1072
http://omc.svn.sourceforge.net/omc/?rev=1072&view=rev
Author: kkaempf
Date: 2008-10-06 12:58:25 +0000 (Mon, 06 Oct 2008)
Log Message:
-----------
- enable testing with CTest
- make subdir name consistent with swig/python/tests
Modified Paths:
--------------
cmpi-bindings/trunk/CMakeLists.txt
cmpi-bindings/trunk/swig/ruby/CMakeLists.txt
Added Paths:
-----------
cmpi-bindings/trunk/swig/ruby/tests/
cmpi-bindings/trunk/swig/ruby/tests/CMakeLists.txt
Removed Paths:
-------------
cmpi-bindings/trunk/swig/ruby/test/
Modified: cmpi-bindings/trunk/CMakeLists.txt
===================================================================
--- cmpi-bindings/trunk/CMakeLists.txt 2008-10-06 12:55:45 UTC (rev 1071)
+++ cmpi-bindings/trunk/CMakeLists.txt 2008-10-06 12:58:25 UTC (rev 1072)
@@ -5,6 +5,7 @@
cmake_minimum_required(VERSION 2.4)
+include(CTest)
enable_testing()
#
# cmake2.6: backward compatibility to cmake 2.4
Modified: cmpi-bindings/trunk/swig/ruby/CMakeLists.txt
===================================================================
--- cmpi-bindings/trunk/swig/ruby/CMakeLists.txt 2008-10-06 12:55:45 UTC (rev 1071)
+++ cmpi-bindings/trunk/swig/ruby/CMakeLists.txt 2008-10-06 12:58:25 UTC (rev 1072)
@@ -2,6 +2,9 @@
# CMakeLists.txt for cmpi-bindings/swig/ruby
#
+enable_testing()
+ADD_SUBDIRECTORY(tests)
+
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorarchdir']" OUTPUT_VARIABLE RUBY_ARCH_DIR)
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorlibdir']" OUTPUT_VARIABLE RUBY_LIB_DIR)
Property changes on: cmpi-bindings/trunk/swig/ruby/tests
___________________________________________________________________
Added: svn:mergeinfo
+
Added: cmpi-bindings/trunk/swig/ruby/tests/CMakeLists.txt
===================================================================
--- cmpi-bindings/trunk/swig/ruby/tests/CMakeLists.txt (rev 0)
+++ cmpi-bindings/trunk/swig/ruby/tests/CMakeLists.txt 2008-10-06 12:58:25 UTC (rev 1072)
@@ -0,0 +1,6 @@
+#
+# CMakeLists.txt for cmpi-bindings/swig/ruby/test
+#
+ENABLE_TESTING()
+ADD_TEST(bindings_ruby_loading ruby ${CMAKE_CURRENT_SOURCE_DIR}/loading.rb )
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kk...@us...> - 2008-10-06 12:57:21
|
Revision: 1071
http://omc.svn.sourceforge.net/omc/?rev=1071&view=rev
Author: kkaempf
Date: 2008-10-06 12:55:45 +0000 (Mon, 06 Oct 2008)
Log Message:
-----------
revive CMPIData accessors again
Modified Paths:
--------------
cmpi-bindings/trunk/swig/cmpi_defs.i
Modified: cmpi-bindings/trunk/swig/cmpi_defs.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi_defs.i 2008-10-03 16:30:08 UTC (rev 1070)
+++ cmpi-bindings/trunk/swig/cmpi_defs.i 2008-10-06 12:55:45 UTC (rev 1071)
@@ -4,9 +4,9 @@
#
%nodefault CMPIData;
-%ignore _CMPIData::type;
-%ignore _CMPIData::state;
-%ignore _CMPIData::value;
+#%ignore _CMPIData::type;
+#%ignore _CMPIData::state;
+#%ignore _CMPIData::value;
%rename(CMPIData) _CMPIData;
%nodefault CMPIStatus;
@@ -114,14 +114,6 @@
{
return CMIsArray((*($self)));
}
- int _type()
- {
- return $self->type;
- }
- int _state()
- {
- return $self->state;
- }
#if defined(SWIGRUBY)
VALUE
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2008-10-03 16:30:21
|
Revision: 1070
http://omc.svn.sourceforge.net/omc/?rev=1070&view=rev
Author: bartw
Date: 2008-10-03 16:30:08 +0000 (Fri, 03 Oct 2008)
Log Message:
-----------
code cleanup
Modified Paths:
--------------
cmpi-bindings/trunk/test/python/TestMethod.py
Modified: cmpi-bindings/trunk/test/python/TestMethod.py
===================================================================
--- cmpi-bindings/trunk/test/python/TestMethod.py 2008-10-03 16:26:48 UTC (rev 1069)
+++ cmpi-bindings/trunk/test/python/TestMethod.py 2008-10-03 16:30:08 UTC (rev 1070)
@@ -47,13 +47,11 @@
'''
ch = env.get_cimom_handle()
try:
- e = ch.EnumerateInstanceNames("root/cimv2", "TestAssoc_Userx")
+ e = ch.EnumerateInstanceNames("root/cimv2", "TestAssoc_User")
for i in e:
print i
except pywbem.CIMError, e:
- print "ABCDEFG"
print e
- print "HIJKLMNOP"
'''
'''
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2008-10-03 16:27:02
|
Revision: 1069
http://omc.svn.sourceforge.net/omc/?rev=1069&view=rev
Author: bartw
Date: 2008-10-03 16:26:48 +0000 (Fri, 03 Oct 2008)
Log Message:
-----------
fixed bug in python code
Modified Paths:
--------------
cmpi-bindings/trunk/swig/cmpi_types.i
Modified: cmpi-bindings/trunk/swig/cmpi_types.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi_types.i 2008-10-03 12:33:03 UTC (rev 1068)
+++ cmpi-bindings/trunk/swig/cmpi_types.i 2008-10-03 16:26:48 UTC (rev 1069)
@@ -518,12 +518,11 @@
#if defined(SWIGPYTHON)
%pythoncode %{
def keys(self):
- r = range(0,self.key_count())
- while r:
- yield self.get_key_at(r.pop(0))
+ for i in xrange(0, self.key_count()):
+ yield self.get_key_at(i)
%}
#endif
-
+
/* Set/replace namespace and classname components from <src>. */
void replace_from(const CMPIObjectPath * src)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kk...@us...> - 2008-10-03 12:33:06
|
Revision: 1068
http://omc.svn.sourceforge.net/omc/?rev=1068&view=rev
Author: kkaempf
Date: 2008-10-03 12:33:03 +0000 (Fri, 03 Oct 2008)
Log Message:
-----------
major improvements in CMPIData bindings
(overloading its struct elements is still a hassle, maybe we should
move CMPIData out of cmpi_defs.h in our local copy ?!)
Modified Paths:
--------------
cmpi-bindings/trunk/swig/cmpi.i
cmpi-bindings/trunk/swig/cmpi_defs.i
cmpi-bindings/trunk/swig/cmpi_types.i
Modified: cmpi-bindings/trunk/swig/cmpi.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi.i 2008-10-03 12:31:35 UTC (rev 1067)
+++ cmpi-bindings/trunk/swig/cmpi.i 2008-10-03 12:33:03 UTC (rev 1068)
@@ -32,10 +32,14 @@
#define Target_Void Py_None
#define Target_Type PyObject*
#define Target_Bool(x) PyBool_FromLong(x)
+#define Target_WChar(x) PyInt_FromLong(x)
#define Target_Int(x) PyInt_FromLong(x)
#define Target_String(x) PyString_FromString(x)
+#define Target_Real(x) Py_None
#define Target_Array() PyList_New(0)
+#define Target_SizedArray(len) PyList_New(len)
#define Target_Append(x,y) PyList_Append(x,y)
+#define Target_DateTime(x) Py_None
#include <Python.h>
#define TARGET_THREAD_BEGIN_BLOCK SWIG_PYTHON_THREAD_BEGIN_BLOCK
#define TARGET_THREAD_END_BLOCK SWIG_PYTHON_THREAD_END_BLOCK
@@ -53,10 +57,14 @@
#define Target_Void Qnil
#define Target_Type VALUE
#define Target_Bool(x) ((x)?Qtrue:Qfalse)
+#define Target_WChar(x) INT2FIX(x)
#define Target_Int(x) INT2FIX(x)
#define Target_String(x) rb_str_new2(x)
+#define Target_Real(x) rb_float_new(x)
#define Target_Array() rb_ary_new()
+#define Target_SizedArray(len) rb_ary_new2(len)
#define Target_Append(x,y) rb_ary_push(x,y)
+#define Target_DateTime(x) Qnil
#define TARGET_THREAD_BEGIN_BLOCK
#define TARGET_THREAD_END_BLOCK
#define TARGET_THREAD_BEGIN_ALLOW
@@ -75,10 +83,14 @@
#define Target_Void NULL
#define Target_Type SV *
#define Target_Bool(x) (x)
+#define Target_WChar(x) NULL
#define Target_Int(x) NULL /* should be Target_From_long(x), but Swig declares it too late. FIXME */
#define Target_String(x) NULL /* Target_FromCharPtr(x), also */
+#define Target_Real(x) NULL
#define Target_Array(x) NULL
+#define Target_SizedArray(len) NULL
#define Target_Append(x,y) av_create_and_push(&x, y)
+#define Target_DateTime(x) NULL
#define TARGET_THREAD_BEGIN_BLOCK
#define TARGET_THREAD_END_BLOCK
#define TARGET_THREAD_BEGIN_ALLOW
@@ -99,8 +111,113 @@
#include <pthread.h>
+/*
+ * value_value
+ * convert CMPIValue to target value
+ * Attn: CMPIValue must be of non-array type !
+ */
+
+static Target_Type
+value_value(const CMPIValue *value, const CMPIType type)
+{
+ Target_Type result;
+ switch (type)
+ {
+ case CMPI_null:
+ result = Target_Null;
+ break;
+
+ case CMPI_boolean: /* (2+0) */
+ result = Target_Bool(value->boolean);
+ break;
+ case CMPI_char16: /* (2+1) */
+ result = Target_WChar(value->char16);
+ break;
+
+ case CMPI_real32: /* ((2+0)<<2) */
+ result = Target_Real(value->real32);
+ break;
+ case CMPI_real64: /* ((2+1)<<2) */
+ result = Target_Real(value->real64);
+ break;
+
+ case CMPI_uint8: /* ((8+0)<<4) */
+ result = Target_Int(value->uint8);
+ break;
+ case CMPI_uint16: /* ((8+1)<<4) */
+ result = Target_Int(value->uint16);
+ break;
+ case CMPI_uint32: /* ((8+2)<<4) */
+ result = Target_Int(value->uint32);
+ break;
+ case CMPI_uint64: /* ((8+3)<<4) */
+ result = Target_Int(value->uint64);
+ break;
+
+ case CMPI_sint8: /* ((8+4)<<4) */
+ result = Target_Int(value->sint8);
+ break;
+ case CMPI_sint16: /* ((8+5)<<4) */
+ result = Target_Int(value->sint16);
+ break;
+ case CMPI_sint32: /* ((8+6)<<4) */
+ result = Target_Int(value->sint32);
+ break;
+ case CMPI_sint64: /* ((8+7)<<4) */
+ result = Target_Int(value->sint64);
+ break;
+
+ case CMPI_instance: /* ((16+0)<<8) */
+ return SWIG_NewPointerObj((void*) (value->inst), SWIGTYPE_p__CMPIInstance, 1);
+ break;
+ case CMPI_ref: /* ((16+1)<<8) */
+ return SWIG_NewPointerObj((void*) (value->ref), SWIGTYPE_p__CMPIObjectPath, 1);
+ break;
+ case CMPI_args: /* ((16+2)<<8) */
+ return SWIG_NewPointerObj((void*) (value->args), SWIGTYPE_p__CMPIArgs, 1);
+ break;
+ case CMPI_class: /* ((16+3)<<8) */
+ return SWIG_NewPointerObj((void*) (value->inst), SWIGTYPE_p__CMPIInstance, 1);
+ break;
+ case CMPI_filter: /* ((16+4)<<8) */
+ return SWIG_NewPointerObj((void*) (value->filter), SWIGTYPE_p__CMPISelectExp, 1);
+ break;
+ case CMPI_enumeration: /* ((16+5)<<8) */
+ return SWIG_NewPointerObj((void*) (value->Enum), SWIGTYPE_p__CMPIEnumeration, 1);
+ break;
+ case CMPI_string: /* ((16+6)<<8) */
+ result = Target_String(CMGetCharPtr(value->string));
+ break;
+ case CMPI_chars: /* ((16+7)<<8) */
+ result = Target_String(value->chars);
+ break;
+ case CMPI_dateTime: /* ((16+8)<<8) */
+ result = Target_DateTime(value->dateTime);
+ break;
+ case CMPI_ptr: /* ((16+9)<<8) */
+ return SWIG_NewPointerObj((void*) &(value->dataPtr), SWIGTYPE_p__CMPIValuePtr, 1);
+ break;
+ case CMPI_charsptr: /* ((16+10)<<8) */
+ /* FIXME: unused ? */
+ result = Target_Null;
+ break;
+ default:
+ /* FIXME: raise ! */
+ result = Target_Null;
+ break;
+ }
+ Target_INCREF(result);
+ return result;
+}
+
+
+/*
+ * data_clone
+ * clone CMPIData
+ */
+
static CMPIData *
-clone_data(const CMPIData *dp)
+data_clone(const CMPIData *dp)
{
CMPIData *data = (CMPIData *)calloc(1, sizeof(CMPIData));
memcpy(data, dp, sizeof(CMPIData));
@@ -109,6 +226,36 @@
/*
+ * data_value
+ * Convert CMPIValue to target type
+ */
+
+static Target_Type
+data_value(const CMPIData *dp)
+{
+ Target_Type result = Target_Null;
+
+ if ((dp->type) & CMPI_ARRAY)
+ {
+ int size = CMGetArrayCount(dp->value.array, NULL);
+ int i;
+ result = Target_SizedArray(size);
+ for (i = 0; i < size; --i)
+ {
+ CMPIData data = CMGetArrayElementAt(dp->value.array, i, NULL);
+ Target_Append(result, value_value(&(data.value), (dp->type) & ~CMPI_ARRAY));
+ }
+ Target_INCREF(result);
+ }
+ else
+ {
+ result = value_value(&(dp->value), dp->type);
+ }
+
+ return result;
+}
+
+/*
**==============================================================================
**
** struct _CMPIException
Modified: cmpi-bindings/trunk/swig/cmpi_defs.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi_defs.i 2008-10-03 12:31:35 UTC (rev 1067)
+++ cmpi-bindings/trunk/swig/cmpi_defs.i 2008-10-03 12:33:03 UTC (rev 1068)
@@ -4,9 +4,9 @@
#
%nodefault CMPIData;
-#%ignore _CMPIData::type;
-#%ignore _CMPIData::state;
-#%ignore _CMPIData::value;
+%ignore _CMPIData::type;
+%ignore _CMPIData::state;
+%ignore _CMPIData::value;
%rename(CMPIData) _CMPIData;
%nodefault CMPIStatus;
@@ -75,15 +75,66 @@
#
%extend CMPIData {
- CMPIData()
+ CMPIData(CMPIData *data)
{
- CMPIData *data = (CMPIData *)calloc(1, sizeof(CMPIData));
- return data;
+ return data_clone(data);
}
~CMPIData()
{
- free( $self );
+ free($self);
}
+
+#ifdef SWIGRUBY
+ VALUE to_s()
+ {
+ Target_Type value = data_value($self);
+ return rb_funcall(value, rb_intern("to_s"), 0);
+ }
+#endif
+
+#if defined(SWIGRUBY)
+ %rename("null?") is_null;
+#endif
+
+ int is_null()
+ {
+ return CMIsNullValue((*($self)));
+ }
+#if defined(SWIGRUBY)
+ %rename("key?") is_key;
+#endif
+ int is_key()
+ {
+ return CMIsKeyValue((*($self)));
+ }
+#if defined(SWIGRUBY)
+ %rename("array?") is_array;
+#endif
+ int is_array()
+ {
+ return CMIsArray((*($self)));
+ }
+ int _type()
+ {
+ return $self->type;
+ }
+ int _state()
+ {
+ return $self->state;
+ }
+#if defined(SWIGRUBY)
+ VALUE
+#endif
+#if defined(SWIGPYTHON)
+ PyObject *
+#endif
+#if defined(SWIGPERL5)
+ SV *
+#endif
+ _value()
+ {
+ return data_value($self);
+ }
}
@@ -114,4 +165,3 @@
return CMGetCharPtr(s);
}
}
-
Modified: cmpi-bindings/trunk/swig/cmpi_types.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi_types.i 2008-10-03 12:31:35 UTC (rev 1067)
+++ cmpi-bindings/trunk/swig/cmpi_types.i 2008-10-03 12:33:03 UTC (rev 1068)
@@ -461,7 +461,7 @@
CMPIData data = CMGetKeyAt($self, index, &s, &st);
#if defined (SWIGRUBY)
- VALUE rbdata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 0);
+ VALUE rbdata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 0);
VALUE rl = rb_ary_new2(2);
return rb_ary_push(rb_ary_push(rl, rbdata), rb_str_new2(CMGetCharPtr(s)));
#endif
@@ -474,7 +474,7 @@
}
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 1);
+ PyObject* pydata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 1);
PyObject* pl = PyTuple_New(2);
PyTuple_SetItem(pl, 0, pydata);
@@ -495,7 +495,35 @@
return result;
}
-
+ /* iterate over keys as [<value>,<name>] pairs */
+#if defined(SWIGRUBY)
+ void keys()
+ {
+ int i;
+ int count = CMGetKeyCount($self, NULL);
+ CMPIString *name;
+ for (i = 0; i < count; ++i )
+ {
+ VALUE yield = rb_ary_new2(2);
+ name = NULL;
+ CMPIData data = CMGetKeyAt($self, i, &name, NULL);
+ VALUE rbdata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 1);
+ rb_ary_push(yield, rbdata);
+ rb_ary_push(yield, rb_str_new2(CMGetCharPtr(name)));
+
+ rb_yield(yield);
+ }
+ }
+#endif
+#if defined(SWIGPYTHON)
+ %pythoncode %{
+ def keys(self):
+ r = range(0,self.key_count())
+ while r:
+ yield self.get_key_at(r.pop(0))
+ %}
+#endif
+
/* Set/replace namespace and classname components from <src>. */
void replace_from(const CMPIObjectPath * src)
{
@@ -768,7 +796,7 @@
CMPIData data = CMGetPropertyAt($self, index, &s, &st);
#if defined (SWIGRUBY)
- VALUE rbdata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 0);
+ VALUE rbdata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 0);
VALUE rl = rb_ary_new2(2);
return rb_ary_push(rb_ary_push(rl, rbdata), rb_str_new2(CMGetCharPtr(s)));
#endif
@@ -781,7 +809,7 @@
}
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 1);
+ PyObject* pydata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 1);
PyObject* pl = PyTuple_New(2);
PyTuple_SetItem(pl, 0, pydata);
@@ -907,7 +935,7 @@
CMPIData data = CMGetArgAt($self, index, &s, &st);
#if defined (SWIGRUBY)
- VALUE rbdata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 0);
+ VALUE rbdata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 0);
VALUE rl = rb_ary_new2(2);
return rb_ary_push(rb_ary_push(rl, rbdata), rb_str_new2(CMGetCharPtr(s)));
#endif
@@ -921,7 +949,7 @@
}
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 1);
+ PyObject* pydata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 1);
PyObject* pl = PyTuple_New(2);
PyTuple_SetItem(pl, 0, pydata);
@@ -1153,13 +1181,13 @@
CMPIData data = CMGetContextEntryAt($self, index, &s, NULL);
#if defined (SWIGRUBY)
- VALUE rbdata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 0);
+ VALUE rbdata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 0);
VALUE rl = rb_ary_new2(2);
return rb_ary_push(rb_ary_push(rl, rbdata), rb_str_new2(CMGetCharPtr(s)));
#endif
#if defined (SWIGPYTHON)
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 1);
+ PyObject* pydata = SWIG_NewPointerObj((void*) data_clone(&data), SWIGTYPE_p__CMPIData, 1);
PyObject* pl = PyTuple_New(2);
PyTuple_SetItem(pl, 0, pydata);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kk...@us...> - 2008-10-03 12:31:41
|
Revision: 1067
http://omc.svn.sourceforge.net/omc/?rev=1067&view=rev
Author: kkaempf
Date: 2008-10-03 12:31:35 +0000 (Fri, 03 Oct 2008)
Log Message:
-----------
small increments in Ruby instrumentation
Modified Paths:
--------------
cmpi-bindings/trunk/test/ruby/test_atom_provider.rb
Added Paths:
-----------
cmpi-bindings/trunk/test/ruby/Test_Atom.rb
Added: cmpi-bindings/trunk/test/ruby/Test_Atom.rb
===================================================================
--- cmpi-bindings/trunk/test/ruby/Test_Atom.rb (rev 0)
+++ cmpi-bindings/trunk/test/ruby/Test_Atom.rb 2008-10-03 12:31:35 UTC (rev 1067)
@@ -0,0 +1,44 @@
+# Model an atom, For use with CIMOM and Ruby provider
+#
+# 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
+#
+
+class Test_Atom
+ attr_accessor :uint8Prop, :uint8Propa, :sint8prop, :sint8propa
+ attr_accessor :uint16Prop, :uint16Propa, :sint16prop, :sint16propa
+ attr_accessor :uint32Prop, :uint32Propa, :sint32prop, :sint32propa
+ attr_accessor :uint64Prop, :uint64Propa, :sint64prop, :sint64propa
+ attr_accessor :stringProp, :stringPropa
+ attr_accessor :real32Prop, :real32Propa, :real64Prop, :real64Propa
+ attr_accessor :dateProp, :boolProp
+
+ def initialize name
+ @uint8Prop = @sint8prop = @uint16Prop = @sint16prop = 0
+ @uint8Propa = @sint8propa = @uint16Propa = @sint16propa = []
+ @uint32Prop = @sint32prop = @uint64Prop = @sint64prop = 0
+ @uint32Propa = @sint32propa = @uint64Propa = @sint64propa = []
+ @stringProp = ""
+ @stringPropa = []
+ @real32prop = @real64prop = 0.0
+ @real32propa = @real64Propa = []
+ @dateProb = Time.new
+ @boolProb = false
+ @name = name
+ end
+
+end
Modified: cmpi-bindings/trunk/test/ruby/test_atom_provider.rb
===================================================================
--- cmpi-bindings/trunk/test/ruby/test_atom_provider.rb 2008-10-03 12:30:25 UTC (rev 1066)
+++ cmpi-bindings/trunk/test/ruby/test_atom_provider.rb 2008-10-03 12:31:35 UTC (rev 1067)
@@ -5,7 +5,7 @@
#
module Cmpi
-
+
STDERR.puts "This is test_atom_provider.rb"
# Instrument the CIM class TestAtom
#
@@ -13,14 +13,22 @@
#
class TestAtomProvider < InstanceProvider
- # create new instance -> check with .mof file
+ require 'Test_Atom'
+
+ # create new provider instance -> check with .mof file
def initialize broker
+ @instances = {}
super
end
# use i.e. 'include MethodProviderIF' to implement multiple MIs
def create_instance context, result, reference, newinst
STDERR.puts "TestAtomProvider.create_instance: #{reference}"
+ STDERR.puts "TestAtomProvider.create_instance: #{reference.key_count} keys"
+ reference.keys do |value,name|
+ STDERR.puts "Key #{name} = #{value}"
+ end
+ @instances[reference.to_s] = Test_Atom.new reference.get_key_at(0)[0]._value
result.return_objectpath reference
result.done
end
@@ -30,10 +38,14 @@
plist = plist.join(',') if plist.respond_to? :join
STDERR.puts "TestAtomProvider.get_instance: #{objname}: #{plist}"
+ instance = @instances[objname]
+ result.return_instance instance if instance
+ result.done
end
def delete_instance context, result, objname
STDERR.puts "TestAtomProvider.delete_instance: #{objname}"
+ @instances.delete objname
end
end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kk...@us...> - 2008-10-03 12:30:37
|
Revision: 1066
http://omc.svn.sourceforge.net/omc/?rev=1066&view=rev
Author: kkaempf
Date: 2008-10-03 12:30:25 +0000 (Fri, 03 Oct 2008)
Log Message:
-----------
define SWIG_init() per target, keeps gcc happy
Modified Paths:
--------------
cmpi-bindings/trunk/src/cmpi_provider.c
cmpi-bindings/trunk/src/target_python.c
cmpi-bindings/trunk/src/target_ruby.c
Modified: cmpi-bindings/trunk/src/cmpi_provider.c
===================================================================
--- cmpi-bindings/trunk/src/cmpi_provider.c 2008-10-03 00:29:33 UTC (rev 1065)
+++ cmpi-bindings/trunk/src/cmpi_provider.c 2008-10-03 12:30:25 UTC (rev 1066)
@@ -59,11 +59,6 @@
}
#endif
-
-#if 0
-SWIGEXPORT void SWIG_init(void);
-#endif
-
#define _CMPI_SETFAIL(msgstr) {if (st != NULL) st->rc = CMPI_RC_ERR_FAILED; st->msg = msgstr; }
/*
Modified: cmpi-bindings/trunk/src/target_python.c
===================================================================
--- cmpi-bindings/trunk/src/target_python.c 2008-10-03 00:29:33 UTC (rev 1065)
+++ cmpi-bindings/trunk/src/target_python.c 2008-10-03 12:30:25 UTC (rev 1066)
@@ -138,6 +138,7 @@
Py_SetProgramName("cmpi_swig");
Py_Initialize();
+ SWIGEXPORT void SWIG_init(void);
SWIG_init();
cmpiMainPyThreadState = PyGILState_GetThisThreadState();
PyEval_ReleaseThread(cmpiMainPyThreadState);
Modified: cmpi-bindings/trunk/src/target_ruby.c
===================================================================
--- cmpi-bindings/trunk/src/target_ruby.c 2008-10-03 00:29:33 UTC (rev 1065)
+++ cmpi-bindings/trunk/src/target_ruby.c 2008-10-03 12:30:25 UTC (rev 1066)
@@ -105,6 +105,7 @@
ruby_init();
ruby_init_loadpath();
ruby_script("cmpi_swig_ruby");
+ extern void SWIG_init();
SWIG_init();
/* load module */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mik...@us...> - 2008-10-03 00:29:43
|
Revision: 1065
http://omc.svn.sourceforge.net/omc/?rev=1065&view=rev
Author: mike-brasher
Date: 2008-10-03 00:29:33 +0000 (Fri, 03 Oct 2008)
Log Message:
-----------
Works towards logging.
Modified Paths:
--------------
cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py
cmpi-bindings/trunk/test/python/TestMethod.py
Modified: cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py
===================================================================
--- cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-10-02 18:45:12 UTC (rev 1064)
+++ cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-10-03 00:29:33 UTC (rev 1065)
@@ -359,17 +359,17 @@
class Logger(object):
def __init__(self, broker):
+ #self.broker = ExceptionClassWrapper(broker)
self.broker = broker
+ def log_error(self, msg):
+ self.broker.LogMessage(1, "ERROR", msg);
+ def log_info(self, msg):
+ self.broker.LogMessage(2, "INFO", msg);
+ def log_warn(self, msg):
+ self.broker.LogMessage(3, "WARN", msg);
def log_debug(self, msg):
- print msg
- def log_info(self, msg):
- pass
- def log_error(self, msg):
- pass
- def log_fatal(self, msg):
- pass
+ self.broker.LogMessage(4, "DEBUG", msg);
-
class ProviderEnvironment(object):
def __init__(self, proxy, ctx):
self.proxy = proxy
Modified: cmpi-bindings/trunk/test/python/TestMethod.py
===================================================================
--- cmpi-bindings/trunk/test/python/TestMethod.py 2008-10-02 18:45:12 UTC (rev 1064)
+++ cmpi-bindings/trunk/test/python/TestMethod.py 2008-10-03 00:29:33 UTC (rev 1065)
@@ -44,7 +44,7 @@
logger.log_debug('Entering %s.enum_instances()' \
% self.__class__.__name__)
- #'''
+ '''
ch = env.get_cimom_handle()
try:
e = ch.EnumerateInstanceNames("root/cimv2", "TestAssoc_Userx")
@@ -54,7 +54,7 @@
print "ABCDEFG"
print e
print "HIJKLMNOP"
- #'''
+ '''
'''
ch = env.get_cimom_handle()
@@ -65,7 +65,11 @@
print e
'''
+ l = env.get_logger()
+ l.log_debug("hello");
+ #except CIMError, e:
+
for key in g_insts.keys():
model['id'] = key
model.path['id'] = key
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mik...@us...> - 2008-10-02 18:45:44
|
Revision: 1064
http://omc.svn.sourceforge.net/omc/?rev=1064&view=rev
Author: mike-brasher
Date: 2008-10-02 18:45:12 +0000 (Thu, 02 Oct 2008)
Log Message:
-----------
Put master catch and convert (CIMExcpption/CIMErorr) around provider proxy.
Modified Paths:
--------------
cmpi-bindings/trunk/src/cmpi_provider.c
cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py
Modified: cmpi-bindings/trunk/src/cmpi_provider.c
===================================================================
--- cmpi-bindings/trunk/src/cmpi_provider.c 2008-10-02 14:00:50 UTC (rev 1063)
+++ cmpi-bindings/trunk/src/cmpi_provider.c 2008-10-02 18:45:12 UTC (rev 1064)
@@ -60,7 +60,10 @@
#endif
+#if 0
SWIGEXPORT void SWIG_init(void);
+#endif
+
#define _CMPI_SETFAIL(msgstr) {if (st != NULL) st->rc = CMPI_RC_ERR_FAILED; st->msg = msgstr; }
/*
Modified: cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py
===================================================================
--- cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-10-02 14:00:50 UTC (rev 1063)
+++ cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2008-10-02 18:45:12 UTC (rev 1064)
@@ -106,10 +106,38 @@
##==============================================================================
##
+## _mwrap()
##
+## Wrap a method in a try block.
##
##==============================================================================
+def _mwrap(obj, meth, *args, **kwds):
+ try:
+ return obj.meth(*args, **kwds)
+ except cmpi.CMPIException,e:
+ raise _exception_to_error(e)
+
+##==============================================================================
+##
+## _fwrap()
+##
+## Wrap a function in a try block.
+##
+##==============================================================================
+
+def _fwrap(meth, *args, **kwds):
+ try:
+ return meth(*args, **kwds)
+ except cmpi.CMPIException,e:
+ raise _exception_to_error(e)
+
+##==============================================================================
+##
+##
+##
+##==============================================================================
+
class ContextWrap(object):
def __init__(self, proxy, cmpicontext):
self.proxy = proxy
@@ -366,7 +394,7 @@
raise pywbem.CIMError(pywbem.CIM_ERR_FAILED,
'New broker not the same as cached broker!')
except KeyError:
- prox = CMPIProxyProvider(miname, broker)
+ prox = ExceptionClassWrapper(CMPIProxyProvider(miname, broker))
g_proxies[miname] = prox
return prox
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kk...@us...> - 2008-10-02 14:05:10
|
Revision: 1063
http://omc.svn.sourceforge.net/omc/?rev=1063&view=rev
Author: kkaempf
Date: 2008-10-02 14:00:50 +0000 (Thu, 02 Oct 2008)
Log Message:
-----------
initial add of Perl target (incomplete!)
Modified Paths:
--------------
cmpi-bindings/trunk/swig/CMakeLists.txt
cmpi-bindings/trunk/swig/cmpi.i
Added Paths:
-----------
cmpi-bindings/trunk/swig/perl/
cmpi-bindings/trunk/swig/perl/CMakeLists.txt
Modified: cmpi-bindings/trunk/swig/CMakeLists.txt
===================================================================
--- cmpi-bindings/trunk/swig/CMakeLists.txt 2008-10-02 14:00:08 UTC (rev 1062)
+++ cmpi-bindings/trunk/swig/CMakeLists.txt 2008-10-02 14:00:50 UTC (rev 1063)
@@ -20,3 +20,10 @@
ADD_SUBDIRECTORY(python)
ENDIF (PYTHON_LINK_LIBS)
ENDIF (PYTHON_LIBRARY)
+
+FIND_PACKAGE(Perl)
+IF (PERL_EXECUTABLE)
+ MESSAGE(STATUS "Building Perl...")
+ ADD_SUBDIRECTORY(perl)
+ENDIF (PERL_EXECUTABLE)
+
\ No newline at end of file
Modified: cmpi-bindings/trunk/swig/cmpi.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi.i 2008-10-02 14:00:08 UTC (rev 1062)
+++ cmpi-bindings/trunk/swig/cmpi.i 2008-10-02 14:00:50 UTC (rev 1063)
@@ -72,10 +72,11 @@
#define Target_True (&PL_sv_yes)
#define Target_False (&PL_sv_no)
#define Target_Null NULL
+#define Target_Void NULL
#define Target_Type SV *
#define Target_Bool(x) (x)
-#define Target_Int(x) 0 /* should be Target_From_long(x), but Swig declares it too late. FIXME */
-#define Target_String(x) "" /* Target_FromCharPtr(x), also */
+#define Target_Int(x) NULL /* should be Target_From_long(x), but Swig declares it too late. FIXME */
+#define Target_String(x) NULL /* Target_FromCharPtr(x), also */
#define Target_Array(x) NULL
#define Target_Append(x,y) av_create_and_push(&x, y)
#define TARGET_THREAD_BEGIN_BLOCK
Added: cmpi-bindings/trunk/swig/perl/CMakeLists.txt
===================================================================
--- cmpi-bindings/trunk/swig/perl/CMakeLists.txt (rev 0)
+++ cmpi-bindings/trunk/swig/perl/CMakeLists.txt 2008-10-02 14:00:50 UTC (rev 1063)
@@ -0,0 +1,60 @@
+#
+# CMakeLists.txt for cmpi-bindings/swig/perl
+#
+
+EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE} -e "use Config; print \$Config{ccflags}" OUTPUT_VARIABLE PERL_CCFLAGS)
+EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE} -e "use Config; print \$Config{archlib}.\"/CORE\"" OUTPUT_VARIABLE PERL_CORE_DIR)
+EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE} -e "use Config; print \$Config{installvendorarch}" OUTPUT_VARIABLE PERL_VENDOR_ARCH)
+EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE} -e "use Config; print \$Config{installvendorlib}" OUTPUT_VARIABLE PERL_VENDOR_LIB)
+EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE} -e "use Config; print \$Config{ccdlflags}" OUTPUT_VARIABLE PERL_LINK_FLAGS)
+
+MESSAGE(STATUS "Perl executable: ${PERL_EXECUTABLE}")
+MESSAGE(STATUS "Perl core dir: ${PERL_CORE_DIR}")
+MESSAGE(STATUS "Perl vendor arch dir: ${PERL_VENDOR_ARCH}")
+MESSAGE(STATUS "Perl vendor lib dir: ${PERL_VENDOR_LIB}")
+
+SET( SWIG_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmpi_wrap.c" )
+SET( SWIG_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/../cmpi.i" )
+
+if(COMMAND cmake_policy)
+ cmake_policy(SET CMP0003 NEW)
+endif(COMMAND cmake_policy)
+
+ADD_CUSTOM_COMMAND (
+ OUTPUT ${SWIG_OUTPUT}
+ COMMAND ${CMAKE_COMMAND} -E echo_append "Creating wrapper code for Perl ..."
+ COMMAND ${SWIG_EXECUTABLE} -perl -shadow -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
+)
+
+SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" )
+
+INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include/cmpi )
+INCLUDE_DIRECTORIES( ${CMPI_INCLUDE_DIR} )
+INCLUDE_DIRECTORIES( ${PERL_CORE_DIR} )
+
+ADD_DEFINITIONS(-DCMPI_PLATFORM_LINUX_GENERIC_GNU -DCMPI_VERSION=200)
+ADD_DEFINITIONS(-DTARGET_PERL)
+
+ADD_DEFINITIONS( ${PERL_CCFLAGS} -Wno-unused -Wno-error )
+LINK_DIRECTORIES( ${PERL_CORE_DIR} )
+
+#
+# cmpi_instance: provider .so
+#
+
+SET( NAME plCmpiProvider )
+ADD_LIBRARY( ${NAME} SHARED ${SWIG_OUTPUT})
+TARGET_LINK_LIBRARIES( ${NAME} ${PERL_LIBRARY} )
+
+INSTALL(TARGETS ${NAME} LIBRARY DESTINATION ${CMPI_LIBRARY_DIR})
+
+#
+# cmpi_rbwbem_bindings: provider implementation
+#
+INSTALL(FILES cmpi_plwbem_bindings.pl DESTINATION ${PERL_VENDOR_LIB})
+
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmpi.pm DESTINATION ${PERL_VENDOR_LIB} )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kk...@us...> - 2008-10-02 14:04:29
|
Revision: 1062
http://omc.svn.sourceforge.net/omc/?rev=1062&view=rev
Author: kkaempf
Date: 2008-10-02 14:00:08 +0000 (Thu, 02 Oct 2008)
Log Message:
-----------
add comment, remove C++ flags
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-10-02 13:31:15 UTC (rev 1061)
+++ cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-10-02 14:00:08 UTC (rev 1062)
@@ -1,11 +1,11 @@
#
-# CMakeLists.txt for cmpi-bindings
+# CMakeLists.txt for cmpi-bindings/swig/ruby
#
+
enable_testing()
add_subdirectory(tests)
SET (BUILD_SHARED_LIBS ON)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
FIND_PACKAGE(PythonInterp REQUIRED)
Modified: cmpi-bindings/trunk/swig/ruby/CMakeLists.txt
===================================================================
--- cmpi-bindings/trunk/swig/ruby/CMakeLists.txt 2008-10-02 13:31:15 UTC (rev 1061)
+++ cmpi-bindings/trunk/swig/ruby/CMakeLists.txt 2008-10-02 14:00:08 UTC (rev 1062)
@@ -1,6 +1,7 @@
+#
+# CMakeLists.txt for cmpi-bindings/swig/ruby
+#
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
-
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorarchdir']" OUTPUT_VARIABLE RUBY_ARCH_DIR)
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorlibdir']" OUTPUT_VARIABLE RUBY_LIB_DIR)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kk...@us...> - 2008-10-02 14:03:40
|
Revision: 1060
http://omc.svn.sourceforge.net/omc/?rev=1060&view=rev
Author: kkaempf
Date: 2008-10-02 13:30:26 +0000 (Thu, 02 Oct 2008)
Log Message:
-----------
- add CMPIObjectPath constructor
- CMPIObjectPath.string() method
Modified Paths:
--------------
cmpi-bindings/trunk/swig/cmpi_types.i
Modified: cmpi-bindings/trunk/swig/cmpi_types.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi_types.i 2008-10-01 23:24:28 UTC (rev 1059)
+++ cmpi-bindings/trunk/swig/cmpi_types.i 2008-10-02 13:30:26 UTC (rev 1060)
@@ -296,7 +296,7 @@
%extend _CMPIResult
{
/* no con-/destructor, the broker handles this */
-
+
const char* to_s(const CMPIBroker* broker)
{
CMPIStatus st = { CMPI_RC_OK, NULL };
@@ -336,7 +336,12 @@
%extend _CMPIObjectPath
{
- /* no ctor. use method on broker instead. */
+ CMPIObjectPath(const CMPIBroker * mb, const char *ns, const char *cn)
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ return CMNewObjectPath( mb, ns, cn, &st );
+ }
+
~CMPIObjectPath()
{
}
@@ -350,6 +355,17 @@
}
*/
+#ifdef SWIGPYTHON
+%rename ("__str__") string();
+#endif
+#ifdef SWIGRUBY
+%rename ("to_s") string();
+#endif
+ const char *string()
+ {
+ return CMGetCharPtr($self->ft->toString($self, NULL));
+ }
+
/* Adds/replaces a named key property.
* name: Key property name.
* value: Address of value structure.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kk...@us...> - 2008-10-02 14:02:08
|
Revision: 1061
http://omc.svn.sourceforge.net/omc/?rev=1061&view=rev
Author: kkaempf
Date: 2008-10-02 13:31:15 +0000 (Thu, 02 Oct 2008)
Log Message:
-----------
- add test cases for cmpi_rbwbem_bindings.rb
- load Ruby providers on-demand
- provide interface modules for the various MI types and their functions
Modified Paths:
--------------
cmpi-bindings/trunk/src/target_ruby.c
cmpi-bindings/trunk/swig/ruby/cmpi_rbwbem_bindings.rb
cmpi-bindings/trunk/test/ruby/test_atom_provider.rb
Added Paths:
-----------
cmpi-bindings/trunk/swig/ruby/test/
cmpi-bindings/trunk/swig/ruby/test/create.rb
cmpi-bindings/trunk/swig/ruby/test/loading.rb
Modified: cmpi-bindings/trunk/src/target_ruby.c
===================================================================
--- cmpi-bindings/trunk/src/target_ruby.c 2008-10-02 13:30:26 UTC (rev 1060)
+++ cmpi-bindings/trunk/src/target_ruby.c 2008-10-02 13:31:15 UTC (rev 1061)
@@ -20,40 +20,27 @@
static VALUE
load_module()
{
- _SBLIM_TRACE(1,("Ruby: require '%s'...", RB_BINDINGS_FILE));
-
- rb_require(RB_BINDINGS_FILE);
-
- _SBLIM_TRACE(1,("Ruby: ... done"));
-
- return Qnil;
+ ruby_script(RB_BINDINGS_FILE);
+ return rb_require(RB_BINDINGS_FILE);
}
/*
- * create_mi
- * call constructor for MI implementation class
+ * create_mi (called from rb_protect)
+ * load Ruby provider and create provider instance
*
* I args : pointer to array of 2 values
- * values[0] = broker, passed to constructor
- * values[1] = id of class (rb_intern(<classname>))
+ * values[0] = classname (String)
+ * values[1] = broker, passed to constructor
*/
static VALUE
create_mi(VALUE args)
{
VALUE *values = (VALUE *)args;
- _SBLIM_TRACE(1,("Ruby: %s.new ...", rb_id2name(values[1])));
- VALUE klass = rb_const_get(_TARGET_MODULE, values[1]);
- _SBLIM_TRACE(1,("Ruby: ... klass -> %ld", klass));
- if (NIL_P(klass))
- {
- _SBLIM_TRACE(1,("Ruby: ... klass is NULL"));
- return klass;
- }
- VALUE instance = rb_class_new_instance(1, values, klass);
- _SBLIM_TRACE(1,("Ruby: ... done -> %ld", instance));
- return instance;
+
+ _SBLIM_TRACE(1,("Ruby: %s.new ...", StringValuePtr(values[0])));
+ return rb_funcall2(_TARGET_MODULE, rb_intern("create_provider"), 2, values);
}
@@ -78,6 +65,25 @@
/*
+ * get Ruby exception trace -> CMPIString
+ *
+ */
+
+#define TB_ERROR(str) {tbstr = str; goto cleanup;}
+static CMPIString *
+get_exc_trace(const CMPIBroker* broker)
+{
+ VALUE exception = rb_gv_get("$!"); /* get last exception */
+ VALUE reason = rb_funcall(exception, rb_intern("to_s"), 0 );
+ VALUE trace = rb_gv_get("$@"); /* get last exception trace */
+ VALUE backtrace = rb_funcall(trace, rb_intern("join"), 1, rb_str_new("\n\t", 2));
+
+ char* tmp = fmtstr("%s\n\t%s", StringValuePtr(reason), StringValuePtr(backtrace));
+ return broker->eft->newString(broker, tmp, NULL);
+}
+
+
+/*
* Global Ruby initializer
* loads the Ruby interpreter
* init threads
@@ -88,11 +94,8 @@
{
int error;
- _SBLIM_TRACE(1,("<%d> RbGlobalInitialize() called", getpid()));
-
if (_TARGET_INIT)
{
- _SBLIM_TRACE(1,("<%d> RbGlobalInitialize() returning: already initialized", getpid()));
return 0;
}
_TARGET_INIT=1;//true
@@ -101,14 +104,16 @@
ruby_init();
ruby_init_loadpath();
- ruby_script("cmpi_swig");
+ ruby_script("cmpi_swig_ruby");
SWIG_init();
/* load module */
rb_protect(load_module, Qnil, &error);
if (error)
{
- _SBLIM_TRACE(1,("<%d> Ruby: import '%s' failed, error %d", getpid(), RB_BINDINGS_FILE, error));
+ CMPIString *trace = get_exc_trace(broker);
+
+ _SBLIM_TRACE(1,("<%d> Ruby: import '%s' failed: %s", getpid(), RB_BINDINGS_FILE, CMGetCharPtr(trace)));
/* _CMPI_SETFAIL(<CMPIString *>); */
abort();
return -1;
@@ -155,15 +160,17 @@
_SBLIM_TRACE(1,("<%d> TargetInitialize(Ruby) called, miName '%s'", getpid(), hdl->miName));
- args[0] = SWIG_NewPointerObj((void*) hdl->broker, SWIGTYPE_p__CMPIBroker, 0);
- args[1] = rb_intern(hdl->miName);
+ args[0] = rb_str_new2(hdl->miName);
+ args[1] = SWIG_NewPointerObj((void*) hdl->broker, SWIGTYPE_p__CMPIBroker, 0);
hdl->instance = rb_protect(create_mi, (VALUE)args, &error);
if (error)
{
- _SBLIM_TRACE(1,("Ruby: FAILED creating %s, error %d", hdl->miName, error));
+ CMPIString *trace = get_exc_trace(hdl->broker);
+ _SBLIM_TRACE(1,("Ruby: FAILED creating %s:", hdl->miName, CMGetCharPtr(trace)));
if (st != NULL)
{
st->rc = CMPI_RC_ERR_INVALID_CLASS;
+ st->msg = trace;
}
}
else
@@ -189,17 +196,6 @@
VALUE *args, result, op = rb_intern(opname);
va_list vargs;
- _SBLIM_TRACE(1,("call_provider %s[%d]", opname, nargs));
-
- if (!rb_respond_to(hdl->instance, op))
- {
- char* str = fmtstr("Ruby provider does not implement \"%s\"", opname);
- _SBLIM_TRACE(1,("%s", str));
- st->rc = CMPI_RC_ERR_FAILED;
- st->msg = hdl->broker->eft->newString(hdl->broker, str, NULL);
- return 1;
- }
-
/* add hdl->instance, op and nargs to the args array, so rb_protect can be called */
nargs += 3;
args = (VALUE *)malloc(nargs * sizeof(VALUE));
@@ -228,8 +224,9 @@
if (i)
{
- char* str = fmtstr("Ruby provider call to \"%s\" failed", opname);
- _SBLIM_TRACE(1,("%s", str));
+ CMPIString *trace = get_exc_trace(hdl->broker);
+ char* str = fmtstr("Ruby: calling '%s' failed: %s", opname, CMGetCharPtr(trace));
+ _SBLIM_TRACE(1,("%s", str));
st->rc = CMPI_RC_ERR_FAILED;
st->msg = hdl->broker->eft->newString(hdl->broker, str, NULL);
return 1;
Modified: cmpi-bindings/trunk/swig/ruby/cmpi_rbwbem_bindings.rb
===================================================================
--- cmpi-bindings/trunk/swig/ruby/cmpi_rbwbem_bindings.rb 2008-10-02 13:30:26 UTC (rev 1060)
+++ cmpi-bindings/trunk/swig/ruby/cmpi_rbwbem_bindings.rb 2008-10-02 13:31:15 UTC (rev 1061)
@@ -5,27 +5,86 @@
#
module Cmpi
- STDERR.puts "Hello from cmpi-bindings-ruby"
# init
- RBCIMPATH = "/usr/lib/rbcim/"
+ RBCIMPATH = "/usr/lib/rbcim"
- # look for .rb files below RBCIMPATH
- # and load them
- if File.directory?(RBCIMPATH) then
+ #
+ # on-demand loading of Ruby providers
+ # create provider for 'classname'
+ # pass 'broker' to its constructor
+ #
+ def self.create_provider classname, broker
$:.unshift RBCIMPATH # add to load path
- STDERR.puts "Looking into #{RBCIMPATH}"
- Dir.foreach( RBCIMPATH ) do |entry|
- STDERR.puts "Found #{entry}"
- split = entry.split '.'
- if split[1] == 'rb' then
- begin
- STDERR.puts "Loading #{split[0]}"
- require split[0]
- rescue Exception => e
- STDERR.puts "Loading #{split[0]} failed: #{e}"
- end
- end
- end
+ # CamelCase -> under_score
+ underscore = classname.
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
+ tr("-", "_").
+ downcase
+ STDERR.puts "create_provider #{classname}: #{underscore}"
+ # load implementation
+ require underscore
+
$:.shift # take load path away
+
+ Cmpi.const_get(classname).new broker
end
+
+ # define MI provider interfaces as modules
+ # so they can be used as mixins
+ module InstanceProviderIF
+ def create_instance context, result, reference, newinst
+ end
+ def get_instance context, result, objname, plist
+ end
+ def delete_instance context, result, objname
+ end
+ def method_missing method, *args
+ STDERR.puts "InstanceProvider.#{method}: not implemented"
+ end
+ end
+
+ module MethodProviderIF
+ def method_missing method, *args
+ STDERR.puts "MethodProvider.#{method}: not implemented"
+ end
+ end
+
+ module AssociationProviderIF
+ def method_missing method, *args
+ STDERR.puts "AssociationProvider.#{method}: not implemented"
+ end
+ end
+ module IndicationProviderIF
+ def method_missing method, *args
+ STDERR.puts "IndicationProvider.#{method}: not implemented"
+ end
+ end
+
+ # now define MI classes, so they can be derived from
+ class InstanceProvider
+ include InstanceProviderIF
+ def initialize broker
+ @broker = broker
+ end
+ end
+ class MethodProvider
+ include MethodProviderIF
+ def initialize broker
+ @broker = broker
+ end
+ end
+ class AssociationProvider
+ include AssociationProviderIF
+ def initialize broker
+ @broker = broker
+ end
+ end
+ class IndicationProvider
+ include IndicationProviderIF
+ def initialize broker
+ @broker = broker
+ end
+ end
+
end
Added: cmpi-bindings/trunk/swig/ruby/test/create.rb
===================================================================
--- cmpi-bindings/trunk/swig/ruby/test/create.rb (rev 0)
+++ cmpi-bindings/trunk/swig/ruby/test/create.rb 2008-10-02 13:31:15 UTC (rev 1061)
@@ -0,0 +1,9 @@
+#
+# provider creation
+#
+
+$:.unshift("..")
+
+require 'cmpi_rbwbem_bindings'
+
+Cmpi::create_provider "TestProvider", nil
Added: cmpi-bindings/trunk/swig/ruby/test/loading.rb
===================================================================
--- cmpi-bindings/trunk/swig/ruby/test/loading.rb (rev 0)
+++ cmpi-bindings/trunk/swig/ruby/test/loading.rb 2008-10-02 13:31:15 UTC (rev 1061)
@@ -0,0 +1,4 @@
+# load cmpi_rbwbem_bindings.rb
+
+$:.unshift("..")
+require 'cmpi_rbwbem_bindings'
Modified: cmpi-bindings/trunk/test/ruby/test_atom_provider.rb
===================================================================
--- cmpi-bindings/trunk/test/ruby/test_atom_provider.rb 2008-10-02 13:30:26 UTC (rev 1060)
+++ cmpi-bindings/trunk/test/ruby/test_atom_provider.rb 2008-10-02 13:31:15 UTC (rev 1061)
@@ -1,7 +1,7 @@
#
# Ruby Provider for TestAtom
#
-# Instruments the CIM class TestAtom
+# Instruments the CIM class Test_Atom
#
module Cmpi
@@ -12,17 +12,30 @@
# Model an atom, For use with CIMOM and RbWbem Provider
#
- class TestAtomProvider
- STDERR.puts "This is TestAtomProvider within test_atom_provider.rb"
-
+ class TestAtomProvider < InstanceProvider
+ # create new instance -> check with .mof file
def initialize broker
- STDERR.puts "TestAtomProvider initialized!"
- @broker = broker
+ super
end
+ # use i.e. 'include MethodProviderIF' to implement multiple MIs
def create_instance context, result, reference, newinst
- STDERR.puts "TestAtomProvider.create_instance"
+ STDERR.puts "TestAtomProvider.create_instance: #{reference}"
+ result.return_objectpath reference
+ result.done
end
+
+ def get_instance context, result, objname, plist
+
+ plist = plist.join(',') if plist.respond_to? :join
+
+ STDERR.puts "TestAtomProvider.get_instance: #{objname}: #{plist}"
+ end
+
+ def delete_instance context, result, objname
+ STDERR.puts "TestAtomProvider.delete_instance: #{objname}"
+ end
+
end
-end
\ No newline at end of file
+end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mik...@us...> - 2008-10-01 23:24:35
|
Revision: 1059
http://omc.svn.sourceforge.net/omc/?rev=1059&view=rev
Author: mike-brasher
Date: 2008-10-01 23:24:28 +0000 (Wed, 01 Oct 2008)
Log Message:
-----------
CMPIStatus/CIMError mappings for cmpi_types.i
Modified Paths:
--------------
cmpi-bindings/trunk/swig/cmpi.i
cmpi-bindings/trunk/swig/cmpi_types.i
Added Paths:
-----------
cmpi-bindings/trunk/test/python/install.sh
Removed Paths:
-------------
cmpi-bindings/trunk/test/python/setup.sh
Modified: cmpi-bindings/trunk/swig/cmpi.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi.i 2008-10-01 22:04:31 UTC (rev 1058)
+++ cmpi-bindings/trunk/swig/cmpi.i 2008-10-01 23:24:28 UTC (rev 1059)
@@ -193,10 +193,10 @@
#include "../src/cmpi_provider.c"
/* RAISE exception IF status argument has a nonzero rc member */
-#define RAISE_IF(ST) \
+#define RAISE_IF(EXPR) \
do \
{ \
- CMPIStatus __st__ = (ST); \
+ CMPIStatus __st__ = (EXPR); \
if (__st__.rc) \
_raise_ex(&__st__); \
} \
Modified: cmpi-bindings/trunk/swig/cmpi_types.i
===================================================================
--- cmpi-bindings/trunk/swig/cmpi_types.i 2008-10-01 22:04:31 UTC (rev 1058)
+++ cmpi-bindings/trunk/swig/cmpi_types.i 2008-10-01 23:24:28 UTC (rev 1059)
@@ -110,21 +110,25 @@
%rename(CMPIException) CMPIException;
typedef struct _CMPIException {} CMPIException;
-%extend CMPIException {
-
- CMPIException() {
+%extend CMPIException
+{
+ CMPIException()
+ {
return (CMPIException*)calloc(1, sizeof(CMPIException));
}
- ~CMPIException() {
+ ~CMPIException()
+ {
free($self->description);
}
- int get_error_code() {
+ int get_error_code()
+ {
return $self->error_code;
}
- const char* get_description() {
+ const char* get_description()
+ {
return $self->description;
}
}
@@ -136,7 +140,8 @@
#-----------------------------------------------------
#ifdef SWIGPYTHON
-%exception {
+%exception
+{
_clr_raised();
$action
if (_get_raised())
@@ -153,75 +158,76 @@
# CMPIError
#
-%extend _CMPIError {
+%extend _CMPIError
+{
~CMPIError() { }
/* Gets the type of this Error */
CMPIErrorType type() {
- return CMGetErrorType( $self, NULL );
+ return CMGetErrorType($self, NULL);
}
/* Sets the error type of this error object. */
#if defined(SWIGRUBY)
%rename("type=") set_type(const CMPIErrorType et);
#endif
void set_type(const CMPIErrorType et) {
- CMSetErrorType( $self, et );
+ CMSetErrorType($self, et);
}
/* Returns a string which describes the alternate error type. */
const char *other_type() {
- return CMGetCharPtr( CMGetOtherErrorType( $self, NULL ) );
+ return CMGetCharPtr(CMGetOtherErrorType($self, NULL));
}
/* Sets the 'other' error type of this error object. */
#if defined(SWIGRUBY)
%rename("other_type=") set_other_type(const char *ot);
#endif
void set_other_type(const char *ot) {
- CMSetOtherErrorType( $self, ot );
+ CMSetOtherErrorType($self, ot);
}
/* Returns a string which describes the owning entity. */
const char *owning_entity() {
- return CMGetCharPtr( CMGetOwningEntity( $self, NULL ) );
+ return CMGetCharPtr(CMGetOwningEntity($self, NULL));
}
/* Returns a string which is the message ID. */
const char *message_id() {
- return CMGetCharPtr( CMGetMessageID( $self, NULL ) );
+ return CMGetCharPtr(CMGetMessageID($self, NULL));
}
/* Returns a string comnating an error message. */
const char *message() {
- return CMGetCharPtr( CMGetErrorMessage( $self, NULL ) );
+ return CMGetCharPtr(CMGetErrorMessage($self, NULL));
}
/* Returns the perceieved severity of this error. */
CMPIErrorSeverity severity() {
- return CMGetPerceivedSeverity( $self, NULL );
+ return CMGetPerceivedSeverity($self, NULL);
}
/* Returns the probable cause of this error. */
CMPIErrorProbableCause probable_cause() {
- return CMGetProbableCause( $self, NULL );
+ return CMGetProbableCause($self, NULL);
}
/* Sets the description of the probable cause. */
#if defined(SWIGRUBY)
%rename("probable_cause=") set_probable_cause(const char *pcd);
#endif
void set_probable_cause(const char *pcd) {
- CMSetProbableCauseDescription( $self, pcd );
+ CMSetProbableCauseDescription($self, pcd);
}
/* Returns a string which describes the probable cause. */
const char *probable_cause_description() {
- return CMGetCharPtr( CMGetProbableCauseDescription( $self, NULL ) );
+ return CMGetCharPtr(CMGetProbableCauseDescription($self, NULL));
}
/* Returns an array of strings which describes recomended actions. */
CMPIArray *recommended_actions() {
- return CMGetRecommendedActions( $self, NULL );
+ return CMGetRecommendedActions($self, NULL);
}
/* Sets the recomended actions array. */
#if defined(SWIGRUBY)
%rename("recommended_actions=") set_recommended_actions(const CMPIArray* ra);
#endif
void set_recommended_actions(const CMPIArray* ra) {
- CMSetRecommendedActions( $self, ra );
+ CMSetRecommendedActions($self, ra);
}
/* Returns a string which describes the Error source. */
const char *source() {
- return CMGetCharPtr( CMGetErrorSource( $self, NULL ) );
+ return CMGetCharPtr(CMGetErrorSource($self, NULL));
}
/* Specifies a string which specifes The identifying information of
the entity (i.e., the instance) generating the error. */
@@ -229,56 +235,56 @@
%rename("source=") set_source(const char *es);
#endif
void set_source(const char *es) {
- CMSetErrorSource( $self, es );
+ CMSetErrorSource($self, es);
}
/* Returns a the format that the error src is in. */
CMPIErrorSrcFormat source_format() {
- return CMGetErrorSourceFormat( $self, NULL );
+ return CMGetErrorSourceFormat($self, NULL);
}
/* Sets the source format of the error object. */
#if defined(SWIGRUBY)
%rename("source_format=") set_source_format(const CMPIErrorSrcFormat esf);
#endif
void set_source_format(const CMPIErrorSrcFormat esf) {
- CMSetErrorSourceFormat( $self, esf );
+ CMSetErrorSourceFormat($self, esf);
}
/* Returns a string which describes the 'other' format, only
available if the error source is OTHER. */
const char *other_format() {
- return CMGetCharPtr( CMGetOtherErrorSourceFormat( $self, NULL ) );
+ return CMGetCharPtr(CMGetOtherErrorSourceFormat($self, NULL));
}
/* specifies A string defining "Other" values for ErrorSourceFormat */
#if defined(SWIGRUBY)
%rename("other_format=") set_other_format(const char *oesf);
#endif
void set_other_format(const char *oesf) {
- CMSetOtherErrorSourceFormat( $self, oesf );
+ CMSetOtherErrorSourceFormat($self, oesf);
}
/* Returns the status code of this error. */
CMPIrc status_code() {
- return CMGetCIMStatusCode( $self, NULL );
+ return CMGetCIMStatusCode($self, NULL);
}
/* Returns a string which describes the status code error. */
const char *status_description() {
- return CMGetCharPtr( CMGetCIMStatusCodeDescription( $self, NULL ) );
+ return CMGetCharPtr(CMGetCIMStatusCodeDescription($self, NULL));
}
/* Sets the description of the status code. */
#if defined(SWIGRUBY)
%rename("status_description=") set_status_description(const char *cd);
#endif
void set_status_description(const char *cd) {
- CMSetCIMStatusCodeDescription( $self, cd );
+ CMSetCIMStatusCodeDescription($self, cd);
}
/* Returns an array which contains the dynamic content of the message. */
CMPIArray *message_arguments() {
- return CMGetMessageArguments( $self, NULL );
+ return CMGetMessageArguments($self, NULL);
}
/* Sets an array of strings for the dynamic content of the message. */
#if defined(SWIGRUBY)
%rename("message_arguments=") set_message_arguments(CMPIArray* ma);
#endif
void set_message_arguments(CMPIArray* ma) {
- CMSetMessageArguments( $self, ma );
+ CMSetMessageArguments($self, ma);
}
}
@@ -287,25 +293,39 @@
# CMPIResult
#
-%extend _CMPIResult {
+%extend _CMPIResult
+{
/* no con-/destructor, the broker handles this */
- const char* to_s(const CMPIBroker* broker) {
- CMPIString *s = CDToString(broker, $self, NULL);
- return CMGetCharPtr(s);
+ const char* to_s(const CMPIBroker* broker)
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIString* result;
+
+ result = CDToString(broker, $self, &st);
+ RAISE_IF(st);
+
+ return CMGetCharPtr(result);
}
- void return_instance(CMPIInstance *instance) {
- CMReturnInstance( $self, instance );
+ void return_instance(CMPIInstance *instance)
+ {
+ RAISE_IF(CMReturnInstance($self, instance));
}
- void return_objectpath(CMPIObjectPath *path) {
- CMReturnObjectPath( $self, path );
+
+ void return_objectpath(CMPIObjectPath *path)
+ {
+ RAISE_IF(CMReturnObjectPath($self, path));
}
- void return_data(const CMPIValue* value, const CMPIType type) {
- CMReturnData( $self, value, type);
+
+ void return_data(const CMPIValue* value, const CMPIType type)
+ {
+ RAISE_IF(CMReturnData($self, value, type));
}
- void done() {
- CMReturnDone( $self );
+
+ void done()
+ {
+ RAISE_IF(CMReturnDone($self));
}
}
@@ -314,15 +334,19 @@
# CMPIObjectPath
#
-%extend _CMPIObjectPath {
+%extend _CMPIObjectPath
+{
/* no ctor. use method on broker instead. */
- ~CMPIObjectPath( ) { }
+ ~CMPIObjectPath()
+ {
+ }
+
/**
* Create an independent copy of this ObjectPath object. The resulting
* object must be released explicitly.
FIXME: if clone() is exposed, release() must also
CMPIObjectPath *clone() {
- return $self->ft->clone( $self, NULL );
+ return $self->ft->clone($self, NULL);
}
*/
@@ -345,54 +369,67 @@
CMPIValue *value = (CMPIValue *)malloc(sizeof(CMPIValue));
CMPIType type;
if (SYMBOL_P(property)) {
- name = rb_id2name( SYM2ID( property ) );
+ name = rb_id2name(SYM2ID(property));
}
else {
- name = StringValuePtr( property );
+ name = StringValuePtr(property);
}
switch (TYPE(data)) {
case T_FLOAT:
value->Float = RFLOAT(data)->value;
- type = CMPI_real32;
+ type = CMPI_real32;
break;
case T_STRING:
value->string = CMNewString(_BROKER, StringValuePtr(data), NULL);
- type = CMPI_string;
+ type = CMPI_string;
break;
case T_FIXNUM:
value->Int = FIX2ULONG(data);
- type = CMPI_uint32;
+ type = CMPI_uint32;
break;
case T_TRUE:
value->boolean = 1;
- type = CMPI_boolean;
+ type = CMPI_boolean;
break;
case T_FALSE:
value->boolean = 0;
- type = CMPI_boolean;
+ type = CMPI_boolean;
break;
case T_SYMBOL:
- value->string = CMNewString(_BROKER, rb_id2name(SYM2ID( data )), NULL);
- type = CMPI_string;
+ value->string = CMNewString(_BROKER, rb_id2name(SYM2ID(data)), NULL);
+ type = CMPI_string;
break;
default:
value->chars = NULL;
- type = CMPI_null;
+ type = CMPI_null;
break;
}
- return CMAddKey( $self, name, value, type );
+ return CMAddKey($self, name, value, type);
}
#endif
#endif
- CMPIStatus add_key( const char *name, const CMPIValue * value, const CMPIType type) {
- return CMAddKey( $self, name, value, type );
+
+ void add_key(
+ const char *name,
+ const CMPIValue* value,
+ const CMPIType type)
+ {
+ RAISE_IF(CMAddKey($self, name, value, type));
}
+
/* Gets a named key property value.
* name: Key property name.
*/
- CMPIData get_key( const char *name ) {
- return CMGetKey( $self, name, NULL );
+ CMPIData get_key(const char *name)
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIData result;
+ result = CMGetKey($self, name, &st);
+ RAISE_IF(st);
+
+ return result;
}
+
/* Gets a key property value defined by its index.
* name: [out] Key property name
*/
@@ -402,16 +439,24 @@
#if defined (SWIGPYTHON)
PyObject*
#endif
- get_key_at( int index ) {
+ get_key_at(int index) {
CMPIString *s = NULL;
- CMPIData data = CMGetKeyAt( $self, index, &s, NULL );
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIData data = CMGetKeyAt($self, index, &s, &st);
#if defined (SWIGRUBY)
VALUE rbdata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 0);
VALUE rl = rb_ary_new2(2);
- return rb_ary_push( rb_ary_push( rl, rbdata ), rb_str_new2(CMGetCharPtr(s) ) );
+ return rb_ary_push(rb_ary_push(rl, rbdata), rb_str_new2(CMGetCharPtr(s)));
#endif
#if defined (SWIGPYTHON)
+
+ if (st.rc)
+ {
+ RAISE_IF(st);
+ return NULL;
+ }
+
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 1);
@@ -422,80 +467,156 @@
return pl;
#endif
}
+
/* Gets the number of key properties contained in this ObjectPath. */
- int key_count() {
- return CMGetKeyCount( $self, NULL );
+ int key_count()
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ int result;
+
+ result = CMGetKeyCount($self, &st);
+ RAISE_IF(st);
+
+ return result;
}
+
/* Set/replace namespace and classname components from <src>. */
- void replace_from( const CMPIObjectPath * src ) {
- CMSetNameSpaceFromObjectPath( $self, src );
+ void replace_from(const CMPIObjectPath * src)
+ {
+ RAISE_IF(CMSetNameSpaceFromObjectPath($self, src));
}
- /* Set/replace hostname, namespace and classname components from <src>. */
- void replace_all_from( const CMPIObjectPath * src ) {
- CMSetHostAndNameSpaceFromObjectPath( $self, src );
+
+ /* Set/replace hostname, namespace and classname components from <src>.
+ */
+ void replace_all_from(const CMPIObjectPath * src)
+ {
+ RAISE_IF(CMSetHostAndNameSpaceFromObjectPath($self, src));
}
+
/* Get class qualifier value.
* qName: Qualifier name.
*/
- CMPIData qualifier( const char *qname ) {
- return CMGetClassQualifier( $self, qname, NULL );
+ CMPIData qualifier(const char *qname)
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIData result;
+
+ result = CMGetClassQualifier($self, qname, &st);
+ RAISE_IF(st);
+
+ return result;
}
+
/* Get property qualifier value.
* pName Property name.
* qName Qualifier name.
*/
- CMPIData property_qualifier( const char *pName, const char *qName ) {
- return CMGetPropertyQualifier( $self, pName, qName, NULL );
+ CMPIData property_qualifier(const char *pName, const char *qName)
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIData result;
+
+ result = CMGetPropertyQualifier($self, pName, qName, &st);
+ RAISE_IF(st);
+
+ return result;
}
+
/* Get method qualifier value.
* mName: Method name.
* qName: Qualifier name.
*/
- CMPIData method_qualifier(const char *methodName, const char *qName) {
- return CMGetMethodQualifier( $self, methodName, qName, NULL);
+ CMPIData method_qualifier(const char *methodName, const char *qName)
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIData result;
+
+ result = CMGetMethodQualifier($self, methodName, qName, &st);
+ RAISE_IF(st);
+
+ return result;
}
+
/* Get method parameter qualifier value.
* mName: Method name.
* pName: Parameter name.
* qName: Qualifier name.
*/
- CMPIData parameter_qualifier( const char *mName, const char *pName, const char *qName ) {
- return CMGetParameterQualifier( $self, mName, pName, qName, NULL );
+ CMPIData parameter_qualifier(
+ const char *mName,
+ const char *pName,
+ const char *qName)
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIData result;
+
+ result = CMGetParameterQualifier($self, mName, pName, qName, &st);
+ RAISE_IF(st);
+
+ return result;
}
+
/* Get the namespace component. */
- const char *namespace() {
- return CMGetCharPtr( CMGetNameSpace( $self, NULL ) );
+ const char *namespace()
+ {
+ const char* result;
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+
+ result = CMGetCharPtr(CMGetNameSpace($self, &st));
+
+ return result;
}
+
/* Set/replace the namespace component. */
#if defined(SWIGRUBY)
%rename("namespace=") set_namespace(const char *nm);
#endif
- void set_namespace( const char *nm ) {
- CMSetNameSpace( $self, nm );
+ void set_namespace(const char *nm)
+ {
+ RAISE_IF(CMSetNameSpace($self, nm));
}
+
/* Set/replace the hostname component. */
#if defined(SWIGRUBY)
%rename("hostname=") set_hostname(const char *hostname);
#endif
- void set_hostname( const char *hostname ) {
- CMSetHostname( $self, hostname );
+ void set_hostname(const char *hostname)
+ {
+ RAISE_IF(CMSetHostname($self, hostname));
}
+
/* Get the hostname component. */
- const char *hostname() {
- return CMGetCharPtr(CMGetHostname($self, NULL));
+ const char *hostname()
+ {
+ const char* result;
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+
+ result = CMGetCharPtr(CMGetHostname($self, NULL));
+ RAISE_IF(st);
+
+ return result;
}
+
/* Set/replace the classname component. */
#if defined(SWIGRUBY)
%rename("classname=") set_classname(const char *classname);
#endif
- void set_classname( const char *classname ) {
- CMSetClassName( $self, classname );
+ void set_classname(const char *classname)
+ {
+ RAISE_IF(CMSetClassName($self, classname));
}
+
/* Get the classname component. */
- const char *classname() {
- return CMGetCharPtr(CMGetClassName($self, NULL));
+ const char *classname()
+ {
+ const char* result;
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+
+ result = CMGetCharPtr(CMGetClassName($self, &st));
+ RAISE_IF(st);
+
+ return result;
}
-
}
#-----------------------------------------------------
@@ -503,9 +624,12 @@
# CMPIInstance
#
-%extend _CMPIInstance {
+%extend _CMPIInstance
+{
/* path: ObjectPath containing namespace and classname. */
- ~CMPIInstance() { }
+ ~CMPIInstance()
+ {
+ }
/* Adds/replaces a named Property.
* name: Entry name.
@@ -526,10 +650,10 @@
CMPIValue *value = (CMPIValue *)malloc(sizeof(CMPIValue));
CMPIType type;
if (SYMBOL_P(property)) {
- name = rb_id2name( SYM2ID( property ) );
+ name = rb_id2name(SYM2ID(property));
}
else {
- name = StringValuePtr( property );
+ name = StringValuePtr(property);
}
switch (TYPE(data)) {
case T_FLOAT:
@@ -553,7 +677,7 @@
type = CMPI_boolean;
break;
case T_SYMBOL:
- value->string = CMNewString(_BROKER, rb_id2name(SYM2ID( data )), NULL);
+ value->string = CMNewString(_BROKER, rb_id2name(SYM2ID(data)), NULL);
type = CMPI_string;
break;
default:
@@ -561,13 +685,19 @@
type = CMPI_null;
break;
}
- return CMSetProperty( $self, name, value, type );
+ return CMSetProperty($self, name, value, type);
}
#endif
#endif
- CMPIStatus set_property(const char *name, const CMPIValue * value, const CMPIType type) {
- return CMSetProperty( $self, name, value, type );
+
+ void set_property(
+ const char *name,
+ const CMPIValue * value,
+ const CMPIType type)
+ {
+ RAISE_IF(CMSetProperty($self, name, value, type));
}
+
/* get a named property value */
#if defined(SWIGRUBY)
%alias get "[]";
@@ -580,23 +710,32 @@
CMPIData get(VALUE property)
{
if (FIXNUM_P(property)) {
- return CMGetPropertyAt( $self, FIX2ULONG(property), NULL, NULL );
+ return CMGetPropertyAt($self, FIX2ULONG(property), NULL, NULL);
}
else {
const char *name;
if (SYMBOL_P(property)) {
- name = rb_id2name( SYM2ID( property ) );
+ name = rb_id2name(SYM2ID(property));
}
else {
- name = StringValuePtr( property );
+ name = StringValuePtr(property);
}
- return CMGetProperty( $self, name, NULL );
+ return CMGetProperty($self, name, NULL);
}
}
#endif
- CMPIData get_property(const char *name) {
- return CMGetProperty( $self, name, NULL );
+
+ CMPIData get_property(const char *name)
+ {
+ CMPIData result;
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+
+ result = CMGetProperty($self, name, &st);
+ RAISE_IF(st);
+
+ return result;
}
+
/** Gets a Property value defined by its index.
* index: Position in the internal Data array.
*/
@@ -606,16 +745,25 @@
#if defined (SWIGPYTHON)
PyObject*
#endif
- get_property_at(int index) {
+ get_property_at(int index)
+ {
CMPIString *s = NULL;
- CMPIData data = CMGetPropertyAt( $self, index, &s, NULL );
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIData data = CMGetPropertyAt($self, index, &s, &st);
#if defined (SWIGRUBY)
VALUE rbdata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 0);
VALUE rl = rb_ary_new2(2);
- return rb_ary_push( rb_ary_push( rl, rbdata ), rb_str_new2(CMGetCharPtr(s) ) );
+ return rb_ary_push(rb_ary_push(rl, rbdata), rb_str_new2(CMGetCharPtr(s)));
#endif
#if defined (SWIGPYTHON)
+
+ if (st.rc)
+ {
+ RAISE_IF(st);
+ return NULL;
+ }
+
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 1);
@@ -626,21 +774,37 @@
return pl;
#endif
}
+
/* Gets the number of properties contained in this Instance. */
#if defined(SWIGRUBY)
%alias property_count "size";
#endif
- int property_count() {
- return CMGetPropertyCount( $self, NULL );
+ int property_count()
+ {
+ int result;
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+
+ result = CMGetPropertyCount($self, &st);
+ RAISE_IF(st);
+
+ return result;
}
+
/* Generates an ObjectPath out of the namespace, classname and
* key propeties of this Instance.
*/
- CMPIObjectPath *objectpath() {
- CMPIObjectPath *path = CMGetObjectPath( $self, NULL );
-/* fprintf(stderr, "<%p>.objectpath = %p\n", $self, path ); */
- return path;
+ CMPIObjectPath *objectpath()
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIObjectPath* result;
+
+ result = CMGetObjectPath($self, &st);
+ RAISE_IF(st);
+ /* fprintf(stderr, "<%p>.objectpath = %p\n", $self, result); */
+
+ return result;
}
+
/* Replaces the ObjectPath of the instance.
* The passed objectpath shall contain the namespace, classname,
* as well as all keys for the specified instance.
@@ -648,17 +812,21 @@
#if defined(SWIGRUBY)
%alias set_objectpath "objectpath=";
#endif
- CMPIStatus set_objectpath(const CMPIObjectPath *path) {
- return CMSetObjectPath( $self, path );
+ void set_objectpath(const CMPIObjectPath *path)
+ {
+ RAISE_IF(CMSetObjectPath($self, path));
}
+
/* Directs CMPI to ignore any setProperty operations for this
* instance for any properties not in this list.
* properties: If not NULL, the members of the array define one
* or more Property names to be accepted by setProperty operations.
*/
- CMPIStatus set_property_filter( const char **properties ) {
- return CMSetPropertyFilter( $self, properties, NULL );
+ void set_property_filter(const char **properties)
+ {
+ RAISE_IF(CMSetPropertyFilter($self, properties, NULL));
}
+
/* Add/replace a named Property value and origin
* name: is a string containing the Property name.
* value: points to a CMPIValue structure containing the value
@@ -667,10 +835,13 @@
* origin: specifies the instance origin. If NULL, then
no origin is attached to the property
*/
- CMPIStatus set_property_with_origin(const char *name,
- const CMPIValue * value, CMPIType type, const char * origin)
+ void set_property_with_origin(
+ const char *name,
+ const CMPIValue *value,
+ CMPIType type,
+ const char* origin)
{
- return CMSetPropertyWithOrigin( $self, name, value, type, origin );
+ RAISE_IF(CMSetPropertyWithOrigin($self, name, value, type, origin));
}
}
@@ -678,20 +849,33 @@
#
# CMPIArgs
-%extend _CMPIArgs {
- ~CMPIArgs() { }
+%extend _CMPIArgs
+{
+ ~CMPIArgs()
+ {
+ }
/* Adds/replaces a named argument. */
- void set( char *name, const CMPIValue * value, const CMPIType type) {
- CMAddArg( $self, name, value, type );
+ void set(char *name, const CMPIValue * value, const CMPIType type)
+ {
+ RAISE_IF(CMAddArg($self, name, value, type));
}
+
/* Gets a named argument value. */
#if defined(SWIGRUBY)
%alias get "[]";
#endif
- CMPIData get( const char *name ) {
- return CMGetArg( $self, name, NULL );
+ CMPIData get(const char *name)
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIData result;
+
+ result = CMGetArg($self, name, &st);
+ RAISE_IF(st);
+
+ return result;
}
+
/* Gets a Argument value defined by its index.
*/
#if defined (SWIGRUBY)
@@ -700,16 +884,26 @@
#if defined (SWIGPYTHON)
PyObject*
#endif
- get_arg_at(int index) {
+ get_arg_at(int index)
+ {
CMPIString *s = NULL;
- CMPIData data = CMGetArgAt( $self, index, &s, NULL );
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIData data = CMGetArgAt($self, index, &s, &st);
#if defined (SWIGRUBY)
VALUE rbdata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 0);
VALUE rl = rb_ary_new2(2);
- return rb_ary_push( rb_ary_push( rl, rbdata ), rb_str_new2(CMGetCharPtr(s) ) );
+ return rb_ary_push(rb_ary_push(rl, rbdata), rb_str_new2(CMGetCharPtr(s)));
#endif
#if defined (SWIGPYTHON)
+
+ RAISE_IF(st);
+
+ if (st.rc)
+ {
+ return NULL;
+ }
+
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyObject* pydata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 1);
@@ -720,12 +914,19 @@
return pl;
#endif
}
+
/* Gets the number of arguments contained in this Args. */
- int arg_count() {
- return CMGetArgCount($self, NULL);
+ int arg_count()
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ int result;
+
+ result = CMGetArgCount($self, &st);
+ RAISE_IF(st);
+
+ return result;
}
-
}
#-----------------------------------------------------
@@ -738,7 +939,7 @@
*/
~CMPISelectExp() { }
const char* to_s() {
- return CMGetCharPtr( CMGetSelExpString( $self, NULL ) );
+ return CMGetCharPtr(CMGetSelExpString($self, NULL));
}
}
@@ -775,36 +976,69 @@
#
# CMPIEnumeration
-%extend _CMPIEnumeration {
+%extend _CMPIEnumeration
+{
#if defined(SWIGRUBY)
%alias length "size";
#endif
- int length() {
+ int length()
+ {
int l = 0;
- while (CMHasNext( $self, NULL ) ) {
+ while (CMHasNext($self, NULL)) {
++l;
- CMGetNext( $self, NULL );
+ CMGetNext($self, NULL);
}
return l;
}
- CMPIData next() {
- return CMGetNext( $self, NULL );
+
+ CMPIData next()
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIData result;
+
+ result = CMGetNext($self, &st);
+ RAISE_IF(st);
+
+ return result;
}
+
#if defined(SWIGRUBY)
%alias hasNext "empty?";
#endif
- int hasNext() {
- return CMHasNext( $self, NULL );
+ int hasNext()
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ int result;
+
+ result = CMHasNext($self, NULL);
+ RAISE_IF(st);
+
+ return result;
}
+
#if defined(SWIGRUBY)
%alias toArray "to_ary";
#endif
- CMPIArray *toArray() {
- return CMToArray( $self, NULL );
+ CMPIArray *toArray()
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIArray* result;
+
+ result = CMToArray($self, NULL);
+ RAISE_IF(st);
+
+ return result;
}
- const char* to_s(const CMPIBroker* broker) {
- CMPIString *s = CDToString(broker, $self, NULL);
- return CMGetCharPtr(s);
+
+ const char* to_s(const CMPIBroker* broker)
+ {
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ CMPIString *result;
+
+ result = CDToString(broker, $self, &st);
+ RAISE_IF(st);
+
+ return CMGetCharPtr(result);
}
}
@@ -812,35 +1046,58 @@
#
# CMPIArray
-%extend _CMPIArray {
- const char* to_s(const CMPIBroker* broker) {
+%extend _CMPIArray
+{
+ const char* to_s(const CMPIBroker* broker)
+ {
CMPIString *s = CDToString(broker, $self, NULL);
return CMGetCharPtr(s);
}
- int size() {
- return CMGetArrayCount( $self, NULL );
+
+ int size()
+ {
+ return CMGetArrayCount($self, NULL);
}
+
/* Gets the element type. */
- CMPIType cmpi_type() {
- return CMGetArrayType( $self, NULL );
+ CMPIType cmpi_type()
+ {
+ CMPIType result;
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+
+ result = CMGetArrayType($self, &st);
+ RAISE_IF(st);
+
+ return result;
}
+
/* Gets an element value defined by its index. */
#if defined(SWIGRUBY)
%alias at "[]";
#endif
- CMPIData at( int index ) {
- return CMGetArrayElementAt( $self, index, NULL );
+ CMPIData at(int index)
+ {
+ CMPIData result;
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+
+ result = CMGetArrayElementAt($self, index, &st);
+ RAISE_IF(st);
+
+ return result;
}
+
/* Sets an element value defined by its index. */
#if defined(SWIGRUBY)
%alias set "[]=";
#endif
- void set(int index, const CMPIValue * value, CMPIType type) {
- CMSetArrayElementAt( $self, index, value, type );
+ void set(int index, const CMPIValue * value, CMPIType type)
+ {
+ RAISE_IF(CMSetArrayElementAt($self, index, value, type));
}
-
}
+#BOOKMARK
+
#-----------------------------------------------------
#
# CMPIString
@@ -875,14 +1132,14 @@
#if defined (SWIGPYTHON)
PyObject*
#endif
- get_entry_at( int index ) {
+ get_entry_at(int index) {
CMPIString *s = NULL;
- CMPIData data = CMGetContextEntryAt( $self, index, &s, NULL );
+ CMPIData data = CMGetContextEntryAt($self, index, &s, NULL);
#if defined (SWIGRUBY)
VALUE rbdata = SWIG_NewPointerObj((void*) clone_data(&data), SWIGTYPE_p__CMPIData, 0);
VALUE rl = rb_ary_new2(2);
- return rb_ary_push( rb_ary_push( rl, rbdata ), rb_str_new2(CMGetCharPtr(s) ) );
+ return rb_ary_push(rb_ary_push(rl, rbdata), rb_str_new2(CMGetCharPtr(s)));
#endif
#if defined (SWIGPYTHON)
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
@@ -910,17 +1167,17 @@
%extend _CMPIDateTime {
~CMPIDateTime() { }
const char* to_s() {
- return CMGetCharPtr( CMGetStringFormat( $self, NULL ) );
+ return CMGetCharPtr(CMGetStringFormat($self, NULL));
}
uint64_t to_i() {
- return CMGetBinaryFormat( $self, NULL );
+ return CMGetBinaryFormat($self, NULL);
}
/* Tests whether DateTime is an interval value. */
#if defined(SWIGRUBY)
%rename("interval?") is_interval;
#endif
int is_interval() {
- return CMIsInterval( $self, NULL );
+ return CMIsInterval($self, NULL);
}
}
Copied: cmpi-bindings/trunk/test/python/install.sh (from rev 1057, cmpi-bindings/trunk/test/python/setup.sh)
===================================================================
--- cmpi-bindings/trunk/test/python/install.sh (rev 0)
+++ cmpi-bindings/trunk/test/python/install.sh 2008-10-01 23:24:28 UTC (rev 1059)
@@ -0,0 +1,62 @@
+#!/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
+
+ echo "rm -f $dir/$fn"
+ rm -f $dir/$fn
+ echo "ln -s `pwd`/$fn $dir"
+ ln -s `pwd`/$fn $dir
+}
+
+##
+## Check usage
+##
+
+if [ "$#" != 1 ]; then
+ echo "Usage: $0 [op|sfcb]"
+ exit 1
+fi
+
+if [ "$1" != "op" -a "$1" != "sfcb" ]; then
+ echo "Usage: $0 [op|sfcb]"
+ exit 1
+fi
+
+##
+## Install python providers:
+##
+
+__install TestMethod.py /usr/lib/pycim
+__install TestAssocProvider.py /usr/lib/pycim
+__install TestAtomProvider.py /usr/lib/pycim
+
+if [ "$1" = "op" ]; then
+ cimmof TestMethod.mof
+ cimmof -n root/PG_InterOp TestMethod.peg.reg
+ cimmof TestAssoc.mof
+ cimmof -n root/PG_InterOp TestAssocProvider-peg.reg
+ cimmof TestAtom.mof
+ cimmof -n root/PG_InterOp TestAtomProvider.peg.reg
+else
+ __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 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
+fi
Deleted: cmpi-bindings/trunk/test/python/setup.sh
===================================================================
--- cmpi-bindings/trunk/test/python/setup.sh 2008-10-01 22:04:31 UTC (rev 1058)
+++ cmpi-bindings/trunk/test/python/setup.sh 2008-10-01 23:24:28 UTC (rev 1059)
@@ -1,62 +0,0 @@
-#!/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
-
- echo "rm -f $dir/$fn"
- rm -f $dir/$fn
- echo "ln -s `pwd`/$fn $dir"
- ln -s `pwd`/$fn $dir
-}
-
-##
-## Check usage
-##
-
-if [ "$#" != 1 ]; then
- echo "Usage: $0 [op|sfcb]"
- exit 1
-fi
-
-if [ "$1" != "op" -a "$1" != "sfcb" ]; then
- echo "Usage: $0 [op|sfcb]"
- exit 1
-fi
-
-##
-## Install python providers:
-##
-
-__install TestMethod.py /usr/lib/pycim
-__install TestAssocProvider.py /usr/lib/pycim
-__install TestAtomProvider.py /usr/lib/pycim
-
-if [ "$1" = "op" ]; then
- cimmof TestMethod.mof
- cimmof -n root/PG_InterOp TestMethod.peg.reg
- cimmof TestAssoc.mof
- cimmof -n root/PG_InterOp TestAssocProvider-peg.reg
- cimmof TestAtom.mof
- cimmof -n root/PG_InterOp TestAtomProvider.peg.reg
-else
- __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 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
-fi
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bni...@us...> - 2008-10-01 22:04:38
|
Revision: 1058
http://omc.svn.sourceforge.net/omc/?rev=1058&view=rev
Author: bnicholes
Date: 2008-10-01 22:04:31 +0000 (Wed, 01 Oct 2008)
Log Message:
-----------
Fix the subprocess imports for calling external utilities and also set the caption and description to at least the service name if no short name is found
Modified Paths:
--------------
pybase/trunk/OMC_InitdService.py
Modified: pybase/trunk/OMC_InitdService.py
===================================================================
--- pybase/trunk/OMC_InitdService.py 2008-10-01 14:19:39 UTC (rev 1057)
+++ pybase/trunk/OMC_InitdService.py 2008-10-01 22:04:31 UTC (rev 1058)
@@ -82,9 +82,9 @@
#------------------------------------------------------------------------------
def _get_rpm_install_date(fullpath):
try:
- l=subprocess.Popen([r'/bin/rpm', '-qf', '--queryformat', \
+ l=Popen([r'/bin/rpm', '-qf', '--queryformat', \
'%{INSTALLTIME}', fullpath], \
- stdout=subprocess.PIPE).communicate()[0]
+ stdout=PIPE).communicate()[0]
if len(l):
return pywbem.CIMDateTime.fromtimestamp(long(l))
except:
@@ -143,7 +143,7 @@
raise pywbem.CIMError(CIM_ERR_NOT_FOUND)
fo = open(fullpath, 'r')
- caption = None
+ caption = model['name']
for line in fo.xreadlines():
if line.startswith('#') and 'Short-Description:' in line:
caption = line[line.find(':')+1:]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kk...@us...> - 2008-10-01 14:21:49
|
Revision: 1057
http://omc.svn.sourceforge.net/omc/?rev=1057&view=rev
Author: kkaempf
Date: 2008-10-01 14:19:39 +0000 (Wed, 01 Oct 2008)
Log Message:
-----------
some improvements on the Ruby side
Modified Paths:
--------------
cmpi-bindings/trunk/src/target_ruby.c
cmpi-bindings/trunk/swig/ruby/cmpi_rbwbem_bindings.rb
Added Paths:
-----------
cmpi-bindings/trunk/test/ruby/
cmpi-bindings/trunk/test/ruby/TestAtomProvider.peg.reg
cmpi-bindings/trunk/test/ruby/TestAtomProvider.reg
cmpi-bindings/trunk/test/ruby/TestAtomProvider.sfcb.reg
cmpi-bindings/trunk/test/ruby/setup.sh
cmpi-bindings/trunk/test/ruby/test_atom_provider.rb
Modified: cmpi-bindings/trunk/src/target_ruby.c
===================================================================
--- cmpi-bindings/trunk/src/target_ruby.c 2008-09-30 12:57:40 UTC (rev 1056)
+++ cmpi-bindings/trunk/src/target_ruby.c 2008-10-01 14:19:39 UTC (rev 1057)
@@ -10,7 +10,7 @@
#define RB_BINDINGS_FILE "cmpi_rbwbem_bindings"
/* expect 'module <RB_BINDINGS_MODULE>' inside */
-#define RB_BINDINGS_MODULE "RbCmpi"
+#define RB_BINDINGS_MODULE "Cmpi"
/*
* load_module
@@ -43,14 +43,41 @@
create_mi(VALUE args)
{
VALUE *values = (VALUE *)args;
- _SBLIM_TRACE(1,("Ruby: <MIclass>.new ..."));
- VALUE klass = rb_class_new_instance(1, values, rb_const_get(_TARGET_MODULE, values[1]));
- _SBLIM_TRACE(1,("Ruby: ... done"));
- return klass;
+ _SBLIM_TRACE(1,("Ruby: %s.new ...", rb_id2name(values[1])));
+ VALUE klass = rb_const_get(_TARGET_MODULE, values[1]);
+ _SBLIM_TRACE(1,("Ruby: ... klass -> %ld", klass));
+ if (NIL_P(klass))
+ {
+ _SBLIM_TRACE(1,("Ruby: ... klass is NULL"));
+ return klass;
+ }
+ VALUE instance = rb_class_new_instance(1, values, klass);
+ _SBLIM_TRACE(1,("Ruby: ... done -> %ld", instance));
+ return instance;
}
/*
+ * call_mi
+ * call function of instance
+ *
+ * I args: pointer to array of at least 3 values
+ * args[0] -> (VALUE) instance
+ * args[1] -> (VALUE) id of function
+ * args[2] -> (int) number of arguments
+ * args[3...n] -> (VALUE) arguments
+ */
+
+static VALUE
+call_mi(VALUE args)
+{
+ VALUE *values = (VALUE *)args;
+ return rb_funcall3(values[0], values[1], (int)values[2], values+3);
+}
+
+
+
+/*
* Global Ruby initializer
* loads the Ruby interpreter
* init threads
@@ -81,12 +108,18 @@
rb_protect(load_module, Qnil, &error);
if (error)
{
- _SBLIM_TRACE(1,("<%d> Ruby: import '%s' failed", getpid(), RB_BINDINGS_FILE));
+ _SBLIM_TRACE(1,("<%d> Ruby: import '%s' failed, error %d", getpid(), RB_BINDINGS_FILE, error));
/* _CMPI_SETFAIL(<CMPIString *>); */
abort();
return -1;
}
- _TARGET_MODULE = rb_intern(RB_BINDINGS_MODULE);
+ _TARGET_MODULE = rb_const_get(rb_cModule, rb_intern(RB_BINDINGS_MODULE));
+ if (NIL_P(_TARGET_MODULE))
+ {
+ _SBLIM_TRACE(1,("<%d> Ruby: import '%s' doesn't define module '%s'", getpid(), RB_BINDINGS_MODULE));
+ st->rc = CMPI_RC_ERR_NOT_FOUND;
+ return -1;
+ }
_SBLIM_TRACE(1,("<%d> RbGlobalInitialize() succeeded -> %ld", getpid(), _TARGET_MODULE));
return 0;
}
@@ -120,18 +153,17 @@
goto exit;
}
- _SBLIM_TRACE(1,("<%d> TargetInitialize(Ruby) called", getpid()));
-
+ _SBLIM_TRACE(1,("<%d> TargetInitialize(Ruby) called, miName '%s'", getpid(), hdl->miName));
+
args[0] = SWIG_NewPointerObj((void*) hdl->broker, SWIGTYPE_p__CMPIBroker, 0);
- args[1] = rb_str_new2(hdl->miName);
+ args[1] = rb_intern(hdl->miName);
hdl->instance = rb_protect(create_mi, (VALUE)args, &error);
if (error)
{
- _SBLIM_TRACE(1,("Ruby: FAILED creating %s", hdl->miName));
- hdl->instance = Qnil;
+ _SBLIM_TRACE(1,("Ruby: FAILED creating %s, error %d", hdl->miName, error));
if (st != NULL)
{
- st->rc = CMPI_RC_ERR_FAILED;
+ st->rc = CMPI_RC_ERR_INVALID_CLASS;
}
}
else
@@ -153,6 +185,57 @@
call_provider(ProviderMIHandle* hdl, CMPIStatus* st,
const char* opname, int nargs, ...)
{
+ int i;
+ VALUE *args, result, op = rb_intern(opname);
+ va_list vargs;
+
+ _SBLIM_TRACE(1,("call_provider %s[%d]", opname, nargs));
+
+ if (!rb_respond_to(hdl->instance, op))
+ {
+ char* str = fmtstr("Ruby provider does not implement \"%s\"", opname);
+ _SBLIM_TRACE(1,("%s", str));
+ st->rc = CMPI_RC_ERR_FAILED;
+ st->msg = hdl->broker->eft->newString(hdl->broker, str, NULL);
+ return 1;
+ }
+
+ /* add hdl->instance, op and nargs to the args array, so rb_protect can be called */
+ nargs += 3;
+ args = (VALUE *)malloc(nargs * sizeof(VALUE));
+ if (args == NULL)
+ {
+ _SBLIM_TRACE(1,("Out of memory"));
+ abort();
+ }
+ args[0] = (VALUE)(hdl->instance);
+ args[1] = op;
+ args[2] = (VALUE)(nargs-3);
+ if (nargs > 3)
+ {
+ va_start(vargs, nargs);
+ for (i = 3; i < nargs; ++i)
+ {
+ args[i] = va_arg(vargs, VALUE);
+ }
+ va_end(vargs);
+ }
+
+
+ result = rb_protect(call_mi, (VALUE)args, &i);
+
+ free( args );
+
+ if (i)
+ {
+ char* str = fmtstr("Ruby provider call to \"%s\" failed", opname);
+ _SBLIM_TRACE(1,("%s", str));
+ st->rc = CMPI_RC_ERR_FAILED;
+ st->msg = hdl->broker->eft->newString(hdl->broker, str, NULL);
+ return 1;
+ }
+
+ st->rc = CMPI_RC_OK;
return 0;
}
Modified: cmpi-bindings/trunk/swig/ruby/cmpi_rbwbem_bindings.rb
===================================================================
--- cmpi-bindings/trunk/swig/ruby/cmpi_rbwbem_bindings.rb 2008-09-30 12:57:40 UTC (rev 1056)
+++ cmpi-bindings/trunk/swig/ruby/cmpi_rbwbem_bindings.rb 2008-10-01 14:19:39 UTC (rev 1057)
@@ -1,55 +1,31 @@
#
+# Module RbCmpi
#
+# Main entry point for cmpi-bindings-ruby, Ruby based CIM Providers
#
-STDERR.puts "Hello, from rcmpi_instance.rb"
-require "pp"
-
-class Cmpi_Instance
- def initialize name
- STDERR.puts "Creating Cmpi_Instance #{name}"
- end
- def enum_instance_names context, results, reference
- STDERR.puts "Running Cmpi_Instance:enum_instance_names"
- begin
- nm = reference.namespace
- object_path = Cmpi::CMPIObjectPath.new nm
-
- object_path["hello"] = "Hello,"
- results.return_objectpath object_path
-
- object_path["hello"] = "world!"
- results.return_objectpath object_path
-
- results.done
- rescue Exception
- STDERR.puts "Exception: #{$!.message}"
+module Cmpi
+ STDERR.puts "Hello from cmpi-bindings-ruby"
+ # init
+ RBCIMPATH = "/usr/lib/rbcim/"
+
+ # look for .rb files below RBCIMPATH
+ # and load them
+ if File.directory?(RBCIMPATH) then
+ $:.unshift RBCIMPATH # add to load path
+ STDERR.puts "Looking into #{RBCIMPATH}"
+ Dir.foreach( RBCIMPATH ) do |entry|
+ STDERR.puts "Found #{entry}"
+ split = entry.split '.'
+ if split[1] == 'rb' then
+ begin
+ STDERR.puts "Loading #{split[0]}"
+ require split[0]
+ rescue Exception => e
+ STDERR.puts "Loading #{split[0]} failed: #{e}"
+ end
+ end
end
+ $:.shift # take load path away
end
- def enum_instances context, results, reference, properties
- STDERR.puts "Running Cmpi_Instance:enum_instances"
- begin
-# pp "Context #{context}"
-# pp "Result #{results}"
-# pp "Reference #{reference}"
-# pp "Properties #{properties}"
-
- nm = reference.namespace
- pp "nm #{nm}"
-
- object_path = Cmpi::CMPIObjectPath.new nm
-
- instance = Cmpi::CMPIInstance.new object_path
- instance[:hello] = "Hello,"
- results.return_instance instance
-
- instance = Cmpi::CMPIInstance.new object_path
- instance["hello"] = "world!"
- results.return_instance instance
-
- results.done
- rescue Exception
- STDERR.puts "Exception: #{$!.message}"
- end
- end
end
Added: cmpi-bindings/trunk/test/ruby/TestAtomProvider.peg.reg
===================================================================
--- cmpi-bindings/trunk/test/ruby/TestAtomProvider.peg.reg (rev 0)
+++ cmpi-bindings/trunk/test/ruby/TestAtomProvider.peg.reg 2008-10-01 14:19:39 UTC (rev 1057)
@@ -0,0 +1,28 @@
+// Provider registration for TestAtom
+instance of PG_ProviderModule
+{
+ Name = "TestAtom_Module";
+ Location = "pyCmpiProvider";
+ Vendor = "Novell";
+ Version = "1.0.0";
+ InterfaceType = "CMPI";
+ InterfaceVersion = "2.0.0";
+};
+
+instance of PG_Provider
+{
+ Name = "TestAtomProvider";
+ ProviderModuleName = "TestAtom_Module";
+};
+
+instance of PG_ProviderCapabilities
+{
+ ProviderModuleName = "TestAtom_Module";
+ ProviderName = "TestAtomProvider";
+ ClassName = "Test_Atom";
+ ProviderType = { 2 };
+ Namespaces = {"root/cimv2"};
+ SupportedProperties = NULL;
+ SupportedMethods = NULL;
+ CapabilityID = "TestAtom-Prov-1";
+};
Added: cmpi-bindings/trunk/test/ruby/TestAtomProvider.reg
===================================================================
--- cmpi-bindings/trunk/test/ruby/TestAtomProvider.reg (rev 0)
+++ cmpi-bindings/trunk/test/ruby/TestAtomProvider.reg 2008-10-01 14:19:39 UTC (rev 1057)
@@ -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/ruby/TestAtomProvider.sfcb.reg
===================================================================
--- cmpi-bindings/trunk/test/ruby/TestAtomProvider.sfcb.reg (rev 0)
+++ cmpi-bindings/trunk/test/ruby/TestAtomProvider.sfcb.reg 2008-10-01 14:19:39 UTC (rev 1057)
@@ -0,0 +1,5 @@
+[Test_Atom]
+ provider: TestAtomProvider
+ location: rbCmpiProvider
+ type: instance
+ namespace: root/cimv2
Added: cmpi-bindings/trunk/test/ruby/setup.sh
===================================================================
--- cmpi-bindings/trunk/test/ruby/setup.sh (rev 0)
+++ cmpi-bindings/trunk/test/ruby/setup.sh 2008-10-01 14:19:39 UTC (rev 1057)
@@ -0,0 +1,62 @@
+#!/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
+
+ echo "rm -f $dir/$fn"
+ rm -f $dir/$fn
+ echo "ln -s `pwd`/$fn $dir"
+ ln -s `pwd`/$fn $dir
+}
+
+##
+## Check usage
+##
+
+if [ "$#" != 1 ]; then
+ echo "Usage: $0 [op|sfcb]"
+ exit 1
+fi
+
+if [ "$1" != "op" -a "$1" != "sfcb" ]; then
+ echo "Usage: $0 [op|sfcb]"
+ exit 1
+fi
+
+##
+## Install Ruby providers:
+##
+
+__install TestMethod.rb /usr/lib/rbcim
+__install TestAssocProvider.rb /usr/lib/rbcim
+__install TestAtomProvider.rb /usr/lib/rbcim
+
+if [ "$1" = "op" ]; then
+ cimmof ../python/TestMethod.mof
+ cimmof -n root/PG_InterOp TestMethod.peg.reg
+ cimmof ../python/TestAssoc.mof
+ cimmof -n root/PG_InterOp TestAssocProvider.peg.reg
+ cimmof ../python/TestAtom.mof
+ cimmof -n root/PG_InterOp TestAtomProvider.peg.reg
+else
+ __install ../python/TestMethod.mof /var/lib/sfcb/stage/mofs/root/cimv2
+ __install ../python/TestAssoc.mof /var/lib/sfcb/stage/mofs/root/cimv2
+ __install ../python/TestAtom.mof /var/lib/sfcb/stage/mofs/root/cimv2
+
+ __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
+fi
Property changes on: cmpi-bindings/trunk/test/ruby/setup.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: cmpi-bindings/trunk/test/ruby/test_atom_provider.rb
===================================================================
--- cmpi-bindings/trunk/test/ruby/test_atom_provider.rb (rev 0)
+++ cmpi-bindings/trunk/test/ruby/test_atom_provider.rb 2008-10-01 14:19:39 UTC (rev 1057)
@@ -0,0 +1,28 @@
+#
+# Ruby Provider for TestAtom
+#
+# Instruments the CIM class TestAtom
+#
+
+module Cmpi
+
+ STDERR.puts "This is test_atom_provider.rb"
+ # Instrument the CIM class TestAtom
+ #
+ # Model an atom, For use with CIMOM and RbWbem Provider
+ #
+
+ class TestAtomProvider
+ STDERR.puts "This is TestAtomProvider within test_atom_provider.rb"
+
+ def initialize broker
+ STDERR.puts "TestAtomProvider initialized!"
+ @broker = broker
+ end
+
+ def create_instance context, result, reference, newinst
+ STDERR.puts "TestAtomProvider.create_instance"
+ end
+ end
+
+end
\ 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-30 12:58:04
|
Revision: 1056
http://omc.svn.sourceforge.net/omc/?rev=1056&view=rev
Author: kkaempf
Date: 2008-09-30 12:57:40 +0000 (Tue, 30 Sep 2008)
Log Message:
-----------
make target_python and target_ruby more similar
Modified Paths:
--------------
cmpi-bindings/trunk/CMakeLists.txt
cmpi-bindings/trunk/src/cmpi_provider.c
cmpi-bindings/trunk/src/target_python.c
cmpi-bindings/trunk/src/target_ruby.c
cmpi-bindings/trunk/swig/ruby/CMakeLists.txt
Added Paths:
-----------
cmpi-bindings/trunk/swig/ruby/cmpi_rbwbem_bindings.rb
Removed Paths:
-------------
cmpi-bindings/trunk/swig/ruby/rcmpi_instance.rb
Modified: cmpi-bindings/trunk/CMakeLists.txt
===================================================================
--- cmpi-bindings/trunk/CMakeLists.txt 2008-09-30 11:07:41 UTC (rev 1055)
+++ cmpi-bindings/trunk/CMakeLists.txt 2008-09-30 12:57:40 UTC (rev 1056)
@@ -35,7 +35,7 @@
INCLUDE(${CMAKE_SOURCE_DIR}/VERSION.cmake)
-SET(CMAKE_VERBOSE_MAKEFILE FALSE)
+SET(CMAKE_VERBOSE_MAKEFILE TRUE)
SET( PACKAGE "cmpi-bindings" )
SET( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
Modified: cmpi-bindings/trunk/src/cmpi_provider.c
===================================================================
--- cmpi-bindings/trunk/src/cmpi_provider.c 2008-09-30 11:07:41 UTC (rev 1055)
+++ cmpi-bindings/trunk/src/cmpi_provider.c 2008-09-30 12:57:40 UTC (rev 1056)
@@ -29,8 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
+#include <sys/types.h>
#include <stdio.h>
#include <stdarg.h>
+#include <unistd.h>
#include <pthread.h>
/* Include the required CMPI macros, data types, and API function headers */
@@ -79,7 +81,7 @@
typedef struct __ProviderMIHandle
{
char *miName;
- Target_Type tgMod;
+ Target_Type instance;
const CMPIBroker* broker;
} ProviderMIHandle;
@@ -165,10 +167,23 @@
**==============================================================================
*/
-static int _MI_COUNT = 0;
+/*
+ * There is one target interpreter, serving multiple MIs
+ * The number of MIs using the interpreter is counted in _MI_COUNT,
+ * when the last user goes aways, the target interpreter is unloaded.
+ *
+ * _CMPI_INIT_MUTEX protects this references counter from concurrent access.
+ *
+ */
+
+static int _TARGET_INIT = 0; /* acts as a boolean - is target initialized? */
+static int _MI_COUNT = 0; /* use count, number of MIs */
+static pthread_mutex_t _CMPI_INIT_MUTEX = PTHREAD_MUTEX_INITIALIZER; /* mutex around _MI_COUNT */
+static Target_Type _TARGET_MODULE = Target_Null; /* The target module (aka namespace) */
+
/* on-demand init */
-#define TARGET_CMPI_INIT { if (((ProviderMIHandle*)(self->hdl))->tgMod == Target_Null) if (TargetInitialize(((ProviderMIHandle*)(self->hdl)), &status) != 0) return status; }
+#define TARGET_CMPI_INIT { if (((ProviderMIHandle*)(self->hdl))->instance == Target_Null) if (TargetInitialize(((ProviderMIHandle*)(self->hdl)), &status) != 0) return status; }
#if defined(SWIGPYTHON)
#include "target_python.c"
@@ -1095,7 +1110,7 @@
_SBLIM_TRACE(1, ("\n>>>>> in FACTORY: CMPI"#ptype"MI* _Generic_Create_"#ptype"MI... miname=%s", miname)); \
ProviderMIHandle *hdl = (ProviderMIHandle*)malloc(sizeof(ProviderMIHandle)); \
if (hdl) { \
- hdl->tgMod = Target_Null; \
+ hdl->instance = Target_Null; \
hdl->miName = strdup(miname); \
hdl->broker = broker; \
} \
Modified: cmpi-bindings/trunk/src/target_python.c
===================================================================
--- cmpi-bindings/trunk/src/target_python.c 2008-09-30 11:07:41 UTC (rev 1055)
+++ cmpi-bindings/trunk/src/target_python.c 2008-09-30 12:57:40 UTC (rev 1056)
@@ -11,17 +11,14 @@
static PyThreadState* cmpiMainPyThreadState = NULL;
-static int _PY_INIT = 0; // acts as a boolean - is target initialized?
-static Target_Type _PYPROVMOD = NULL;
-static pthread_mutex_t _CMPI_INIT_MUTEX = PTHREAD_MUTEX_INITIALIZER;
/*
- * print Python exception trace
+ * get Python exception trace -> CMPIString
*
*/
#define TB_ERROR(str) {tbstr = str; goto cleanup;}
-static CMPIString*
+static CMPIString *
get_exc_trace(const CMPIBroker* broker)
{
char *tbstr = NULL;
@@ -119,7 +116,9 @@
/*
* Global Python initializer
- * loads the Python interpreter
+ *
+ * load the Python interpreter
+ * import 'cmpi_pywbem_bindings' -> _TARGET_MODULE
* init threads
*/
@@ -128,12 +127,12 @@
{
_SBLIM_TRACE(1,("<%d/0x%x> PyGlobalInitialize() called", getpid(), pthread_self()));
- if (_PY_INIT)
+ if (_TARGET_INIT)
{
_SBLIM_TRACE(1,("<%d/0x%x> PyGlobalInitialize() returning: already initialized", getpid(), pthread_self()));
return 0;
}
- _PY_INIT=1;//true
+ _TARGET_INIT=1;//true
_SBLIM_TRACE(1,("<%d/0x%x> Python: Loading", getpid(), pthread_self()));
@@ -144,8 +143,13 @@
PyEval_ReleaseThread(cmpiMainPyThreadState);
TARGET_THREAD_BEGIN_BLOCK;
- _PYPROVMOD = PyImport_ImportModule("cmpi_pywbem_bindings");
- if (_PYPROVMOD == NULL)
+
+ /*
+ * import 'cmpi_pywbem_bindings'
+ */
+
+ _TARGET_MODULE = PyImport_ImportModule("cmpi_pywbem_bindings");
+ if (_TARGET_MODULE == NULL)
{
TARGET_THREAD_END_BLOCK;
_SBLIM_TRACE(1,("<%d/0x%x> Python: import cmpi_pywbem_bindings failed", getpid(), pthread_self()));
@@ -156,7 +160,7 @@
abort();
return -1;
}
- _SBLIM_TRACE(1,("<%d/0x%x> Python: _PYPROVMOD at %p", getpid(), pthread_self(), _PYPROVMOD));
+ _SBLIM_TRACE(1,("<%d/0x%x> Python: _TARGET_MODULE at %p", getpid(), pthread_self(), _TARGET_MODULE));
TARGET_THREAD_END_BLOCK;
_SBLIM_TRACE(1,("<%d/0x%x> PyGlobalInitialize() succeeded", getpid(), pthread_self()));
@@ -167,65 +171,6 @@
/*---------------------------------------------------------------*/
/*
- * local (per MI) Python initializer
- * keeps track of reference count
- */
-
-static int
-TargetInitialize(ProviderMIHandle* hdl, CMPIStatus* st)
-{
- int rc = 0;
- /* Set _CMPI_INIT, protected by _CMPI_INIT_MUTEX
- * so we call Py_Finalize() only once.
- */
- if (pthread_mutex_lock(&_CMPI_INIT_MUTEX))
- {
- perror("Can't lock _CMPI_INIT_MUTEX");
- abort();
- }
- rc = PyGlobalInitialize(hdl->broker, st);
- pthread_mutex_unlock(&_CMPI_INIT_MUTEX);
- if (rc != 0)
- {
- return rc;
- }
-
- _SBLIM_TRACE(1,("<%d/0x%x> TargetInitialize(Python) called", getpid(), pthread_self()));
-
- TARGET_THREAD_BEGIN_BLOCK;
- PyObject *provclass = PyObject_GetAttrString(_PYPROVMOD,
- "get_cmpi_proxy_provider");
- if (provclass == NULL)
- {
- TARGET_THREAD_END_BLOCK;
- _CMPI_SETFAIL(get_exc_trace(hdl->broker));
- return -1;
- }
- PyObject *broker = SWIG_NewPointerObj((void*) hdl->broker, SWIGTYPE_p__CMPIBroker, 0);
- PyObject *args = PyTuple_New(2);
- _SBLIM_TRACE(1,("\n<%d/0x%x> >>>>> TargetInitialize(Python) called, MINAME=%s\n",
- getpid(), pthread_self(), hdl->miName));
- PyTuple_SetItem(args, 0, string2target(hdl->miName));
- PyTuple_SetItem(args, 1, broker);
- PyObject *provinst = PyObject_CallObject(provclass, args);
- Py_DecRef(args);
- Py_DecRef(provclass);
- if (provinst == NULL)
- {
- TARGET_THREAD_END_BLOCK;
- _CMPI_SETFAIL(get_exc_trace(hdl->broker));
- return -1;
- }
-
- hdl->tgMod = provinst;
-
- TARGET_THREAD_END_BLOCK;
- _SBLIM_TRACE(1,("<%d/0x%x> TargetInitialize(Python) succeeded", getpid(), pthread_self()));
- return 0;
-}
-
-
-/*
* call_provider
*
*/
@@ -242,7 +187,7 @@
TARGET_THREAD_BEGIN_BLOCK;
pyargs = PyTuple_New(nargs);
- pyfunc = PyObject_GetAttrString(hdl->tgMod, opname);
+ pyfunc = PyObject_GetAttrString(hdl->instance, opname);
if (pyfunc == NULL)
{
PyErr_Print();
@@ -348,6 +293,70 @@
/*
+ * local (per MI) Python initializer
+ * keeps track of reference count
+ */
+
+static int
+TargetInitialize(ProviderMIHandle* hdl, CMPIStatus* st)
+{
+ int rc = 0;
+ /* Set _CMPI_INIT, protected by _CMPI_INIT_MUTEX
+ * so we call Py_Finalize() only once.
+ */
+ if (pthread_mutex_lock(&_CMPI_INIT_MUTEX))
+ {
+ perror("Can't lock _CMPI_INIT_MUTEX");
+ abort();
+ }
+ /* import 'cmpi_pywbem_bindings' */
+ rc = PyGlobalInitialize(hdl->broker, st);
+ pthread_mutex_unlock(&_CMPI_INIT_MUTEX);
+ if (rc != 0)
+ {
+ return rc;
+ }
+
+ _SBLIM_TRACE(1,("<%d/0x%x> TargetInitialize(Python) called", getpid(), pthread_self()));
+
+ TARGET_THREAD_BEGIN_BLOCK;
+
+ /* cmpi_pywbem_bindings::get_cmpi_proxy_provider */
+ PyObject *provclass = PyObject_GetAttrString(_TARGET_MODULE,
+ "get_cmpi_proxy_provider");
+ if (provclass == NULL)
+ {
+ TARGET_THREAD_END_BLOCK;
+ _CMPI_SETFAIL(get_exc_trace(hdl->broker));
+ return -1;
+ }
+ PyObject *broker = SWIG_NewPointerObj((void*) hdl->broker, SWIGTYPE_p__CMPIBroker, 0);
+ PyObject *args = PyTuple_New(2);
+ _SBLIM_TRACE(1,("\n<%d/0x%x> >>>>> TargetInitialize(Python) called, MINAME=%s\n",
+ getpid(), pthread_self(), hdl->miName));
+ PyTuple_SetItem(args, 0, string2target(hdl->miName));
+ PyTuple_SetItem(args, 1, broker);
+
+ /* provinst = cmpi_pywbem_bindings::get_cmpi_proxy_provider( miName, broker ) */
+ PyObject *provinst = PyObject_CallObject(provclass, args);
+ Py_DecRef(args);
+ Py_DecRef(provclass);
+ if (provinst == NULL)
+ {
+ TARGET_THREAD_END_BLOCK;
+ _CMPI_SETFAIL(get_exc_trace(hdl->broker));
+ return -1;
+ }
+ /* save per-MI provider instance */
+ hdl->instance = provinst;
+
+ TARGET_THREAD_END_BLOCK;
+ _SBLIM_TRACE(1,("<%d/0x%x> TargetInitialize(Python) succeeded", getpid(), pthread_self()));
+ return 0;
+}
+
+
+/*
* TargetCleanup
*/
@@ -369,16 +378,16 @@
}
TARGET_THREAD_BEGIN_BLOCK;
- Py_DecRef(_PYPROVMOD);
+ Py_DecRef(_TARGET_MODULE);
TARGET_THREAD_END_BLOCK;
PyEval_AcquireLock();
PyThreadState_Swap(cmpiMainPyThreadState);
- if (_PY_INIT) // if PY is initialized and _MI_COUNT == 0, call Py_Finalize
+ if (_TARGET_INIT) // if Python is initialized and _MI_COUNT == 0, call Py_Finalize
{
_SBLIM_TRACE(1,("Calling Py_Finalize()"));
Py_Finalize();
- _PY_INIT=0; // false
+ _TARGET_INIT=0; // false
}
pthread_mutex_unlock(&_CMPI_INIT_MUTEX);
Modified: cmpi-bindings/trunk/src/target_ruby.c
===================================================================
--- cmpi-bindings/trunk/src/target_ruby.c 2008-09-30 11:07:41 UTC (rev 1055)
+++ cmpi-bindings/trunk/src/target_ruby.c 2008-09-30 12:57:40 UTC (rev 1056)
@@ -6,30 +6,92 @@
* Here: Ruby
*/
+/* load <RB_BINDINGS_FILE>.rb */
+#define RB_BINDINGS_FILE "cmpi_rbwbem_bindings"
+/* expect 'module <RB_BINDINGS_MODULE>' inside */
+#define RB_BINDINGS_MODULE "RbCmpi"
+
+/*
+ * load_module
+ * separate function for rb_require so it can be wrapped into rb_protect()
+ */
+
static VALUE
-load_code()
+load_module()
{
- _SBLIM_TRACE(1,("Ruby: require 'rcmpi_instance'..."));
-
- rb_require("rcmpi_instance");
+ _SBLIM_TRACE(1,("Ruby: require '%s'...", RB_BINDINGS_FILE));
- _SBLIM_TRACE(1,("Ruby: ... done"));
+ rb_require(RB_BINDINGS_FILE);
- return Qnil;
+ _SBLIM_TRACE(1,("Ruby: ... done"));
+
+ return Qnil;
}
+
+/*
+ * create_mi
+ * call constructor for MI implementation class
+ *
+ * I args : pointer to array of 2 values
+ * values[0] = broker, passed to constructor
+ * values[1] = id of class (rb_intern(<classname>))
+ */
+
static VALUE
-create_cmpi(VALUE args)
+create_mi(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;
+ VALUE *values = (VALUE *)args;
+ _SBLIM_TRACE(1,("Ruby: <MIclass>.new ..."));
+ VALUE klass = rb_class_new_instance(1, values, rb_const_get(_TARGET_MODULE, values[1]));
+ _SBLIM_TRACE(1,("Ruby: ... done"));
+ return klass;
}
+/*
+ * Global Ruby initializer
+ * loads the Ruby interpreter
+ * init threads
+ */
+
+static int
+RbGlobalInitialize(const CMPIBroker* broker, CMPIStatus* st)
+{
+ int error;
+
+ _SBLIM_TRACE(1,("<%d> RbGlobalInitialize() called", getpid()));
+
+ if (_TARGET_INIT)
+ {
+ _SBLIM_TRACE(1,("<%d> RbGlobalInitialize() returning: already initialized", getpid()));
+ return 0;
+ }
+ _TARGET_INIT=1;//true
+
+ _SBLIM_TRACE(1,("<%d> Ruby: Loading", getpid()));
+
+ ruby_init();
+ ruby_init_loadpath();
+ ruby_script("cmpi_swig");
+ SWIG_init();
+
+ /* load module */
+ rb_protect(load_module, Qnil, &error);
+ if (error)
+ {
+ _SBLIM_TRACE(1,("<%d> Ruby: import '%s' failed", getpid(), RB_BINDINGS_FILE));
+/* _CMPI_SETFAIL(<CMPIString *>); */
+ abort();
+ return -1;
+ }
+ _TARGET_MODULE = rb_intern(RB_BINDINGS_MODULE);
+ _SBLIM_TRACE(1,("<%d> RbGlobalInitialize() succeeded -> %ld", getpid(), _TARGET_MODULE));
+ return 0;
+}
+
+
/*---------------------------------------------------------------*/
/*
@@ -40,54 +102,45 @@
static int
TargetInitialize(ProviderMIHandle* hdl, CMPIStatus* st)
{
- 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"));
+ VALUE args[2];
+ int error;
- _SBLIM_TRACE(1,("Ruby: Loading"));
- ruby_init();
- ruby_init_loadpath();
- ruby_script("rcmpi_instance");
- SWIG_init();
+ /* Set _CMPI_INIT, protected by _CMPI_INIT_MUTEX
+ * so we call ruby_finalize() only once.
+ */
+ if (pthread_mutex_lock(&_CMPI_INIT_MUTEX))
+ {
+ perror("Can't lock _CMPI_INIT_MUTEX");
+ abort();
+ }
+ error = RbGlobalInitialize(hdl->broker, st);
+ pthread_mutex_unlock(&_CMPI_INIT_MUTEX);
+ if (error != 0)
+ {
+ goto exit;
+ }
- 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(hdl->miName);
- 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;
- }
+ _SBLIM_TRACE(1,("<%d> TargetInitialize(Ruby) called", getpid()));
+
+ args[0] = SWIG_NewPointerObj((void*) hdl->broker, SWIGTYPE_p__CMPIBroker, 0);
+ args[1] = rb_str_new2(hdl->miName);
+ hdl->instance = rb_protect(create_mi, (VALUE)args, &error);
+ if (error)
+ {
+ _SBLIM_TRACE(1,("Ruby: FAILED creating %s", hdl->miName));
+ hdl->instance = Qnil;
+ if (st != NULL)
+ {
+ st->rc = CMPI_RC_ERR_FAILED;
}
- else {
- _SBLIM_TRACE(1,("Ruby: cmpi at %p", cmpiInstance));
- hdl->tgMod = cmpiInstance;
- }
}
-
- /* Finished. */
+ else
+ {
+ _SBLIM_TRACE(1,("Ruby: cmpi at %p", hdl->instance));
+ }
exit:
- _SBLIM_TRACE(1,("Initialize() %s", (rc == 0)? "succeeded":"failed"));
- return rc;
+ _SBLIM_TRACE(1,("Initialize() %s", (error == 0)? "succeeded":"failed"));
+ return error;
}
@@ -111,8 +164,8 @@
static void
TargetCleanup(void)
{
- ruby_finalize();
-
+ ruby_finalize();
+ _TARGET_MODULE = Qnil;
return;
}
Modified: cmpi-bindings/trunk/swig/ruby/CMakeLists.txt
===================================================================
--- cmpi-bindings/trunk/swig/ruby/CMakeLists.txt 2008-09-30 11:07:41 UTC (rev 1055)
+++ cmpi-bindings/trunk/swig/ruby/CMakeLists.txt 2008-09-30 12:57:40 UTC (rev 1056)
@@ -50,6 +50,6 @@
INSTALL(TARGETS ${NAME} LIBRARY DESTINATION ${CMPI_LIBRARY_DIR})
#
-# rcmpi_instance.rb: provider implementation
+# cmpi_rbwbem_bindings: provider implementation
#
-INSTALL(FILES rcmpi_instance.rb DESTINATION ${RUBY_LIB_DIR})
+INSTALL(FILES cmpi_rbwbem_bindings.rb DESTINATION ${RUBY_LIB_DIR})
Copied: cmpi-bindings/trunk/swig/ruby/cmpi_rbwbem_bindings.rb (from rev 1055, cmpi-bindings/trunk/swig/ruby/rcmpi_instance.rb)
===================================================================
--- cmpi-bindings/trunk/swig/ruby/cmpi_rbwbem_bindings.rb (rev 0)
+++ cmpi-bindings/trunk/swig/ruby/cmpi_rbwbem_bindings.rb 2008-09-30 12:57:40 UTC (rev 1056)
@@ -0,0 +1,55 @@
+#
+#
+#
+STDERR.puts "Hello, from rcmpi_instance.rb"
+
+require "pp"
+
+class Cmpi_Instance
+ def initialize name
+ STDERR.puts "Creating Cmpi_Instance #{name}"
+ end
+ def enum_instance_names context, results, reference
+ STDERR.puts "Running Cmpi_Instance:enum_instance_names"
+ begin
+ nm = reference.namespace
+ object_path = Cmpi::CMPIObjectPath.new nm
+
+ object_path["hello"] = "Hello,"
+ results.return_objectpath object_path
+
+ object_path["hello"] = "world!"
+ results.return_objectpath object_path
+
+ results.done
+ rescue Exception
+ STDERR.puts "Exception: #{$!.message}"
+ end
+ end
+ def enum_instances context, results, reference, properties
+ STDERR.puts "Running Cmpi_Instance:enum_instances"
+ begin
+# pp "Context #{context}"
+# pp "Result #{results}"
+# pp "Reference #{reference}"
+# pp "Properties #{properties}"
+
+ nm = reference.namespace
+ pp "nm #{nm}"
+
+ object_path = Cmpi::CMPIObjectPath.new nm
+
+ instance = Cmpi::CMPIInstance.new object_path
+ instance[:hello] = "Hello,"
+ results.return_instance instance
+
+ instance = Cmpi::CMPIInstance.new object_path
+ instance["hello"] = "world!"
+ results.return_instance instance
+
+ results.done
+ rescue Exception
+ STDERR.puts "Exception: #{$!.message}"
+ end
+ end
+end
Property changes on: cmpi-bindings/trunk/swig/ruby/cmpi_rbwbem_bindings.rb
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: cmpi-bindings/trunk/swig/ruby/rcmpi_instance.rb
===================================================================
--- cmpi-bindings/trunk/swig/ruby/rcmpi_instance.rb 2008-09-30 11:07:41 UTC (rev 1055)
+++ cmpi-bindings/trunk/swig/ruby/rcmpi_instance.rb 2008-09-30 12:57:40 UTC (rev 1056)
@@ -1,55 +0,0 @@
-#
-#
-#
-STDERR.puts "Hello, from rcmpi_instance.rb"
-
-require "pp"
-
-class Cmpi_Instance
- def initialize name
- STDERR.puts "Creating Cmpi_Instance #{name}"
- end
- def enum_instance_names context, results, reference
- STDERR.puts "Running Cmpi_Instance:enum_instance_names"
- begin
- nm = reference.namespace
- object_path = Cmpi::CMPIObjectPath.new nm
-
- object_path["hello"] = "Hello,"
- results.return_objectpath object_path
-
- object_path["hello"] = "world!"
- results.return_objectpath object_path
-
- results.done
- rescue Exception
- STDERR.puts "Exception: #{$!.message}"
- end
- end
- def enum_instances context, results, reference, properties
- STDERR.puts "Running Cmpi_Instance:enum_instances"
- begin
-# pp "Context #{context}"
-# pp "Result #{results}"
-# pp "Reference #{reference}"
-# pp "Properties #{properties}"
-
- nm = reference.namespace
- pp "nm #{nm}"
-
- object_path = Cmpi::CMPIObjectPath.new nm
-
- instance = Cmpi::CMPIInstance.new object_path
- instance[:hello] = "Hello,"
- results.return_instance instance
-
- instance = Cmpi::CMPIInstance.new object_path
- instance["hello"] = "world!"
- results.return_instance instance
-
- results.done
- rescue Exception
- STDERR.puts "Exception: #{$!.message}"
- end
- end
-end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <kk...@us...> - 2008-09-30 11:07:53
|
Revision: 1055
http://omc.svn.sourceforge.net/omc/?rev=1055&view=rev
Author: kkaempf
Date: 2008-09-30 11:07:41 +0000 (Tue, 30 Sep 2008)
Log Message:
-----------
fix DESTDIR, $ENV must be escaped to \$ENV
Modified Paths:
--------------
cmpi-bindings/trunk/swig/python/CMakeLists.txt
Modified: cmpi-bindings/trunk/swig/python/CMakeLists.txt
===================================================================
--- cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-09-30 00:51:56 UTC (rev 1054)
+++ cmpi-bindings/trunk/swig/python/CMakeLists.txt 2008-09-30 11:07:41 UTC (rev 1055)
@@ -65,4 +65,4 @@
INSTALL(FILES cmpi_pywbem_bindings.py DESTINATION ${PYTHON_SITE_DIR} )
#INSTALL(FILES Py_UnixProcessProvider.py DESTINATION /usr/lib/pycim )
-INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -m py_compile $ENV{DESTDIR}${PYTHON_SITE_DIR}/cmpi.py $ENV{DESTDIR}${PYTHON_SITE_DIR}/cmpi_pywbem_bindings.py)")
+INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -m py_compile \$ENV{DESTDIR}${PYTHON_SITE_DIR}/cmpi.py \$ENV{DESTDIR}${PYTHON_SITE_DIR}/cmpi_pywbem_bindings.py)")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ba...@us...> - 2008-09-30 00:52:03
|
Revision: 1054
http://omc.svn.sourceforge.net/omc/?rev=1054&view=rev
Author: bartw
Date: 2008-09-30 00:51:56 +0000 (Tue, 30 Sep 2008)
Log Message:
-----------
fixed _is_auto_start, used it to set EnabledDefault
Modified Paths:
--------------
pybase/trunk/OMC_InitdService.py
Modified: pybase/trunk/OMC_InitdService.py
===================================================================
--- pybase/trunk/OMC_InitdService.py 2008-09-29 22:56:32 UTC (rev 1053)
+++ pybase/trunk/OMC_InitdService.py 2008-09-30 00:51:56 UTC (rev 1054)
@@ -94,13 +94,23 @@
#------------------------------------------------------------------------------
def _is_auto_start(name):
try:
- l=subprocess.Popen([r'/usr/bin/find', '/etc/init.d', '-name', \
- 'S[0-9][0-9]%s'%name], \
- stdout=subprocess.PIPE).communicate()[0]
- if l.endswith('\n'):
- l = l[0:-1]
- return len(l.split()) > 0
+ fo = open('/etc/inittab', 'r')
+ for line in fo.xreadlines():
+ if line.startswith('id:'):
+ runlevel = line.split(':')[1]
+ fo.close()
+ break
+ else:
+ fo.close()
+ return False
+ ents = os.listdir('/etc/init.d/rc%s.d' % runlevel)
+ for ent in ents:
+ if ent.startswith('S') and ent[3:] == name:
+ return True
+ else:
+ return False
except:
+ print '**** Exception caught in _is_auto_start() !!'
pass
return False
@@ -125,7 +135,6 @@
% (self.__class__.__name__, model['name']))
#model['ElementName'] = # TODO (type = unicode)
- #model['EnabledDefault'] = # TODO (type = pywbem.Uint16 self.Values.EnabledDefault) (default=2L)
#model['EnabledState'] = # TODO (type = pywbem.Uint16 self.Values.EnabledState) (default=5L)
#model['HealthState'] = # TODO (type = pywbem.Uint16 self.Values.HealthState)
fullpath = '/etc/init.d/' + model['name']
@@ -164,7 +173,12 @@
if osts:
model['OperationalStatus'] = osts
- model['StartMode'] = _is_auto_start(model['name']) and 'Automatic' or 'Manual'
+ is_auto_start = _is_auto_start(model['name'])
+ model['StartMode'] = is_auto_start and 'Automatic' or 'Manual'
+ model['EnabledDefault'] = is_auto_start and \
+ self.Values.EnabledDefault.Enabled or \
+ self.Values.EnabledDefault.Disabled
+
svcStarted = (st == self.Values.ServiceStatus.Service_Running)
model['Started'] = svcStarted
#model['OperationalStatus'] = # TODO (type = [pywbem.Uint16,] self.Values.OperationalStatus)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|